com.egurkha.agent.tests
Class GenericTest

java.lang.Object
  |
  +--EgTest
        |
        +--com.egurkha.agent.tests.GenericTest

public abstract class GenericTest
extends EgTest

GenericTest is the abstract base class for all user-defined Tests which an eGurkha user can develop and add to the existing eGurkha system.

Every Test runs on a specific component, internally or externally based on the method of execution. It has a set of variables which hold values for the different measures that are obtained as a result of execution.

Following is an example of a non-descriptor based test :


	import com.egurkha.agent.tests.GenericTest;

	public class AvailabilityTest extends GenericTest
	{
	   // declare necessary variables

	   public AvailabilityTest ( String [] args )
	   {
		super(args);			
		setMeasureCount(1);
	   }

	   public void computeMeasures ( Hashtable paramList )
	   {
		double availability = getAvailability(param1);
		ArrayList al = new ArrayList();
		al.add(new Double(availability));
		addNewMeasure(al);
	   }

	   // other methods

	   public double getAvailability(String commStr)
	   {
		// User defined Implementation
	   }

	}
	

Following is an example of a descriptor based test :


	import com.egurkha.agent.tests.GenericTest;

	public class AvailabilityTest extends GenericTest
	{
	   String param1;

	   // declare other necessary variables

	   public AvailabilityTest ( String [] args )
	   {
		super(args);			
		setMeasureCount(1);
	   }

	   public void computeMeasures ( Hashtable paramList )
	   {
		param1 = paramList.get("communityString");
		String [] servers = tokenizeServerList(param1);
		double availability = 0;
		ArrayList al = null;
		for(int i=0; i=servers.length-1; i++)
		{
			availability = getAvailability(servers[i]);
			al = new ArrayList();
			al.add(new Double(availability));
			addNewMeasure(servers[i], al);
		}
	   }

	   // other methods

	   public double getAvailability(String commStr)
	   {
		// User defined Implementation
	   }
	
	   public String [] tokenizeServerList(String param)
	   {
		// User defined Implementation 
	   }

	}
	


Field Summary
protected  java.util.Hashtable descMeasures
           
protected  int measureCount
           
protected  java.util.ArrayList measures
           
protected  java.util.Hashtable params
           
 
Fields inherited from class EgTest
configInfo, dateInfo, debug, disableInfo, disableReported, disableSection, disableTest, egConfigDir, errorMsg, info, infoFieldSeparator, infoList, infos, infoTable, ipAddresses, isValid, measurementHost, noneValue, numOutputFields, os, portNo, process, results, sid, siteAndInfoSeparator, siteName, target, targetHost, testDateAndTime, testInfo, thresholds, timeSinceLastTest
 
Constructor Summary
GenericTest(java.lang.String[] args)
           
 
Method Summary
 void addMeasures(java.util.ArrayList measureList)
          Adds measures from the Test to the eGurkha system
 void addMeasures(java.lang.String descriptor, java.util.ArrayList measureList)
          Adds measures from the Test to the eGurkha system
 void addNewMeasure(java.util.ArrayList al)
           
 void addNewMeasure(java.lang.String desc, java.util.ArrayList al)
           
 void addUnknownMeasures()
          Adds unknown measures from the Test to the eGurkha system during an exceptional condition
 void computeMeasures(java.util.Hashtable params)
           
 boolean executeTest()
           
 void getParams(java.lang.String[] args)
          Initializes the necessary variables of the test and is called from the constructor
 java.lang.String getValueForParam(java.lang.String name)
          Gets the value for a parameter passed for the Test
 void initTest()
          Initializes the Test
 void setErrorMessage(java.lang.String errorMsg)
          Logs an error message associated with the Test to the eGurkha system
 void setMeasureCount(int measureCount)
          Sets the count of measures for a test and is called from the test's constructor
 void updateAllMeasures()
          Updates all measures for the Test with the eGurkha system
 void updateAllMeasures(boolean dynamic)
          Updates all measures for the Test with the eGurkha system
 
Methods inherited from class EgTest
addIndexToResultSet, addToDisabledInfo, addValueToResultSet, closeReader, destroy, executeProgram, getHostName, getMeasurementsLength, getValidIndex, infoDisabledFor, populateInfoTable, setThresholdProperties, stopTest, updateAllResultSets, updateAllResultSets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

params

protected java.util.Hashtable params

measureCount

protected int measureCount

measures

protected java.util.ArrayList measures

descMeasures

protected java.util.Hashtable descMeasures
Constructor Detail

GenericTest

public GenericTest(java.lang.String[] args)
Method Detail

computeMeasures

public void computeMeasures(java.util.Hashtable params)

executeTest

public boolean executeTest()
Overrides:
executeTest in class EgTest

addNewMeasure

public final void addNewMeasure(java.util.ArrayList al)

addNewMeasure

public final void addNewMeasure(java.lang.String desc,
                                java.util.ArrayList al)

setMeasureCount

public final void setMeasureCount(int measureCount)
Sets the count of measures for a test and is called from the test's constructor
Parameters:
measureCount - Number of measures (int) reported by the Test

getParams

public final void getParams(java.lang.String[] args)
Initializes the necessary variables of the test and is called from the constructor
Parameters:
args - Array of java.lang.String passed to the constructor

getValueForParam

public java.lang.String getValueForParam(java.lang.String name)
Gets the value for a parameter passed for the Test
Parameters:
name - java.lang.String - name of the parameter

initTest

public final void initTest()
Initializes the Test

Called usually from the beginning of executeTest()

Overrides:
initTest in class EgTest

addMeasures

public final void addMeasures(java.util.ArrayList measureList)
Adds measures from the Test to the eGurkha system
Parameters:
measureList - Measures stored in a java.util.ArrayList

addMeasures

public final void addMeasures(java.lang.String descriptor,
                              java.util.ArrayList measureList)
Adds measures from the Test to the eGurkha system
Parameters:
descriptor - java.lang.String which identifies the set of measures added
measureList - Measures stored in a java.util.ArrayList

addUnknownMeasures

public final void addUnknownMeasures()
Adds unknown measures from the Test to the eGurkha system during an exceptional condition

updateAllMeasures

public final void updateAllMeasures()
Updates all measures for the Test with the eGurkha system

updateAllMeasures

public final void updateAllMeasures(boolean dynamic)
Updates all measures for the Test with the eGurkha system
Parameters:
dynamic - boolean true if the descriptors for the test are dynamically resolved

setErrorMessage

public final void setErrorMessage(java.lang.String errorMsg)
Logs an error message associated with the Test to the eGurkha system
Parameters:
errorMsg - java.lang.String which explains the error occured