def start_barrier_sink(self, op): """Start a barrier thread to ensure all expected replies are received""" try: # The process-based approach of creating a child barrier process # is working fine. But we will use thread-based as it is easier #--------------- this part works fine ---------------------- # create the apparatus to start a child process #operation = os.getcwd () + "/mr_barriersink.py" #args = ['/usr/bin/python', operation, '-p', str(self.masterport+1), barrier_cond] #print "MR::start_barrier_sink invoking child with args: ", args # start the process #p = sp.Popen (args) #------------------------------------------------------------------- # Note that barriers start at base port of master + 2, +3, and +4 # for map and reduce barriers, respectively. There are three # possible operations; to check if the map and reduce workers # are up or not; and then the map and reduce results themselves. if (op == "workers_up"): # need to receive response from these many workers barrier_cond = self.M + self.R port = self.masterport + 2 receiver = self.rcv4barrier elif (op == "map_results"): # need to receive response from these many workers barrier_cond = self.M port = self.masterport + 3 receiver = self.rcv4map_res elif (op == "reduce_results"): # need to receive response from these many workers barrier_cond = self.R port = self.masterport + 4 receiver = self.rcv4reduce_res else: print("bad op in starting barrier process") return None # create the args to send to the thread args = { 'op': op, 'port': port, 'cond': barrier_cond, 'receiver': receiver } # instantiate a thread obj and start the thread print("MR::solve - start_barrier_sink with args: ", args) self.thr_obj_dict[op] = MR_Thread(barrier_sink, args) self.thr_obj_dict[op].start() except: print("Unexpected error in init_server:", sys.exc_info()[0]) raise
def start_barrier_sink(self, op): """Initialize the networking part of the server including sinks""" try: # The process-based approach of creating a child barrier process # is working fine. But we will use thread-based as it is easier #--------------- this part works fine ---------------------- # create the apparatus to start a child process #operation = os.getcwd () + "/mr_barriersink.py" #args = ['/usr/bin/python', operation, '-p', str(self.masterport+1), barrier_cond] #print "MR::start_barrier_sink invoking child with args: ", args # start the process #p = sp.Popen (args) #------------------------------------------------------------------- # Note that barriers start at base port of master + 2 and +3 # for map and reduce barriers, respectively. if (op == "map"): barrier_cond = self.M port = self.masterport + 2 elif (op == "reduce"): barrier_cond = self.R port = self.masterport + 3 else: print "bad op in starting barrier process" return None # create the args to send to the thread args = {'port': port, 'cond': barrier_cond} # instantiate a thread obj and start the thread print "MR::solve - start_barrier_sink with args: ", args self.threads[op] = MR_Thread(barrier_sink, args) self.threads[op].start() except: print "Unexpected error in init_server:", sys.exc_info()[0] raise