Example usage for javax.management.openmbean CompositeData get

List of usage examples for javax.management.openmbean CompositeData get

Introduction

In this page you can find the example usage for javax.management.openmbean CompositeData get.

Prototype

public Object get(String key);

Source Link

Document

Returns the value of the item whose name is key .

Usage

From source file:com.stumbleupon.hbaseadmin.JMXQuery.java

protected StringBuffer recurseCompositeData(StringBuffer buffer, String indent, String name,
        CompositeData data) {
    indent = addNameToBuffer(buffer, indent, name);
    Iterator i = data.getCompositeType().keySet().iterator();
    while (i.hasNext()) {
        String key = (String) i.next();
        Object o = data.get(key);
        if (o instanceof CompositeData) {
            recurseCompositeData(buffer, indent + " ", key, (CompositeData) o);
        } else if (o instanceof TabularData) {
            recurseTabularData(buffer, indent, key, (TabularData) o);
        } else {//from  w  ww .  ja va  2 s . c  o m
            buffer.append(indent);
            buffer.append(key);
            buffer.append(": ");
            buffer.append(o);
            buffer.append("\n");
        }
    }
    return buffer;
}

From source file:dk.netarkivet.harvester.harvesting.controller.JMXHeritrixController.java

/** Check if the crawl has ended, either because Heritrix finished
 * of its own, or because we terminated it.
 *
 * @return True if the crawl has ended, either because Heritrix finished
 * or because we terminated it. Otherwise we return false.
 * @see HeritrixController#crawlIsEnded()
 *//*from   w  w w .j a v a2  s. c  o m*/
public synchronized boolean crawlIsEnded() {
    // End of crawl can be seen in one of three ways:
    // 1) The Heritrix process has exited.
    // 2) The job has been moved to the completed jobs list in Heritrix.
    // 3) The job is in one of the FINISHED states.
    if (processHasExited()) {
        return true;
    }
    TabularData jobs = (TabularData) executeHeritrixCommand(COMPLETED_JOBS_COMMAND);
    if (jobs != null && jobs.size() > 0) {
        for (CompositeData value : (Collection<CompositeData>) jobs.values()) {
            String thisJobID = value.get(JmxUtils.NAME) + "-" + value.get(UID_PROPERTY);
            if (thisJobID.equals(jobName)) {
                return true;
            }
        }
    }
    String status = (String) getCrawlJobAttribute(STATUS_ATTRIBUTE);
    return status == null || status.equals(FINISHED_STATUS) || status.equals(ILLEGAL_STATUS);
}

From source file:com.streamsets.datacollector.bundles.content.SdcInfoContentGenerator.java

private void writeObject(JsonGenerator jg, Object value) throws IOException {
    if (value == null) {
        jg.writeNull();//ww  w  .j  a v  a 2s  . c o  m
    } else {
        Class<?> c = value.getClass();
        if (c.isArray()) {
            jg.writeStartArray();
            int len = Array.getLength(value);
            for (int j = 0; j < len; j++) {
                Object item = Array.get(value, j);
                writeObject(jg, item);
            }
            jg.writeEndArray();
        } else if (value instanceof Number) {
            Number n = (Number) value;
            if (value instanceof Double && (((Double) value).isInfinite() || ((Double) value).isNaN())) {
                jg.writeString(n.toString());
            } else {
                jg.writeNumber(n.toString());
            }
        } else if (value instanceof Boolean) {
            Boolean b = (Boolean) value;
            jg.writeBoolean(b);
        } else if (value instanceof CompositeData) {
            CompositeData cds = (CompositeData) value;
            CompositeType comp = cds.getCompositeType();
            Set<String> keys = comp.keySet();
            jg.writeStartObject();
            for (String key : keys) {
                writeAttribute(jg, key, cds.get(key));
            }
            jg.writeEndObject();
        } else if (value instanceof TabularData) {
            TabularData tds = (TabularData) value;
            jg.writeStartArray();
            for (Object entry : tds.values()) {
                writeObject(jg, entry);
            }
            jg.writeEndArray();
        } else if (value instanceof GaugeValue) {
            ((GaugeValue) value).serialize(jg);
        } else {
            jg.writeString(value.toString());
        }
    }
}

From source file:org.apache.hadoop.jmx.JMXJsonServlet.java

private void writeObject(JsonGenerator jg, Object value) throws IOException {
    if (value == null) {
        jg.writeNull();//from w w  w .j av  a2 s .  co m
    } else {
        Class<?> c = value.getClass();
        if (c.isArray()) {
            jg.writeStartArray();
            int len = Array.getLength(value);
            for (int j = 0; j < len; j++) {
                Object item = Array.get(value, j);
                writeObject(jg, item);
            }
            jg.writeEndArray();
        } else if (value instanceof Number) {
            Number n = (Number) value;
            jg.writeNumber(n.toString());
        } else if (value instanceof Boolean) {
            Boolean b = (Boolean) value;
            jg.writeBoolean(b);
        } else if (value instanceof CompositeData) {
            CompositeData cds = (CompositeData) value;
            CompositeType comp = cds.getCompositeType();
            Set<String> keys = comp.keySet();
            jg.writeStartObject();
            for (String key : keys) {
                writeAttribute(jg, key, cds.get(key));
            }
            jg.writeEndObject();
        } else if (value instanceof TabularData) {
            TabularData tds = (TabularData) value;
            jg.writeStartArray();
            for (Object entry : tds.values()) {
                writeObject(jg, entry);
            }
            jg.writeEndArray();
        } else {
            jg.writeString(value.toString());
        }
    }
}

From source file:org.eclipse.virgo.server.svt.hostedrepo.RemoteHostedRepositoryTests.java

@Test
public void testUnscopedPlanDeployThatDependsUponArtifactsInRemoteHostedRepo() throws IOException, Exception {
    signature = new String[] { String.class.getName() };
    params = new Object[] { new File(APP_URI_UNSCOPED_PLAN).toURI().toString() };
    CompositeData compositeData = deploy(signature, params);
    artifactName3 = compositeData.get("symbolicName").toString();
    artifactType3 = compositeData.get("type").toString();
    artifactVersion3 = compositeData.get("version").toString();

    waitForMBeanRegister(artifactType3, artifactName3, artifactVersion3, HALF_SECOND, TWO_MINUTES);
    assertArtifactExists(artifactType3, artifactName3, artifactVersion3);
    assertArtifactState(artifactType3, artifactName3, artifactVersion3, "ACTIVE");
}

From source file:org.eclipse.virgo.server.svt.hostedrepo.RemoteHostedRepositoryTests.java

@Test
public void testJmxDeploymentOfUnscopedPlanThatDependsUponArtifactsInRemoteHostedRepo()
        throws IOException, Exception {
    signature = new String[] { String.class.getName() };
    params = new Object[] { new File(APP_URI_UNSCOPED_PLAN).toURI().toString() };
    CompositeData compositeData = deploy(signature, params);
    artifactName4 = compositeData.get("symbolicName").toString();
    artifactType4 = compositeData.get("type").toString();
    artifactVersion4 = compositeData.get("version").toString();

    waitForMBeanRegister(artifactType4, artifactName4, artifactVersion4, HALF_SECOND, TWO_MINUTES);
    assertArtifactExists(artifactType4, artifactName4, artifactVersion4);
    assertArtifactState(artifactType4, artifactName4, artifactVersion4, "ACTIVE");
}

From source file:org.eclipse.virgo.server.svt.hostedrepo.RemoteHostedRepositoryTests.java

@Test
public void testDeploymentOfSharedServicesWarDependsOnArtfiactsInUnscopedPlan() throws IOException, Exception {
    signature = new String[] { String.class.getName() };
    params = new Object[] { new File(APP_URI_SHAREDSERVICES_WAR1).toURI().toString() };
    CompositeData compositeData = deploy(signature, params);
    artifactName5 = compositeData.get("symbolicName").toString();
    artifactType5 = compositeData.get("type").toString();
    artifactVersion5 = compositeData.get("version").toString();

    waitForMBeanRegister(artifactType5, artifactName5, artifactVersion5, HALF_SECOND, TWO_MINUTES);
    UrlWaitLatch.waitFor("http://localhost:8081/hello_war_shared_services/");
    assertArtifactExists(artifactType5, artifactName5, artifactVersion5);
    assertArtifactState(artifactType5, artifactName5, artifactVersion5, "ACTIVE");
}

From source file:org.eclipse.virgo.server.svt.hostedrepo.RemoteHostedRepositoryTests.java

@Test
public void testParDeployThatDependsUponArtifactsInRemoteHostedRepo() throws Exception {
    signature = new String[] { String.class.getName() };
    params = new Object[] { new File(APP_URI_PAR).toURI().toString() };
    CompositeData compositeData = deploy(signature, params);
    artifactName7 = compositeData.get("symbolicName").toString();
    artifactType7 = compositeData.get("type").toString();
    artifactVersion7 = compositeData.get("version").toString();

    waitForMBeanRegister(artifactType7, artifactName7, artifactVersion7, HALF_SECOND, TWO_MINUTES);
    assertArtifactExists(artifactType7, artifactName7, artifactVersion7);
    UrlWaitLatch.waitFor("http://localhost:8081/greenpages/app/home.htm");
    assertArtifactState(artifactType7, artifactName7, artifactVersion7, "ACTIVE");
}

From source file:org.eclipse.virgo.server.svt.hostedrepo.RemoteHostedRepositoryTests.java

@Ignore
@Test/* w w  w.j a va 2  s .c o  m*/
public void planDeployReferencesParArtifactFromRemoteRepository() throws Exception {
    signature = new String[] { String.class.getName() };
    params = new Object[] { new File(APP_URI_PLAN2).toURI().toString() };

    CompositeData compositeData = deploy(signature, params);
    artifactName8 = compositeData.get("symbolicName").toString();
    artifactType8 = compositeData.get("type").toString();
    artifactVersion8 = compositeData.get("version").toString();

    waitForMBeanRegister(artifactType8, artifactName8, artifactVersion8, HALF_SECOND, TWO_MINUTES);
    assertArtifactExists(artifactType8, artifactName8, artifactVersion8);
    assertArtifactState(artifactType8, artifactName8, artifactVersion8, "ACTIVE");
}

From source file:org.eclipse.virgo.server.svt.hostedrepo.RemoteHostedRepositoryTests.java

@Test
public void testPlanArtifactDeploy() throws Exception {
    signature = new String[] { String.class.getName() };
    params = new Object[] { new File(APP_URI_PLAN1).toURI().toString() };
    CompositeData compositeData = deploy(signature, params);
    artifactName1 = compositeData.get("symbolicName").toString();
    artifactType1 = compositeData.get("type").toString();
    artifactVersion1 = compositeData.get("version").toString();

    waitForMBeanRegister(artifactType1, artifactName1, artifactVersion1, HALF_SECOND, TWO_MINUTES);
    assertArtifactExists(artifactType1, artifactName1, artifactVersion1);
    waitForArtifactState("plan", "scoped.plan", "1.0.0", "ACTIVE", HALF_SECOND, TWO_MINUTES);
    ObjectName[] objectNameList = (ObjectName[]) getMBeanServerConnection()
            .getAttribute(getObjectName(artifactType1, artifactName1, artifactVersion1), "Dependents");
    for (ObjectName objectName : objectNameList) {
        assertPlanReferencedArtifacts(objectName);
    }// w  ww . ja  v a2 s  .c o m
    assertArtifactState(artifactType1, artifactName1, artifactVersion1, "ACTIVE");
}