def __init__(self): self.ci = lab_channel.Channel() self.server = self.ci.join('server') self.timeout = 3 # create instance logger self.logger = logging.getLogger('vs2lab.lab2.channel.Server') self.logger.debug('New Server created.')
def __init__(self): self.ci = lab_channel.Channel() self.client = self.ci.join('client') self.server = self.ci.subgroup('server') # create instance logger self.logger = logging.getLogger('vs2lab.lab2.channel.Client') self.logger.debug('New Client created.')
def create_and_run(num_bits, proc_class, enter_bar, run_bar): """ Create and run a peer :param num_bits: address range of the channel :param node_class: class of peer :param enter_bar: barrier syncing channel population :param run_bar: barrier syncing bootstrap """ chan = lab_channel.Channel(n_bits=num_bits) proc = proc_class(chan) enter_bar.wait() # wait for all peers to join the channel proc.init() # do some bootstrapping run_bar.wait() # wait for all nodes to finish proc.run() # start operating
def create_and_run(num_bits, node_class, enter_bar, run_bar): """ Create and run a node (server or client role) :param num_bits: address range of the channel :param node_class: class of node :param enter_bar: barrier syncing channel population :param run_bar: barrier syncing node creation """ chan = lab_channel.Channel(n_bits=num_bits) node = node_class(chan) enter_bar.wait() # wait for all nodes to join the channel node.enter() # do what is needed to enter the ring run_bar.wait() # wait for all nodes to finish entering node.run() # start operating the node
proc.init() # do some bootstrapping run_bar.wait() # wait for all nodes to finish proc.run() # start operating if __name__ == "__main__": # if script is started from command line m = 8 # Number of bits for process ids n = 4 # Number of processes in the group # Check for command line parameters m, n. if len(sys.argv) > 2: m = int(sys.argv[1]) n = int(sys.argv[2]) # Flush communication channel chan = lab_channel.Channel() chan.channel.flushall() # we need to spawn processes for support of windows mp.set_start_method('spawn') # create barriers to synchonize bootstrapping bar1 = mp.Barrier(n) # Wait for channel population to complete bar2 = mp.Barrier(n) # Wait for process-group init to complete # start n competing peers in separate processes children = [] for i in range(n): peer_proc = mp.Process(target=create_and_run, name="Peer-" + str(i), args=(m, Process, bar1, bar2))
def __init__(self): self.chan = lab_channel.Channel() self.server = self.chan.join('server') self.timeout = 3
def __init__(self): self.chan = lab_channel.Channel() self.client = self.chan.join('client') self.server = None
def __init__(self): self.chan = lab_channel.Channel() self.client = self.chan.join('client') self.server = None self.logger = logging.getLogger("vs2lab.lab2.rpc.client") self.logger.info("init client")