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

LoadBalancerContextRootStatsImpl

public final class LoadBalancerContextRootStatsImpl extends Object implements CustomStatsImpl

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

    
public LoadBalancerContextRootStatsImpl(String lbName, String lbConfigName, String clusterName, String instanceName, String appName, String contextRoot)

        this.lbName=lbName;
        this.clusterName=clusterName;
        this.instanceName=instanceName;
        this.appName=appName;
        this.contextRoot=contextRoot;
        this.lbConfigName=lbConfigName;
        this.lbff = ApplicationServer.getServerContext().
                getPluggableFeatureFactory().getLBFeatureFactory();
        this.startTime=System.currentTimeMillis();
    
Methods Summary
private javax.management.j2ee.statistics.CountStatisticcreateActiveRequestCountStat(long sampleTime, long count)

        return new CountStatisticImpl("ActiveRequestCount", 
                "Active Request Count", "count", startTime, sampleTime,count);
    
private javax.management.j2ee.statistics.CountStatisticcreateAverageRespTimeStat(long sampleTime, long count)

        return new CountStatisticImpl("AverageResponseTime", 
                "Average Response Time", "MILLISECOND", startTime, sampleTime,count);
    
private javax.management.j2ee.statistics.Statistic[]createEmptyStats()

        Statistic[] statArr1 = new Statistic[7];
        statArr1[0] = createResponseTimeStat(-1, -1, -1, -1, -1);
        statArr1[1] = createAverageRespTimeStat(-1, -1);
        statArr1[2] = createFailoverReqCountStat(-1, -1);
        statArr1[3] = createErrorRequestCountStat(-1, -1);
        statArr1[4] = createActiveRequestCountStat(-1, -1);
        statArr1[5] = createTotalRequestCountStat(-1, -1);
        statArr1[6] = createIdempotentUrlAccessCountStat( -1, -1);
        return statArr1;
    
private javax.management.j2ee.statistics.CountStatisticcreateErrorRequestCountStat(long sampleTime, long count)

        return new CountStatisticImpl("ErrorRequestCount", 
                "Error Request Count", "count", startTime, sampleTime,count);
    
private javax.management.j2ee.statistics.CountStatisticcreateFailoverReqCountStat(long sampleTime, long count)

        return new CountStatisticImpl("FailoverReqCount", 
                "Failover Request Count", "count", startTime, sampleTime,count);
    
private javax.management.j2ee.statistics.CountStatisticcreateIdempotentUrlAccessCountStat(long sampleTime, long count)

        return new CountStatisticImpl("IdempotentUrlAccessCount", 
                "Idempotent Url Access Count", "count", startTime, sampleTime,count);
    
private javax.management.j2ee.statistics.TimeStatisticcreateResponseTimeStat(long maxRespTime, long totalRequests, long sampleTime, long minRespTime, long avgRespTime)

        return new TimeStatisticImpl("ResponseTime", "Response Time", 
                "MILLISECOND", startTime, sampleTime,totalRequests,maxRespTime,
                minRespTime, totalRequests*avgRespTime);
    
private javax.management.j2ee.statistics.Statistic[]createStats(com.sun.enterprise.admin.monitor.stats.lb.InstanceStatsInterface istat)

        Statistic[] emptyStats = createEmptyStats();
        if(istat==null)
            return emptyStats;
        long avgRespTime = Long.parseLong(
                istat.getApplicationStatsAverageResponseTime());
        long maxRespTime = Long.parseLong(
                istat.getApplicationStatsMaxResponseTime());
        long minRespTime = Long.parseLong(
                istat.getApplicationStatsMinResponseTime());
        long noActiveReq = Long.parseLong(
                istat.getApplicationStatsNumActiveRequests());
        long noErrorReq = Long.parseLong(
                istat.getApplicationStatsNumErrorRequests());
        long noFailoverReq = Long.parseLong(
                istat.getApplicationStatsNumFailoverRequests());
        long noIdempotentUrlReq = Long.parseLong(
                istat.getApplicationStatsNumIdempotentUrlRequests());
        long totalRequests = Long.parseLong(
                istat.getApplicationStatsNumTotalRequests());
        long sampleTime = System.currentTimeMillis();
        Statistic[] statArr = new Statistic[7];
        statArr[0] = createResponseTimeStat(maxRespTime, totalRequests, 
                sampleTime, minRespTime, avgRespTime);
        statArr[1] = createAverageRespTimeStat(sampleTime, avgRespTime);
        statArr[2] = createFailoverReqCountStat(sampleTime, noFailoverReq);
        statArr[3] = createErrorRequestCountStat(sampleTime, noErrorReq);
        statArr[4] = createActiveRequestCountStat(sampleTime, noActiveReq);
        statArr[5] = createTotalRequestCountStat(sampleTime, totalRequests);
        statArr[6] = createIdempotentUrlAccessCountStat(sampleTime, 
                noIdempotentUrlReq);

        return statArr;
    
private javax.management.j2ee.statistics.CountStatisticcreateTotalRequestCountStat(long sampleTime, long count)

        return new CountStatisticImpl("TotalRequestCount", 
                "Total Request Count", "count", startTime, sampleTime,count);
    
public javax.management.j2ee.statistics.CountStatisticgetActiveRequestCount()
Returns the number of active requests

return
an instance of {@link CountStatistic}

        LoadBalancerStatsInterface lbstats = 
                lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        InstanceStatsInterface istat =  getInstanceStats(lbstats);
        if(istat!=null){
            long time = Long.parseLong(
                    istat.getApplicationStatsNumActiveRequests());
            long sampleTime = System.currentTimeMillis();
            return createActiveRequestCountStat(sampleTime,time);
        }
        return null;
    
public javax.management.j2ee.statistics.CountStatisticgetAverageResponseTime()
Returns average response time in milliseconds

return
an instance of {@link TimeStatistic}

        LoadBalancerStatsInterface lbstats = 
                lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        InstanceStatsInterface istat =  getInstanceStats(lbstats);
        if(istat!=null){
            long avgRespTime = Long.parseLong(
                    istat.getApplicationStatsAverageResponseTime());
            long sampleTime = System.currentTimeMillis();
            return createAverageRespTimeStat(sampleTime,avgRespTime);
        }
        return null;
    
public javax.management.j2ee.statistics.CountStatisticgetErrorRequestCount()
Returns the number of error requests

return
an instance of {@link CountStatistic}

        LoadBalancerStatsInterface lbstats = 
                lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        InstanceStatsInterface istat =  getInstanceStats(lbstats);
        if(istat!=null){
            long time = Long.parseLong(
                    istat.getApplicationStatsNumErrorRequests());
            long sampleTime = System.currentTimeMillis();
            return createErrorRequestCountStat(sampleTime,time);
        }
        return null;
    
public javax.management.j2ee.statistics.CountStatisticgetFailoverReqCount()
Returns the number of failover requests

return
an instance of {@link CountStatistic}

        LoadBalancerStatsInterface lbstats = 
                lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        InstanceStatsInterface istat =  getInstanceStats(lbstats);
        if(istat!=null){
            long time = Long.parseLong(
                    istat.getApplicationStatsNumFailoverRequests());
            long sampleTime = System.currentTimeMillis();
            return createFailoverReqCountStat(sampleTime,time);
        }
        return null;
    
public javax.management.j2ee.statistics.CountStatisticgetIdempotentUrlAccessCount()
Returns the number of times all idempotent urls in this application are accessed

return
an instance of {@link CountStatistic}

        LoadBalancerStatsInterface lbstats = 
                lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        InstanceStatsInterface istat =  getInstanceStats(lbstats);
        if(istat!=null){
            long time = Long.parseLong(
                    istat.getApplicationStatsNumIdempotentUrlRequests());
            long sampleTime = System.currentTimeMillis();
            return createIdempotentUrlAccessCountStat(sampleTime,time);
        }
        return null;
    
private com.sun.enterprise.admin.monitor.stats.lb.InstanceStatsInterfacegetInstanceStats(com.sun.enterprise.admin.monitor.stats.lb.LoadBalancerStatsInterface lbstats)

    
      
               
        if(lbstats == null)
            return null;
        ClusterStats [] cstats = lbstats.getClusterStats();
        for(ClusterStats cstat :cstats){
            for(InstanceStats istat : cstat.getInstanceStats()){
                if(!istat.getId().equals(instanceName))
                    continue;
                String appid = istat.getApplicationStatsId();
                    if(!appid.equals(contextRoot))
                        continue;
                return istat;

            }
        }
        return null;
    
public javax.management.j2ee.statistics.TimeStatisticgetResponseTime()
Returns average response time in milliseconds

return
an instance of {@link TimeStatistic}

        LoadBalancerStatsInterface lbstats = 
                lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        InstanceStatsInterface istat =  getInstanceStats(lbstats);
        if(istat!=null){
            long avgRespTime = Long.parseLong(
                    istat.getApplicationStatsAverageResponseTime());
            long maxRespTime = Long.parseLong(
                    istat.getApplicationStatsMaxResponseTime());
            long minRespTime = Long.parseLong(
                    istat.getApplicationStatsMinResponseTime());
            long totalRequests = Long.parseLong(
                    istat.getApplicationStatsNumTotalRequests()); 
            long sampleTime = System.currentTimeMillis();
            return createResponseTimeStat(maxRespTime, 
            totalRequests, sampleTime, 
            minRespTime, avgRespTime);
        }
        return null;
    
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);
        InstanceStatsInterface instance =  getInstanceStats(lbstats);
        return createStats(instance);
    
public javax.management.j2ee.statistics.CountStatisticgetTotalRequestCount()
Returns the number of total requests

return
an instance of {@link CountStatistic}

        LoadBalancerStatsInterface lbstats = 
                lbff.getLoadBalancerMonitoringStats(lbConfigName,lbName);
        InstanceStatsInterface istat =  getInstanceStats(lbstats);
        if(istat!=null){
            long time = Long.parseLong(
                    istat.getApplicationStatsNumTotalRequests());
            long sampleTime = System.currentTimeMillis();
            return createTotalRequestCountStat(sampleTime,time);
        }
        return null;