Example #1
0
        public CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder)
        {
            IZookeeperFactory localZookeeperFactory = makeZookeeperFactory(builder.GetZookeeperFactory());

            this.client = new CuratorZookeeperClient(localZookeeperFactory,
                                                     builder.GetEnsembleProvider(),
                                                     builder.GetSessionTimeoutMs(),
                                                     builder.GetConnectionTimeoutMs(),
                                                     new WatchedWatcher(this),
                                                     builder.GetRetryPolicy(),
                                                     builder.CanBeReadOnly());

            listeners = new ListenerContainer <ICuratorListener>();
            unhandledErrorListeners = new ListenerContainer <IUnhandledErrorListener>();
            backgroundOperations    = new DelayQueue <OperationAndData <object> >();
            @namespace             = new NamespaceImpl(this, builder.GetNamespace());
            maxCloseWaitMs         = builder.GetMaxCloseWaitMs();
            connectionStateManager = new ConnectionStateManager(this, builder.GetEventQueueSize());
            compressionProvider    = builder.GetCompressionProvider();
            aclProvider            = builder.GetAclProvider();
            state = new AtomicReference <CuratorFrameworkState>(CuratorFrameworkState.LATENT);
            useContainerParentsIfAvailable = builder.UseContainerParentsIfAvailable();

            byte[] builderDefaultData = builder.GetDefaultData();
            byte[] destDefaults       = new byte[builderDefaultData.Length];
            Array.Copy(builderDefaultData, destDefaults, builderDefaultData.Length);
            defaultData = (builderDefaultData != null)
                            ?  destDefaults
                            : new byte[0];
            authInfos = buildAuths(builder);

            failedDeleteManager  = new FailedDeleteManager(this);
            namespaceWatcherMap  = new NamespaceWatcherMap(this);
            namespaceFacadeCache = new NamespaceFacadeCache(this);
        }
Example #2
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);
 }
Example #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;
		}
Example #4
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;
 }
Example #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;
 }
Example #6
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;
 }
Example #7
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);
        }
Example #8
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);
		}
		/**
     * @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);
		}
Example #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);
        }
Example #11
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);
        }
Example #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);
        }
Example #13
0
 public InternalZookeeperFactory(CuratorFrameworkImpl factory, IZookeeperFactory zookeeperFactory)
 {
     _factory = factory;
     _actualZookeeperFactory = zookeeperFactory;
 }
Example #14
0
 private IZookeeperFactory makeZookeeperFactory(IZookeeperFactory actualZookeeperFactory)
 {
     return(new InternalZookeeperFactory(this, actualZookeeperFactory));
 }
 /**
  * @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 InternalZookeeperFactory(CuratorFrameworkImpl factory, IZookeeperFactory zookeeperFactory)
 {
     _factory = factory;
     _actualZookeeperFactory = zookeeperFactory;
 }
 /**
  * @param zookeeperFactory the zookeeper factory to use
  * @return this
  */
 public Builder ZookeeperFactory(IZookeeperFactory zookeeperFactory)
 {
     this.zookeeperFactory = zookeeperFactory;
     return this;
 }
 /**
  * @param zookeeperFactory the zookeeper factory to use
  * @return this
  */
 public Builder ZookeeperFactory(IZookeeperFactory zookeeperFactory)
 {
     this.zookeeperFactory = zookeeperFactory;
     return(this);
 }