Search in sources :

Example 41 with Result

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");
    }
}
Also used : FabricService(io.fabric8.api.FabricService)

Example 42 with 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);
    }
}
Also used : ClassLoaderObjectInputStream(io.fabric8.dosgi.util.ClassLoaderObjectInputStream)

Example 43 with Result

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");
            }
        }
    }
}
Also used : MBeanOpersResult(io.fabric8.insight.metrics.model.MBeanOpersResult) HashSet(java.util.HashSet) Set(java.util.Set) RawNumericMetric(org.rhq.metrics.core.RawNumericMetric) MBeanAttrsResult(io.fabric8.insight.metrics.model.MBeanAttrsResult) MBeanAttrsResult(io.fabric8.insight.metrics.model.MBeanAttrsResult) Result(io.fabric8.insight.metrics.model.Result) MBeanAttrResult(io.fabric8.insight.metrics.model.MBeanAttrResult) MBeanOperResult(io.fabric8.insight.metrics.model.MBeanOperResult) QueryResult(io.fabric8.insight.metrics.model.QueryResult) MBeanOpersResult(io.fabric8.insight.metrics.model.MBeanOpersResult) MBeanOperResult(io.fabric8.insight.metrics.model.MBeanOperResult) MBeanAttrResult(io.fabric8.insight.metrics.model.MBeanAttrResult) List(java.util.List) Map(java.util.Map) HashSet(java.util.HashSet)

Example 44 with Result

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();
    }
}
Also used : Hello(io.fabric8.demo.cxf.Hello) FabricService(io.fabric8.api.FabricService) ContainerProxy(io.fabric8.itests.paxexam.support.ContainerProxy) Test(org.junit.Test)

Example 45 with Result

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;
}
Also used : HashMap(java.util.HashMap) Version(org.osgi.framework.Version) Artifact.isSameButVersion(io.fabric8.patch.management.Artifact.isSameButVersion) ManagedPatch(io.fabric8.patch.management.ManagedPatch) Patch(io.fabric8.patch.management.Patch) PatchDetailsRequest(io.fabric8.patch.management.PatchDetailsRequest) LinkedList(java.util.LinkedList) Artifact(io.fabric8.patch.management.Artifact)

Aggregations

Test (org.junit.Test)104 Expectations (mockit.Expectations)49 HashMap (java.util.HashMap)32 Map (java.util.Map)24 ArrayList (java.util.ArrayList)23 File (java.io.File)21 GitContext (io.fabric8.api.GitContext)20 IOException (java.io.IOException)20 Exchange (org.apache.camel.Exchange)20 Processor (org.apache.camel.Processor)20 DefaultPullPushPolicy (io.fabric8.git.internal.DefaultPullPushPolicy)18 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)17 Probe (io.fabric8.kubernetes.api.model.Probe)16 PatchResult (io.fabric8.patch.management.PatchResult)13 Properties (java.util.Properties)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)11 Patch (io.fabric8.patch.management.Patch)11 PatchException (io.fabric8.patch.management.PatchException)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 TreeMap (java.util.TreeMap)10