private void connectAuthenticatedSensors() {
hostsHttpFeed = HttpFeed.builder()
.entity(this)
.period(1000, TimeUnit.MILLISECONDS)
.baseUri(String.format("%s/api/v1/hosts", ambariUri))
.credentials(usernamePasswordCredentials.getUserName(), usernamePasswordCredentials.getPassword())
.header(HttpHeaders.AUTHORIZATION, HttpTool.toBasicAuthorizationValue(usernamePasswordCredentials))
.poll(new HttpPollConfig<List<String>>(REGISTERED_HOSTS)
.onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), getHosts()))
.onFailureOrException(Functions.<List<String>>constant(ImmutableList.<String>of())))
.build();
clusterHttpFeed = HttpFeed.builder()
.entity(this)
.period(1000, TimeUnit.MILLISECONDS)
.baseUri(String.format("%s/api/v1/clusters/%s/requests/%d",
ambariUri,
getConfig(AmbariCluster.CLUSTER_NAME),
1))
.credentials(usernamePasswordCredentials.getUserName(), usernamePasswordCredentials.getPassword())
.header(HttpHeaders.AUTHORIZATION, HttpTool.toBasicAuthorizationValue(usernamePasswordCredentials))
.poll(new HttpPollConfig<String>(CLUSTER_STATE)
.onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), getRequestState()))
.onFailureOrException(Functions.<String>constant(null)))
.build();
}