Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
creating also the metric types for URL monitoring (status.duration.ty…
Browse files Browse the repository at this point in the history
…pe and status.code.type)
  • Loading branch information
jkremser committed Apr 13, 2015
1 parent 7b12632 commit 2f798a5
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.hawkular.component.pinger;

import org.hawkular.inventory.api.model.Environment;
import org.hawkular.inventory.api.model.MetricType;
import org.hawkular.inventory.api.model.MetricUnit;
import org.hawkular.inventory.api.model.ResourceType;
import org.hawkular.inventory.api.model.Tenant;
import org.hawkular.metrics.client.common.SingleMetric;
Expand All @@ -42,6 +44,8 @@
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import java.util.function.Function;

/**
* A SLSB that coordinates the pinging of resources
Expand Down Expand Up @@ -87,13 +91,20 @@ public void startUp() {
response = target.request().post(Entity.json(new Tenant.Blueprint(tenantId)));
if (isResponseOk(response.getStatus())) {
response.close();
target = client.target(inventoryUrl + tenantId + "/environments");
response = target.request().post(Entity.json(new Environment.Blueprint(environmentId)));
response.close();

// the 2nd call could have been done in parallel, but let's not risk in the startUp method
WebTarget target2 = client.target(inventoryUrl + tenantId + "/resourceTypes");
target2.request().post(Entity.json(new ResourceType.Blueprint("URL", "1.0")));
Function<String, Consumer<org.hawkular.inventory.api.model.Entity.Blueprint>> create =
path -> blueprint -> {
final WebTarget url = client.target(inventoryUrl + tenantId + path);
final Response resp = url.request().post(Entity.json(blueprint));
resp.close();
};

create.apply("/environments").accept(new Environment.Blueprint(environmentId));
create.apply("/resourceTypes").accept(new ResourceType.Blueprint("URL", "1.0"));
create.apply("/metricTypes").accept(new MetricType.Blueprint("status.duration.type",
MetricUnit.MILLI_SECOND));
create.apply("/metricTypes").accept(new MetricType.Blueprint("status.code.type",
MetricUnit.NONE));
}
} else {
for (Object o : list) {
Expand Down

0 comments on commit 2f798a5

Please sign in to comment.