Skip to content

Commit

Permalink
encounter interval probe start
Browse files Browse the repository at this point in the history
  • Loading branch information
HadiModarres committed Sep 23, 2019
1 parent 29b0583 commit 7503d93
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 10 deletions.
9 changes: 1 addition & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ let faker = require("faker");
let SearchRequest = require("./controllers/SearchRequest");
let SearchResponder = require("./controllers/SearchResponder");
let stringSimilarity = require("string-similarity");
let stats = require("./stats/StatsRecorder");



Expand Down Expand Up @@ -107,15 +106,9 @@ global.runTest = function () {
// });
let searchRequest = new SearchRequest(node, document.getElementById("new_name").value,"list#name");
node.attachController(searchRequest);
stats.addEventEmitter(searchRequest);
node.statsRecorder.addEventEmitter(searchRequest);
searchRequest.initiateSearch();
};
//
// rtc.onChannel("data", function (data) {
// data.receive("data_type",10000).then((message)=>{
// console.info(message);
// });
// });



Expand Down
5 changes: 3 additions & 2 deletions node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let SearchRequest = require("./controllers/SearchRequest");
let SearchResponder = require("./controllers/SearchResponder");
let SearchRelay = require("./controllers/SearchRelay");
const ListManager = require("./proximity/ListManager");
const stats = require("./stats/StatsRecorder");
let StatsRecorder = require("./stats/HTTPStatsRecorder");


const constants = require("./constants");
Expand Down Expand Up @@ -43,14 +43,15 @@ class Node {
this.__controllers = [];
this.listManager = new ListManager();
this.name = '';
this.statsRecorder = new StatsRecorder();
this.__initCyclonNode();
this.__initSearchControllers();
this.__addEventListeners();
}

__addEventListeners(){
for (let c of this.__controllers) {
stats.addEventEmitter(c);
this.statsRecorder.addEventEmitter(c);
}
}
/**
Expand Down
59 changes: 59 additions & 0 deletions stats/EncounterIntervalProbe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Has the responsibility to gather and report number of shuffles between encounters of other nodes. This data
* can possibly be used to measure network size.
*/
class EncounterIntervalProbe {
get node() {
return this._node;
}

get sampleSize() {
return this._sampleSize;
}

get encounterCounts() {
return this._encounterCounts;
}
/**
*
* @param sampleSize number of nodes to check encounters for.
* @param encounterCounts number of encounters to average and report at once
*/
constructor(node,sampleSize,encounterCounts){
this._node = node;
this._sampleSize = sampleSize;
this._encounterCounts = encounterCounts;
this.samples= []
this._gatherData();
this.currentIndex= 0;
}

_gatherData(){
this._node.__cyclonNode.on("neighbours_updated", ()=> {
if (this.currentIndex===0){
this._initializeSamples();
}else{
this._updateSamples();
this._checkFinishCriteria();
}
this.currentIndex++;
});
}
_checkFinishCriteria(){

}

_updateSamples(){

}

_initializeSamples(){
let neighbors = this._node.getRandomSamplePointers();
let size = Math.min(neighbors.length, this._sampleSize);
for (let i=0;i<size;i++){
let sample = {id: neighbors[i].id,encounters:[]};
this.samples.push(sample);
}
};

}

0 comments on commit 7503d93

Please sign in to comment.