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); }
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; } } }
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)); }
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)); }
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); }
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); } }
public void AddRequestStatus(ThrottlingRpcResult result) { this.AddRequestStatusToCounters(result, -1L); }