use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class DeploymentAgent method updateStatus.
private void updateStatus(String status, Throwable result, boolean force) {
try {
FabricService fs;
if (force) {
fs = fabricService.waitForService(0);
} else {
fs = fabricService.getService();
}
updateStatus(fs, status, result, force);
} catch (Throwable e) {
LOGGER.warn("Unable to set provisioning result");
}
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class ObjectSerializationStrategy method decodeResponse.
public void decodeResponse(ClassLoader loader, Class<?> type, DataByteArrayInputStream source, AsyncCallback result) throws IOException, ClassNotFoundException {
ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(source);
ois.setClassLoader(loader);
Throwable error = (Throwable) ois.readObject();
Object value = ois.readObject();
if (error != null) {
result.onFailure(error);
} else {
result.onSuccess(value);
}
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class RhqMetricsStorage method store.
@Override
public void store(String type, long timestamp, QueryResult queryResult) {
assertValid();
if (metricsService == null) {
throw new IllegalStateException("No metricsService available!");
}
Map<String, Result<?>> results = queryResult.getResults();
if (results != null) {
Set<RawNumericMetric> data = new HashSet<>();
Set<Map.Entry<String, Result<?>>> entries = results.entrySet();
for (Map.Entry<String, Result<?>> entry : entries) {
String key = entry.getKey();
Result<?> result = entry.getValue();
if (result instanceof MBeanOpersResult) {
MBeanOpersResult opersResult = (MBeanOpersResult) result;
List<MBeanOperResult> operResults = opersResult.getResults();
if (operResults != null) {
for (MBeanOperResult operResult : operResults) {
Object value = operResult.getValue();
Double doubleValue = toDouble(value);
if (doubleValue != null) {
String id = Metrics.metricId(type, opersResult.getRequest());
data.add(new RawNumericMetric(id, doubleValue, timestamp));
}
}
}
} else if (result instanceof MBeanAttrsResult) {
MBeanAttrsResult attrsResult = (MBeanAttrsResult) result;
List<MBeanAttrResult> attrResults = attrsResult.getResults();
if (attrResults != null) {
for (MBeanAttrResult attrResult : attrResults) {
Map<String, Object> attrs = attrResult.getAttrs();
if (attrs != null) {
Set<Map.Entry<String, Object>> attrEntries = attrs.entrySet();
for (Map.Entry<String, Object> attrEntry : attrEntries) {
String attributeName = attrEntry.getKey();
Object value = attrEntry.getValue();
Double doubleValue = toDouble(value);
if (doubleValue != null) {
String id = Metrics.metricId(type, attrsResult.getRequest(), attributeName);
data.add(new RawNumericMetric(id, doubleValue, timestamp));
}
}
}
}
}
}
}
if (!data.isEmpty()) {
metricsService.addData(data);
if (LOG.isDebugEnabled()) {
LOG.debug("added " + data.size() + " metrics");
}
}
}
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class ExampleCxfProfileLongTest method testExample.
@Test
public void testExample() throws Exception {
System.out.println("creating the cxf-server container.");
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
try {
Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy).withName("child").withProfiles("example-cxf-cxf.server").assertProvisioningResult().build();
try {
assertTrue("We should create the cxf-server container.", containers.size() == 1);
System.out.println("created the cxf-server container.");
// install bundle of CXF
Thread.sleep(2000);
System.out.println(executeCommand("fabric:cluster-list"));
// install bundle of CXF
Thread.sleep(2000);
// calling the client here
System.out.println("install the cxf client demo in root container");
// This test need to take sometime to download the cxf feature related bundles
System.out.println(executeCommand("features:install fabric-cxf", 600000, false));
String projectVersion = System.getProperty("fabricitest.version");
// install bundle of CXF demo client
System.out.println(executeCommand("osgi:install -s mvn:io.fabric8.examples/fabric-cxf-demo-common/" + projectVersion));
System.out.println(executeCommand("osgi:install -s mvn:io.fabric8.examples/fabric-cxf-demo-client/" + projectVersion));
System.out.println(executeCommand("osgi:list"));
System.out.println("invoking the web service");
Hello proxy = ServiceLocator.awaitService(bundleContext, Hello.class);
assertNotNull(proxy);
String result1 = proxy.sayHello();
String result2 = proxy.sayHello();
assertNotSame("We should get the two different result", result1, result2);
} finally {
ContainerBuilder.destroy(containers);
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceImpl method gatherOverrides.
/**
* Returns list of bundle updates (maven coordinates) from HF/P patch that should be preserved during
* installation of R patch
* @param hfPatchId ID of patch that was detected to be HF patch
* @param patch currently installed R patch
* @return
*/
private List<String> gatherOverrides(String hfPatchId, Patch patch) {
Patch hf = loadPatch(new PatchDetailsRequest(hfPatchId));
List<String> result = new LinkedList<>();
if (hf != null && hf.getPatchData() != null) {
result.addAll(hf.getPatchData().getBundles());
// leave only these artifacts that are in newer version than in R patch being installed
if (patch != null && patch.getPatchData() != null) {
Map<String, Artifact> cache = new HashMap<>();
for (String bu : patch.getPatchData().getBundles()) {
Artifact rPatchArtifact = Utils.mvnurlToArtifact(bu, true);
if (rPatchArtifact != null) {
cache.put(String.format("%s:%s", rPatchArtifact.getGroupId(), rPatchArtifact.getArtifactId()), rPatchArtifact);
}
}
for (String bu : hf.getPatchData().getBundles()) {
Artifact hfPatchArtifact = Utils.mvnurlToArtifact(bu, true);
String key = String.format("%s:%s", hfPatchArtifact.getGroupId(), hfPatchArtifact.getArtifactId());
if (cache.containsKey(key)) {
Version hfVersion = Utils.getOsgiVersion(hfPatchArtifact.getVersion());
Version rVersion = Utils.getOsgiVersion(cache.get(key).getVersion());
if (rVersion.compareTo(hfVersion) >= 0) {
result.remove(bu);
}
}
}
}
}
return result;
}
Aggregations