Exemplo n.º 1
0
        // Token: 0x06000030 RID: 48 RVA: 0x00002E90 File Offset: 0x00001090
        protected override void OnStartInternal(string[] args)
        {
            TimeSpan startupTimeout = TimeSpan.FromMinutes(6.0);

            base.ExRequestAdditionalTime((int)startupTimeout.TotalMilliseconds);
            ThrottlingService.StartStopBreadcrumbs.Drop("Starting Throttling Service", new object[0]);
            ThrottlingService.tracer.TraceDebug(0L, "Starting Throttling Service");
            if (ThrottlingAppConfig.LoggingEnabled && ThrottlingAppConfig.LogPath != null)
            {
                ThrottlingServiceLog.Start();
            }
            if (!ThrottlingRpcServerImpl.TryCreateInstance(startupTimeout, out this.rpcServer))
            {
                ThrottlingService.StartStopBreadcrumbs.Drop("Failed to start Throttling Service, exiting", new object[0]);
                Environment.Exit(1);
            }
            ThrottlingService.tracer.TraceDebug(0L, "Throttling Service started successfully");
            ThrottlingService.StartStopBreadcrumbs.Drop("Throttling Service started successfully", new object[0]);
            ThrottlingServiceLog.LogServiceStart();
        }
        // Token: 0x06000020 RID: 32 RVA: 0x00002504 File Offset: 0x00000704
        public static bool TryCreateInstance(TimeSpan startupTimeout, out ThrottlingRpcServerImpl instance)
        {
            TimeSpan       timeout = TimeSpan.FromMilliseconds(Math.Min(ThrottlingAppConfig.ADOperationTimeout.TotalMilliseconds, startupTimeout.TotalMilliseconds / 2.0));
            ObjectSecurity rpcSecurityDescriptor;

            if (!ThrottlingRpcServerImpl.TryGetRpcSecurityDescriptor(timeout, out rpcSecurityDescriptor))
            {
                instance = null;
                return(false);
            }
            if (!ThrottlingRpcServerImpl.TryRegisterRpcServer(rpcSecurityDescriptor, out instance))
            {
                instance = null;
                return(false);
            }
            instance.userSubmissionTokens = new TokenBucketMap <Guid>();
            instance.userSubmissionTokens.Start();
            instance.mailboxRuleSubmissionTokens = new TokenBucketMap <Guid>();
            instance.mailboxRuleSubmissionTokens.Start();
            return(true);
        }
        // Token: 0x06000025 RID: 37 RVA: 0x000027FC File Offset: 0x000009FC
        private static bool TryGetRpcSecurityDescriptor(TimeSpan timeout, out ObjectSecurity sd)
        {
            ObjectSecurity tmp = null;

            sd = null;
            ThrottlingService.StartStopBreadcrumbs.Drop("Obtaining RPC security descriptor", new object[0]);
            ThrottlingService.Tracer.TraceDebug(0L, "Obtaining RPC security descriptor");
            ADOperationResult result = null;
            Thread            thread = new Thread(delegate()
            {
                result = ADNotificationAdapter.TryRunADOperation(delegate()
                {
                    tmp = ThrottlingRpcServerImpl.GetRpcSecurityDescriptor();
                }, 3);
            });

            thread.Start();
            if (!thread.Join(timeout))
            {
                result = new ADOperationResult(ADOperationErrorCode.PermanentError, new TimeoutException(string.Format("Timed out AD operation after {0}", timeout.ToString())));
            }
            if (result.Succeeded)
            {
                ThrottlingService.StartStopBreadcrumbs.Drop("Successfully obtained RPC security descriptor", new object[0]);
                ThrottlingService.Tracer.TraceDebug(0L, "Successfully obtained RPC security descriptor");
                sd = tmp;
                return(true);
            }
            ThrottlingService.StartStopBreadcrumbs.Drop("Failed to obtain RPC security descriptor. Exception: {0}", new object[]
            {
                result.Exception
            });
            ThrottlingService.Tracer.TraceError <Exception>(0L, "Failed to obtain RPC security descriptor. Exception: {0}", result.Exception);
            ThrottlingService.EventLogger.LogEvent(ThrottlingServiceEventLogConstants.Tuple_RpcSecurityDescriptorFailure, null, new object[]
            {
                result.Exception
            });
            return(false);
        }
 // Token: 0x06000028 RID: 40 RVA: 0x00002A38 File Offset: 0x00000C38
 private static bool TryRegisterRpcServer(ObjectSecurity rpcSecurityDescriptor, out ThrottlingRpcServerImpl serverInstance)
 {
     ThrottlingService.StartStopBreadcrumbs.Drop("Trying to register RPC server", new object[0]);
     ThrottlingService.Tracer.TraceDebug(0L, "Trying to register RPC server");
     serverInstance = null;
     try
     {
         serverInstance = (ThrottlingRpcServerImpl)RpcServerBase.RegisterServer(typeof(ThrottlingRpcServerImpl), rpcSecurityDescriptor, 1, false, ThrottlingRpcServerImpl.GetThreadPoolSize());
     }
     catch (RpcException ex)
     {
         ThrottlingService.StartStopBreadcrumbs.Drop("Failed to register RPC server: {0}", new object[]
         {
             ex
         });
         ThrottlingService.Tracer.TraceError <RpcException>(0L, "Failed to register RPC server: {0}", ex);
         ThrottlingService.EventLogger.LogEvent(ThrottlingServiceEventLogConstants.Tuple_RegisterRpcServerFailure, null, new object[]
         {
             ex
         });
         return(false);
     }
     ThrottlingService.StartStopBreadcrumbs.Drop("Successfully registered RPC server", new object[0]);
     ThrottlingService.Tracer.TraceDebug(0L, "Successfully registered RPC server");
     return(true);
 }