コード例 #1
0
    def _processCall(self, payloadEnvelope: PayloadEnvelope, vortexName,
                     sendResponse, *args, **kwargs):
        """ Process
        
        Process the incoming RPC call payloads.
        
        """
        # If the sending vortex, is local, then ignore it, RPC can not be called locally
        if VortexFactory.isVortexNameLocal(vortexName):
            logger.warning(
                "Received RPC call to %s, from local vortex %s, ignoring it",
                self.__funcName, vortexName)
            return

        # Apply the "allow" logic
        if self.__acceptOnlyFromVortex and vortexName not in self.__acceptOnlyFromVortex:
            logger.debug(
                "Call from non-accepted vortex %s, allowing only from %s",
                vortexName, str(self.__acceptOnlyFromVortex))
            return

        # Get the args tuple
        payload = yield payloadEnvelope.decodePayloadDefer()
        argsTuple = payload.tuples[0]
        assert isinstance(
            argsTuple,
            _VortexRPCArgTuple), ("argsTuple is not an instance of %s" %
                                  _VortexRPCArgTuple)

        logger.debug("Received RPC call for %s", self.__funcName)

        # Call the method and setup the callbacks
        result = yield self.callLocally(argsTuple.args, argsTuple.kwargs)
        yield self._processCallCallback(result, sendResponse,
                                        payloadEnvelope.filt)
コード例 #2
0
    def _processResponseCallback(self, payloadEnvelope: PayloadEnvelope,
                                 stack):
        """ Process Response Callback
        
        Convert the PayloadResponse payload to the result from the remotely called
        method.
        
        """

        if not payloadEnvelope.result in (None, True):
            return Failure(Exception(
                payloadEnvelope.result).with_traceback(stack),
                           exc_tb=stack)

        # Get the Result from the payload
        payload = yield payloadEnvelope.decodePayloadDefer()
        resultTuple = payload.tuples[0]
        assert isinstance(
            resultTuple,
            _VortexRPCResultTuple), ("resultTuple is not an instance of %s" %
                                     _VortexRPCResultTuple)

        logger.debug("Received RPC result for %s", self.__funcName)

        # Return the remote result
        return resultTuple.result
コード例 #3
0
    def _process(self, payloadEnvelope: PayloadEnvelope, vortexName: str,
                 sendResponse: SendVortexMsgResponseCallable,
                 **kwargs) -> None:

        # Ignore responses from the backend, these are handled by PayloadResponse
        if vortexName == self._proxyToVortexName:
            return

        # Shortcut the logic, so that we don't decode the payload unless we need to.
        if not self._delegateProcessor.delegateCount:
            yield self._processForProxy(payloadEnvelope, vortexName,
                                        sendResponse)
            return

        # If we have local processors, then work out if this tupleAction is meant for
        # the local processor.
        payload = yield payloadEnvelope.decodePayloadDefer()

        assert len(payload.tuples) == 1, (
            "TupleActionProcessor:%s Expected 1 tuples, received %s" %
            (self._tupleActionProcessorName, len(payload.tuples)))

        tupleAction = payload.tuples[0]

        if self._delegateProcessor.hasDelegate(tupleAction.tupleName()):
            self._delegateProcessor._processTupleAction(
                payloadEnvelope.filt, sendResponse, tupleAction)
            return

        # Else, Just send it on to the delegate we're proxying for (the backend)
        yield self._processForProxy(payloadEnvelope, vortexName, sendResponse)
コード例 #4
0
    def _process(self, payloadEnvelope: PayloadEnvelope,
                 sendResponse: SendVortexMsgResponseCallable, **kwargs):
        """ Process the Payload / Tuple Action
        """

        payload = yield payloadEnvelope.decodePayloadDefer()

        assert len(payload.tuples) == 1, (
                "TupleActionProcessor:%s Expected 1 tuples, received %s" % (
            self._tupleActionProcessorName, len(payload.tuples)))

        tupleAction = payload.tuples[0]

        self._processTupleAction(payloadEnvelope.filt, sendResponse, tupleAction)
コード例 #5
0
    def _processTraceConfigPayload(self, payloadEnvelope: PayloadEnvelope,
                                   **kwargs):
        payload = yield payloadEnvelope.decodePayloadDefer()

        dataDict = payload.tuples[0]

        if payload.filt.get(plDeleteKey):
            modelSetKey = dataDict["modelSetKey"]
            traceConfigKeys = dataDict["traceConfigKeys"]
            self._removeTraceConfigFromCache(modelSetKey, traceConfigKeys)
            return

        modelSetKey = dataDict["modelSetKey"]

        traceConfigTuples: List[GraphDbTraceConfigTuple] = dataDict["tuples"]
        self._loadTraceConfigIntoCache(modelSetKey, traceConfigTuples)
コード例 #6
0
    def _processObserve(self, payloadEnvelope: PayloadEnvelope,
                        vortexUuid: str,
                        sendResponse: SendVortexMsgResponseCallable, **kwargs):
        cacheAll = payloadEnvelope.filt.get("cacheAll") == True

        payload = yield payloadEnvelope.decodePayloadDefer()

        lastUpdateByGridKey: DeviceGridT = payload.tuples[0]

        if not cacheAll:
            gridKeys = list(lastUpdateByGridKey.keys())
            self._observedGridKeysByVortexUuid[vortexUuid] = gridKeys
            self._rebuildStructs()

        self._replyToObserve(payload.filt,
                             lastUpdateByGridKey,
                             sendResponse,
                             cacheAll=cacheAll)
コード例 #7
0
    def __handlePrFailure(self, f: Failure, payloadEnvelope: PayloadEnvelope,
                          sendResponse: SendVortexMsgResponseCallable):
        payload = yield payloadEnvelope.decodePayloadDefer()
        action = payload.tuples[0]
        if f.check(TimeoutError):
            logger.error("Received no response from\nprocessor %s\naction %s",
                         self._filt, action)
        else:
            logger.error("Unexpected error, %s\nprocessor %s\naction %s", f,
                         self._filt, action)

        vortexLogFailure(f, logger)

        vortexMsg = yield PayloadEnvelope(filt=payloadEnvelope.filt,
                                          result=str(
                                              f.value)).toVortexMsgDefer()

        sendResponse(vortexMsg)