Example usage for javax.management AttributeList AttributeList

List of usage examples for javax.management AttributeList AttributeList

Introduction

In this page you can find the example usage for javax.management AttributeList AttributeList.

Prototype

public AttributeList(List<Attribute> list) 

Source Link

Document

Constructs an AttributeList containing the elements of the List specified, in the order in which they are returned by the List 's iterator.

Usage

From source file:org.ow2.proactive_grid_cloud_portal.rm.RMRestTest.java

private JSONObject callGetStatHistory() throws Exception {
    RMProxyUserInterface rmMock = mock(RMProxyUserInterface.class);
    String sessionId = SharedSessionStoreTestUtils.createValidSession(rmMock);

    AttributeList value = new AttributeList(
            Collections.singletonList(new Attribute("test", createRrdDb().getBytes())));
    when(rmMock.getMBeanAttributes(Matchers.<ObjectName>any(), Matchers.<String[]>any())).thenReturn(value);
    RMRestInterface client = ProxyFactory.create(RMRestInterface.class, "http://localhost:" + port + "/");

    String statHistory = client.getStatHistory(sessionId, "hhhhh");
    return (JSONObject) new JSONParser().parse(statHistory);
}

From source file:com.joyent.manta.http.PoolStatsMBean.java

@Override
public AttributeList getAttributes(final String[] attributes) {
    updatePoolStats();/*from   ww  w.  jav  a 2  s.  c o  m*/

    AttributeList list = new AttributeList(NO_OF_PROPERTIES);

    for (String a : attributes) {
        Integer result = getAttributeFromPoolStats(a, this.stats);
        if (result != null) {
            list.add(result);
        }
    }

    return list;
}

From source file:org.jolokia.jmx.JsonDymamicMBeanImplTest.java

@Test
public void setGetAttributes() throws Exception {
    AttributeList attrList = new AttributeList(
            Arrays.asList(new Attribute("Chili", "aji"), new Attribute("Numbers", "16,11,68")));
    platformServer.setAttributes(testName, attrList);

    AttributeList ret = platformServer.getAttributes(testName, new String[] { "Chili", "Numbers" });
    Attribute chili = (Attribute) ret.get(0);
    Attribute num = (Attribute) ret.get(1);
    assertEquals(chili.getValue(), "aji");

    JSONArray numsJ = (JSONArray) toJSON((String) num.getValue());
    assertEquals(numsJ.get(0), 16L);// w  w  w  .  j  av  a2s  .c om
    assertEquals(numsJ.get(1), 11L);
    assertEquals(numsJ.get(2), 68L);
    assertEquals(numsJ.size(), 3);

    Assert.assertTrue(platformServer.getAttributes(testName, new String[0]).size() == 0);

}

From source file:net.lightbody.bmp.proxy.jetty.util.jmx.ModelMBeanImpl.java

public AttributeList getAttributes(String[] names) {
    log.debug("getAttributes");
    AttributeList results = new AttributeList(names.length);
    for (int i = 0; i < names.length; i++) {
        try {//from  w  w w .j  a v  a 2  s . co m
            results.add(new Attribute(names[i], getAttribute(names[i])));
        } catch (Exception e) {
            log.warn(LogSupport.EXCEPTION, e);
        }
    }
    return results;
}

From source file:net.lightbody.bmp.proxy.jetty.util.jmx.ModelMBeanImpl.java

public AttributeList setAttributes(AttributeList attrs) {
    log.debug("setAttributes");

    AttributeList results = new AttributeList(attrs.size());
    Iterator iter = attrs.iterator();
    while (iter.hasNext()) {
        try {//  ww w. ja  v a2 s  .  c om
            Attribute attr = (Attribute) iter.next();
            setAttribute(attr);
            results.add(new Attribute(attr.getName(), getAttribute(attr.getName())));
        } catch (Exception e) {
            log.warn(LogSupport.EXCEPTION, e);
        }
    }
    return results;
}