public class JamService extends Object
| Modifier and Type | Field and Description |
|---|---|
static org.apache.log4j.Logger |
LOGGER
Logger for this class.
|
| Constructor and Description |
|---|
JamService(String jamServerBaseUrl)
The base url for the JAM server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addServerToServiceQueue(String queueName,
String brokerUrl,
String host,
int port)
A web service that add a server to an existing service queue.
|
protected String |
createJmxServerXml(String queueName,
String brokerUrl,
String host,
int port)
Creates the XML request used by other methods when calling the web service.
|
void |
disableServiceQueue(String queueName)
Disable monitoring of a service queue.
|
boolean |
doesServiceQueueExist(String queueName,
String brokerUrl)
Given a queue name, determine if it already exists.
|
protected String |
doHttpCall(org.apache.commons.httpclient.HttpMethod method)
Does the HTTP call and returns the response body as a string, or throws and HttpException.
|
void |
enableServiceQueue(String queueName)
Enable monitoring on an existing service queue.
|
org.apache.commons.httpclient.HttpClient |
getClient()
Return the HttpClient used for communication, or null if one has not been set/created yet.
|
String |
getJamServerBaseUrl()
Get the JAM server base url.
|
protected String |
getRegisterServiceRequestBody(String queueName,
String brokerUrl,
int queryIntervalInSeconds,
boolean resetStatisticsAfterQuery,
boolean profileEnabled)
Returns the xml for the registerServiceRequest method.
|
protected String |
getServiceQueueExistRequestBody(String queueName,
String brokerUrl)
Get the serviceQueueExistRequest body xml.
|
int |
loadJMXAgent(int port)
Load the JMX Agent for gathering statistics via JMX on this running service.
|
void |
registerServiceQueue(String queueName,
String brokerUrl,
int queryIntervalInSeconds,
boolean resetStatisticsAfterQuery,
boolean profileEnabled)
Registers a new service queue in Jam.
|
void |
removeServerFromServiceQueue(String queueName,
String brokerUrl,
String host,
int port)
Remove a host/port from a service queue.
|
void |
removeServiceQueue(String queueName)
Removes a service queue, and all related hosts and monitoring jobs.
|
void |
runGather(String queueName,
String brokerUrl)
Given a queuename and broker, do an immediate gather of stats.
|
void |
setClient(org.apache.commons.httpclient.HttpClient client)
Set the HttpClient to use for communication.
|
void |
setJamServerBaseUrl(String jamServerBaseUrl)
Set the JAM server base url.
|
public JamService(String jamServerBaseUrl)
jamServerBaseUrl - the base url for the JAM server to communicate with.public org.apache.commons.httpclient.HttpClient getClient()
public void setClient(org.apache.commons.httpclient.HttpClient client)
client - An HttpClient to use for communication.public String getJamServerBaseUrl()
public void setJamServerBaseUrl(String jamServerBaseUrl)
jamServerBaseUrl - the JAM server base urlpublic void addServerToServiceQueue(String queueName, String brokerUrl, String host, int port) throws IOException
queueName - the name of the queue to add this host to.host - the host name to add to the service queueport - the port on the host that is added to the service queuebrokerUrl - the broker url this service is using.IOException - if any communication exception occurs.public void disableServiceQueue(String queueName) throws IOException
queueName - the queue name to disable.IOException - if any communication exception occurs.public boolean doesServiceQueueExist(String queueName, String brokerUrl) throws IOException
queueName - the ServiceQueue.queueName to check forbrokerUrl - the broker url this service is using.IOException - if any communication exception occurs.public void enableServiceQueue(String queueName) throws IOException
queueName - the name of the queue to enable monitoring on.IOException - if any communication exception occurs.public void registerServiceQueue(String queueName, String brokerUrl, int queryIntervalInSeconds, boolean resetStatisticsAfterQuery, boolean profileEnabled) throws IOException
queueName - the name of the queue to register with.brokerUrl - the broker url this service is using.queryIntervalInSeconds - the interval in seconds to query the running service for metrics.resetStatisticsAfterQuery - if true, statistics are reset to 0 after each gather. If false, statistics are
cumulative.profileEnabled - if true the profile is enabled for gathering, if false, it is registered, but not enabled
for gathering.IOException - if any communication exception occurs.public void removeServerFromServiceQueue(String queueName, String brokerUrl, String host, int port) throws IOException
queueName - the name of the queue to remove.brokerUrl - the broker url this service is using.host - the host the service is running on.port - the port the service is running on.IOException - if any communication exception occurs.public void removeServiceQueue(String queueName) throws IOException
queueName - the queue name to remove.IOException - if any communication exception occurs.public void runGather(String queueName, String brokerUrl) throws IOException
queueName - the queue name of the service.brokerUrl - the broker url for the service.IOException - if any communication exception occurs.protected String createJmxServerXml(String queueName, String brokerUrl, String host, int port)
<?xml version="1.0" encoding="ISO-8859-1"?>
<jmxServer>
<queueName>queueName</queueName>
<brokerUrl>brokerUrl</brokerUrl>
<host>host</host>
<port>port</port>
</jmxServer>
queueName - queue name for this service.brokerUrl - UIMA broker url for this service.host - Host the service is running on.port - Port JMX is enabled on for the service.protected String doHttpCall(org.apache.commons.httpclient.HttpMethod method) throws IOException, org.apache.commons.httpclient.HttpException
method - The HttpMethod to call.IOException - if any communication exception occurs.org.apache.commons.httpclient.HttpException - If HttpStatus is NOT SC_OK, an HttpException is thrown with the error.protected String getRegisterServiceRequestBody(String queueName, String brokerUrl, int queryIntervalInSeconds, boolean resetStatisticsAfterQuery, boolean profileEnabled)
<?xml version="1.0" encoding="ISO-8859-1"?>
<serviceQueue>
<queueName>queueName</queueName>
<brokerUrl>brokerUrl</brokerUrl>
<queryIntervalInSeconds>queryIntervalInSeconds</queryIntervalInSeconds>
<resetStatisticsAfterQuery>resetStatisticsAfterQuery</resetStatisticsAfterQuery>
<profileEnabled>profileEnabled</profileEnabled>
</serviceQueue>
queueName - the queue name of the service.brokerUrl - the broker url for the service.queryIntervalInSeconds - the interval in seconds to query the running service for metrics.resetStatisticsAfterQuery - if true, statistics are reset to 0 after each gather. If false, statistics are
cumulative.profileEnabled - if true the profile is enabled for gathering, if false, it is registered, but not enabled
for gathering.protected String getServiceQueueExistRequestBody(String queueName, String brokerUrl)
<?xml version="1.0" encoding="ISO-8859-1"?>
<serviceQueue>
<queueName>queueName</queueName>
<brokerUrl>brokerUrl</brokerUrl>
</serviceQueue>
queueName - the queue name of the service.brokerUrl - the broker url for the service.public int loadJMXAgent(int port)
throws IOException,
com.sun.tools.attach.AttachNotSupportedException,
com.sun.tools.attach.AgentLoadException,
com.sun.tools.attach.AgentInitializationException
port - The port to bind the jmx server to. If -1, an open port is automatically chosen.IOExceptioncom.sun.tools.attach.AttachNotSupportedExceptioncom.sun.tools.attach.AgentLoadExceptioncom.sun.tools.attach.AgentInitializationExceptionCopyright © 2018 Department of Veterans Affairs. All Rights Reserved.