public class HttpFeed extends AbstractFeed
private HttpFeed feed;
//@Override
protected void connectSensors() {
super.connectSensors();
feed = 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<Boolean>(SERVICE_UP)
.onSuccess(HttpValueFunctions.responseCodeEquals(200))
.onError(Functions.constant(false)))
.poll(new HttpPollConfig<Integer>(REQUEST_COUNT)
.onSuccess(HttpValueFunctions.jsonContents("requestCount", Integer.class)))
.build();
}
{@literal @}Override
protected void disconnectSensors() {
super.disconnectSensors();
if (feed != null) feed.stop();
}
This also supports giving a Supplier for the URL
(e.g. Entities#attributeSupplier(org.apache.brooklyn.api.entity.Entity, org.apache.brooklyn.api.event.AttributeSensor)
)
from a sensor. Note however that if a Supplier-based sensor is *https*,
https-specific initialization may not occur if the URL is not available at start time,
and it may report errors if that sensor is not available.
Some guidance for controlling enablement of a feed based on availability of a sensor
can be seen in HttpLatencyDetector (in brooklyn-policy).
Modifier and Type | Class and Description |
---|---|
static class |
HttpFeed.Builder |
AbstractEntityAdjunct.AdjunctTagSupport, AbstractEntityAdjunct.BasicSubscriptionSupport
BrooklynObject.RelationSupport<T extends BrooklynObject>, BrooklynObject.SubscriptionSupport, BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal, BrooklynObjectInternal.RelationSupportInternal<T extends BrooklynObject>, BrooklynObjectInternal.SubscriptionSupportInternal
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
log |
static ConfigKey<<any>> |
POLLS |
ONLY_IF_SERVICE_UP
HIGHLIGHT_NAME_LAST_ACTION, HIGHLIGHT_NAME_LAST_CONFIRMATION, HIGHLIGHT_NAME_LAST_VIOLATION, HIGHLIGHT_NAME_TRIGGERS
Constructor and Description |
---|
HttpFeed()
For rebind; do not call directly; use builder
|
Modifier and Type | Method and Description |
---|---|
static HttpFeed.Builder |
builder() |
destroy, getEntity, getRebindSupport, isActivated, isRunning, isSuspended, relations, resume, setEntity, start, stop, suspend
config, configure, getAdjunctType, getConfig, getDisplayName, getExecutionContext, getHighlights, getManagementContext, getUniqueTag, isDestroyed, setDisplayName, setHighlights, subscriptions, tags, toString
addSearchPath, getCatalogItemId, getCatalogItemIdSearchPath, getId, init, rebind, setCatalogItemId, setCatalogItemIdAndSearchPath, setManagementContext, stackCatalogItemId
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getHighlights, getId, getUniqueTag, isDestroyed
getCatalogItemId, getCatalogItemIdSearchPath, getDisplayName, subscriptions, tags
config, getConfig
addSearchPath, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId
public static final org.slf4j.Logger log
public static final ConfigKey<<any>> POLLS
public static HttpFeed.Builder builder()