Example #1
0
        public void PostSubmitInfo_HeBaoKeyIsException_ReturnExpectationFailed()
        {
            //配置
            IValidateService validateService = Substitute.For <IValidateService>();
            IMessageCenter   messageCenter   = Substitute.For <IMessageCenter>();
            IRemoveHeBaoKey  removeHeBaoKey  = Substitute.For <IRemoveHeBaoKey>();
            IPostValidate    postValidate    = Substitute.For <IPostValidate>();

            validateService.Validate(Arg.Any <PostSubmitInfoRequest>(), Arg.Any <IEnumerable <KeyValuePair <string, string> > >()).Returns(new BaseResponse()
            {
                Status = HttpStatusCode.OK
            });
            postValidate.SubmitInfoValidate(Arg.Any <PostSubmitInfoRequest>()).Returns(Tuple.Create <BaseResponse, bx_userinfo, bx_submit_info>(new BaseResponse()
            {
                Status = HttpStatusCode.OK
            }, new bx_userinfo(), new bx_submit_info()));
            removeHeBaoKey.When(x => x.RemoveHeBao(Arg.Any <PostSubmitInfoRequest>())).Do(info =>
            {
                throw new RedisOperateException();
            });
            PostSubmitInfoService postSubmitInfoService = new PostSubmitInfoService(validateService, messageCenter, removeHeBaoKey, postValidate);
            //操作
            var result = postSubmitInfoService.PostSubmitInfo(new PostSubmitInfoRequest()
            {
                Source = 1, LicenseNo = "京", Agent = 102, CustKey = "aaaaa", RenewalCarType = 0
            }, null);

            //断言
            Assert.AreEqual(HttpStatusCode.ExpectationFailed, result.Status);
        }
Example #2
0
 public DeploymentLoadPublisher(
     ILocalSiloDetails siloDetails,
     ISiloStatusOracle siloStatusOracle,
     IOptions <DeploymentLoadPublisherOptions> options,
     IInternalGrainFactory grainFactory,
     OrleansTaskScheduler scheduler,
     ILoggerFactory loggerFactory,
     IMessageCenter messageCenter,
     ActivationDirectory activationDirectory,
     ActivationCollector activationCollector,
     IAppEnvironmentStatistics appEnvironmentStatistics,
     IHostEnvironmentStatistics hostEnvironmentStatistics,
     IOptions <LoadSheddingOptions> loadSheddingOptions)
     : base(Constants.DeploymentLoadPublisherSystemTargetId, siloDetails.SiloAddress, loggerFactory)
 {
     this.logger                    = loggerFactory.CreateLogger <DeploymentLoadPublisher>();
     this.siloDetails               = siloDetails;
     this.siloStatusOracle          = siloStatusOracle;
     this.grainFactory              = grainFactory;
     this.scheduler                 = scheduler;
     this.messageCenter             = messageCenter;
     this.activationDirectory       = activationDirectory;
     this.activationCollector       = activationCollector;
     this.appEnvironmentStatistics  = appEnvironmentStatistics;
     this.hostEnvironmentStatistics = hostEnvironmentStatistics;
     this.loadSheddingOptions       = loadSheddingOptions;
     statisticsRefreshTime          = options.Value.DeploymentLoadPublisherRefreshTime;
     periodicStats                  = new ConcurrentDictionary <SiloAddress, SiloRuntimeStatistics>();
     siloStatisticsChangeListeners  = new List <ISiloStatisticsChangeListener>();
 }
Example #3
0
        public void PostSubmitInfo_MessageCenterIsNull_ReturnOK()
        {
            //配置
            IValidateService validateService = Substitute.For <IValidateService>();
            IMessageCenter   messageCenter   = Substitute.For <IMessageCenter>();
            IRemoveHeBaoKey  removeHeBaoKey  = Substitute.For <IRemoveHeBaoKey>();
            IPostValidate    postValidate    = Substitute.For <IPostValidate>();

            validateService.Validate(Arg.Any <PostSubmitInfoRequest>(), Arg.Any <IEnumerable <KeyValuePair <string, string> > >()).Returns(new BaseResponse()
            {
                Status = HttpStatusCode.OK
            });
            postValidate.SubmitInfoValidate(Arg.Any <PostSubmitInfoRequest>()).Returns(Tuple.Create <BaseResponse, bx_userinfo, bx_submit_info>(new BaseResponse()
            {
                Status = HttpStatusCode.OK
            }, new bx_userinfo(), new bx_submit_info()));
            removeHeBaoKey.RemoveHeBao(Arg.Any <PostSubmitInfoRequest>()).Returns(x => "test-string");
            messageCenter.SendToMessageCenter(Arg.Any <string>(), Arg.Any <string>()).Returns(x => null);
            PostSubmitInfoService postSubmitInfoService = new PostSubmitInfoService(validateService, messageCenter, removeHeBaoKey, postValidate);
            //操作
            var result = postSubmitInfoService.PostSubmitInfo(new PostSubmitInfoRequest()
            {
                Source = 1
            }, null);

            //断言
            Assert.AreEqual(HttpStatusCode.OK, result.Status);
        }
 public AccountBusiness(ImageProcessor imageProcessor,
                        UnitOfWork unitOfWork, IMessageCenter mesageCenter, IWebEnvironment hostEnvironment) : base(unitOfWork)
 {
     _imageProcessor  = imageProcessor;
     _hostEnvironment = hostEnvironment;
     _mesageCenter    = mesageCenter;
 }
Example #5
0
 public GetSpecialAssumpsitService(IValidateService validateService, IUserInfoValidateService userInfoValidateService,
                                   IMessageCenter messageCenter)
 {
     _validateService         = validateService;
     _userInfoValidateService = userInfoValidateService;
     _messageCenter           = messageCenter;
 }
        internal async Task Start(StatisticsProviderManager statsManager, IMessageCenter transport, GrainId clientId)
        {
            runtimeStats.Start();

            // Configure Metrics
            IProvider statsProvider = null;

            if (!string.IsNullOrEmpty(config.StatisticsProviderName))
            {
                var extType = config.StatisticsProviderName;
                statsProvider = statsManager.GetProvider(extType);
                var metricsDataPublisher = statsProvider as IClientMetricsDataPublisher;
                if (metricsDataPublisher == null)
                {
                    var msg = String.Format("Trying to create {0} as a metrics publisher, but the provider is not configured."
                                            , extType);
                    throw new ArgumentException(msg, "ProviderType (configuration)");
                }
                var configurableMetricsDataPublisher = metricsDataPublisher as IConfigurableClientMetricsDataPublisher;
                if (configurableMetricsDataPublisher != null)
                {
                    configurableMetricsDataPublisher.AddConfiguration(
                        config.DeploymentId, config.DNSHostName, clientId.ToString(), transport.MyAddress.Endpoint.Address);
                }
                tableStatistics = new ClientTableStatistics(transport, metricsDataPublisher, runtimeStats, this.loggerFactory)
                {
                    MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval
                };
            }
            else if (config.UseAzureSystemStore)
            {
                // Hook up to publish client metrics to Azure storage table
                var publisher = AssemblyLoader.LoadAndCreateInstance <IClientMetricsDataPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger, this.serviceProvider);
                await publisher.Init(config, transport.MyAddress.Endpoint.Address, clientId.ToParsableString());

                tableStatistics = new ClientTableStatistics(transport, publisher, runtimeStats, this.loggerFactory)
                {
                    MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval
                };
            }

            // Configure Statistics
            if (config.StatisticsWriteLogStatisticsToTable)
            {
                if (statsProvider != null)
                {
                    logStatistics.StatsTablePublisher = statsProvider as IStatisticsPublisher;
                    // Note: Provider has already been Init-ialized above.
                }
                else if (config.UseAzureSystemStore)
                {
                    var statsDataPublisher = AssemblyLoader.LoadAndCreateInstance <IStatisticsPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger, this.serviceProvider);
                    await statsDataPublisher.Init(false, config.DataConnectionString, config.DeploymentId,
                                                  transport.MyAddress.Endpoint.ToString(), clientId.ToParsableString(), config.DNSHostName);

                    logStatistics.StatsTablePublisher = statsDataPublisher;
                }
            }
            logStatistics.Start();
        }
Example #7
0
 public PostSubmitInfoService(IValidateService validateService, IMessageCenter messageCenter, IRemoveHeBaoKey removeHeBaoKey, IPostValidate postValidate)
 {
     _validateService = validateService;
     _messageCenter   = messageCenter;
     _removeHeBaoKey  = removeHeBaoKey;
     _postValidate    = postValidate;
 }
 public GetFloatingInfoService(IValidateService validateService, IUserInfoValidateService userInfoValidateService,
                               IMessageCenter messageCenter, ISubmitInfoRepository submitInfoRepository)
 {
     _validateService         = validateService;
     _userInfoValidateService = userInfoValidateService;
     _messageCenter           = messageCenter;
     _submitInfoRepository    = submitInfoRepository;
 }
Example #9
0
 internal ClientTableStatistics(IMessageCenter mc, IClientMetricsDataPublisher metricsDataPublisher, RuntimeStatisticsGroup runtime)
 {
     this.mc = mc;
     this.metricsDataPublisher = metricsDataPublisher;
     runtimeStats          = runtime;
     reportFrequency       = TimeSpan.Zero;
     connectedGatewayCount = IntValueStatistic.Find(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT);
 }
 internal ClientTableStatistics(IMessageCenter mc, IClientMetricsDataPublisher metricsDataPublisher, RuntimeStatisticsGroup runtime)
 {
     this.mc = mc;
     this.metricsDataPublisher = metricsDataPublisher;
     runtimeStats = runtime;
     reportFrequency = TimeSpan.Zero;
     connectedGatewayCount = IntValueStatistic.Find(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT);
 }
 public PictureService(IAgentRepository agentRepository, ICacheHelper cacheHelper, IPictureRepository pictureRepository, IUserInfoRepository userInfoRepository, IMessageCenter messageCenter)
     : base(agentRepository, cacheHelper)
 {
     _pictureRepository  = pictureRepository;
     _userInfoRepository = userInfoRepository;
     _messageCenter      = messageCenter;
     logInfo             = LogManager.GetLogger("INFO");
     logError            = LogManager.GetLogger("ERROR");
 }
Example #12
0
        internal async Task Start(StatisticsProviderManager statsManager, IMessageCenter transport, GrainId clientId)
        {
            runtimeStats.Start();

            // Configure Metrics
            IProvider statsProvider = null;
            if (!string.IsNullOrEmpty(config.StatisticsProviderName))
            {
                var extType = config.StatisticsProviderName;
                statsProvider = statsManager.GetProvider(extType);
                var metricsDataPublisher = statsProvider as IClientMetricsDataPublisher;
                if (metricsDataPublisher == null)
                {
                    var msg = String.Format("Trying to create {0} as a metrics publisher, but the provider is not configured."
                        , extType);
                    throw new ArgumentException(msg, "ProviderType (configuration)");
                }
                var configurableMetricsDataPublisher = metricsDataPublisher as IConfigurableClientMetricsDataPublisher;
                if (configurableMetricsDataPublisher != null)
                {
                    configurableMetricsDataPublisher.AddConfiguration(
                        config.DeploymentId, config.DNSHostName, clientId.ToString(), transport.MyAddress.Endpoint.Address);
                }
                tableStatistics = new ClientTableStatistics(transport, metricsDataPublisher, runtimeStats)
                {
                    MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval
                };
            }
            else if (config.UseAzureSystemStore)
            {
                // Hook up to publish client metrics to Azure storage table
                var publisher = AssemblyLoader.LoadAndCreateInstance<IClientMetricsDataPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
                await publisher.Init(config, transport.MyAddress.Endpoint.Address, clientId.ToParsableString());
                tableStatistics = new ClientTableStatistics(transport, publisher, runtimeStats)
                {
                    MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval
                };
            }

            // Configure Statistics
            if (config.StatisticsWriteLogStatisticsToTable)
            {
                if (statsProvider != null)
                {
                    logStatistics.StatsTablePublisher = statsProvider as IStatisticsPublisher;
                    // Note: Provider has already been Init-ialized above.
                }
                else if (config.UseAzureSystemStore)
                {
                    var statsDataPublisher = AssemblyLoader.LoadAndCreateInstance<IStatisticsPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
                    await statsDataPublisher.Init(false, config.DataConnectionString, config.DeploymentId,
                        transport.MyAddress.Endpoint.ToString(), clientId.ToParsableString(), config.DNSHostName);
                    logStatistics.StatsTablePublisher = statsDataPublisher;
                }
            }
            logStatistics.Start();
        }
 public AgentController(IAgentViewRepository agentViewRepository, IMembershipService membershipService, IModelConverter<Agent, AgentEditModel> agentModelConverter, 
                        IMessageCenter mailService, IBlobStore blobStore, IUnitOfWork unitOfWork) : base(membershipService, blobStore)
 {
     _membershipService = membershipService;
     _agentModelConverter = agentModelConverter;
     _mailService = mailService;
     _unitOfWork = unitOfWork;
     _agentViewRepository = agentViewRepository;
 }
Example #14
0
 internal IncomingMessageAgent(Message.Categories cat, IMessageCenter mc, ActivationDirectory ad, OrleansTaskScheduler sched, Dispatcher dispatcher) :
     base(cat.ToString())
 {
     category        = cat;
     messageCenter   = mc;
     directory       = ad;
     scheduler       = sched;
     this.dispatcher = dispatcher;
     OnFault         = FaultBehavior.RestartOnFault;
 }
Example #15
0
 internal IncomingMessageAgent(Message.Categories cat, IMessageCenter mc, ActivationDirectory ad, OrleansTaskScheduler sched, Dispatcher dispatcher) :
     base(cat.ToString())
 {
     category = cat;
     messageCenter = mc;
     directory = ad;
     scheduler = sched;
     this.dispatcher = dispatcher;
     OnFault = FaultBehavior.RestartOnFault;
 }
 public PatientController(IPatientViewRepository patientViewRepository, IMembershipService membershipService, 
                          IModelConverter<Patient, PatientEditModel> modelConverter, IMessageCenter mailService, 
                          IAgentViewRepository agentViewRepository) : base(membershipService)
 {
     _patientViewRepository = patientViewRepository;
     _modelConverter = modelConverter;
     _mailService = mailService;
     _agentViewRepository = agentViewRepository;
     _membershipService = membershipService;
 }
Example #17
0
 public MessageHandler(IServiceProvider serviceProvider,
                       ILoggerFactory loggerFactory,
                       IMessageCenter messageCenter,
                       IMessageCodec codec)
 {
     this.messageCenter   = messageCenter;
     this.serviceProvider = serviceProvider;
     this.logger          = loggerFactory.CreateLogger("Network");
     this.codec           = codec;
 }
Example #18
0
 public GetNewVehicleInfoService(IValidateService validateService, IGetAgentInfoService getAgentInfoService, IUserInfoRepository userInfoRepository,
                                 IQuoteReqCarinfoRepository quoteReqCarinfoRepository, IGetMoldNameFromCenter getMoldNameFromCenter, IMessageCenter messageCenter)
 {
     _validateService           = validateService;
     _getAgentInfoService       = getAgentInfoService;
     _userInfoRepository        = userInfoRepository;
     _quoteReqCarinfoRepository = quoteReqCarinfoRepository;
     _getMoldNameFromCenter     = getMoldNameFromCenter;
     _messageCenter             = messageCenter;
 }
Example #19
0
 public DummySilo(
     ILifecycleObservable lifecycle,
     ILoggerFactory loggerFactory,
     IMembershipOracle membershipOracle,
     IReminderService reminderService,
     IMessageCenter messageCenter,
     IRuntime runtime)
 {
     logger = loggerFactory.CreateLogger <DummySilo>();
     lifecycle.Subscribe(Initialize, Start, Stop);
 }
Example #20
0
 public IncomingRequestMonitor(
     IAsyncTimerFactory asyncTimerFactory,
     IMessageCenter messageCenter,
     MessageFactory messageFactory,
     IOptionsMonitor <SiloMessagingOptions> siloMessagingOptions)
 {
     _scanPeriodTimer  = asyncTimerFactory.Create(TimeSpan.FromSeconds(1), nameof(IncomingRequestMonitor));
     _messageCenter    = messageCenter;
     _messageFactory   = messageFactory;
     _messagingOptions = siloMessagingOptions;
 }
 public ProjectBusiness(UnitOfWork unitOfWork,
                        TaskBusiness task, IWebEnvironment hostEnvironment,
                        IMessageCenter mesageCenter, AccountBusiness accountBusiness,
                        IAccountContext accountContext) : base(unitOfWork)
 {
     _task            = task;
     _hostEnvironment = hostEnvironment;
     _mesageCenter    = mesageCenter;
     _accountBusiness = accountBusiness;
     _accountContext  = accountContext;
 }
Example #22
0
 internal ClientTableStatistics(IMessageCenter mc, IClientMetricsDataPublisher metricsDataPublisher, RuntimeStatisticsGroup runtime, ILoggerFactory loggerFactory)
 {
     this.mc = mc;
     this.metricsDataPublisher = metricsDataPublisher;
     this.logger = loggerFactory.CreateLogger <ClientTableStatistics>();
     //async timer created through current class all share this logger for perf reasons
     this.timerLogger      = loggerFactory.CreateLogger <AsyncTaskSafeTimer>();
     runtimeStats          = runtime;
     reportFrequency       = TimeSpan.Zero;
     connectedGatewayCount = IntValueStatistic.Find(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT);
 }
Example #23
0
 public PostIndependentSubmitService(IValidateService validateService, IUserInfoValidateService userInfoValidateService,
                                     IRemoveHeBaoKey removeHeBaoKey, IMessageCenter messageCenter, IRepository <bx_anxin_delivery> anxindeliveryRepository,
                                     IUserInfoRepository userInfoRepository, ISubmitInfoRepository submitInfoRepository)
 {
     _validateService         = validateService;
     _userInfoValidateService = userInfoValidateService;
     _removeHeBaoKey          = removeHeBaoKey;
     _messageCenter           = messageCenter;
     _anxindeliveryRepository = anxindeliveryRepository;
     _userInfoRepository      = userInfoRepository;
     _submitInfoRepository    = submitInfoRepository;
 }
Example #24
0
        public GatewayClientFactory(ILoggerFactory loggerFactory,
                                    IMessageCenter messageCenter,
                                    IPlacement placement,
                                    ClientConnectionPool clientPool
                                    )
        {
            this.logger               = loggerFactory.CreateLogger("GatewayClient");
            this.messageCenter        = messageCenter;
            this.placement            = placement;
            this.clientConnectionPool = clientPool;

            this.placement.RegisterServerChangedEvent(this.OnAddServer, this.OnRemoveServer, this.OnOfflineServer);
            this.placement.OnException(this.OnPDKeepAliveException);
        }
Example #25
0
        internal async Task Start(IMessageCenter transport, GrainId clientId)
        {
            IClientMetricsDataPublisher metricsDataPublisher = this.serviceProvider.GetService <IClientMetricsDataPublisher>();

            if (metricsDataPublisher != null)
            {
                var configurableMetricsDataPublisher = metricsDataPublisher as IConfigurableClientMetricsDataPublisher;
                if (configurableMetricsDataPublisher != null)
                {
                    configurableMetricsDataPublisher.AddConfiguration(
                        this.clusterClientOptions.ClusterId, config.DNSHostName, clientId.ToString(), transport.MyAddress.Endpoint.Address);
                }
                tableStatistics = new ClientTableStatistics(transport, metricsDataPublisher, this.hostEnvironmentStatistics, this.appEnvironmentStatistics, this.loggerFactory)
                {
                    MetricsTableWriteInterval = statisticsOptions.MetricsTableWriteInterval
                };
            }
            else if (config.UseAzureSystemStore)
            {
                // Hook up to publish client metrics to Azure storage table
                var publisher = AssemblyLoader.LoadAndCreateInstance <IClientMetricsDataPublisher>(Constants.ORLEANS_STATISTICS_AZURESTORAGE, logger, this.serviceProvider);
                await publisher.Init(config, transport.MyAddress.Endpoint.Address, clientId.ToParsableString());

                tableStatistics = new ClientTableStatistics(transport, publisher, this.hostEnvironmentStatistics, this.appEnvironmentStatistics, this.loggerFactory)
                {
                    MetricsTableWriteInterval = statisticsOptions.MetricsTableWriteInterval
                };
            }

            // Configure Statistics
            if (statisticsOptions.WriteLogStatisticsToTable)
            {
                IStatisticsPublisher statsProvider = this.serviceProvider.GetService <IStatisticsPublisher>();
                if (statsProvider != null)
                {
                    logStatistics.StatsTablePublisher = statsProvider;
                    // Note: Provider has already been Init-ialized above.
                }
                else if (config.UseAzureSystemStore)
                {
                    var statsDataPublisher = AssemblyLoader.LoadAndCreateInstance <IStatisticsPublisher>(Constants.ORLEANS_STATISTICS_AZURESTORAGE, logger, this.serviceProvider);
                    await statsDataPublisher.Init(false, config.DataConnectionString, this.clusterClientOptions.ClusterId,
                                                  transport.MyAddress.Endpoint.ToString(), clientId.ToParsableString(), config.DNSHostName);

                    logStatistics.StatsTablePublisher = statsDataPublisher;
                }
            }
            logStatistics.Start();
        }
Example #26
0
        public SiloControl(
            ILocalSiloDetails localSiloDetails,
            DeploymentLoadPublisher deploymentLoadPublisher,
            Catalog catalog,
            CachedVersionSelectorManager cachedVersionSelectorManager,
            CompatibilityDirectorManager compatibilityDirectorManager,
            VersionSelectorManager selectorManager,
            IServiceProvider services,
            ILoggerFactory loggerFactory,
            IMessageCenter messageCenter,
            ActivationCollector activationCollector,
            ActivationDirectory activationDirectory,
            IActivationWorkingSet activationWorkingSet,
            IAppEnvironmentStatistics appEnvironmentStatistics,
            IHostEnvironmentStatistics hostEnvironmentStatistics,
            IOptions <LoadSheddingOptions> loadSheddingOptions,
            GrainCountStatistics grainCountStatistics)
            : base(Constants.SiloControlType, localSiloDetails.SiloAddress, loggerFactory)
        {
            this.localSiloDetails = localSiloDetails;

            this.logger = loggerFactory.CreateLogger <SiloControl>();
            this.deploymentLoadPublisher = deploymentLoadPublisher;
            this.catalog = catalog;
            this.cachedVersionSelectorManager = cachedVersionSelectorManager;
            this.compatibilityDirectorManager = compatibilityDirectorManager;
            this.selectorManager           = selectorManager;
            _activationCollector           = activationCollector;
            this.activationDirectory       = activationDirectory;
            this.activationWorkingSet      = activationWorkingSet;
            this.appEnvironmentStatistics  = appEnvironmentStatistics;
            this.hostEnvironmentStatistics = hostEnvironmentStatistics;
            this.loadSheddingOptions       = loadSheddingOptions;
            _grainCountStatistics          = grainCountStatistics;
            this.controllables             = new Dictionary <Tuple <string, string>, IControllable>();
            IEnumerable <IKeyedServiceCollection <string, IControllable> > namedIControllableCollections = services.GetServices <IKeyedServiceCollection <string, IControllable> >();

            foreach (IKeyedService <string, IControllable> keyedService in namedIControllableCollections.SelectMany(c => c.GetServices(services)))
            {
                IControllable controllable = keyedService.GetService(services);
                if (controllable != null)
                {
                    this.controllables.Add(Tuple.Create(controllable.GetType().FullName, keyedService.Key), controllable);
                }
            }
        }
Example #27
0
        public void PostSubmitInfo_ValidateNoPass_ReturnForbidden()
        {
            //配置
            IValidateService validateService       = Substitute.For <IValidateService>();
            IMessageCenter   messageCenter         = Substitute.For <IMessageCenter>();
            IRemoveHeBaoKey  removeHeBaoKeyService = Substitute.For <IRemoveHeBaoKey>();
            IPostValidate    postValidate          = Substitute.For <IPostValidate>();

            validateService.Validate(Arg.Any <PostSubmitInfoRequest>(), Arg.Any <IEnumerable <KeyValuePair <string, string> > >()).Returns(new BaseResponse()
            {
                Status = HttpStatusCode.Forbidden
            });
            PostSubmitInfoService postSubmitInfoService = new PostSubmitInfoService(validateService, messageCenter, removeHeBaoKeyService, postValidate);
            //操作
            var result = postSubmitInfoService.PostSubmitInfo(new PostSubmitInfoRequest(), null);

            //断言
            Assert.AreEqual(HttpStatusCode.Forbidden, result.Status);
        }
 internal IncomingMessageAgent(
     Message.Categories cat,
     IMessageCenter mc,
     ActivationDirectory ad,
     OrleansTaskScheduler sched,
     Dispatcher dispatcher,
     MessageFactory messageFactory,
     ILoggerFactory loggerFactory) :
     base(cat.ToString(), loggerFactory)
 {
     category            = cat;
     messageCenter       = mc;
     directory           = ad;
     scheduler           = sched;
     this.dispatcher     = dispatcher;
     this.messageFactory = messageFactory;
     OnFault             = FaultBehavior.RestartOnFault;
     messageCenter.RegisterLocalMessageHandler(cat, ReceiveMessage);
 }
Example #29
0
 internal IncomingMessageAgent(
     Message.Categories cat,
     IMessageCenter mc,
     ActivationDirectory ad,
     OrleansTaskScheduler sched,
     Dispatcher dispatcher,
     MessageFactory messageFactory,
     ExecutorService executorService,
     ILoggerFactory loggerFactory) :
     base(cat.ToString(), executorService, loggerFactory)
 {
     category            = cat;
     messageCenter       = mc;
     directory           = ad;
     scheduler           = sched;
     this.dispatcher     = dispatcher;
     this.messageFactory = messageFactory;
     OnFault             = FaultBehavior.RestartOnFault;
 }
        internal async Task Start(IMessageCenter transport, GrainId clientId)
        {
            // Configure Statistics
            if (statisticsOptions.WriteLogStatisticsToTable)
            {
                IStatisticsPublisher statsProvider = this.serviceProvider.GetService <IStatisticsPublisher>();
                if (statsProvider != null)
                {
                    logStatistics.StatsTablePublisher = statsProvider;
                    // Note: Provider has already been initialized as a IProvider in the lifecycle
                }
                else if (CanUseAzureTable())
                {
                    var statsDataPublisher = AssemblyLoader.LoadAndCreateInstance <IStatisticsPublisher>(Constants.ORLEANS_STATISTICS_AZURESTORAGE, logger, this.serviceProvider);
                    await statsDataPublisher.Init(false, storageOptions.DataConnectionString, this.clusterClientOptions.ClusterId,
                                                  transport.MyAddress.Endpoint.ToString(), clientId.ToParsableString(), dnsHostName);

                    logStatistics.StatsTablePublisher = statsDataPublisher;
                }
            }
            logStatistics.Start();
        }
Example #31
0
        public GatewayMessageHandler(IServiceProvider serviceProvider,
                                     IMessageCenter messageCenter,
                                     ILoggerFactory loggerFactory,
                                     IConnectionManager sessionManager,
                                     IPlacement placement)

        {
            this.serviceProvider      = serviceProvider;
            this.logger               = loggerFactory.CreateLogger("MessageHandler");
            this.messageCenter        = messageCenter;
            this.sessionManager       = sessionManager;
            this.placement            = placement;
            this.clientConnectionPool = serviceProvider.GetService <ClientConnectionPool>();

            this.messageCenter.RegisterMessageProc(new BlockMessageCodec().CodecName, this.ProcessWebSocketMessage, false);
            this.messageCenter.RegisterDefaultMessageProc(this.ProcessDefaultMessage);
            this.RegisterHandler <ResponseAccountLogin>(this.ProcessResponseAccountLogin);
            this.RegisterHandler <RequestCloseSession>(this.ProcessRequestCloseSession);
            this.RegisterHandler <RequestSendMessageToSession>(this.ProcessRequestSendMessageToSession);
            this.RegisterHandler <RequestHeartBeat>(this.ProcessRequestHeartBeat);
            this.RegisterHandler <ResponseHeartBeat>(this.ProcessResponseHeartBeat);
        }
Example #32
0
 internal SiloRuntimeStatistics(
     IMessageCenter messageCenter,
     int activationCount,
     int recentlyUsedActivationCount,
     IAppEnvironmentStatistics appEnvironmentStatistics,
     IHostEnvironmentStatistics hostEnvironmentStatistics,
     IOptions <LoadSheddingOptions> loadSheddingOptions,
     DateTime dateTime)
 {
     ActivationCount             = activationCount;
     RecentlyUsedActivationCount = recentlyUsedActivationCount;
     SendQueueLength             = messageCenter.SendQueueLength;
     CpuUsage            = hostEnvironmentStatistics.CpuUsage;
     AvailableMemory     = hostEnvironmentStatistics.AvailableMemory;
     MemoryUsage         = appEnvironmentStatistics.MemoryUsage;
     IsOverloaded        = loadSheddingOptions.Value.LoadSheddingEnabled && this.CpuUsage > loadSheddingOptions.Value.LoadSheddingLimit;
     ClientCount         = MessagingStatisticsGroup.ConnectedClientCount.GetCurrentValue();
     TotalPhysicalMemory = hostEnvironmentStatistics.TotalPhysicalMemory;
     ReceivedMessages    = MessagingStatisticsGroup.MessagesReceived.GetCurrentValue();
     SentMessages        = MessagingStatisticsGroup.MessagesSentTotal.GetCurrentValue();
     DateTime            = dateTime;
 }
Example #33
0
 public GetReInfoMainService(IManagerRoleRepository managerRoleRepository, IGetAgentInfoService getAgentInfoService, IFiterAndRepeatDataService fiterAndRepeatDataService,
                             IUserInfoRepository userInfoRepository, IAgentRepository agentRepository, ICheckCarNeedDrivingInfoService checkCarNeedDrivingInfoService,
                             IQuoteReqCarinfoRepository quoteReqCarinfoRepository, IMessageCenter messageCenter, ICarInsuranceCache carInsuranceCache, ICarRenewalRepository carRenewalRepository, ICarInfoRepository carInfoRepository,
                             IBatchRenewalRepository batchRenewalRepository, ISentDistributedService sentDistributedService, IGetReInfoState getReInfoState,
                             IToCenterFromReInfoService toCenterFromReInfoService)
 {
     _managerRoleRepository          = managerRoleRepository;
     _getAgentInfoService            = getAgentInfoService;
     _fiterAndRepeatDataService      = fiterAndRepeatDataService;
     _userInfoRepository             = userInfoRepository;
     _agentRepository                = agentRepository;
     _checkCarNeedDrivingInfoService = checkCarNeedDrivingInfoService;
     _quoteReqCarinfoRepository      = quoteReqCarinfoRepository;
     _messageCenter             = messageCenter;
     _carInsuranceCache         = carInsuranceCache;
     _carRenewalRepository      = carRenewalRepository;
     _carInfoRepository         = carInfoRepository;
     _batchRenewalRepository    = batchRenewalRepository;
     _sentDistributedService    = sentDistributedService;
     _getReInfoState            = getReInfoState;
     _toCenterFromReInfoService = toCenterFromReInfoService;
 }
Example #34
0
        public void PostSubmitInfo_SubmitInfoValidateNoPass_ReturnNotAcceptable()
        {
            //配置
            IValidateService validateService       = Substitute.For <IValidateService>();
            IMessageCenter   messageCenter         = Substitute.For <IMessageCenter>();
            IRemoveHeBaoKey  removeHeBaoKeyService = Substitute.For <IRemoveHeBaoKey>();
            IPostValidate    postValidate          = Substitute.For <IPostValidate>();

            validateService.Validate(Arg.Any <PostSubmitInfoRequest>(), Arg.Any <IEnumerable <KeyValuePair <string, string> > >()).Returns(new BaseResponse()
            {
                Status = HttpStatusCode.OK
            });
            postValidate.SubmitInfoValidate(Arg.Any <PostSubmitInfoRequest>()).Returns(Tuple.Create <BaseResponse, bx_userinfo, bx_submit_info>(new BaseResponse()
            {
                Status = HttpStatusCode.NotAcceptable
            }, null, null));
            PostSubmitInfoService postSubmitInfoService = new PostSubmitInfoService(validateService, messageCenter, removeHeBaoKeyService, postValidate);
            //操作
            var result = postSubmitInfoService.PostSubmitInfo(new PostSubmitInfoRequest(), null);

            //断言
            Assert.AreEqual(HttpStatusCode.NotAcceptable, result.Status);
        }
 public UserProcedureConsentService(IUnitOfWork unitOfWork, IMessageCenter mailService)
 {
     _unitOfWork = unitOfWork;
     _mailService = mailService;
 }
Example #36
0
        public void AnalyzeWorkload(DateTime now, IMessageCenter messageCenter, MessageFactory messageFactory, SiloMessagingOptions options)
        {
            var slowRunningRequestDuration = options.RequestProcessingWarningTime;
            var longQueueTimeDuration      = options.RequestQueueDelayWarningTime;

            List <string> diagnostics = null;

            lock (this)
            {
                if (State != ActivationState.Valid)
                {
                    return;
                }

                if (this.Blocking is object)
                {
                    var message         = this.Blocking;
                    var timeSinceQueued = now - message.QueuedTime;
                    var executionTime   = now - currentRequestStartTime;
                    if (executionTime >= slowRunningRequestDuration)
                    {
                        GetStatusList(ref diagnostics);
                        if (timeSinceQueued.HasValue)
                        {
                            diagnostics.Add($"Message {message} was enqueued {timeSinceQueued} ago and has now been executing for {executionTime}.");
                        }
                        else
                        {
                            diagnostics.Add($"Message {message} has been executing for {executionTime}.");
                        }

                        var response = messageFactory.CreateDiagnosticResponseMessage(message, isExecuting: true, isWaiting: false, diagnostics);
                        messageCenter.SendMessage(response);
                    }
                }

                foreach (var running in RunningRequests)
                {
                    var message   = running.Key;
                    var startTime = running.Value;
                    if (ReferenceEquals(message, this.Blocking))
                    {
                        continue;
                    }

                    // Check how long they've been executing.
                    var executionTime = now - startTime;
                    if (executionTime >= slowRunningRequestDuration)
                    {
                        // Interleaving message X has been executing for a long time
                        GetStatusList(ref diagnostics);
                        var messageDiagnostics = new List <string>(diagnostics)
                        {
                            $"Interleaving message {message} has been executing for {executionTime}."
                        };

                        var response = messageFactory.CreateDiagnosticResponseMessage(message, isExecuting: true, isWaiting: false, messageDiagnostics);
                        messageCenter.SendMessage(response);
                    }
                }

                if (waiting is object)
                {
                    var queueLength = 1;
                    foreach (var message in waiting)
                    {
                        var waitTime = now - message.QueuedTime;
                        if (waitTime >= longQueueTimeDuration)
                        {
                            // Message X has been enqueued on the target grain for Y and is currently position QueueLength in queue for processing.
                            GetStatusList(ref diagnostics);
                            var messageDiagnostics = new List <string>(diagnostics)
                            {
                                $"Message {message} has been enqueued on the target grain for {waitTime} and is currently position {queueLength} in queue for processing."
                            };

                            var response = messageFactory.CreateDiagnosticResponseMessage(message, isExecuting: false, isWaiting: true, messageDiagnostics);
                            messageCenter.SendMessage(response);
                        }

                        queueLength++;
                    }
                }
            }

            void GetStatusList(ref List <string> diagnostics)
            {
                if (diagnostics is object)
                {
                    return;
                }

                diagnostics = new List <string>
                {
                    this.ToDetailedString(),
                    $"TaskScheduler status: {this.WorkItemGroup.DumpStatus()}"
                };
            }
        }