Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.clustermate.dw;
 
Metrics health check for use with DropWizard that checks health of the cluster handling and state.
public class HealthCheckForCluster extends HealthCheck
    protected final ClusterViewByServer _cluster;
    public HealthCheckForCluster(ServiceConfig configClusterViewByServer cluster)
    {
         = cluster;
    }
    @Override
    protected Result check() throws Exception
    {
        // first: see if we have 100% active coverage; if we do, great
        int activeCoverage = .getActiveCoveragePct();
        if (activeCoverage == 100) {
            return Result.healthy("Full Active coverage (100%)");
        }
        // If not, should we accept passive coverage as well
        int passiveCoverage = .getTotalCoveragePct();
        if (passiveCoverage == 100 && activeCoverage >= 50) {
            return Result.healthy("No full active coverage ("+activeCoverage+"%), but full passive");
        }
        return Result.unhealthy("Insufficient coverage: active="+activeCoverage+"%; passive "+passiveCoverage+"%");
    }
New to GrepCode? Check out our FAQ X