Exemple #1
0
    def locate():
        """Use to locate running instance of Chimera.

        When started, Manager creates a UDP broadcast server. This
        method tries to locate the Manager using a broadcast message
        and waiting for an answer.
        """
        
        sk = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sk.setblocking(0)

        try:
            try:
                sk.sendto(MANAGER_BEACON_CHALLENGE, ("", MANAGER_BEACON_PORT))
            
                ins, outs, excs = select.select([sk], [], [sk], 1)
            
                if sk in ins:
                    data, _ = sk.recvfrom(1024)
                    if data.strip() != MANAGER_BEACON_ERROR:
                        host, port = data.split(":")
                        return Proxy(uri=getManagerURI(host, int(port)))

                raise ManagerNotFoundException("Couldn't locate any suitable Manager.")

            except socket.error, e:
                raise ManagerNotFoundException("Error trying to locate a suitable Manager.")

        finally:
            sk.close()
Exemple #2
0
    def __init__(self, host=None, port=None):
        RemoteObject.__init__(self)

        log.info("Starting manager.")

        self.resources = ResourcesManager()
        self.classLoader = ClassLoader()

        # identity
        self.setGUID(MANAGER_LOCATION)

        # shutdown event
        self.died = threading.Event()

        # our daemon server
        self.adapter = ManagerAdapter(self, host, port)
        self.adapterThread = threading.Thread(target=self.adapter.requestLoop)
        self.adapterThread.setDaemon(True)
        self.adapterThread.start()

        # register ourselves
        self.resources.add(
            MANAGER_LOCATION,
            self,
            getManagerURI(self.getHostname(),
                          self.getPort()))
 def locate(host, port=None):
     """Simple class to easily contact an Manager
     """
     p = Proxy(uri=getManagerURI(host, port or MANAGER_DEFAULT_PORT))
     if not p.ping():
         raise ManagerNotFoundException("Couldn't find manager running on %s:%d" % (host, port))
     return p
Exemple #4
0
 def locate(host, port=None):
     """Simple class to easily contact an Manager
     """
     p = Proxy(uri=getManagerURI(host, port or MANAGER_DEFAULT_PORT))
     if not p.ping():
         raise ManagerNotFoundException(
             "Couldn't find manager running on %s:%d" % (host, port))
     return p
Exemple #5
0
    def __init__(self, host=None, port=None, local=False):
        RemoteObject.__init__(self)

        log.info("Starting manager.")

        self.resources = ResourcesManager()
        self.classLoader = ClassLoader()

        # identity
        self.setGUID(MANAGER_LOCATION)

        # shutdown event
        self.died = threading.Event()

        if not local:
            try:
                ManagerLocator.locate()
                raise ChimeraException("Chimera is already running"
                                       " on this system. Use chimera-admin"
                                       " to manage it.")
            except ManagerNotFoundException:
                # ok, we are alone.
                pass

        # our daemon server
        self.adapter = ManagerAdapter(self, host, port)
        self.adapterThread = threading.Thread(target=self.adapter.requestLoop)
        self.adapterThread.setDaemon(True)
        self.adapterThread.start()

        # finder beacon
        if not local:
            self.beacon = ManagerBeacon(self)
            self.beaconThread = threading.Thread(target=self.beacon.run)
            self.beaconThread.setDaemon(True)
            self.beaconThread.start()
        else:
            self.beacon = None

        # register ourself
        self.resources.add(MANAGER_LOCATION, self,
                           getManagerURI(self.getHostname(), self.getPort()))

        # signals
        signal.signal(signal.SIGTERM, self._sighandler)
        signal.signal(signal.SIGINT, self._sighandler)
        atexit.register(self._sighandler)
Exemple #6
0
    def __init__(self, host=None, port=None):
        RemoteObject.__init__(self)

        log.info("Starting manager.")

        self.resources = ResourcesManager()
        self.classLoader = ClassLoader()

        # identity
        self.setGUID(MANAGER_LOCATION)

        # shutdown event
        self.died = threading.Event()

        # our daemon server
        self.adapter = ManagerAdapter(self, host, port)
        self.adapterThread = threading.Thread(target=self.adapter.requestLoop)
        self.adapterThread.setDaemon(True)
        self.adapterThread.start()

        # register ourself
        self.resources.add(MANAGER_LOCATION, self,
                           getManagerURI(self.getHostname(), self.getPort()))