Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package io.advantageous.qbit.admin;
  
This is a utility class for when you are running in a PaaS like Heroku or Docker. It also allows you to share stat, health and system manager setup.
 
 public class ManagedServiceBuilder {
 
 
     private QBitSystemManager systemManager;
     private boolean enableLocalStats=true;
     private boolean enableStatsD=false;
     private boolean enableLocalHealth=true;
     private HealthServiceAsync healthService;
     private boolean enableStats = true;
     private int sampleStatFlushRate = 5;
     private int checkTimingEveryXCalls = 100;
 
 
     public ManagedServiceBuilder setHealthServiceBuilder(final HealthServiceBuilder healthServiceBuilder) {
         this. = healthServiceBuilder;
         return this;
     }
 
 
         if ( == null) {
              = HealthServiceBuilder.healthServiceBuilder();
         }
         return ;
     }
 
     public static ManagedServiceBuilder managedServiceBuilder() {
         return new ManagedServiceBuilder();
     }
 
         if ( == null) {
              = HttpServerBuilder.httpServerBuilder();
 
             String port = System.getenv("WEB_PORT");
             if (Str.isEmpty(port)) {
                 port = System.getenv("PORT");
             }
             if (!Str.isEmpty(port)) {
                 .setPort(Integer.parseInt(port));
             }
         }
         return ;
     }
 
     public ManagedServiceBuilder setHttpServerBuilder(HttpServerBuilder httpServerBuilder) {
         this. = httpServerBuilder;
         return this;
     }
 
     public boolean isEnableStatsD() {
         return ;
     }
 
     public ManagedServiceBuilder setEnableStatsD(boolean enableStatsD) {
         this. = enableStatsD;
         return this;
     }
 
         if (==null) {
              = LocalStatsCollectorBuilder.localStatsCollectorBuilder();
         }
         return ;
     }
 
     public ManagedServiceBuilder setLocalStatsCollectorBuilder(LocalStatsCollectorBuilder localStatsCollectorBuilder) {
         this. = localStatsCollectorBuilder;
         return this;
     }
 
     public boolean isEnableLocalStats() {
         return ;
     }
 
     public ManagedServiceBuilder setEnableLocalStats(boolean enableLocalStats) {
        this. = enableLocalStats;
        return this;
    }
    public boolean isEnableLocalHealth() {
        return ;
    }
    public ManagedServiceBuilder setEnableLocalHealth(boolean enableLocalHealth) {
        this. = enableLocalHealth;
        return this;
    }
        if ( == null) {
             = new QBitSystemManager();
        }
        return ;
    }
    public ManagedServiceBuilder setSystemManager(QBitSystemManager systemManager) {
        this. = systemManager;
        return this;
    }
        if ( == null) {
             =  StatServiceBuilder.statServiceBuilder();
            if () {
            }
            .build();
        }
        return ;
    }
    public ManagedServiceBuilder setStatServiceBuilder(StatServiceBuilder statServiceBuilder) {
        this. = statServiceBuilder;
        return this;
    }
        if (==null) {
             = EndpointServerBuilder.endpointServerBuilder();
            if (isEnableStats()) {
            }
            if (isEnableLocalStats()) {
                .setEnableStatEndpoint(true);
            }
        }
        return ;
    }
        EndpointServerBuilder endpointServerBuilder = EndpointServerBuilder.endpointServerBuilder();
        endpointServerBuilder.setEnableHealthEndpoint(isEnableLocalHealth());
        endpointServerBuilder.setSystemManager(this.getSystemManager());
        endpointServerBuilder.setHealthService(getHealthService());
        endpointServerBuilder.setStatsFlushRateSeconds(getSampleStatFlushRate());
        endpointServerBuilder.setCheckTimingEveryXCalls(getCheckTimingEveryXCalls());
        if (isEnableStats()) {
            endpointServerBuilder.setStatsCollector(getStatServiceBuilder().buildStatsCollectorWithAutoFlush());
        }
        if (isEnableLocalStats()) {
                endpointServerBuilder.setEnableStatEndpoint(true);
                endpointServerBuilder.setStatsCollection(getLocalStatsCollectorBuilder().build());
        }
        return endpointServerBuilder;
    }
        ServiceBundleBuilder serviceBundleBuilder = ServiceBundleBuilder.serviceBundleBuilder();
        serviceBundleBuilder.setSystemManager(this.getSystemManager());
        serviceBundleBuilder.setHealthService(getHealthService());
        serviceBundleBuilder.setCheckTimingEveryXCalls(this.getCheckTimingEveryXCalls());
        serviceBundleBuilder.setStatsFlushRateSeconds(this.getSampleStatFlushRate());
        if (isEnableStats()) {
            serviceBundleBuilder.setStatsCollector(getStatServiceBuilder().buildStatsCollector());
        }
        return serviceBundleBuilder;
    }
        ServiceBuilder serviceBuilder = ServiceBuilder.serviceBuilder();
        serviceBuilder.setSystemManager(this.getSystemManager());
        final String bindStatHealthName =  AnnotationUtils.readServiceName(serviceObject);
        if (isEnableLocalHealth()) {
            serviceBuilder.registerHealthChecks(getHealthService(), bindStatHealthName);
        }
        if (isEnableStats()) {
            serviceBuilder.registerStatsCollections(bindStatHealthName,
        }
        return serviceBuilder;
    }
    public ManagedServiceBuilder setEndpointServerBuilder(EndpointServerBuilder endpointServerBuilder) {
        this. = endpointServerBuilder;
        return this;
    }
        if ( == null) {
            if ( == null) {
                HealthServiceBuilder builder = getHealthServiceBuilder();
                 = builder.setAutoFlush().buildAndStart();
            }
            return ;
        } else {
            return .buildHealthSystemReporter();
        }
    }
    public ManagedServiceBuilder setHealthService(HealthServiceAsync healthServiceAsync) {
        this. = healthServiceAsync;
        return this;
    }
    public boolean isEnableStats() {
        return ;
    }
    public void setEnableStats(boolean enableStats) {
        this. = enableStats;
    }
    public int getSampleStatFlushRate() {
        return ;
    }
    public void setSampleStatFlushRate(int sampleStatFlushRate) {
        this. = sampleStatFlushRate;
    }
    public int getCheckTimingEveryXCalls() {
        return ;
    }
    public void setCheckTimingEveryXCalls(int checkTimingEveryXCalls) {
        this. = checkTimingEveryXCalls;
    }
New to GrepCode? Check out our FAQ X