Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package io.advantageous.qbit.metrics.support;
  
  
  
created by rhightower on 5/22/15.
 
 public class StatsDReplicatorBuilder {
 
     public static final String STATSD_REPLICATOR_PROPS = "qbit.statsd.replicator.";
     private String host = "localhost";
     private int port = 8125;
     private boolean multiMetrics = true;
     private int bufferSize = 1500;
     private int flushRateIntervalMS = 1000;
     private ServiceBuilder serviceBuilder;
     private ServiceQueue serviceQueue;
 
     public StatsDReplicatorBuilder() {
         this(PropertyResolver.createSystemPropertyResolver());
     }
 
     public StatsDReplicatorBuilder(PropertyResolver propertyResolver) {
 
         this. = propertyResolver.getStringProperty("host");
         this. = propertyResolver.getIntegerProperty("port");
         this. = propertyResolver.getBooleanProperty("multiMetrics");
         this. = propertyResolver.getIntegerProperty("bufferSize");
         this. = propertyResolver.getIntegerProperty("flushRateIntervalMS");
 
     }
 
     public StatsDReplicatorBuilder(final Properties properties) {
         this(PropertyResolver.createPropertiesPropertyResolver(
                 properties));
     }
 
     public static StatsDReplicatorBuilder statsDReplicatorBuilder() {
         return new StatsDReplicatorBuilder();
     }
 
     public ServiceBuilder getServiceBuilder() {
 
         if ( == null) {
              = ServiceBuilder.serviceBuilder();
         }
         return ;
     }
 
     public void setServiceBuilder(ServiceBuilder serviceBuilder) {
         this. = serviceBuilder;
     }
 
     public String getHost() {
         return ;
     }
 
     public StatsDReplicatorBuilder setHost(String host) {
         this. = host;
         return this;
     }
 
     public int getPort() {
         return ;
     }
 
     public StatsDReplicatorBuilder setPort(int port) {
         this. = port;
         return this;
     }
 
     public boolean isMultiMetrics() {
         return ;
     }
 
     public StatsDReplicatorBuilder setMultiMetrics(boolean multiMetrics) {
         this. = multiMetrics;
         return this;
     }
 
     public int getBufferSize() {
         return ;
     }
 
     public StatsDReplicatorBuilder setBufferSize(int bufferSize) {
         this. = bufferSize;
         return this;
     }
 
     public int getFlushRateIntervalMS() {
         return ;
    }
    public StatsDReplicatorBuilder setFlushRateIntervalMS(int flushRateIntervalMS) {
        this. = flushRateIntervalMS;
        return this;
    }
    private void buildQueue() {
        final StatsDReplicator statsDReplicator = createStatsDReplicator();
        final ServiceBuilder serviceBuilder = this.getServiceBuilder();
        serviceBuilder.setServiceObject(statsDReplicator);
        this. = serviceBuilder.build();
    }
    public ServiceQueue getServiceQueue() {
        return ;
    }
    public StatReplicator build() {
        buildQueue();
        //noinspection UnnecessaryLocalVariable
        @SuppressWarnings("UnnecessaryLocalVariable"final StatReplicator proxyWithAutoFlush =
                .createProxyWithAutoFlush(StatReplicator.class, 100, .);
        return proxyWithAutoFlush;
    }
    public StatReplicator buildAndStart() {
        buildQueue();
        final StatReplicator proxyWithAutoFlush =
                .createProxyWithAutoFlush(StatReplicator.class, 100, .);
        .start();
        return proxyWithAutoFlush;
    }
        try {
            return new StatsDReplicator(getHost(),
                    getPort(), this.isMultiMetrics(),
                    this.getBufferSize(), this.getFlushRateIntervalMS());
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
New to GrepCode? Check out our FAQ X