コード例 #1
0
 public ServiceRemotingClientWrapper(IServiceRemotingClient inner)
 {
     _inner = inner;
     ResolvedServicePartition = inner.ResolvedServicePartition;
     ListenerName             = inner.ListenerName;
     Endpoint = inner.Endpoint;
 }
コード例 #2
0
        public CorrelatingServiceRemotingClient(IServiceRemotingClient innerClient, Uri serviceUri, IMethodNameProvider methodNameProvider)
        {
            InnerClient = innerClient ?? throw new ArgumentNullException(nameof(innerClient));

            this.serviceUri         = serviceUri ?? throw new ArgumentNullException(nameof(serviceUri));
            this.methodNameProvider = methodNameProvider;
        }
コード例 #3
0
 public Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client,
                                                                   ExceptionInformation exceptionInformation,
                                                                   OperationRetrySettings retrySettings,
                                                                   CancellationToken cancellationToken)
 {
     return(serviceRemotingClientFactory.ReportOperationExceptionAsync(((ServiceRemotingClientWrapper)client).Client, exceptionInformation, retrySettings, cancellationToken));
 }
コード例 #4
0
        public Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client, ExceptionInformation exceptionInformation, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            IServiceRemotingClient effectiveClient = (client as IWrappingClient)?.InnerClient ?? client;

            return(_innerClientFactory.ReportOperationExceptionAsync(effectiveClient, exceptionInformation, retrySettings,
                                                                     cancellationToken));
        }
コード例 #5
0
 public FabricTransportActorRemotingClient(IServiceRemotingClient innerClient, Uri serviceUri, IActorClientLogger logger,
                                           MethodDispatcherBase actorMethodDispatcher, MethodDispatcherBase serviceMethodDispatcher)
     : base(innerClient, serviceUri, logger, serviceMethodDispatcher)
 {
     _logger = logger;
     _actorMethodDispatcher = actorMethodDispatcher;
 }
コード例 #6
0
        public async Task <IServiceRemotingClient> GetClientAsync(Uri serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, string listenerName, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            IServiceRemotingClient inner = await _inner.GetClientAsync(
                serviceUri, partitionKey, targetReplicaSelector, listenerName, retrySettings, cancellationToken);

            return(new CorrelatingServiceRemotingClient(inner));
        }
 public ServiceRemotingClientWrapper(IServiceRemotingClient client, Func <CustomHeaders> customHeadersProvider, Func <ServiceRequestInfo, Task <object> > beforeSendRequestResponseAsync, Func <ServiceResponseInfo, Task> afterSendRequestResponseAsync)
 {
     Client = client;
     this.customHeadersProvider          = customHeadersProvider;
     this.beforeSendRequestResponseAsync = beforeSendRequestResponseAsync;
     this.afterSendRequestResponseAsync  = afterSendRequestResponseAsync;
 }
コード例 #8
0
        public async Task <IServiceRemotingClient> GetClientAsync(ResolvedServicePartition previousRsp, TargetReplicaSelector targetReplicaSelector, string listenerName, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            IServiceRemotingClient inner = await _inner.GetClientAsync(
                previousRsp, targetReplicaSelector, listenerName, retrySettings, cancellationToken);

            return(new CorrelatingServiceRemotingClient(inner));
        }
コード例 #9
0
        public async Task <IServiceRemotingClient> GetClientAsync(ResolvedServicePartition previousRsp, TargetReplicaSelector targetReplicaSelector, string listenerName, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            IServiceRemotingClient innerClient = await _innerClientFactory
                                                 .GetClientAsync(previousRsp, targetReplicaSelector, listenerName, retrySettings, cancellationToken)
                                                 .ConfigureAwait(false);

            return(new CorrelatingServiceRemotingClient(innerClient, previousRsp.ServiceName, _methodNameProvider));
        }
コード例 #10
0
        public async Task <IServiceRemotingClient> GetClientAsync(Uri serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, string listenerName, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            IServiceRemotingClient innerClient = await _innerClientFactory
                                                 .GetClientAsync(serviceUri, partitionKey, targetReplicaSelector, listenerName,
                                                                 retrySettings, cancellationToken).ConfigureAwait(false);

            return(new CorrelatingServiceRemotingClient(innerClient, serviceUri, _methodNameProvider));
        }
コード例 #11
0
 public Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client, ExceptionInformation exceptionInformation, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
 {
     return(this.ReportOperationExceptionAsync(
                (client as CustomServiceRemotingClient).InnerClient,
                exceptionInformation,
                retrySettings,
                cancellationToken));
 }
コード例 #12
0
 public CorrelatingServiceRemotingClient(ILog log, IServiceRemotingClient inner, Action <CallSummary> raiseSummary, string remoteServiceName)
 {
     _log               = log;
     _inner             = inner;
     _raiseSummary      = raiseSummary;
     _remoteServiceName = remoteServiceName;
     _enricher          = new RequestEnricher();
 }
コード例 #13
0
 public FabricTransportServiceRemotingClient(IServiceRemotingClient innerClient, Uri serviceUri, IServiceClientLogger logger,
                                             MethodDispatcherBase serviceMethodDispatcher)
 {
     InnerClient = innerClient;
     ServiceUri  = serviceUri;
     Logger      = logger;
     _serviceMethodDispatcher = serviceMethodDispatcher;
 }
コード例 #14
0
 /// <summary>
 /// Registers an <see cref="OperationRetryControl"/> to return from <see cref="ReportOperationExceptionAsync"/>.
 /// </summary>
 /// <param name="client"></param>
 /// <param name="control"></param>
 public void RegisterOperationRetryControl(IServiceRemotingClient client, OperationRetryControl control)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     _operationRetryControls[client] = control;
 }
コード例 #15
0
        public async Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client, ExceptionInformation exceptionInformation, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            if (client is CorrelatingServiceRemotingClient correlatingClient)
            {
                client = correlatingClient.Inner;
            }

            return(await _inner.ReportOperationExceptionAsync(client, exceptionInformation, retrySettings, cancellationToken));
        }
コード例 #16
0
 public CorrelatingServiceRemotingClient(
    IServiceRemotingClient innerClient,
    Uri serviceUri,
    IMethodNameProvider methodNameProvider)
 {
    InnerClient = innerClient;
    _serviceUri = serviceUri;
    _methodNameProvider = methodNameProvider;
 }
コード例 #17
0
        /// <summary>
        /// Registers the provided <paramref name="exceptionInformation"/> in <see cref="ReportedExceptionInformation"/> and return the registered <see cref="OperationRetryControl"/>. (using <see cref="RegisterOperationRetryControl"/>)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="exceptionInformation"></param>
        /// <param name="retrySettings"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client, ExceptionInformation exceptionInformation,
                                                                          OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            _reportedExceptionInformation[client] = exceptionInformation;
            OperationRetryControl operationRetryControl;

            _operationRetryControls.TryGetValue(client, out operationRetryControl);
            return(Task.FromResult(operationRetryControl));
        }
 public Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client, ExceptionInformation exceptionInformation, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
 {
     return(this.innerFactory.ReportOperationExceptionAsync(
                // HACK: requirement that the inner client is the original remoting client for the inner factory - there seems to be some bleed out in their design here
                ((FabricTransportPipelineServiceRemotingClient)client).InnerClient,
                exceptionInformation,
                retrySettings,
                cancellationToken));
 }
 /// <summary>
 /// Handles the exceptions that occur in the CommunicationClient when sending a message to the Service
 /// </summary>
 /// <param name="client">Communication client</param>
 /// <param name="exceptionInformation">Information about exception that happened while communicating with the service.</param>
 /// <param name="retrySettings">Specifies the retry policy that should be used for handling the reported exception.</param>
 /// <param name="cancellationToken">Cancellation token</param>
 /// <returns>
 /// A <see cref="System.Threading.Tasks.Task">Task</see> that represents outstanding operation. The result of the Task is
 /// a <see cref="OperationRetryControl" /> object that provides information on retry policy for this exception.
 /// </returns>
 public Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client,
                                                                   ExceptionInformation exceptionInformation,
                                                                   OperationRetrySettings retrySettings, CancellationToken cancellationToken)
 {
     return(this.clientFactoryImpl.ReportOperationExceptionAsync((FabricTransportServiceRemotingClient)client,
                                                                 exceptionInformation,
                                                                 retrySettings,
                                                                 cancellationToken));
 }
コード例 #20
0
 public Task <OperationRetryControl> ReportOperationExceptionAsync(
     IServiceRemotingClient client,
     ExceptionInformation exceptionInformation,
     OperationRetrySettings retrySettings,
     CancellationToken cancellationToken) =>
 m_serviceRemotingClientFactory.ReportOperationExceptionAsync(
     Unwrap(client),
     exceptionInformation,
     retrySettings,
     cancellationToken);
        public async Task <IServiceRemotingClient> GetClientAsync(ResolvedServicePartition previousRsp, TargetReplicaSelector targetReplicaSelector, string listenerName, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            IServiceRemotingClient client = await this.innerFactory.GetClientAsync(
                previousRsp,
                targetReplicaSelector,
                listenerName,
                retrySettings,
                cancellationToken);

            return(new FabricTransportPipelineServiceRemotingClient(client));
        }
コード例 #22
0
 /// <summary>
 /// Handles the exceptions that occur in the CommunicationClient when sending a message to the Service
 /// </summary>
 /// <param name="client">Communication client</param>
 /// <param name="exceptionInformation">Information about exception that happened while communicating with the service.</param>
 /// <param name="retrySettings">Specifies the retry policy that should be used for handling the reported exception.</param>
 /// <param name="cancellationToken">Cancellation token</param>
 /// <returns>
 /// A <see cref="System.Threading.Tasks.Task">Task</see> that represents outstanding operation. The result of the Task is
 /// a <see cref="OperationRetryControl" /> object that provides information on retry policy for this exception.
 /// </returns>
 Task <OperationRetryControl> ICommunicationClientFactory <IServiceRemotingClient> .ReportOperationExceptionAsync(
     IServiceRemotingClient client,
     ExceptionInformation exceptionInformation,
     OperationRetrySettings retrySettings,
     CancellationToken cancellationToken)
 {
     return(this.wcfFactory.ReportOperationExceptionAsync(
                ((WcfServiceRemotingClient)client).WcfClient,
                exceptionInformation,
                retrySettings,
                cancellationToken));
 }
コード例 #23
0
        public Task <OperationRetryControl> ReportOperationExceptionAsync(
            IServiceRemotingClient client,
            ExceptionInformation exceptionInformation,
            OperationRetrySettings retrySettings,
            CancellationToken cancellationToken)
        {
            IServiceRemotingClient innerClient = ((ActivityServiceRemotingClient)client)._inner;

            return(_inner.ReportOperationExceptionAsync(
                       innerClient,
                       exceptionInformation,
                       retrySettings,
                       cancellationToken));
        }
コード例 #24
0
        public async Task <IServiceRemotingClient> GetClientAsync(
            Uri serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, string listenerName,
            OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            IServiceRemotingClient remotingClient = await this.innerRemotingClientFactory.GetClientAsync(
                serviceUri,
                partitionKey,
                targetReplicaSelector,
                listenerName,
                retrySettings,
                cancellationToken);

            return(new MyServiceRemotingClient(remotingClient));
        }
 public Task <OperationRetryControl> ReportOperationExceptionAsync(
     IServiceRemotingClient client,
     ExceptionInformation exceptionInformation,
     OperationRetrySettings retrySettings,
     CancellationToken cancellationToken)
 {
     return(_InnerClientFactory.ReportOperationExceptionAsync(
                // This expects a an object of type FabricTransportServiceRemotingClient, hence
                // why we need to expose the InnerClient here.
                // https://github.com/Azure/service-fabric-services-and-actors-dotnet/issues/43
                ((TrackingFabricTransportServiceRemotingClient)client).InnerClient,
                exceptionInformation,
                retrySettings,
                cancellationToken));
 }
        public Task <OperationRetryControl> ReportOperationExceptionAsync(
            IServiceRemotingClient client,
            ExceptionInformation exceptionInformation,
            OperationRetrySettings retrySettings,
            CancellationToken cancellationToken)
        {
            var customClient = client as CustomServiceRemotingClient;

            if (customClient != null)
            {
                client = customClient.Wrapped;
            }

            return(this._wrapped.ReportOperationExceptionAsync(client, exceptionInformation, retrySettings, cancellationToken));
        }
        /// <summary>
        /// Initializes the <see cref="CorrelatingServiceRemotingClient"/> object. It wraps the given inner client object for all the core
        /// remote call operation.
        /// </summary>
        /// <param name="innerClient">The client object which this client wraps.</param>
        /// <param name="serviceUri">The target Uri of the service which this client will call.</param>
        /// <param name="methodNameProvider">The provider that helps resolve method ids into method names.</param>
        public CorrelatingServiceRemotingClient(IServiceRemotingClient innerClient, Uri serviceUri, IMethodNameProvider methodNameProvider)
        {
            if (innerClient == null)
            {
                throw new ArgumentNullException(nameof(innerClient));
            }
            if (serviceUri == null)
            {
                throw new ArgumentNullException(nameof(serviceUri));
            }

            this.InnerClient        = innerClient;
            this.serviceUri         = serviceUri;
            this.telemetryClient    = new TelemetryClient();
            this.methodNameProvider = methodNameProvider;
        }
コード例 #28
0
        public async Task <OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client, ExceptionInformation exceptionInformation, OperationRetrySettings retrySettings, CancellationToken cancellationToken)
        {
            var exceptionTelemetry = new ExceptionTelemetry();

            exceptionTelemetry.Context.Operation.Id = CallContext.GetData(Constants.CorrelationId)?.ToString();
            exceptionTelemetry.Exception            = exceptionInformation.Exception;
            exceptionTelemetry.Message = "An unhandled exception occured";

            _telemetryClient.TrackException(exceptionTelemetry);

            //Use the inner client since this is the one who does all the requests etc
            var wrapperClient = client as ServiceRemotingClientWrapper;
            var innerClient   = await _inner.GetClientAsync(wrapperClient.ResolvedServicePartition, TargetReplicaSelector.Default, wrapperClient.ListenerName, retrySettings, cancellationToken);

            return(await _inner.ReportOperationExceptionAsync(innerClient, exceptionInformation, retrySettings, cancellationToken));
        }
コード例 #29
0
        public async Task <IServiceRemotingClient> GetClientAsync(
            ResolvedServicePartition previousRsp,
            TargetReplicaSelector targetReplicaSelector,
            string listenerName,
            OperationRetrySettings retrySettings,
            CancellationToken cancellationToken)
        {
            IServiceRemotingClient client = await m_serviceRemotingClientFactory.GetClientAsync(
                previousRsp,
                targetReplicaSelector,
                listenerName,
                retrySettings,
                cancellationToken).ConfigureAwait(false);

            return(new ServiceRemotingClientWrapper(client));
        }
        /// <summary>
        /// Initializes the <see cref="CorrelatingServiceRemotingClient"/> object. It wraps the given inner client object for all the core
        /// remote call operation.
        /// </summary>
        /// <param name="innerClient">The client object which this client wraps.</param>
        /// <param name="serviceUri">The target Uri of the service which this client will call.</param>
        /// <param name="methodNameProvider">The provider that helps resolve method ids into method names.</param>
        public CorrelatingServiceRemotingClient(IServiceRemotingClient innerClient, Uri serviceUri, IMethodNameProvider methodNameProvider)
        {
            if (innerClient == null)
            {
                throw new ArgumentNullException(nameof(innerClient));
            }
            if (serviceUri == null)
            {
                throw new ArgumentNullException(nameof(serviceUri));
            }

            this.InnerClient        = innerClient;
            this.serviceUri         = serviceUri;
            this.baggageSerializer  = new Lazy <DataContractSerializer>(() => new DataContractSerializer(typeof(IEnumerable <KeyValuePair <string, string> >)));
            this.telemetryClient    = new TelemetryClient();
            this.methodNameProvider = methodNameProvider;
        }
 public virtual Task<OperationRetryControl> ReportOperationExceptionAsync(IServiceRemotingClient client, Exception exception, string listenerName, CancellationToken cancellationToken)
 {
     return WcfFactory.ReportOperationExceptionAsync(((WcfServiceRemotingClient)client).WcfClient, exception, listenerName, cancellationToken);
 }