Proposed "feeds" for polling an underlying resource for populating brooklyn attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FROM JBOSS AS 7, polling its http management api | |
@Override | |
protected void connectSensors() { | |
super.connectSensors(); | |
httpFeed = HttpFeed.builder() | |
.entity(this) | |
.period(200) | |
.baseUri(String.format("http://%s:%s/management/subsystem/web/connector/http/read-resource", host, port)) | |
.baseUriVars(ImmutableMap.of("include-runtime","true")) | |
.poll(new HttpPollConfig<Integer>(MANAGEMENT_STATUS) | |
.onSuccess(HttpValueFunctions.responseCode())) | |
.poll(new HttpPollConfig<Boolean>(SERVICE_UP) | |
.onSuccess(HttpValueFunctions.responseCodeEquals(200))) | |
.poll(new HttpPollConfig<Integer>(REQUEST_COUNT) | |
.onSuccess(HttpValueFunctions.jsonContents("requestCount", Integer.class))) | |
.poll(new HttpPollConfig<Integer>(ERROR_COUNT) | |
.onSuccess(HttpValueFunctions.jsonContents("errorCount", Integer.class))) | |
.poll(new HttpPollConfig<Integer>(TOTAL_PROCESSING_TIME) | |
.onSuccess(HttpValueFunctions.jsonContents("processingTime", Integer.class))) | |
.poll(new HttpPollConfig<Integer>(MAX_PROCESSING_TIME) | |
.onSuccess(HttpValueFunctions.jsonContents("maxTime", Integer.class))) | |
.poll(new HttpPollConfig<Long>(BYTES_RECEIVED) | |
.onSuccess(HttpValueFunctions.jsonContents("bytesReceived", Long.class))) | |
.poll(new HttpPollConfig<Long>(BYTES_SENT) | |
.onSuccess(HttpValueFunctions.jsonContents("bytesSent", Long.class))) | |
.build(); | |
} | |
@Override | |
protected void disconnectSensors() { | |
super.disconnectSensors(); | |
if (httpFeed != null) httpFeed.stop(); | |
} | |
// === | |
// FROM JBOSS AS 6, POLLING ITS JMX API | |
@Override | |
public void connectSensors() { | |
super.connectSensors(); | |
String requestProcessorMbeanName = "jboss.web:type=GlobalRequestProcessor,name=http-*"; | |
String serverMbeanName = "jboss.system:type=Server"; | |
jmxFeed = JmxFeed.builder() | |
.entity(this) | |
.period(500, TimeUnit.MILLISECONDS) | |
.pollAttribute(new JmxAttributePollConfig<Integer>(ERROR_COUNT) | |
.objectName(requestProcessorMbeanName) | |
.attributeName("errorCount")) | |
.pollAttribute(new JmxAttributePollConfig<Integer>(REQUEST_COUNT) | |
.objectName(requestProcessorMbeanName) | |
.attributeName("requestCount")) | |
.pollAttribute(new JmxAttributePollConfig<Integer>(TOTAL_PROCESSING_TIME) | |
.objectName(requestProcessorMbeanName) | |
.attributeName("processingTime")) | |
.pollAttribute(new JmxAttributePollConfig<Boolean>(SERVICE_UP) | |
.objectName(serverMbeanName) | |
.attributeName("Started") | |
.onError(Functions.constant(false))) | |
.build(); | |
} | |
@Override | |
public void disconnectSensors() { | |
super.disconnectSensors(); | |
if (jmxFeed != null) jmxFeed.stop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment