Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *
   *  Copyright 2011 Netflix, Inc.
   *
   *     Licensed under the Apache License, Version 2.0 (the "License");
   *     you may not use this file except in compliance with the License.
   *     You may obtain a copy of the License at
   *
   *         http://www.apache.org/licenses/LICENSE-2.0
  *
  *     Unless required by applicable law or agreed to in writing, software
  *     distributed under the License is distributed on an "AS IS" BASIS,
  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *     See the License for the specific language governing permissions and
  *     limitations under the License.
  *
  */
 package com.netflix.curator.framework;
 
Factory methods for creating framework-style clients
 
 public class CuratorFrameworkFactory
 {
     private static final int        DEFAULT_SESSION_TIMEOUT_MS = 15 * 1000;     // TODO make configurable
     private static final int        DEFAULT_CONNECTION_TIMEOUT_MS = 10 * 1000;  // TODO make configurable
 
    
Return a new builder that builds a CuratorFramework

Returns:
new builder
 
     public static Builder       builder()
     {
         return new Builder();
     }

    
Create a new client with default session timeout and default connection timeout

Parameters:
connectString list of servers to connect to
retryPolicy retry policy to use
Returns:
client
Throws:
java.io.IOException ZK errors
 
     public static CuratorFramework newClient(String connectStringRetryPolicy retryPolicythrows IOException
     {
         return newClient(connectStringretryPolicy);
     }

    
Create a new client

Parameters:
connectString list of servers to connect to
sessionTimeoutMs session timeout
connectionTimeoutMs connection timeout
retryPolicy retry policy to use
Returns:
client
Throws:
java.io.IOException ZK errors
 
     public static CuratorFramework newClient(String connectStringint sessionTimeoutMsint connectionTimeoutMsRetryPolicy retryPolicythrows IOException
     {
         return builder().
             connectString(connectString).
             sessionTimeoutMs(sessionTimeoutMs).
             connectionTimeoutMs(connectionTimeoutMs).
             retryPolicy(retryPolicy).
             build();
     }
 
     public static class Builder
     {
         private String          connectString;
         private int             sessionTimeoutMs = ;
         private int             connectionTimeoutMs = ;
         private RetryPolicy     retryPolicy;
         private ThreadFactory   threadFactory = null;
         private String          namespace;
         private String          authScheme = null;
         private byte[]          authValue = null;
         private byte[]          defaultData = new byte[0];

        
Apply the current values and build a new CuratorFramework

Returns:
new CuratorFramework
Throws:
java.io.IOException errors
 
         public CuratorFramework build() throws IOException
         {
            return new CuratorFrameworkImpl(this);
        }

        
Add connection authorization

Parameters:
scheme the scheme
auth the auth bytes
Returns:
this
        public Builder  authorization(String schemebyte auth[])
        {
            this. = scheme;
            this. = (auth != null) ? Arrays.copyOf(authauth.length) : null;
            return this;
        }

        

Parameters:
connectString list of servers to connect to
Returns:
this
        public Builder connectString(String connectString)
        {
            this. = connectString;
            return this;
        }

        
Sets the data to use when com.netflix.curator.framework.api.PathAndBytesable.forPath(java.lang.String) is used. This is useful for debugging purposes. For example, you could set this to be the IP of the client.

Parameters:
defaultData new default data to use
Returns:
this
        public Builder defaultData(byte[] defaultData)
        {
            this. = (defaultData != null) ? Arrays.copyOf(defaultDatadefaultData.length) : null;
            return this;
        }

        
As ZooKeeper is a shared space, users of a given cluster should stay within a pre-defined namespace. If a namespace is set here, all paths will get pre-pended with the namespace

Parameters:
namespace the namespace
Returns:
this
        public Builder namespace(String namespace)
        {
            this. = namespace;
            return this;
        }

        

Parameters:
sessionTimeoutMs session timeout
Returns:
this
        public Builder sessionTimeoutMs(int sessionTimeoutMs)
        {
            this. = sessionTimeoutMs;
            return this;
        }

        

Parameters:
connectionTimeoutMs connection timeout
Returns:
this
        public Builder connectionTimeoutMs(int connectionTimeoutMs)
        {
            this. = connectionTimeoutMs;
            return this;
        }

        

Parameters:
retryPolicy retry policy to use
Returns:
this
        public Builder retryPolicy(RetryPolicy retryPolicy)
        {
            this. = retryPolicy;
            return this;
        }

        

Parameters:
threadFactory thread factory used to create Executor Services
Returns:
this
        public Builder threadFactory(ThreadFactory threadFactory)
        {
            this. = threadFactory;
            return this;
        }
        public ThreadFactory getThreadFactory()
        {
            return ;
        }
        public String getConnectString()
        {
            return ;
        }
        public int getSessionTimeoutMs()
        {
            return ;
        }
        public int getConnectionTimeoutMs()
        {
            return ;
        }
        public RetryPolicy getRetryPolicy()
        {
            return ;
        }
        public String getNamespace()
        {
            return ;
        }
        public String getAuthScheme()
        {
            return ;
        }
        public byte[] getAuthValue()
        {
            return ( != null) ? Arrays.copyOf(.) : null;
        }
        public byte[] getDefaultData()
        {
            return ;
        }
        private Builder()
        {
        }
    }
    private CuratorFrameworkFactory()
    {
    }
New to GrepCode? Check out our FAQ X