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; }
private void setIntegerAttribute(String attributeName, String propertyName, Object value, int defaultValue, Properties properties, AttributeList resultList) throws InvalidAttributeValueException { checkAssignable(attributeName, Integer.class, value); if (notEmptyOrZero((Integer) value)) { properties.setProperty(propertyName, value.toString()); resultList.add(new Attribute(attributeName, value)); } else { resultList.add(new Attribute(attributeName, new Integer(defaultValue))); } }
@Delegate public AttributeList getAttributes(String[] attributes) { List<Attribute> attrList = new LinkedList<Attribute>(); for (String propertyName : attributes) attrList.add(new Attribute(propertyName, manager.getProperty(propertyName))); return new AttributeList(attrList); }
@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; }
@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())))); }
private void setIntegerAttribute(String attributeName, String propertyName, Object value, int defaultValue, Properties properties, AttributeList resultList) throws InvalidAttributeValueException { checkAssignable(attributeName, Integer.class, value); if (notEmptyOrZero((Integer) value)) { properties.setProperty(propertyName, value.toString()); resultList.add(new Attribute(attributeName, value)); } else { resultList.add(new Attribute(attributeName, new Integer(defaultValue))); } }
@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; }
@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())))); }
/** * {@inheritDoc} */ @Override public AttributeList getAttributes(String[] names) { AttributeList list = new AttributeList(); for (String name : names) { list.add(new Attribute(name, monitor.getValue())); } return list; }
@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 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 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; }
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; }
/** * 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); }
@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();
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; }
@Override public AttributeList getAttributes(String[] attributes) { if (attributes == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute names cannot be null.")); Logger logger = getLogger(); AttributeList list = new AttributeList(); for (int i = 0; i < attributes.length; ++i) { String attrName = attributes[i]; Attribute attribute = null; try { Object value = getAttribute(attrName); attribute = new Attribute(attrName, value); list.add(attribute); } catch (Exception x) { if (logger.isEnabledFor(Logger.TRACE)) logger.trace("getAttribute for attribute " + attrName + " failed", x); // And go on with the next attribute } } return list; }
@Override public synchronized AttributeList getAttributes(String[] names) { AttributeList list = new AttributeList(); for (String name : names) { Object value = _propMap.get(name); if (value != null) list.add(new Attribute(name, value)); } return list; }
@Override public synchronized AttributeList setAttributes(AttributeList list) { Attribute[] attrs = list.toArray(new Attribute[0]); AttributeList retList = new AttributeList(); for (Attribute attr : attrs) { String name = attr.getName(); Object value = attr.getValue(); _propMap.put(name, value); retList.add(new Attribute(name, value)); } return retList; }