def start_coord(self, raw_data, weight): """ starts the coordinator. @param raw_data is the data that coord-node has to process. @param weight is the weight of this node. @param ls is a list that contains all the nodes. """ # set the weight of the node to protocol self.set_weight(weight) # read all waiting, raw data and pass it to a sketch self._read_data(raw_data) # update last statistics vector to hold the localstats self._set_lastStatistics(self.ams.sketch) # update slack vector to 0 VectorOps.init_empty_vector(self.cm.slack, \ self.cm.lastStatistics) self.all_vectors[self.node_name] = \ [self.weight, self.cm.lastStatistics]
def start(self, raw_data, weight): """ starts the protocol. Initialization phase of the coordinator-based algorithm is implemented, exactly as it is presented in the paper [lift2006]. @param raw_data is a list that contains items of unprocessed data. """ # first of all, set the weight of the node to protocol self.set_weight(weight) # read all waiting, raw data and pass it to a sketch self._read_data(raw_data) # update last statistics vector to hold the localstats self._set_lastStatistics(self.ams.sketch) # update slack vector to 0 VectorOps.init_empty_vector(self.cm.slack, \ self.cm.lastStatistics) # create an init message self.init_msg = self.create_init_msg() # send an 'INIT'-type message to coordinator self.sendMessage(self.init_msg) # finally set change state self.set_state('UNSAFE')
def initialization(self): """ inits the centralized protocol. """ # first of all set the weight self.weight = self.getNodeWeight() # hold the initial statistics vector to last statistics self.cm.lastStatistics = self.getDataFromNode() # set slack vector to 0 self.cm.slack = VectorOps.init_empty_vector(self.cm.slack, \ self.cm.lastStatistics) # create then init message self.init_msg = INIT(self.node_name, \ self.COORD, \ self.cm.lastStatistics,\ self.weight) # send message to network self.sendMessage(self.init_msg)