private void HandleResult(ThrottlingRpcResult rpcResult, long requestStartTime, long requestCompletionTime, ThrottlingRpcClient client)
        {
            long msecInterval = ThrottlingRpcClientImpl.GetMsecInterval(requestStartTime, requestCompletionTime);

            if (rpcResult != ThrottlingRpcResult.Failed && msecInterval <= 5000L)
            {
                this.HandleSuccessfulResponse();
            }
            else if (rpcResult != ThrottlingRpcResult.Failed)
            {
                ThrottlingRpcClientImpl.tracer.TraceError <string, long>(0L, "RPC request to mailbox server {0} took {1} milliseconds and treated as failed", this.serverName, msecInterval);
                ThrottlingRpcClientImpl.EventLogger.LogEvent(ThrottlingClientEventLogConstants.Tuple_RpcRequestTimedout, this.serverName, new object[]
                {
                    this.serverName,
                    msecInterval
                });
                this.HandleFailure(requestCompletionTime, null);
            }
            else
            {
                this.HandleFailure(requestCompletionTime, client);
            }
            ThrottlingRpcClientImpl.Unref(client);
            this.perfCounters.AddRequestStatus(rpcResult, msecInterval);
        }
Пример #2
0
        private void AddRequestStatusToCounters(ThrottlingRpcResult result, long requestTimeMsec)
        {
            if (this.perfCountersInstance != null)
            {
                switch (result)
                {
                case ThrottlingRpcResult.Allowed:
                    this.percentageCounterRequestsSucceeded.AddNumerator(1L);
                    break;

                case ThrottlingRpcResult.Bypassed:
                case ThrottlingRpcResult.Failed:
                    this.percentageCounterRequestsBypassed.AddNumerator(1L);
                    break;

                case ThrottlingRpcResult.Denied:
                    this.percentageCounterRequestsDenied.AddNumerator(1L);
                    break;
                }
                this.percentageCounterRequestsSucceeded.AddDenominator(1L);
                this.percentageCounterRequestsDenied.AddDenominator(1L);
                this.percentageCounterRequestsBypassed.AddDenominator(1L);
                this.perfCountersInstance.SuccessfulSubmissionRequests.RawValue = (long)this.percentageCounterRequestsSucceeded.GetSlidingPercentage();
                this.perfCountersInstance.BypassedSubmissionRequests.RawValue   = (long)this.percentageCounterRequestsBypassed.GetSlidingPercentage();
                this.perfCountersInstance.DeniedSubmissionRequest.RawValue      = (long)this.percentageCounterRequestsDenied.GetSlidingPercentage();
                if (requestTimeMsec >= 0L)
                {
                    this.averageCountersForRequestInterval.AddNumerator(requestTimeMsec);
                    this.averageCountersForRequestInterval.AddDenominator(1L);
                    this.perfCountersInstance.AverageSubmissionRequestTime.RawValue = (long)this.averageCountersForRequestInterval.GetSlidingPercentage() / 100L;
                }
            }
        }
Пример #3
0
        private bool ObtainTokensViaNewApi(string mailboxServer, Guid mailboxGuid, RequestedAction requestedAction, int requestedTokenCount, int quota, string clientInfo)
        {
            ThrottlingRpcClientImpl rpcClient = this.GetRpcClient(mailboxServer);
            ThrottlingRpcResult     result    = rpcClient.ObtainTokens(mailboxGuid, requestedAction, requestedTokenCount, quota, clientInfo);

            return(MailboxThrottle.ThrottlingRpcResultToBoolean(result));
        }
Пример #4
0
        private bool ObtainTokensViaOldApi(string mailboxServer, Guid mailboxGuid, int requestedTokenCount, int quota)
        {
            ThrottlingRpcClientImpl rpcClient = this.GetRpcClient(mailboxServer);
            ThrottlingRpcResult     result    = rpcClient.ObtainSubmissionTokens(mailboxGuid, requestedTokenCount, quota, 0);

            return(MailboxThrottle.ThrottlingRpcResultToBoolean(result));
        }
Пример #5
0
 public void AddRequestStatus(ThrottlingRpcResult result, long requestTimeMsec)
 {
     if (requestTimeMsec < 0L)
     {
         throw new ArgumentException("Request time must be greater than or equal to zero.", "requestTimeMsec");
     }
     this.AddRequestStatusToCounters(result, requestTimeMsec);
 }
Пример #6
0
        private static bool ThrottlingRpcResultToBoolean(ThrottlingRpcResult result)
        {
            switch (result)
            {
            case ThrottlingRpcResult.Allowed:
                return(true);

            case ThrottlingRpcResult.Bypassed:
            case ThrottlingRpcResult.Failed:
                return(true);

            case ThrottlingRpcResult.Denied:
                return(false);

            default:
                throw new InvalidOperationException("Unexpected result from RPC client: " + result);
            }
        }
Пример #7
0
 public void AddRequestStatus(ThrottlingRpcResult result)
 {
     this.AddRequestStatusToCounters(result, -1L);
 }