Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.clustermate.client;
  
  
  
Base class for builder class for creating immutable StoreClientConfig instances.
 
 public abstract class StoreClientConfigBuilder<
     K extends EntryKey,
     CONFIG extends StoreClientConfig<K, CONFIG>,
     BUILDER extends StoreClientConfigBuilder<K, CONFIG, BUILDER>
 >
 {
     /*
     /**********************************************************************
     /* Default values
     /**********************************************************************
      */
 
     protected final static OperationConfig DEFAULT_OPERATION_CONFIG = new OperationConfig();
 
     protected final static ObjectMapper DEFAULT_JSON_MAPPER = new ClusterMateObjectMapper();
     
     /*
     /**********************************************************************
     /* Configuration state
     /**********************************************************************
      */
 
     protected EntryKeyConverter<K> _keyConverter;
 
     // We need some additional features; but a single instance is fine:
 
     protected String[] _basePath;
 
     protected RequestPathStrategy _pathStrategy;
     
     // // // General configuration
     
    
Setting that determines whether retries are allowed: usually only disabled for tests.
 
     protected boolean _allowRetries;
 
     // // // For CallConfig
 
     // // Single call timeouts
     
     protected long _connectTimeoutMsecs;
 
     protected long _putCallTimeoutMsecs;
 
     protected long _getCallTimeoutMsecs;
 
     protected long _deleteCallTimeoutMsecs;
 
     protected int _maxExcerptLength;
     
     // // // For OperationConfig
     
     // // High-level operation settings, OK calls to require/try
     
     protected int _minOksToSucceed;
 
     protected int _optimalOks;
 
     protected int _maxOks;
     
     // // Operation timeouts
     
     protected long _putOperationTimeoutMsecs;
 
     protected long _getOperationTimeoutMsecs;
 
     protected long _deleteOperationTimeoutMsecs;
     
     /*
     /**********************************************************************
     /* Instance creation, building
     /**********************************************************************
      */
     
     public StoreClientConfigBuilder(EntryKeyConverter<K> keyConverter,
             String[] basePathRequestPathStrategy pathStrategy)
     {
         this(keyConverterbasePathpathStrategy,
                 );
     }
    public StoreClientConfigBuilder(CONFIG config)
    {
        this(config.getKeyConverter(),
                config.getBasePath(), config.getPathStrategy(), config.getJsonMapper(),
                config.getOperationConfig());
    }
    protected StoreClientConfigBuilder(EntryKeyConverter<K> keyConv,
            String[] basePathRequestPathStrategy pathStrategy,
            ObjectMapper jsonMapperOperationConfig operationConfig)
    {
         = keyConv;
         = jsonMapper;
         = basePath;
         = pathStrategy;
        
         = operationConfig.getMinimalOksToSucceed();
         = operationConfig.getOptimalOks();
         = operationConfig.getMaxOks();
        
         = operationConfig.getPutOperationTimeoutMsecs();
         = operationConfig.getGetOperationTimeoutMsecs();
         = operationConfig.getAllowRetries();
        
        final CallConfig callConfig = operationConfig.getCallConfig();
         = callConfig.getConnectTimeoutMsecs();
         = callConfig.getPutCallTimeoutMsecs();
         = callConfig.getGetCallTimeoutMsecs();
         = callConfig.getDeleteCallTimeoutMsecs();
   }

    
Main build method; needs to be abstract for sub-classes to produce custom config objects.
    public abstract CONFIG build();
    protected OperationConfig buildOperationConfig() {
        CallConfig cc = buildCallConfig();
        return new OperationConfig(cc,
                ,
                
        );
    }
    protected CallConfig buildCallConfig() {
        return new CallConfig(,
                );                
    }
    
    /*
    /**********************************************************************
    /* Mutators
    /**********************************************************************
     */
    // // // Low-level single-call timeouts
    
    @SuppressWarnings("unchecked")
    public BUILDER setConnectTimeoutMsecs(long msecs) {
         = msecs;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setPutCallTimeoutMsecs(long msecs) {
         = msecs;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setGetCallTimeoutMsecs(long msecs) {
         = msecs;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setDeleteCallTimeoutMsecs(long msecs) {
         = msecs;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setMaxExcerptLength(int max) {
         = max;
        return (BUILDER) this;
    }
    
    // // // High-level operation settings
    @SuppressWarnings("unchecked")
    public BUILDER setAllowRetries(boolean enable) {
         = enable;
        return (BUILDER) this;
    }
    
    @SuppressWarnings("unchecked")
    public BUILDER setMinimalOksToSucceed(int count) {
         = count;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setOptimalOks(int count) {
         = count;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setMaxOks(int count) {
         = count;
        return (BUILDER) this;
    }
    // // // Operation timeouts
    
    @SuppressWarnings("unchecked")
    public BUILDER setPutOperationTimeoutMsecs(long msecs) {
         = msecs;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setGetOperationTimeoutMsecs(long msecs) {
         = msecs;
        return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setDeleteOperationTimeoutMsecs(long msecs) {
         = msecs;
         return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setBasePath(String[] path) {
         = path;
         return (BUILDER) this;
    }
    @SuppressWarnings("unchecked")
    public BUILDER setBasePath(RequestPathStrategy pathStrategy) {
         = pathStrategy;
         return (BUILDER) this;
    }
    
    /*
    /**********************************************************************
    /* Accessors
    /**********************************************************************
     */
    public EntryKeyConverter<K> getKeyConverter() {
        return ;
    }
    public String[] getBasePath() {
        return ;
    }
        return ;
    }
    
    public ObjectMapper getJsonMapper() {
    	return ;
    }
New to GrepCode? Check out our FAQ X