|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tivoli.twg.monitor.api.TWGMonAPI
This is an object to encapsulate interfacing to the monitor server this method provides a programming API that can be used in other JVM's to contact and communicate with the monitor server.
This class is instantiated by the class that wishes to use the monitor API. This class will handle establishing a session with the Resource Monitor JVM.
The waitForServerReady or isServerReady methods can be used to check if the server is ready for an instantiated TWGMonAPI object to use it.
Once the object is instantiated, the getAttribute and freeAttribute methods may be used to gain access to an attribute on a system. With the object returned from getAttribute, monitoring may be started and stopped and data points checked.
The getDataRC call may be used to check the return code associated with the last received data point. The isThresholdActive method may be used to check whether an unresolved threshold event is present for an attribute the toString method may be used to get a formated copy of the data returned for an attribute.
The following is a sample of the code needed to set up and use the API object:
public static void main(String argv[]) { TWGMonAPI api = null; long moid; // Enable Component tracing for monitors TWGRas.initialize(); // set up the service node class with all the information it needs ServiceNodeLocalImplFactory snlif = new ServiceNodeLocalImplFactory(); ServiceNode.SetServiceNodeFactory(snlif); System.out.println("create and start the API"); if (TWGRas.isDebugEnabled(TWGRas.MONITORS)) TWGRas.debug(TWGRas.MONITORS, "TWGMonAPI.main: create and start the API"); try { api = new TWGMonAPI( Locale.ENGLISH, 5000); } catch (com.tivoli.twg.monitor.api.TWGMonException e) { ; } // end try . . . System.out.println("shutdown API"); if (TWGRas.isDebugEnabled(TWGRas.MONITORS)) TWGRas.debug(TWGRas.MONITORS, "TWGMonAPI.main: shutdown API"); api.shutdown(); System.out.println("nulling API"); if (TWGRas.isDebugEnabled(TWGRas.MONITORS)) TWGRas.debug(TWGRas.MONITORS, "TWGMonAPI.main: null API"); api = null; if (TWGRas.isDebugEnabled(TWGRas.MONITORS)) TWGRas.debug(TWGRas.MONITORS, "TWGMonAPI.main: exiting"); System.out.println("exiting"); return; }
TWGMonAttribute
Field Summary | |
---|---|
static int |
RC_FAILURE
Return code indicating an operation failed. |
static int |
RC_SUCCESS
Return code indicating an operation succeeded. |
protected ServiceNode |
sn
service node for instances of this class to use in this JAVA virtual machine |
protected boolean |
streamRequests
indicates that we should send/receive IntelByteBuffer streams |
Constructor Summary | |
---|---|
TWGMonAPI(java.util.Locale locale,
long updateMsecs)
|
|
TWGMonAPI(java.util.Locale locale,
long updateMsecs,
ServiceNode sn)
This is the constructor for the API object. |
Method Summary | |
---|---|
int |
deleteAttributeAlias(long[] moidList,
TWGMonPath aliasPath,
boolean tree)
Method to allow removal of Aliases for monitor attributes |
int |
deleteThreshold(TWGMonThreshold apiThresh)
Delete the threshold information from the server |
protected TWGMonRsp |
extractReplyParm(Command cmd,
int outParmIndex,
java.lang.Class replyClass)
method to simplify the grunt work of extracting a monitor server response from a Command object |
void |
finalize()
called by the garbage collector to clean up the object. |
TWGMonNodeList |
findAttributes(TWGMonPath progPath,
LongValueSet moids,
java.util.Locale locale,
long timeout)
handles the request to the monitor server to get a list of attributes that are monitorable. |
void |
findAttributesAsync(TWGMonPath progPath,
LongValueSet moids,
java.util.Locale locale,
long timeout,
TWGMonNodeListener listener)
handles the request to the monitor server to get a list of attributes that are monitorable. |
boolean |
freeAttribute(TWGMonAttribute attribute)
Handles the request to the Monitor Server to stop monitoring and to release an attribute. |
long[] |
getAllNativeMOIDs()
Helper function to retreive all of the Native Director managed object IDs. |
TWGMonThreshold[] |
getAllThresholds(boolean includeTasks)
Populate the threshold information with all thresholds. |
TWGMonAttribute |
getAttribute(TWGMonPath progPath,
long moid)
Handles the request to the Monitor Server to get an attribute and to start monitoring it. |
TWGMonThreshold[] |
getThresholdInfoForGroup(long moid,
TWGMonPath progPath,
boolean wantsExactMatch)
Populate the threshold information for a path associated with a given group. |
TWGMonThreshold[] |
getThresholdInfoForSystem(long moid,
TWGMonPath progPath,
boolean wantsExactMatch)
Populate the threshold information for a path on a given system. |
static boolean |
isServerReady()
method provided to allow the caller to check if the monitor server has initialized to the point that it is ready to handle requests |
protected Command |
sendMonCommand(TWGMonCmd moncmd,
int cmdCode)
Adds the monitor command to a command object and sends it to the monitor server. |
int |
setAttributeAlias(long[] moidList,
TWGMonPath aliasPath,
TWGMonPath[] aliasPathDisplayStrings,
TWGMonPath realPath,
boolean tree)
Method to allow setup of Aliases for monitor attributes |
int |
setThreshold(TWGMonThreshold apiThresh)
Send the threshold information to the server |
void |
shutdown()
Called to clean up the TWGMonAPI object. |
static void |
waitForServerReady()
method provided to allow the caller to wait until the monitor server has initialized to the point that it is ready to handle requests |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int RC_SUCCESS
public static final int RC_FAILURE
protected ServiceNode sn
protected boolean streamRequests
Constructor Detail |
public TWGMonAPI(java.util.Locale locale, long updateMsecs, ServiceNode sn) throws TWGMonException
locale
- requested locale of monitor attributesupdateMsecs
- milliseconds to sleep between data update requests
TWGMonException
- indicates that there was a sever error
while waiting for the server to initialize.
The most likely reason for this exception
to be generated by this method is communication
problems while trying to check if the server
is active.public TWGMonAPI(java.util.Locale locale, long updateMsecs) throws TWGMonException
Method Detail |
public static void waitForServerReady() throws TWGMonException
TWGMonException
- indicates that there was a sever error
while waiting for the server to initialize.
The most likely reason for this exception
to be generated by this method is communication
problems while trying to check if the server
is active.public static boolean isServerReady() throws TWGMonException
TWGMonException
- indicates that there was a sever error
while waiting for the server to initialize.
The most likely reason for this exception
to be generated by this method is communication
problems while trying to check if the server
is active.public void shutdown()
public void finalize() throws java.lang.Throwable
java.lang.Throwable
- items thrown by base class are passed to callerpublic TWGMonNodeList findAttributes(TWGMonPath progPath, LongValueSet moids, java.util.Locale locale, long timeout) throws TWGMonException
progPath
- programmatic Path to check for nodes onmoids
- list of managed objects to check for objects under the path onlocale
- locale to return the displayable information fortimeout
- maximum time to wait for stuff to come back from the server
TWGMonException
- indicates an error occured in processing the request
The most likely cause was invalid parameterspublic void findAttributesAsync(TWGMonPath progPath, LongValueSet moids, java.util.Locale locale, long timeout, TWGMonNodeListener listener) throws TWGMonException
progPath
- programmatic Path to check for nodes onmoids
- list of managed objects to check for objects under the path onlocale
- locale to return the displayable information fortimeout
- maximum time to wait for stuff to come back from the serverlistener
- object to be notified when the request completes. it will
be passed the results that were gathered. The call back
to this object can occur before this routine returns.
TWGMonException
- indicates an error occured in processing the request
The most likely cause was invalid parameterspublic TWGMonAttribute getAttribute(TWGMonPath progPath, long moid)
progPath
- programmatic path to create the attribute onmoid
- managed object id to create the attribute on
public boolean freeAttribute(TWGMonAttribute attribute)
public TWGMonThreshold[] getThresholdInfoForSystem(long moid, TWGMonPath progPath, boolean wantsExactMatch)
moid
- managed object id of the system to be queriedprogPath
- programmatic path for the attribute to be checked for thresholdswantsExactMatch
- flag indicates if the user wants an exact match with path passed in
public TWGMonThreshold[] getThresholdInfoForGroup(long moid, TWGMonPath progPath, boolean wantsExactMatch)
moid
- managed object id of the group to be queriedprogPath
- programmatic path for the attribute to be checked for thresholdswantsExactMatch
- flag indicates if the user wants an exact match with path passed in
public TWGMonThreshold[] getAllThresholds(boolean includeTasks)
includeTasks
- flag indicates if the user wants an threshold plan tasks included with thresholds
public int setThreshold(TWGMonThreshold apiThresh)
apiThresh
- Threshold object containing the threshold information
to send to the monitor server
public int deleteThreshold(TWGMonThreshold apiThresh)
com.tivoli.twg.monitor.TWGMonRC
public int setAttributeAlias(long[] moidList, TWGMonPath aliasPath, TWGMonPath[] aliasPathDisplayStrings, TWGMonPath realPath, boolean tree)
The general idea is that a real path is specified that identifies the programatic path to an attribute or the top of a subtree of attributes that are to have their paths mapped to the alias path. The alias path is used as a substitution for the real path. The AliasPathDisplayStrings are TWGMonPaths that contain the locale specific console strings for the alias path. The English path should always be provided since the product will default to english strings if the information for a requested locale is not available. There should be a path provided for all locales the alias is expected to be viewed in. The tree flag indicates the type of alias being established (subtree vs single attribute)
Example of usage:
// set up the alias to the path, TWGMonPath aliasPath = new TWGMonPath(); aliasPath.AddLevel("IBM Sample Shortcut"); TWGMonPath realPath = new TWGMonPath(); real.AddLevel("Director Agent"); real.AddLevel("MONCPU"); TWGMonPath[] aliasPathDisplayStrings = new TWGMonPath[2]; TWGMonPath englishPathStrings = newTWGMonPath(); englishPathStrings.addLevel("CPU Shortcut"); englishPathStrings.setLocale(Locale.ENGLISH); aliasPathDisplayStrings[0] = englishPathStrings; TWGMonPath frenchPathStrings = newTWGMonPath(); frenchPathStrings.addLevel("Le CPU Shortcut"); frenchPathStrings.setLocale(Locale.FRENCH); aliasPathDisplayStrings[1] = frenchPathStrings; // monAPIobject is an instance of the monitor Api object // this line will set the alias against all currently known Native // managed objects as a TREE based allias monAPIobject.setAttributeAlias(monAPIobject.getAllNativeMOIDs(), aliasPath, aliasPathDisplayStrings, realPath, true );
moidList
- array of managed object ids to set the alias againstaliasPath
- programmatic path to define as the alias pathaliasPathDisplayStrings
- Locale Specific Displayable path information
for the alias pathrealPath
- actual programmatic path to map the alias path totree
- flag indicating if this is mapping one attribute or an attribute subtree.
if true, it is mapping a subtree
com.tivoli.twg.monitor.TWGMonRC
public int deleteAttributeAlias(long[] moidList, TWGMonPath aliasPath, boolean tree)
The parameters include the list of managed objects to remove the alias from, the alias path that is no longer valid and whether the alias path to remove was a subtree or individual attribute alias.
Example of usage:
// set up the alias to the path TWGMonPath aliasPath = new TWGMonPath(); aliasPath.AddLevel("IBM Sample Shortcut"); // monAPIobject is an instance of the monitor Api object // this line will remove the alias against all currently known Native // managed objects (this example makes the assumption that the list of // objects remained the same from the time the alias was set). monAPIobject.deleteAttributeAlias(monAPIobject.getAllNativeMOIDs(), aliasPath, true );
aliasPath
- programmatic path to define as the alias pathtree
- flag indicating if this is mapping one attribute or an attribute subtree.
if true, it is mapping a subtree
com.tivoli.twg.monitor.TWGMonRC
public long[] getAllNativeMOIDs()
protected Command sendMonCommand(TWGMonCmd moncmd, int cmdCode) throws TWGMonException
moncmd
- the TWGMonCmd class derived object that is to be sent to the servercmdCode
- the command code to marke the Command object with
TWGMonException
protected TWGMonRsp extractReplyParm(Command cmd, int outParmIndex, java.lang.Class replyClass)
cmd
- command object containing the response objectoutParmIndex
- index of the output paramter to retrieve from the command objectreplyClass
- class object that identifies the class type of the response that is expected
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |