def do_reclaim_delegation(self,
                              *,
                              actor: ABCActorMixin,
                              proxy: ABCBrokerProxy,
                              delegation: ABCDelegation,
                              callback: ABCClientCallbackProxy,
                              caller: AuthToken,
                              id_token: str = None):
        proxy.get_logger().info(
            "Outbound reclaim delegation request from <{}>: {}".format(
                caller.get_name(), delegation))

        state = proxy.prepare_reclaim_delegation(delegation=delegation,
                                                 callback=callback,
                                                 caller=caller,
                                                 id_token=id_token)
        state.set_caller(caller=caller)
        state.set_type(rtype=RPCRequestType.ReclaimDelegation)

        rpc = RPCRequest(request=state,
                         actor=actor,
                         proxy=proxy,
                         delegation=delegation,
                         sequence=delegation.get_sequence_out())
        # Schedule a timeout
        rpc.timer = KernelTimer.schedule(queue=actor,
                                         task=ReclaimTimeout(req=rpc),
                                         delay=self.CLAIM_TIMEOUT_SECONDS)
        proxy.get_logger().info("Timer started: {} for Reclaim".format(
            rpc.timer))
        self.enqueue(rpc=rpc)
Exemplo n.º 2
0
    def __init__(self,
                 *,
                 e: RPCException = None,
                 request_type: RPCRequestType = None,
                 rid: ID = None,
                 auth: AuthToken = None,
                 request: RPCRequest = None):
        if e is None:
            raise RPCException(message="error cannot be None")

        if rid is None and request is None:
            raise RPCException(message="Both request and rid cannot be None")

        self.error = e
        self.request_type = request_type
        self.rid = rid
        self.remote_auth = auth
        self.request = request

        if request is not None:
            if self.rid is None:
                if request.get_reservation() is not None:
                    self.rid = request.get_reservation().get_reservation_id()
                elif request.get_delegation() is not None:
                    self.rid = request.get_delegation().get_delegation_id()
            if self.request_type is None:
                self.request_type = request.get_request_type()
Exemplo n.º 3
0
 def run(request: RPCRequest, producer: AvroProducerApi):
     """
     Execute RPC
     """
     logger = request.actor.get_logger()
     logger.debug("Performing RPC: type={} to:{}".format(request.request.get_type(),
                                                         request.proxy.get_name()))
     try:
         request.proxy.execute(request=request.request, producer=producer)
         if request.handler is None:
             if request.timer is not None:
                 logger.debug("Canceling the timer: {}".format(request.timer))
             request.cancel_timer()
     except RPCException as e:
         RPCExecutor.post_exception(request=request, e=e)
     finally:
         logger.debug("Completed RPC: type= {} to: {}".format(request.request.get_type(),
                                                              request.proxy.get_name()))
         from fabric_cf.actor.core.kernel.rpc_manager_singleton import RPCManagerSingleton
         RPCManagerSingleton.get().de_queued()
    def do_query_result(self, *, actor: ABCActorMixin,
                        remote_actor: ABCCallbackProxy, request_id: str,
                        response: dict, caller: AuthToken):
        remote_actor.get_logger().info(
            "Outbound query_result request from <{}>".format(
                caller.get_name()))

        state = remote_actor.prepare_query_result(request_id=request_id,
                                                  response=response,
                                                  caller=caller)
        state.set_caller(caller=caller)
        state.set_type(rtype=RPCRequestType.QueryResult)
        rpc = RPCRequest(request=state, actor=actor, proxy=remote_actor)
        self.enqueue(rpc=rpc)
    def do_query(self, *, actor: ABCActorMixin, remote_actor: ABCActorProxy,
                 local_actor: ABCCallbackProxy, query: dict,
                 handler: ABCQueryResponseHandler, caller: AuthToken,
                 id_token: str):
        remote_actor.get_logger().info(
            "Outbound query request from <{}>".format(caller.get_name()))

        state = remote_actor.prepare_query(callback=local_actor,
                                           query=query,
                                           caller=caller,
                                           id_token=id_token)
        state.set_caller(caller=caller)
        state.set_type(rtype=RPCRequestType.Query)
        rpc = RPCRequest(request=state,
                         actor=actor,
                         proxy=remote_actor,
                         handler=handler)
        # Timer
        rpc.timer = KernelTimer.schedule(queue=actor,
                                         task=QueryTimeout(req=rpc),
                                         delay=self.QUERY_TIMEOUT_SECONDS)
        remote_actor.get_logger().info("Timer started: {} for Query".format(
            rpc.timer))
        self.enqueue(rpc=rpc)
    def do_close(self, *, actor: ABCActorMixin, proxy: ABCAuthorityProxy,
                 reservation: ABCControllerReservation,
                 callback: ABCControllerCallbackProxy, caller: AuthToken):
        proxy.get_logger().info("Outbound close request from <{}>: {}".format(
            caller.get_name(), reservation))

        state = proxy.prepare_close(reservation=reservation,
                                    callback=callback,
                                    caller=caller)
        state.set_caller(caller=caller)
        state.set_type(rtype=RPCRequestType.Close)
        rpc = RPCRequest(request=state,
                         actor=actor,
                         proxy=proxy,
                         reservation=reservation,
                         sequence=reservation.get_lease_sequence_out())
        self.enqueue(rpc=rpc)
    def do_ticket(self, *, actor: ABCActorMixin, proxy: ABCBrokerProxy,
                  reservation: ABCClientReservation,
                  callback: ABCClientCallbackProxy, caller: AuthToken):
        proxy.get_logger().info("Outbound ticket request from <{}>: {}".format(
            caller.get_name(), reservation))

        state = proxy.prepare_ticket(reservation=reservation,
                                     callback=callback,
                                     caller=caller)
        state.set_caller(caller=caller)
        state.set_type(rtype=RPCRequestType.Ticket)
        rpc = RPCRequest(request=state,
                         actor=actor,
                         proxy=proxy,
                         reservation=reservation,
                         sequence=reservation.get_ticket_sequence_out())
        self.enqueue(rpc=rpc)
    def do_update_delegation(self, *, actor: ABCActorMixin,
                             proxy: ABCClientCallbackProxy,
                             delegation: ABCDelegation,
                             update_data: UpdateData,
                             callback: ABCCallbackProxy, caller: AuthToken):
        proxy.get_logger().info(
            "Outbound update delegation request from <{}>: {}".format(
                caller.get_name(), delegation))

        state = proxy.prepare_update_delegation(delegation=delegation,
                                                update_data=update_data,
                                                callback=callback,
                                                caller=caller)
        state.set_caller(caller=caller)
        state.set_type(rtype=RPCRequestType.UpdateDelegation)
        rpc = RPCRequest(request=state,
                         actor=actor,
                         proxy=proxy,
                         delegation=delegation,
                         sequence=delegation.get_sequence_out())
        self.enqueue(rpc=rpc)