コード例 #1
0
        public void SendRequest(GrainReference reference, IResponseCompletionSource callback, IInvokable body, InvokeMethodOptions options)
        {
            SetGrainCancellationTokensTarget(reference, body);
            var copy = body;//this.deepCopier.Copy(body);

            this.RuntimeClient.SendRequest(reference, copy, callback, options);
        }
コード例 #2
0
ファイル: CallbackData.cs プロジェクト: dotnet/orleans
        private static void OnRejection(Message message, IResponseCompletionSource context)
        {
            Exception rejection;

            switch (message.RejectionType)
            {
            case Message.RejectionTypes.GatewayTooBusy:
                rejection = new GatewayTooBusyException();
                break;

            case Message.RejectionTypes.DuplicateRequest:
                return;     // Ignore duplicates

            default:
                rejection = message.BodyObject as Exception;
                if (rejection == null)
                {
                    if (string.IsNullOrEmpty(message.RejectionInfo))
                    {
                        message.RejectionInfo = "Unable to send request - no rejection info available";
                    }
                    rejection = new OrleansMessageRejectionException(message.RejectionInfo);
                }
                break;
            }

            context.Complete(Response.FromException(rejection));
        }
コード例 #3
0
        public void SendRequest(GrainReference target, IInvokable request, IResponseCompletionSource context, InvokeMethodOptions options)
        {
            var message = this.messageFactory.CreateMessage(request, options);

            OrleansOutsideRuntimeClientEvent.Log.SendRequest(message);

            SendRequestMessage(target, message, context, options);
        }
コード例 #4
0
ファイル: CallbackData.cs プロジェクト: dotnet/orleans
 public CallbackData(
     SharedCallbackData shared,
     IResponseCompletionSource ctx,
     Message msg)
 {
     this.shared    = shared;
     this.context   = ctx;
     this.Message   = msg;
     this.stopwatch = CoarseStopwatch.StartNew();
 }
コード例 #5
0
ファイル: CallbackData.cs プロジェクト: dotnet/orleans
 public static void ResponseCallback(Message message, IResponseCompletionSource context)
 {
     if (message.Result != Message.ResponseTypes.Rejection)
     {
         try
         {
             var response = (Response)message.BodyObject;
             context.Complete(response);
         }
         catch (Exception exc)
         {
             // catch the exception and break the promise with it.
             context.Complete(Response.FromException(exc));
         }
     }
     else
     {
         OnRejection(message, context);
     }
 }
コード例 #6
0
        private void SendRequestMessage(GrainReference target, Message message, IResponseCompletionSource context, InvokeMethodOptions options)
        {
            message.InterfaceType    = target.InterfaceType;
            message.InterfaceVersion = target.InterfaceVersion;
            var targetGrainId = target.GrainId;
            var oneWay        = (options & InvokeMethodOptions.OneWay) != 0;

            message.SendingGrain      = CurrentActivationAddress.Grain;
            message.SendingActivation = CurrentActivationAddress.Activation;
            message.TargetGrain       = targetGrainId;

            if (SystemTargetGrainId.TryParse(targetGrainId, out var systemTargetGrainId))
            {
                // If the silo isn't be supplied, it will be filled in by the sender to be the gateway silo
                message.TargetSilo       = systemTargetGrainId.GetSiloAddress();
                message.TargetActivation = ActivationId.GetDeterministic(targetGrainId);
            }

            if (message.IsExpirableMessage(this.clientMessagingOptions.DropExpiredMessages))
            {
                // don't set expiration for system target messages.
                message.TimeToLive = this.clientMessagingOptions.ResponseTimeout;
            }

            if (!oneWay)
            {
                var callbackData = new CallbackData(this.sharedCallbackData, context, message);
                callbacks.TryAdd(message.Id, callbackData);
            }
            else
            {
                context?.Complete();
            }

            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.Trace("Send {0}", message);
            }
            MessageCenter.SendMessage(message);
        }
コード例 #7
0
        public void SendRequest(GrainId grainId, IResponseCompletionSource completion, IInvokable body)
        {
            var message = MessagePool.Get();

            message.Direction = Direction.Request;
            message.Target    = grainId;
            message.Body      = body;

            var currentActivation = RuntimeActivationContext.CurrentActivation;

            if (currentActivation != null)
            {
                currentActivation.OnSendMessage(message, completion);
            }
            else
            {
                message.MessageId = Interlocked.Increment(ref this.messageId);
                message.Source    = default;
                this.pendingRequests[message.MessageId] = completion;
            }

            this.connection.SendMessage(message);
        }
コード例 #8
0
 protected void SendRequest(IResponseCompletionSource callback, IInvokable body)
 {
 }
コード例 #9
0
 // The only required method is Invoke and it must have this signature.
 protected void SendRequest(IResponseCompletionSource completion, IInvokable request) => Invocations.Add(request);
コード例 #10
0
ファイル: ProxyBase.cs プロジェクト: swipswaps/Hagar
 protected void SendRequest(IResponseCompletionSource callback, IInvokable body) => _runtimeClient.SendRequest(GrainId, callback, body);
コード例 #11
0
        protected void SendRequest(IResponseCompletionSource callback, IInvokable body)
        {
            var request = (RequestBase)body;

            this.Runtime.SendRequest(this, callback, body, request.Options);
        }