Refine search
@Override public AttributeList getAttributes(String[] names) { AttributeList list = new AttributeList(); for (String name : names) { try { list.add(new Attribute(name, getAttribute(name))); } catch (Exception e) { log.warn("Error getting JMX attribute '{}'", name, e); } } return list; }
@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; } }
@Test public void testGetAttributes() throws Exception { assertEquals(mbeanServerConnection.getAttributes(testMBeanName, new String[] {"Value", "ObjectValue"}), new AttributeList(ImmutableList.of(new Attribute("Value", null), new Attribute("ObjectValue", null)))); testMBean.setValue("FOO"); testMBean.setObjectValue(UUID.randomUUID()); assertEquals(mbeanServerConnection.getAttributes(testMBeanName, new String[] {"Value", "ObjectValue"}), new AttributeList(ImmutableList.of(new Attribute("Value", "FOO"), new Attribute("ObjectValue", testMBean.getObjectValue())))); }
@Override public AttributeList getAttributes(String[] arg0) { AttributeList results = new AttributeList(); synchronized(metricsMap) { for (String key : arg0) { results.add(new Attribute(key,metricsMap.get(key))); } } return results; }
public AttributeList getAttributes(String[] names) { AttributeList al=new AttributeList(); for(String name: names) { Attribute attr=getNamedAttribute(name); if(attr != null) al.add(attr); else log.warn("Did not find attribute " + name); } return al; }
@Test public void testSetAttributes() throws Exception { UUID uuid = UUID.randomUUID(); mbeanServerConnection.setAttributes(testMBeanName, new AttributeList(ImmutableList.of(new Attribute("Value", "Foo"), new Attribute("ObjectValue", uuid)))); assertEquals(testMBean.getValue(), "Foo"); assertEquals(testMBean.getObjectValue(), uuid); mbeanServerConnection.setAttributes(testMBeanName, new AttributeList(ImmutableList.of(new Attribute("Value", null), new Attribute("ObjectValue", null)))); assertEquals(testMBean.getValue(), null); assertEquals(testMBean.getObjectValue(), null); }
@Override public AttributeList getAttributes( String[] attributes ) { AttributeList result = new AttributeList( attributes.length ); for ( String attribute : attributes ) { try { result.add( new Attribute( attribute, getAttribute( attribute ) ) ); } catch ( Exception e ) { throw new RuntimeException( e ); } } return result; }
@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; }
/** * {@inheritDoc} */ @Override public AttributeList getAttributes(String[] names) { AttributeList list = new AttributeList(); for (String name : names) { list.add(new Attribute(name, monitor.getValue())); } return list; }
public AttributeList setAttributes(AttributeList list) { AttributeList results=new AttributeList(); for(int i=0;i < list.size();i++) { Attribute attr=(Attribute)list.get(i); if(setNamedAttribute(attr)) results.add(attr); else { if(log.isWarnEnabled()) log.warn("Failed to update attribute name " + attr.getName() + " with value " + attr.getValue()); } } return results; }
@Override public AttributeList getAttributes(String[] attributes) { AttributeList list = new AttributeList(); for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) { list.add(new Attribute(stats.getKey(), stats.getValue().getHitRate().doubleValue())); } return list; }
@Override public AttributeList setAttributes(AttributeList attributes) { if (attributes == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute list cannot be null.")); Logger logger = getLogger(); AttributeList list = new AttributeList(); for (Iterator i = attributes.iterator(); i.hasNext();) { Attribute attribute = (Attribute) i.next(); String name = attribute.getName(); try { setAttribute(attribute); list.add(attribute); } catch (Exception x) { if (logger.isEnabledFor(Logger.TRACE)) logger.trace("setAttribute for attribute " + name + " failed", x); // And go on with the next one } } return list; }
@Override public synchronized AttributeList getAttributes(String[] names) { AttributeList list = new AttributeList(); for (String name : names) { Field field = attributes.get(name); Object value = null; if (field != null) { value = getFieldValue(field); } if (value != null) { list.add(new Attribute(name, value)); } } return list; }
public final AttributeList setAttributes(AttributeList attributes) { AttributeList r = new AttributeList(attributes.size()); for (Object a : attributes) { try { setAttribute(Attribute.class.cast(a)); r.add(Attribute.class.cast(a)); } catch (AttributeNotFoundException e) { // error is silently ignored } catch (ReflectionException e) { // error is silently ignored } catch (MBeanException e) { // error is silently ignored } catch (InvalidAttributeValueException e) { // error is silently ignored } } return r; } }
private AttributeList getAttributes(ObjectName objName, String[] attrNames) throws InstanceNotFoundException, ReflectionException, IOException { final NameValueMap values = getCachedAttributes(objName, new TreeSet<String>(Arrays.asList(attrNames))); final AttributeList list = new AttributeList(); for (String attrName : attrNames) { final Object value = values.get(attrName); if (value != null || values.containsKey(attrName)) { list.add(new Attribute(attrName, value)); } } return list; }
/** * Set an attribute list. */ public AttributeList setAttributes(AttributeList list) { Attribute[] attrs = list.toArray(new Attribute[0]); AttributeList retlist = new AttributeList(); for (Attribute attr : attrs) { String name = attr.getName(); AttributeProxy a = map.get(name); if (a != null && a.isWrite()) { a.set(name, attr.getValue()); retlist.add(attr); } } return retlist; }
/** * Enables the to get the values of several attributes of the Dynamic MBean. */ public AttributeList getAttributes(String[] attributeNames) { // Check attributeNames is not null to avoid NullPointerException later on if (attributeNames == null) { throw new RuntimeOperationsException( new IllegalArgumentException("attributeNames[] cannot be null"), "Cannot invoke a getter of " + dClassName); } AttributeList resultList = new AttributeList(); // if attributeNames is empty, return an empty result list if (attributeNames.length == 0) return resultList; // build the result attribute list for (int i=0 ; i<attributeNames.length ; i++){ try { Object value = getAttribute((String) attributeNames[i]); resultList.add(new Attribute(attributeNames[i],value)); } catch (JMException e) { e.printStackTrace(); } catch (RuntimeException e) { e.printStackTrace(); } } return(resultList); }
public AttributeList getAttributes(String[] names) { AttributeList al=new AttributeList(); for(String name: names) { Attribute attr=getNamedAttribute(name); if(attr != null) al.add(attr); else log.warn("Did not find attribute " + name); } return al; }
@Override public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException { AttributeList results = new AttributeList(); for (String attribute : attributes) { try { Object value = getAttribute(name, attribute); Attribute att = new Attribute(attribute, value); results.add(att); } catch (Exception e) { throw new GemFireSecurityException("error getting value of " + attribute + " from " + name, e); } } return results; }
"Cannot invoke a setter of " + dClassName); AttributeList resultList = new AttributeList(); String name = attr.getName(); Object value = getAttribute(name); resultList.add(new Attribute(name,value)); } catch(JMException e) { e.printStackTrace();