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; }
private AttributeList getCpuAttributes() { try { String[] names = new String[]{ATTRIBUTE_NAME_ProcessCpuLoad, ATTRIBUTE_NAME_SystemCpuLoad, ATTRIBUTE_NAME_ProcessCpuTime}; AttributeList list = platformMBeanServer.getAttributes(operatingSystemObjectName, names); if (list.size() != names.length) { logger.warn("Failed to get all attributes"); return new AttributeList(); } return list; } catch (Throwable ex) { logger.warn("Failed to get CPU MBean attributes", ex); return null; } } }
if (cpuAttributes != null && cpuAttributes.size() > 0) { Attribute att = (Attribute) cpuAttributes.get(ATTRIBUTE_INDEX_ProcessCpuLoad); processCpuLoad = (Double) att.getValue();
@Test public void durationListedWithUnit() { ConfigurationBean configurationBean = ( (GraphDatabaseAPI) graphdb ).getDependencyResolver().resolveDependency( JmxKernelExtension.class ).getSingleManagementBean( ConfigurationBean.class ); Object v = configurationBean.getAttribute( GraphDatabaseSettings.log_queries_threshold.name() ); assertEquals( "0ms", v ); AttributeList attrs = configurationBean.getAttributes( new String[]{ GraphDatabaseSettings.log_queries_threshold.name() } ); assertEquals( 1, attrs.size() ); Attribute attr = (Attribute) attrs.get( 0 ); assertEquals( "0ms", attr.getValue() ); assertEquals( "dbms.logs.query.threshold = 0ms", attr.toString() ); } }
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; } }
/** {@inheritDoc} */ public AttributeList setAttributes(AttributeList attributes) { final AttributeList ret = new AttributeList(attributes.size()); for (Object o : attributes) { Attribute attr = (Attribute) o; try { setAttribute(attr); ret.add(new Attribute(attr.getName(), getAttribute(attr.getName()))); } catch (Exception e) { // Attribute is not included in returned list. The spec says so } } return ret; }
public AttributeList setAttributes(AttributeList attributes) { Iterator iterator = attributes.iterator(); AttributeList newValues = new AttributeList(attributes.size()); while (iterator.hasNext()) { Attribute attribute = (Attribute) iterator.next(); try { setAttribute(attribute); } catch (Exception exc) { attribute = new Attribute(attribute.getName(), exc); } newValues.add(attribute); } return newValues; }
Map<String, Object> buildAttributeMap(AttributeList attributeList) { Map<String, Object> newAttributeMap = new HashMap<>(attributeList.size()); for (Object attributeObject : attributeList) { Attribute attribute = (Attribute) attributeObject; newAttributeMap.put(attribute.getName(), attribute.getValue()); } return newAttributeMap; }
private static HashMap getObjMap(AttributeList attrList){ HashMap attrs = new HashMap(); for(int k=0; k<attrList.size(); k++){ Attribute currAttr = (Attribute)attrList.get(k); String pname = currAttr.getName(); Object pObjvalue = currAttr.getValue(); attrs.put(pname, pObjvalue); } return attrs; }
public Map<String, Object> attrListToMap(AttributeList attrList) { Map<String, Object> attributeMap = new HashMap<String, Object>(attrList.size()); for(Attribute attr: attrList.asList()) { attributeMap.put(attr.getName(), attr.getValue()); } return attributeMap; }
public AttributeList setAttributes(AttributeList attributeList) { AttributeList result = new AttributeList(attributeList.size()); for (Object o : attributeList) { Attribute attribute = (Attribute) o; try { setAttribute(attribute); } catch (JMException e) { // ignore exceptions which means the attribute won't be in the result } } return result; } }
public AttributeList setAttributes(AttributeList attributeList) { AttributeList result = new AttributeList(attributeList.size()); for (Object o : attributeList) { Attribute attribute = (Attribute) o; try { setAttribute(attribute); } catch (JMException e) { // ignore exceptions which means the attribute won't be in the result } } return result; } }
public AttributeList setAttributes(AttributeList attributeList) { AttributeList result = new AttributeList(attributeList.size()); for (Object o : attributeList) { Attribute attribute = (Attribute) o; try { setAttribute(attribute); } catch (JMException e) { // ignore exceptions which means the attribute won't be in the result } } return result; } }
@Override public Object getAttribute(final String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { // we should call getAttributes - and not vice versa to have the result // of a single check call - and not do a check call for each attribute final AttributeList result = this.getAttributes(new String[] {attribute}); if ( result.size() == 0 ) { throw new AttributeNotFoundException(attribute); } final Attribute attr = (Attribute) result.get(0); return attr.getValue(); }
@Override public Object getAttribute(final String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { // we should call getAttributes - and not vice versa to have the result // of a single check call - and not do a check call for each attribute final AttributeList result = this.getAttributes(new String[] { attribute }); if (result.size() == 0) { throw new AttributeNotFoundException(attribute); } final Attribute attr = (Attribute) result.get(0); return attr.getValue(); }
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; }
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; }
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; }
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; }
/** * Allows the JMX Agent to set a number of command line options at once. */ public synchronized AttributeList setAttributes(AttributeList attributes) { for (int i = 0; i < attributes.size(); i++) { final Attribute att = (Attribute) attributes.get(i); new Exceptions.VoidBlock() { public void inner() throws Exception { setAttribute(att); } }.exec(); } return attributes; }