eu.xtreemos.xosd.resourcemonitor
Class ResourceMonitor

java.lang.Object
  extended by eu.xtreemos.system.eventmachine.stage.AbstractStage
      extended by eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
          extended by eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
              extended by eu.xtreemos.xosd.resourcemonitor.ResourceMonitor
All Implemented Interfaces:
eu.xtreemos.system.eventmachine.queue.IEventHandler, eu.xtreemos.system.eventmachine.stage.IStage

public class ResourceMonitor
extends eu.xtreemos.system.eventmachine.stage.Abstract2wayStage

Service class, responsible for obtaining resource information, converting it and passing it on.

Author:
eva.milosev@xlab.si, matej.artac@xlab.si

Field Summary
static CResourceMonitorConfig config
           
private  java.lang.String gangliaHostName
          hostname or IP address to connect to for Ganglia data.
private  java.net.Socket gangliaSocket
           
(package private)  int gangliaTCPPort
          TCP port to connect to for Ganglia data.
private static org.apache.log4j.Logger logger
          logger object
 java.util.ArrayList<java.lang.reflect.Field> monitoredMetricFields
          The collection that contains only those fileds that the user would like to be monitored, and is a subset of resMetricFields.
private  java.lang.String monitorType
           
static java.util.ArrayList<java.lang.reflect.Field> resMetricFields
          The collection that contains all the fields of ResourceDescriptorRecord that can be monitored on a node.
private  java.lang.Boolean socketInUse
           
private  java.lang.Object socketMutex
          socket mutex. don't laugh.
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
context, counter, curContext, sink
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
queue
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
handlerChain, handlerGroup, handlerThreads, name, running, serviceListeners
 
Constructor Summary
ResourceMonitor()
           
 
Method Summary
 java.lang.Boolean addResAttribute(java.lang.String attribute)
           
private  org.w3c.dom.Document getGangliaElement()
           
 java.lang.String getHandledEventType()
           
 java.util.ArrayList<java.lang.String> getProxyResMetricsReply(java.util.ArrayList<java.lang.String> res)
           
 java.util.ArrayList<java.lang.String> getResMetrics()
           
 java.util.Hashtable<java.lang.String,java.lang.String> getResMonResponse(java.util.Hashtable<java.lang.String,java.lang.Object> glue)
           
 java.lang.Object getResMonResponseFailure(java.lang.Exception ex)
           
 java.util.Hashtable getXMLExtractorReply(java.util.Hashtable list)
           
 java.util.Hashtable getXMLExtractorReplyXMon(java.util.Hashtable list)
           
 void handleEvent(java.lang.Object event)
           
 void init()
           
 java.util.Hashtable<java.lang.String,java.lang.Object> query()
          Queries the local monitor data provider for machine status, translates it into GLUE 1.2-compliant XML and transforms it into a Hashtable.
 java.util.Hashtable<java.lang.String,java.lang.String> queryResInfo()
          Queries the local monitor data provider for machine status and returns the values of the metrics being monitored on this node.
 java.util.ArrayList<ResourceDescriptorRecord> queryResourceDescriptor()
          Queries the local monitor data provider for machine status and returns a filled-in collection (that should at this point contain a single element) of resource descriptor records.
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
getContext, removeContext, SendException, SendException, SendException, SendReply, SendReply, SendReply, setSink
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
dequeue, getSource
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
addHandler, addHandler, addServiceListener, getName, getShortName, getThreadCount, notifyServiceInitialised, notifyServiceStarted, notifyServiceStopped, processEvent, removeHandler, removeServiceListener, setThreadCount, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gangliaSocket

private java.net.Socket gangliaSocket

gangliaHostName

private java.lang.String gangliaHostName
hostname or IP address to connect to for Ganglia data. defaults to localhost.


gangliaTCPPort

int gangliaTCPPort
TCP port to connect to for Ganglia data. defaults to port 8649


logger

private static final org.apache.log4j.Logger logger
logger object


socketMutex

private java.lang.Object socketMutex
socket mutex. don't laugh.


socketInUse

private java.lang.Boolean socketInUse

monitorType

private java.lang.String monitorType

config

public static CResourceMonitorConfig config

resMetricFields

public static java.util.ArrayList<java.lang.reflect.Field> resMetricFields
The collection that contains all the fields of ResourceDescriptorRecord that can be monitored on a node.


monitoredMetricFields

public java.util.ArrayList<java.lang.reflect.Field> monitoredMetricFields
The collection that contains only those fileds that the user would like to be monitored, and is a subset of resMetricFields.

Constructor Detail

ResourceMonitor

public ResourceMonitor()
Method Detail

getResMonResponseFailure

public java.lang.Object getResMonResponseFailure(java.lang.Exception ex)
                                          throws java.lang.Exception
Throws:
java.lang.Exception

getResMonResponse

public java.util.Hashtable<java.lang.String,java.lang.String> getResMonResponse(java.util.Hashtable<java.lang.String,java.lang.Object> glue)
                                                                         throws java.lang.Exception
Throws:
java.lang.Exception

queryResInfo

public java.util.Hashtable<java.lang.String,java.lang.String> queryResInfo()
                                                                    throws java.net.ConnectException,
                                                                           java.io.IOException,
                                                                           java.lang.Exception,
                                                                           java.lang.InterruptedException
Queries the local monitor data provider for machine status and returns the values of the metrics being monitored on this node. The metrics returned are those listed by getResMetrics() and regulated by addResAttribute(String). If the monitorType entry in the configuration file is set to "ganglia", then the method obtains the information from the localhost ganglia daemon. If there is no monitoring system, the service will return a generic answer, contained in the file files/genericAnswer.xml . Alternatively, if the configuration is set to monitorType = "xmonitor", then the information is obtained from local kernel hooks which need to be pre-installed. The call is self-sustainable and does not invlove other services.

Returns:
A hashtable with metrics and their respective values, describing the details of this node.
Throws:
java.net.ConnectException
java.io.IOException
java.lang.Exception
java.lang.InterruptedException

getGangliaElement

private org.w3c.dom.Document getGangliaElement()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

query

public java.util.Hashtable<java.lang.String,java.lang.Object> query()
                                                             throws java.lang.Exception
Queries the local monitor data provider for machine status, translates it into GLUE 1.2-compliant XML and transforms it into a Hashtable. If the monitorType entry in the configuration file is set to "ganglia", then the method obtains the information from the localhost ganglia daemon. If there is no monitoring system, the service will return a generic answer, contained in the file files/genericAnswer.xml . Alternatively, if the configuration is set to monitorType = "xmonitor", then the information is obtained from local kernel hooks which need to be pre-installed. The call is self-sustainable and does not invlove other services.

Returns:
Hashtable with the node's hardware and load information, in a GLUE 1.2-compliant XML structure.
Throws:
java.lang.Exception

queryResourceDescriptor

public java.util.ArrayList<ResourceDescriptorRecord> queryResourceDescriptor()
                                                                      throws java.lang.Exception
Queries the local monitor data provider for machine status and returns a filled-in collection (that should at this point contain a single element) of resource descriptor records. If the monitorType entry in the configuration file is set to "ganglia", then the method obtains the information from the localhost ganglia daemon. If there is no monitoring system, the service will return a generic answer, contained in the file files/genericAnswer.xml . Alternatively, if the configuration is set to monitorType = "xmonitor", then the information is obtained from local kernel hooks which need to be pre-installed. The call is self-sustainable and does not invlove other services.

Returns:
A collection of resource descriptors describing the node. At this point the collection should contain a single element.
Throws:
java.lang.Exception

getXMLExtractorReplyXMon

public java.util.Hashtable getXMLExtractorReplyXMon(java.util.Hashtable list)

getXMLExtractorReply

public java.util.Hashtable getXMLExtractorReply(java.util.Hashtable list)

getResMetrics

public java.util.ArrayList<java.lang.String> getResMetrics()

getProxyResMetricsReply

public java.util.ArrayList<java.lang.String> getProxyResMetricsReply(java.util.ArrayList<java.lang.String> res)

addResAttribute

public java.lang.Boolean addResAttribute(java.lang.String attribute)

getHandledEventType

public java.lang.String getHandledEventType()
Specified by:
getHandledEventType in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage

handleEvent

public void handleEvent(java.lang.Object event)
                 throws java.lang.Exception
Specified by:
handleEvent in interface eu.xtreemos.system.eventmachine.queue.IEventHandler
Specified by:
handleEvent in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
Throws:
java.lang.Exception

init

public void init()
Specified by:
init in interface eu.xtreemos.system.eventmachine.stage.IStage
Overrides:
init in class eu.xtreemos.system.eventmachine.stage.AbstractStage