/** * @param zookeeperFactory factory for creating {@link ZooKeeper} instances * @param ensembleProvider the ensemble provider * @param sessionTimeoutMs session timeout * @param connectionTimeoutMs connection timeout * @param watcher default watcher or null * @param retryPolicy the retry policy to use * @param canBeReadOnly if true, allow ZooKeeper client to enter * read only mode in case of a network partition. See * {@link ZooKeeper#ZooKeeper(String, int, Watcher, long, byte[], boolean)} * for details */ public CuratorZookeeperClient(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, IRetryPolicy retryPolicy, bool canBeReadOnly) { if (ensembleProvider == null) { throw new ArgumentNullException(nameof(ensembleProvider), "ensembleProvider cannot be null"); } if (retryPolicy == null) { throw new ArgumentNullException(nameof(retryPolicy), "retryPolicy cannot be null"); } if (sessionTimeoutMs < connectionTimeoutMs) { log.Warn("session timeout [{0}] is less than connection timeout [{1}]", sessionTimeoutMs, connectionTimeoutMs); } this.connectionTimeoutMs = connectionTimeoutMs; state = new ConnectionState(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, tracer, canBeReadOnly); setRetryPolicy(retryPolicy); }
public HandleHolder(IZookeeperFactory zookeeperFactory, IWatcher watcher, IEnsembleProvider ensembleProvider, TimeSpan sessionTimeout, bool canBeReadOnly) { this.zookeeperFactory = zookeeperFactory; this.watcher = watcher; this.ensembleProvider = ensembleProvider; this.sessionTimeout = sessionTimeout; this.canBeReadOnly = canBeReadOnly; this.helper = null; }
internal HandleHolder(IZookeeperFactory zookeeperFactory, Watcher watcher, IEnsembleProvider ensembleProvider, int sessionTimeout, bool canBeReadOnly) { this.zookeeperFactory = zookeeperFactory; this.watcher = watcher; this.ensembleProvider = ensembleProvider; this.sessionTimeout = sessionTimeout; this.canBeReadOnly = canBeReadOnly; }
public ConnectionState(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, TimeSpan sessionTimeout, TimeSpan connectionTimeout, IWatcher parentWatcher, ITracerDriver tracer, bool canBeReadOnly) { this.ensembleProvider = ensembleProvider; this.sessionTimeout = sessionTimeout; this.connectionTimeout = connectionTimeout; this.tracer = tracer; if (parentWatcher != null) { parentWatchers.Enqueue(parentWatcher); } zooKeeper = new HandleHolder(zookeeperFactory, this, ensembleProvider, sessionTimeout, canBeReadOnly); }
/** * @param ensembleProvider the ensemble provider * @param sessionTimeoutMs session timeout * @param connectionTimeoutMs connection timeout * @param watcher default watcher or null * @param retryPolicy the retry policy to use */ public CuratorZookeeperClient(IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, IRetryPolicy retryPolicy) : this(new DefaultZookeeperFactory(), ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false) { }
public ConnectionState(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, TimeSpan sessionTimeout, TimeSpan connectionTimeout, IWatcher parentWatcher, ITracerDriver tracer, bool canBeReadOnly) { this.ensembleProvider = ensembleProvider; this.sessionTimeout = sessionTimeout; this.connectionTimeout = connectionTimeout; this.tracer = tracer; if ( parentWatcher != null ) { parentWatchers.Enqueue (parentWatcher); } zooKeeper = new HandleHolder(zookeeperFactory, this, ensembleProvider, sessionTimeout, canBeReadOnly); }
/** * @param zookeeperFactory factory for creating {@link ZooKeeper} instances * @param ensembleProvider the ensemble provider * @param sessionTimeoutMs session timeout * @param connectionTimeoutMs connection timeout * @param watcher default watcher or null * @param retryPolicy the retry policy to use * @param canBeReadOnly if true, allow ZooKeeper client to enter * read only mode in case of a network partition. See * {@link ZooKeeper#ZooKeeper(String, int, Watcher, long, byte[], bool)} * for details */ public CuratorZookeeperClient(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, IWatcher watcher, IRetryPolicy retryPolicy, bool canBeReadOnly) { if ( sessionTimeoutMs < connectionTimeoutMs ) { log.Warn(String.Format("session timeout [{0}] is less than connection timeout [{1}]", sessionTimeoutMs, connectionTimeoutMs)); } // retryPolicy = Preconditions.checkNotNull(retryPolicy, "retryPolicy cannot be null"); // ensembleProvider = Preconditions.checkNotNull(ensembleProvider, "ensembleProvider cannot be null"); this.connectionTimeoutMs = connectionTimeoutMs; state = new ConnectionState(zookeeperFactory, ensembleProvider, TimeSpan.FromMilliseconds(sessionTimeoutMs), TimeSpan.FromMilliseconds(connectionTimeoutMs), watcher, tracer, canBeReadOnly); SetRetryPolicy(retryPolicy); }
/** * @param zookeeperFactory factory for creating {@link ZooKeeper} instances * @param ensembleProvider the ensemble provider * @param sessionTimeoutMs session timeout * @param connectionTimeoutMs connection timeout * @param watcher default watcher or null * @param retryPolicy the retry policy to use * @param canBeReadOnly if true, allow ZooKeeper client to enter * read only mode in case of a network partition. See * {@link ZooKeeper#ZooKeeper(String, int, Watcher, long, byte[], bool)} * for details */ public CuratorZookeeperClient(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, IWatcher watcher, IRetryPolicy retryPolicy, bool canBeReadOnly) { if (sessionTimeoutMs < connectionTimeoutMs) { log.Warn(String.Format("session timeout [{0}] is less than connection timeout [{1}]", sessionTimeoutMs, connectionTimeoutMs)); } // retryPolicy = Preconditions.checkNotNull(retryPolicy, "retryPolicy cannot be null"); // ensembleProvider = Preconditions.checkNotNull(ensembleProvider, "ensembleProvider cannot be null"); this.connectionTimeoutMs = connectionTimeoutMs; state = new ConnectionState(zookeeperFactory, ensembleProvider, TimeSpan.FromMilliseconds(sessionTimeoutMs), TimeSpan.FromMilliseconds(connectionTimeoutMs), watcher, tracer, canBeReadOnly); SetRetryPolicy(retryPolicy); }
internal ConnectionState(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher parentWatcher, AtomicReference<ITracerDriver> tracer, bool canBeReadOnly) { this.ensembleProvider = ensembleProvider; this.sessionTimeoutMs = sessionTimeoutMs; this.connectionTimeoutMs = connectionTimeoutMs; this.tracer = tracer; if (parentWatcher != null) { parentWatchers.Enqueue(parentWatcher); } zooKeeper = new HandleHolder(zookeeperFactory, this, ensembleProvider, sessionTimeoutMs, canBeReadOnly); }
internal ConnectionState(IZookeeperFactory zookeeperFactory, IEnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher parentWatcher, AtomicReference <ITracerDriver> tracer, bool canBeReadOnly) { this.ensembleProvider = ensembleProvider; this.sessionTimeoutMs = sessionTimeoutMs; this.connectionTimeoutMs = connectionTimeoutMs; this.tracer = tracer; if (parentWatcher != null) { parentWatchers.Enqueue(parentWatcher); } zooKeeper = new HandleHolder(zookeeperFactory, this, ensembleProvider, sessionTimeoutMs, canBeReadOnly); }
/** * Set the list of servers to connect to. IMPORTANT: use either this or {@link #ensembleProvider(EnsembleProvider)} * but not both. * * @param connectString list of servers to connect to * @return this */ public Builder ConnectString(String connectString) { ensembleProvider = new FixedEnsembleProvider(connectString); return this; }
/** * Set the list of servers to connect to. IMPORTANT: use either this or {@link #ensembleProvider(EnsembleProvider)} * but not both. * * @param connectString list of servers to connect to * @return this */ public Builder ConnectString(String connectString) { ensembleProvider = new FixedEnsembleProvider(connectString); return(this); }
/** * Set the list ensemble provider. IMPORTANT: use either this or {@link #connectString(String)} * but not both. * * @param ensembleProvider the ensemble provider to use * @return this */ public Builder EnsembleProvider(IEnsembleProvider ensembleProvider) { this.ensembleProvider = ensembleProvider; return(this); }
/** * Set the list ensemble provider. IMPORTANT: use either this or {@link #connectString(String)} * but not both. * * @param ensembleProvider the ensemble provider to use * @return this */ public Builder EnsembleProvider(IEnsembleProvider ensembleProvider) { this.ensembleProvider = ensembleProvider; return this; }