public ZooKeeperProvider(string zookeeperHosts,
                                 string zooKeeperRootPath,
                                 TimeSpan sessionTimeout,
                                 TimeSpan connectTimeout,
                                 TimeSpan minimumRebalancingInterval,
                                 RebalancingMode rebalancingMode,
                                 ILogger logger,
                                 IZooKeeperService zooKeeperService = null)
        {
            this.zooKeeperRootPath          = zooKeeperRootPath;
            this.rebalancingMode            = rebalancingMode;
            this.logger                     = logger;
            this.sessionTimeout             = sessionTimeout;
            this.connectTimeout             = connectTimeout;
            this.minimumRebalancingInterval = minimumRebalancingInterval;
            this.rand = new Random(Guid.NewGuid().GetHashCode());

            if (zooKeeperService == null)
            {
                this.zooKeeperService = new ZooKeeperService(zookeeperHosts);
            }
            else
            {
                this.zooKeeperService = zooKeeperService;
            }
        }
Exemplo n.º 2
0
        public Follower(IZooKeeperService zooKeeperService,
                        ILogger logger,
                        ResourceManager store,
                        string clientId,
                        int clientNumber,
                        string watchSiblingPath,
                        TimeSpan sessionTimeout,
                        TimeSpan onStartDelay,
                        CancellationToken followerToken)
        {
            this.zooKeeperService = zooKeeperService;
            this.logger           = logger;
            this.store            = store;
            this.clientId         = clientId;
            this.clientNumber     = clientNumber;
            this.watchSiblingPath = watchSiblingPath;
            this.siblingId        = watchSiblingPath.Substring(watchSiblingPath.LastIndexOf("/", StringComparison.Ordinal));
            this.sessionTimeout   = sessionTimeout;
            this.onStartDelay     = onStartDelay;
            this.followerToken    = followerToken;

            this.rebalancingCts    = new CancellationTokenSource();
            this.events            = new BlockingCollection <FollowerEvent>();
            this.disconnectedTimer = new Stopwatch();
        }
 public ResourceManager(IZooKeeperService zooKeeperService,
                        ILogger logger,
                        OnChangeActions onChangeActions,
                        RebalancingMode rebalancingMode)
 {
     this.zooKeeperService = zooKeeperService;
     this.logger           = logger;
     this.resources        = new List <string>();
     this.assignmentStatus = AssignmentStatus.NoAssignmentYet;
     this.onChangeActions  = onChangeActions;
     this.rebalancingMode  = rebalancingMode;
 }
 public Coordinator(IZooKeeperService zooKeeperService,
                    ILogger logger,
                    ResourceManager store,
                    string clientId,
                    TimeSpan minimumRebalancingInterval,
                    TimeSpan sessionTimeout,
                    TimeSpan onStartDelay,
                    CancellationToken coordinatorToken)
 {
     this.zooKeeperService           = zooKeeperService;
     this.logger                     = logger;
     this.store                      = store;
     this.minimumRebalancingInterval = minimumRebalancingInterval;
     this.clientId                   = clientId;
     this.sessionTimeout             = sessionTimeout;
     this.onStartDelay               = onStartDelay;
     this.coordinatorToken           = coordinatorToken;
     this.rebalancingCts             = new CancellationTokenSource();
     this.events                     = new BlockingCollection <CoordinatorEvent>();
     this.disconnectedTimer          = new Stopwatch();
 }