Exemplo n.º 1
0
 def drizzlerSetup(self):
     MM = 0 # multi mode flag off
     #the drizzler_thread is of the drizzler class within peer head,
     # it guides the construction of the net facing node ( kwargs are a place holder, not used )
     # the args it takes are for unique ports (peer and app_support, a start port and the net size
     while self.peer_port < (config.base_peer_port + config.net_size):
         try:
             drizzler_thread = Drizzler(args=(self.host, self.peer_port, self.local_port,
                                          config.base_peer_port, config.net_size, MM), kwargs={'a':'A', 'b':'B'})
             #start the thread
             drizzler_thread.start()
             break
         except:
             self.peer_port = self.peer_port + 1
             self.local_port = self.local_port + 1
     return
Exemplo n.º 2
0
 def drizzlerSetup(self):
     MM = 0  # multi mode flag off
     # the drizzler_thread is of the drizzler class within peer head,
     # it guides the construction of the net facing node ( kwargs are a place holder, not used )
     # the args it takes are for unique ports (peer and app_support, a start
     # port and the net size
     while self.peer_port < (config.base_peer_port + config.net_size):
         try:
             drizzler_thread = Drizzler(args=(self.host, self.peer_port, self.local_port,
                                              config.base_peer_port, config.net_size, MM), kwargs={'a': 'A', 'b': 'B'})
             # start the thread
             drizzler_thread.start()
             break
         except:
             self.peer_port = self.peer_port + 1
             self.local_port = self.local_port + 1
     return
Exemplo n.º 3
0
    def go_multi_mode(self):
        # MM only works from the node at the base_port
        MM = 1  # multi mode flag
        if self.peer_port == config.base_peer_port:
            threads = []    # a container for threads, which we may or may not attempt to search
            # we'll simulate the growth of the network with the building of
            # threads, net_size of them in this case
            peer_port = self.peer_port + 1
            local_port = self.local_port + 1
            while peer_port < (config.base_peer_port + config.net_size):
                print(peer_port)
                try:
                    # the drizzler_thread is of the drizzler class within peer head,
                    # it guides the construction of the net facing node ( kwargs are a place holder, not used )
                    # the args it takes are for unique ports (peer and
                    # app_support, a start port and the net size
                    drizzler_thread = Drizzler(args=(self.host, peer_port, local_port,
                                                     config.base_peer_port, config.net_size, MM), kwargs={'a': 'A', 'b': 'B'})
                    # add the thread to the container, it will be indexed by i,
                    # the offset of the port number, if it s needed
                    threads.append(drizzler_thread)
                    # start the thread, which doesn't happen right away
                    drizzler_thread.start()
                    # we sleep so a thread can take control

                    # starting them in order will generally allow them to
                    # insert into the network in order
                    time.sleep(.1)
                    # However, if the time is set below 0.1, then the threads may conflict with each other
                    # and instead of one large network, many little networks
                    # will emerge

                except Exception as e:
                    print(e)

                peer_port = peer_port + 1
                local_port = local_port + 1

            # this particular thread will wait for the network setup to
            # conclude
            print("Standby...")
            # I suggest setting net_size to 10 or less for development and
            # sleep to 3 seconds
            time.sleep(3)
        return "ALL NETWORK NODE THREADS HAVE STARTED"
Exemplo n.º 4
0
    def go_multi_mode(self):
        # MM only works from the node at the base_port
        MM = 1 # multi mode flag
        if self.peer_port == config.base_peer_port:
            threads = []    # a container for threads, which we may or may not attempt to search
            # we'll simulate the growth of the network with the building of threads, net_size of them in this case
            peer_port = self.peer_port + 1
            local_port = self.local_port + 1
            while peer_port < (config.base_peer_port + config.net_size):
                print(peer_port)
                try:
                    #the drizzler_thread is of the drizzler class within peer head,
                    # it guides the construction of the net facing node ( kwargs are a place holder, not used )
                    # the args it takes are for unique ports (peer and app_support, a start port and the net size
                    drizzler_thread = Drizzler(args=(self.host, peer_port, local_port,
                                                 config.base_peer_port, config.net_size, MM), kwargs={'a':'A', 'b':'B'})
                    #add the thread to the container, it will be indexed by i, the offset of the port number, if it s needed
                    threads.append(drizzler_thread)
                    #start the thread, which doesn't happen right away
                    drizzler_thread.start()
                    #we sleep so a thread can take control

                    # starting them in order will generally allow them to
                    # insert into the network in order
                    time.sleep(.1)
                    # However, if the time is set below 0.1, then the threads may conflict with each other
                    # and instead of one large network, many little networks will emerge

                except Exception as e:
                    print(e)

                peer_port = peer_port + 1
                local_port = local_port + 1

            # this particular thread will wait for the network setup to conclude
            print("Standby...")
            # I suggest setting net_size to 10 or less for development and sleep to 3 seconds
            time.sleep(3)
        return "ALL NETWORK NODE THREADS HAVE STARTED"