use of javax.management.AttributeList in project hadoop by apache.
the class MetricsSourceAdapter method getAttributes.
@Override
public AttributeList getAttributes(String[] attributes) {
updateJmxCache();
synchronized (this) {
AttributeList ret = new AttributeList();
for (String key : attributes) {
Attribute attr = attrCache.get(key);
if (LOG.isDebugEnabled()) {
LOG.debug(key + ": " + attr);
}
ret.add(attr);
}
return ret;
}
}
use of javax.management.AttributeList in project hive by apache.
the class MetricsMBeanImpl method setAttributes.
@Override
public AttributeList setAttributes(AttributeList arg0) {
AttributeList attributesSet = new AttributeList();
for (Attribute attr : arg0.asList()) {
try {
setAttribute(attr);
attributesSet.add(attr);
} catch (AttributeNotFoundException e) {
// ignore exception - we simply don't add this attribute
// back in to the resultant set.
} catch (InvalidAttributeValueException e) {
// ditto
} catch (MBeanException e) {
// likewise
} catch (ReflectionException e) {
// and again, one last time.
}
}
return attributesSet;
}
use of javax.management.AttributeList in project tomcat by apache.
the class BaseModelMBean method setAttributes.
/**
* Set the values of several attributes of this MBean.
*
* @param attributes THe names and values to be set
*
* @return The list of attributes that were set and their new values
*/
@Override
public AttributeList setAttributes(AttributeList attributes) {
AttributeList response = new AttributeList();
// Validate the input parameters
if (attributes == null)
return response;
// Prepare and return our response, eating all exceptions
String[] names = new String[attributes.size()];
int n = 0;
Iterator<?> items = attributes.iterator();
while (items.hasNext()) {
Attribute item = (Attribute) items.next();
names[n++] = item.getName();
try {
setAttribute(item);
} catch (Exception e) {
// Ignore all exceptions
}
}
return (getAttributes(names));
}
use of javax.management.AttributeList in project jetty.project by eclipse.
the class ObjectMBean method setAttributes.
/* ------------------------------------------------------------ */
public AttributeList setAttributes(AttributeList attrs) {
if (LOG.isDebugEnabled())
LOG.debug("setAttributes");
AttributeList results = new AttributeList(attrs.size());
Iterator<Object> iter = attrs.iterator();
while (iter.hasNext()) {
try {
Attribute attr = (Attribute) iter.next();
setAttribute(attr);
results.add(new Attribute(attr.getName(), getAttribute(attr.getName())));
} catch (Exception e) {
LOG.warn(Log.EXCEPTION, e);
}
}
return results;
}
use of javax.management.AttributeList in project jmxtrans by jmxtrans.
the class JmxResultProcessorTest method canReadFieldsOfTabularData.
@Test(timeout = 1000)
public void canReadFieldsOfTabularData() throws MalformedObjectNameException, AttributeNotFoundException, MBeanException, ReflectionException, InstanceNotFoundException {
// Need to induce a GC for the attribute below to be populated
Runtime.getRuntime().gc();
ObjectInstance runtime = null;
try {
runtime = getG1YoungGen();
} catch (InstanceNotFoundException e) {
// ignore test if G1 not enabled
assumeNoException("G1 GC in Java 7/8 needs to be enabled with -XX:+UseG1GC", e);
}
AttributeList attr;
// but takes a non-deterministic amount of time for LastGcInfo to get populated
while (true) {
// but bounded by Test timeout
attr = ManagementFactory.getPlatformMBeanServer().getAttributes(runtime.getObjectName(), new String[] { "LastGcInfo" });
if (((Attribute) attr.get(0)).getValue() != null) {
break;
}
}
List<Result> results = new JmxResultProcessor(dummyQueryWithResultAlias(), runtime, attr.asList(), runtime.getClassName(), TEST_DOMAIN_NAME).getResults();
assertThat(results.size()).isGreaterThan(2);
Optional<Result> result = from(results).firstMatch(new ByAttributeName("LastGcInfo"));
assertThat(result.isPresent()).isTrue();
// Should have primitive typed fields
assertThat(result.get().getValues().size()).isGreaterThan(0);
assertThat(result.get().getValues().get("duration")).isNotNull();
// assert tabular fields are excluded
assertThat(result.get().getValues().get("memoryUsageBeforeGc")).isNull();
assertThat(result.get().getValues().get("memoryUsageAfterGc")).isNull();
}
Aggregations