FileDocCategorySizeDatePackage
LoadBalancerServerStatsImpl.javaAPI DocGlassfish v2 API6509Fri May 04 22:23:40 BST 2007com.sun.enterprise.management.monitor.stats

LoadBalancerServerStatsImpl

public final class LoadBalancerServerStatsImpl extends Object implements CustomStatsImpl

Fields Summary
private String
instanceName
private String
lbName
private String
lbConfigName
private String
clusterName
private com.sun.enterprise.server.pluggable.LBFeatureFactory
lbff
private long
startTime
Constructors Summary
public LoadBalancerServerStatsImpl(String lbName, String lbConfigName, String clusterName, String instanceName)

        this.lbName=lbName;
        this.clusterName=clusterName;
        this.instanceName=instanceName;
        this.lbConfigName=lbConfigName;
        this.lbff = ApplicationServer.getServerContext().getPluggableFeatureFactory().getLBFeatureFactory();
        this.startTime=new Date().getTime();
   
public LoadBalancerServerStatsImpl()

    
Methods Summary
public com.sun.appserv.management.j2ee.statistics.StringStatisticgetHealth()
Returns the server's health status - Healthy, Unhealthy or Quiesced.

return
an instance of {@link StringStatistic}

        Statistic[] statArr = getStatistics();
        return (StringStatistic)statArr[0];
    
public javax.management.j2ee.statistics.CountStatisticgetNumberOfActiveRequests()
Returns the number of active requests on this instance

return
an instance of {@link CountStatistic}

        Statistic[] statArr = getStatistics();
        return (CountStatistic)statArr[1];
    
public javax.management.j2ee.statistics.CountStatisticgetNumberOfTotalRequests()
Returns the total number of requests for this instance.

return
an instance of {@link CountStatistic}

        Statistic[] statArr = getStatistics();
        return (CountStatistic)statArr[2];
    
public javax.management.j2ee.statistics.Statistic[]getStatistics()
Returns the statistics for a load-balanced server instance

return
an array of {@link Statistic}

        LoadBalancerStatsInterface lbstats = lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        Statistic[] statArr1 = new Statistic[3];
        StringStatistic stat11 = new StringStatisticImpl("Health", "Instance Health", "state of the server", 0, 0, "");
        CountStatistic stat21 = new CountStatisticImpl("NumberOfActiveRequests", "Number Of Active Requests", "count", 0, 0, 0);
        CountStatistic stat31 = new CountStatisticImpl("NumberOfTotalRequests", "Number Of Total Requests", "count", 0, 0, 0);
        statArr1[0]=stat11;
        statArr1[1]=stat21;
        statArr1[2]=stat31;
        if(lbstats == null)
            return statArr1;
        ClusterStats [] cstats = lbstats.getClusterStats();
        for(ClusterStats cstat :cstats){
            for(InstanceStats istat : cstat.getInstanceStats()){
                if(!istat.getId().equals(instanceName))
                    continue;
                    Statistic[] statArr = new Statistic[3];
                    String health = istat.getHealth();
                    long activeReq = Long.parseLong(istat.getNumActiveRequests());
                    long totalReq = Long.parseLong(istat.getNumTotalRequests());
                    long sampleTime = new Date().getTime();
                    StringStatistic stat1 = new StringStatisticImpl("Health", "Instance Health", "milliseconds", startTime, sampleTime, health);
                    CountStatistic stat2 = new CountStatisticImpl("NumberOfActiveRequests", "Number Of Active Requests", "count", startTime, sampleTime, activeReq);
                    CountStatistic stat3 = new CountStatisticImpl("NumberOfTotalRequests", "Number Of Total Requests", "count", startTime, sampleTime, totalReq);
                    statArr[0] = stat1;
                    statArr[1] = stat2;
                    statArr[2] = stat3;
                    return statArr;
            }
        }
        return null;