public void Initialize()
        {
            int checkBase = config.EndpointSessionWriterCheckIntervalBase;
            int checkMax = config.EndpointSessionWriterCheckIntervalMax;
            schedulePolicy = new ExponentialSchedulePolicy(checkBase, checkMax);

            timer = new Timer(EndpointSessionFlush, null, checkBase, Timeout.Infinite);
        }
示例#2
0
 public GenerateScheduleHandler(IMoviesApiClient client, ISchedulePolicy policy, ISchedulesRepository repository,
                                IEventProcessor processor)
 {
     _client     = client;
     _policy     = policy;
     _repository = repository;
     _processor  = processor;
 }
        private readonly IDictionary <string, ApolloNotificationMessages> m_remoteNotificationMessages; //namespaceName -> watchedKey -> notificationId

        public RemoteConfigLongPollService()
        {
            m_longPollFailSchedulePolicyInSecond = new ExponentialSchedulePolicy(1, 120);    //in second
            m_longPollSuccessSchedulePolicyInMS  = new ExponentialSchedulePolicy(100, 1000); //in millisecond
            m_longPollingStarted         = new ThreadSafe.Boolean(false);
            m_longPollingStopped         = new ThreadSafe.Boolean(false);
            m_longPollNamespaces         = new ConcurrentDictionary <string, ISet <RemoteConfigRepository> >();
            m_notifications              = new ConcurrentDictionary <string, long?>();
            m_remoteNotificationMessages = new ConcurrentDictionary <string, ApolloNotificationMessages>();
        }
    private readonly ConcurrentDictionary <string, ApolloNotificationMessages> _remoteNotificationMessages; //namespaceName -> watchedKey -> notificationId

    public RemoteConfigLongPollService(ConfigServiceLocator serviceLocator, HttpUtil httpUtil, IApolloOptions configUtil)
    {
        _serviceLocator = serviceLocator;
        _httpUtil       = httpUtil;
        _options        = configUtil;
        _longPollFailSchedulePolicyInSecond = new ExponentialSchedulePolicy(1, 120);    //in second
        _longPollSuccessSchedulePolicyInMs  = new ExponentialSchedulePolicy(100, 1000); //in millisecond
        _longPollNamespaces         = new ConcurrentDictionary <string, ISet <RemoteConfigRepository> >();
        _notifications              = new ConcurrentDictionary <string, long?>();
        _remoteNotificationMessages = new ConcurrentDictionary <string, ApolloNotificationMessages>();
    }
        protected override void DoBeforeConsuming(ConsumerLeaseKey key, long correlationId)
        {
            noEndpointSchedulePolicy = new ExponentialSchedulePolicy(Config.NoEndpointWaitBaseMillis,
                Config.NoEndpointWaitMaxMillis);

            QueryLatestOffset(key, correlationId);
            // reset policy
            noEndpointSchedulePolicy.Succeess();

            pullMessagesTask.WriteFullFence(new PullMessagesTask(correlationId, noEndpointSchedulePolicy, this));
        }
 public DefaultPullMessagesTask(long correlationId, ISchedulePolicy noEndpointSchedulePolicy, BaseConsumerTask baseConsumerTask)
     : base(correlationId, noEndpointSchedulePolicy, baseConsumerTask)
 {
 }
 public PullMessagesTask(long correlationId, ISchedulePolicy noEndpointSchedulePolicy, StrictlyOrderedConsumingStrategyConsumerTask baseConsumerTask)
     : base(correlationId, noEndpointSchedulePolicy, baseConsumerTask)
 {
     strictlyOrderedConsumingStrategyConsumerTask = baseConsumerTask;
 }
 public BasePullMessagesTask(long correlationId, ISchedulePolicy noEndpointSchedulePolicy, BaseConsumerTask baseConsumerTask)
 {
     CorrelationId = correlationId;
     NoEndpointSchedulePolicy = noEndpointSchedulePolicy;
     BaseConsumerTask = baseConsumerTask;
 }