FileDocCategorySizeDatePackage
RuntimeStatusList.javaAPI DocGlassfish v2 API5356Fri May 04 22:24:30 BST 2007com.sun.enterprise.admin.servermgmt

RuntimeStatusList

public class RuntimeStatusList extends ArrayList implements Serializable
This class holds a list of runtime status objects which corresponds to a list of server instances (e.g. in a cluster) or a list of node agents.
author
kebbs

Fields Summary
Constructors Summary
public RuntimeStatusList()

         
        super();
    
public RuntimeStatusList(int capacity)

        super(capacity);
    
Methods Summary
public booleanallRunning()

return
true if all of the server or node agents in the list is in a running state. Note that there must be at least one server or node agent in the list.

   
        if (isEmpty()) {
            return false;
        } else {
            return numRunning() == size() ? true : false;
        }
    
public booleananyRunning()

return
true if at least one of the servers / node agents in the list is in a running state.

        return numRunning() > 0 ? true : false;
    
public RuntimeStatusgetStatus(int index)
Return the RuntimeStatus at the specified index

param
index
throws
IndexOutOfBoundsException
return

        return (RuntimeStatus)super.get(index);
    
public booleanisEmpty()

return
true if there are no instances / agents in the list

        return size() == 0 ? true : false;
    
public intnumNeedingRestart()

return
the number of instances / node agents needing a restart. Note that stopped instances (i.e. not running) will not be counted.

        int count = 0;
        for (int i = 0; i < size(); i++) {
            //Only running instances are considered for restart required
            if (((RuntimeStatus)get(i)).isRunning() &&
                ((RuntimeStatus)get(i)).isRestartNeeded())
            {              
                count++;
            }
        }
        return count;
    
public intnumRunning()

return
the number of running instances / node agents.

        int count = 0;
        for (int i = 0; i < size(); i++) {
            if (((RuntimeStatus)get(i)).isRunning()) {              
                count++;
            }
        }
        return count;
    
public intnumStopped()

return
the number of stopped (not running) server instances

        return size() - numRunning();
    
public java.lang.StringtoString()

return
a string version of the list which can be: "running" if allRunning(), "partially running" if anyRunning(), or "stopped" everywhere else.

       if (allRunning()) {
           return Status.getStatusString(Status.kInstanceRunningCode);
       } else if (anyRunning()) {
           return Status.getStatusString(Status.kClusterPartiallyRunningCode);
       } else {
           return Status.getStatusString(Status.kInstanceNotRunningCode);
       }