Ejemplo n.º 1
0
    def register_with_supernode(self):
        Node.update_supernode_rtt()
        # TODO hacky hacky hacky. moving query inside of the node causes
        # SQLAlchemy session errors.
        session.commit()
        session.close_all()

        if not self.node().supernode:
            if not Node.supernodes():
                self.node().supernode = True
                log.info("Registering %s as a supernode, none others found",
                        self.node())
                self.register_with_origin()
            else:
                for supernode in Node.supernodes().order_by('rtt'):
                    self.node().primary_supernode = supernode
                    try:
                        NodesAPI(self.node().primary_supernode.uri()).register(
                                self.node().to_dict())
                    except RequestError, e:
                        log.warning("Can't connect to supernode %s to register"
                                ": %s", self.node().primary_supernode, e)
                        log.info("Informing web server that supernode %s is "
                                "unresponsive and should be deleted", supernode)
                        NodesAPI(settings.ASTRAL_WEBSERVER).unregister(
                                supernode.absolute_url())
                        self.node().primary_supernode = None
                    except RequestFailed, e:
                        log.warning("%s rejected us as a child node: %s",
                                supernode, e)
                        self.node().primary_supernode = None
                    else:
                        self.load_dynamic_bootstrap_nodes(
                                self.node().primary_supernode.uri())
Ejemplo n.º 2
0
 def _request_stream_from_supernodes(cls, stream, destination,
         unconfirmed_tickets=None):
     tickets = []
     for supernode in Node.supernodes():
         if supernode != Node.me() and not cls._already_ticketed(
                 unconfirmed_tickets, destination):
             tickets.append(cls._request_stream_from_node(stream,
                 supernode, destination))
     return filter(None, tickets)
Ejemplo n.º 3
0
 def _request_stream_from_supernodes(cls,
                                     stream,
                                     destination,
                                     unconfirmed_tickets=None):
     tickets = []
     for supernode in Node.supernodes():
         if supernode != Node.me() and not cls._already_ticketed(
                 unconfirmed_tickets, destination):
             tickets.append(
                 cls._request_stream_from_node(stream, supernode,
                                               destination))
     return filter(None, tickets)
Ejemplo n.º 4
0
    def register_with_supernode(self):
        Node.update_supernode_rtt()
        # TODO hacky hacky hacky. moving query inside of the node causes
        # SQLAlchemy session errors.
        session.commit()
        session.close_all()

        if not self.node().supernode:
            if not Node.supernodes():
                self.node().supernode = True
                log.info("Registering %s as a supernode, none others found",
                         self.node())
                self.register_with_origin()
            else:
                for supernode in Node.supernodes().order_by('rtt'):
                    self.node().primary_supernode = supernode
                    try:
                        NodesAPI(self.node().primary_supernode.uri()).register(
                            self.node().to_dict())
                    except RequestError, e:
                        log.warning(
                            "Can't connect to supernode %s to register"
                            ": %s",
                            self.node().primary_supernode, e)
                        log.info(
                            "Informing web server that supernode %s is "
                            "unresponsive and should be deleted", supernode)
                        NodesAPI(settings.ASTRAL_WEBSERVER).unregister(
                            supernode.absolute_url())
                        self.node().primary_supernode = None
                    except RequestFailed, e:
                        log.warning("%s rejected us as a child node: %s",
                                    supernode, e)
                        self.node().primary_supernode = None
                    else:
                        self.load_dynamic_bootstrap_nodes(
                            self.node().primary_supernode.uri())
Ejemplo n.º 5
0
                         supernode, e)
                 self.node().primary_supernode = None
             else:
                 self.load_dynamic_bootstrap_nodes(
                         self.node().primary_supernode.uri())
         if not self.node().primary_supernode:
             self.node().supernode = True
             log.info("No supernode could take us - "
                     "registering ourselves %s as a supernode",
                     self.node())
             self.register_with_origin()
 else:
     log.info("Registering %s as a supernode, my database told me so",
             self.node())
     self.register_with_origin()
     for supernode in Node.supernodes():
         if supernode != Node.me():
             try:
                 NodesAPI(supernode.uri()).register(
                         self.node().to_dict())
             except RequestError, e:
                 log.warning("Can't connect to supernode %s: %s",
                         supernode, e)
                 supernode.delete()
                 log.info("Informing web server that %s is unresponsive "
                         "and should be deleted", supernode)
                 NodesAPI(settings.ASTRAL_WEBSERVER).unregister(
                         supernode.absolute_url())
             except RequestFailed:
                 log.warning("%s threw an error - sure it's not "
                         "running on another computer in your LAN with "
Ejemplo n.º 6
0
                             supernode, e)
                 self.node().primary_supernode = None
             else:
                 self.load_dynamic_bootstrap_nodes(
                     self.node().primary_supernode.uri())
         if not self.node().primary_supernode:
             self.node().supernode = True
             log.info(
                 "No supernode could take us - "
                 "registering ourselves %s as a supernode", self.node())
             self.register_with_origin()
 else:
     log.info("Registering %s as a supernode, my database told me so",
              self.node())
     self.register_with_origin()
     for supernode in Node.supernodes():
         if supernode != Node.me():
             try:
                 NodesAPI(supernode.uri()).register(
                     self.node().to_dict())
             except RequestError, e:
                 log.warning("Can't connect to supernode %s: %s",
                             supernode, e)
                 supernode.delete()
                 log.info(
                     "Informing web server that %s is unresponsive "
                     "and should be deleted", supernode)
                 NodesAPI(settings.ASTRAL_WEBSERVER).unregister(
                     supernode.absolute_url())
             except RequestFailed:
                 log.warning(