Пример #1
0
 /**
  * @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);
 }
Пример #2
0
		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;
		}
Пример #3
0
 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;
 }
Пример #4
0
 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;
 }
Пример #5
0
 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;
 }
Пример #6
0
        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);
        }
Пример #7
0
 /**
  * @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)
 {
 }
Пример #8
0
 /**
  * @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)
 {
 }
Пример #9
0
		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);
		}
Пример #10
0
		/**
     * @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);
		}
Пример #11
0
        /**
         * @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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
 /**
  * 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;
 }
Пример #15
0
 /**
  * @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);
 }
 /**
  * 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);
 }
Пример #18
0
 /**
  * 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;
 }