コード例 #1
0
 def update_requirements(self,
                         actor_id,
                         requirements,
                         extend=False,
                         move=False,
                         authorization_check=False,
                         callback=None):
     """ Update requirements and trigger a potential migration """
     if actor_id not in self.actors:
         # Can only migrate actors from our node
         _log.analyze(self.node.id, "+ NO ACTOR", {'actor_id': actor_id})
         if callback:
             callback(status=response.CalvinResponse(False))
         return
     if not isinstance(requirements, (list, tuple)):
         # Requirements need to be list
         _log.analyze(self.node.id, "+ NO REQ LIST", {'actor_id': actor_id})
         if callback:
             callback(status=response.CalvinResponse(response.BAD_REQUEST))
         return
     actor = self.actors[actor_id]
     actor.requirements_add(requirements, extend)
     self.node.storage.add_actor(
         actor, self.node.id)  # Update requirements in registry
     r = ReqMatch(self.node,
                  callback=CalvinCB(self._update_requirements_placements,
                                    actor_id=actor_id,
                                    move=move,
                                    cb=callback))
     r.match_for_actor(actor_id)
     _log.analyze(self.node.id, "+ END", {'actor_id': actor_id})
コード例 #2
0
    def execute_requirements(self, application_id, cb):
        """ Build dynops iterator to collect all possible placements,
            then trigger migration.

            For initial deployment (all actors on the current node)
        """
        app = None
        try:
            app = self.applications[application_id]
        except:
            _log.debug("execute_requirements did not find app %s" % (application_id,))
            cb(status=response.CalvinResponse(False))
            return
        _log.debug("execute_requirements(app=%s)" % (self.applications[application_id],))

        if hasattr(app, '_org_cb'):
            # application deployment requirements ongoing, abort
            cb(status=response.CalvinResponse(False))
            return
        app._org_cb = cb
        app.actor_placement = {}  # Clean placement slate
        _log.analyze(self._node.id, "+ APP REQ", {}, tb=True)
        actor_ids = app.get_actors()
        app.actor_placement_nbr = len(actor_ids)
        for actor_id in actor_ids:
            if actor_id not in self._node.am.actors.keys():
                _log.debug("Only apply requirements to local actors")
                app.actor_placement[actor_id] = None
                continue
            _log.analyze(self._node.id, "+ ACTOR REQ", {'actor_id': actor_id}, tb=True)
            r = ReqMatch(self._node,
                         callback=CalvinCB(self.collect_placement, app=app, actor_id=actor_id))
            r.match_for_actor(actor_id)
            _log.analyze(self._node.id, "+ ACTOR REQ DONE", {'actor_id': actor_id}, tb=True)
        _log.analyze(self._node.id, "+ DONE", {'application_id': application_id}, tb=True)
コード例 #3
0
 def handle_req_match(self, tunnel, payload):
     actor_id = payload['actor_id']
     r = ReqMatch(self.node, callback=CalvinCB(self.handle_req_match_cb,
         actor_id=actor_id,
         max_placements=payload['max_placements'],
         tunnel=tunnel,
         msgid=payload['msg_uuid']))
     r.match(payload['requirements'], actor_id=actor_id)
コード例 #4
0
    def authorization_runtime_search(self, actor_id, actorstore_signature, callback):
        """Search for runtime where the authorization decision for the actor is 'permit'."""
#       _log.debug("authorization_runtime_search:\n\tactor_id={}\n\tactorstore_signature={}\n\tcallback={}".format(actor_id, actorstore_signature, callback))
        #Search for runtimes supporting the actor with appropriate actorstore_signature
        r = ReqMatch(self.node,
                     callback=CalvinCB(self._authorization_server_search,
                                       actor_id=actor_id,
                                       actorstore_signature=actorstore_signature,
                                       callback=callback))
        r.match_for_actor(actor_id)
コード例 #5
0
 def handle_req_match(self, tunnel, payload):
     actor_id = payload['actor_id']
     r = ReqMatch(self.node,
                  callback=CalvinCB(
                      self.handle_req_match_cb,
                      actor_id=actor_id,
                      max_placements=payload['max_placements'],
                      tunnel=tunnel,
                      msgid=payload['msg_uuid']))
     r.match(payload['requirements'], actor_id=actor_id)
コード例 #6
0
 def replicate_by_requirements(self, actor, callback=None):
     """ Update requirements and trigger a replication """
     actor._replicate_callback = callback
     req = actor._replication_data.requirements
     # Initiate any scaling specific actions
     req_operations[req['op']].initiate(self.node, actor, **req['kwargs'])
     r = ReqMatch(self.node,
                  callback=CalvinCB(self._update_requirements_placements, actor=actor))
     r.match_for_actor(actor.id)
     _log.analyze(self.node.id, "+ END", {'actor_id': actor.id})
コード例 #7
0
 def authorization_runtime_search(self, actor_id, actorstore_signature,
                                  callback):
     """Search for runtime where the authorization decision for the actor is 'permit'."""
     #       _log.debug("authorization_runtime_search:\n\tactor_id={}\n\tactorstore_signature={}\n\tcallback={}".format(actor_id, actorstore_signature, callback))
     #Search for runtimes supporting the actor with appropriate actorstore_signature
     r = ReqMatch(self.node,
                  callback=CalvinCB(
                      self._authorization_server_search,
                      actor_id=actor_id,
                      actorstore_signature=actorstore_signature,
                      callback=callback))
     r.match_for_actor(actor_id)
コード例 #8
0
 def replicate_by_requirements(self, replication_data, callback=None):
     """ Update requirements and trigger a replication """
     if replication_data.status != REPLICATION_STATUS.READY:
         if callback:
             callback(calvinresponse.CalvinResponse(calvinresponse.SERVICE_UNAVAILABLE))
         return
     replication_data.status = REPLICATION_STATUS.REPLICATING
     replication_data._replicate_callback = callback
     req = replication_data.requirements
     # Initiate any scaling specific actions
     req_operations[req['op']].initiate(self.node, replication_data, **req['kwargs'])
     r = ReqMatch(self.node,
                  callback=CalvinCB(self._update_requirements_placements, replication_data=replication_data),
                  replace_infinite=True)
     r.match_actor_registry(replication_data.original_actor_id)
     _log.analyze(self.node.id, "+ END", {'replication_data_id': replication_data.id})
コード例 #9
0
ファイル: appmanager.py プロジェクト: shashi12533/calvin-base
    def execute_requirements(self, application_id, cb):
        """ Build dynops iterator to collect all possible placements,
            then trigger migration.

            For initial deployment (all actors on the current node)
        """
        app = None
        try:
            app = self.applications[application_id]
        except:
            _log.debug("execute_requirements did not find app %s" %
                       (application_id, ))
            cb(status=response.CalvinResponse(False))
            return
        _log.debug("execute_requirements(app=%s)" %
                   (self.applications[application_id], ))

        if hasattr(app, '_org_cb'):
            # application deployment requirements ongoing, abort
            cb(status=response.CalvinResponse(False))
            return
        app._org_cb = cb
        app.actor_placement = {}  # Clean placement slate
        _log.analyze(self._node.id, "+ APP REQ", {}, tb=True)
        actor_ids = app.get_actors()
        app.actor_placement_nbr = len(actor_ids)
        for actor_id in actor_ids:
            if actor_id not in self._node.am.actors.keys():
                _log.debug("Only apply requirements to local actors")
                app.actor_placement[actor_id] = None
                continue
            _log.analyze(self._node.id,
                         "+ ACTOR REQ", {'actor_id': actor_id},
                         tb=True)
            r = ReqMatch(self._node,
                         callback=CalvinCB(self.collect_placement,
                                           app=app,
                                           actor_id=actor_id))
            r.match_for_actor(actor_id)
            _log.analyze(self._node.id,
                         "+ ACTOR REQ DONE", {'actor_id': actor_id},
                         tb=True)
        _log.analyze(self._node.id,
                     "+ DONE", {'application_id': application_id},
                     tb=True)
コード例 #10
0
 def update_requirements(self, actor_id, requirements, extend=False, move=False,
                         authorization_check=False, callback=None):
     """ Update requirements and trigger a potential migration """
     if actor_id not in self.actors:
         # Can only migrate actors from our node
         _log.analyze(self.node.id, "+ NO ACTOR", {'actor_id': actor_id})
         if callback:
             callback(status=response.CalvinResponse(False))
         return
     if not isinstance(requirements, (list, tuple)):
         # Requirements need to be list
         _log.analyze(self.node.id, "+ NO REQ LIST", {'actor_id': actor_id})
         if callback:
             callback(status=response.CalvinResponse(response.BAD_REQUEST))
         return
     actor = self.actors[actor_id]
     actor.requirements_add(requirements, extend)
     self.node.storage.add_actor(actor, self.node.id)  # Update requirements in registry
     r = ReqMatch(self.node,
                  callback=CalvinCB(self._update_requirements_placements, actor_id=actor_id, move=move, cb=callback))
     r.match_for_actor(actor_id)
     _log.analyze(self.node.id, "+ END", {'actor_id': actor_id})