javax.management.Attribute.getName()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中javax.management.Attribute.getName()方法的一些代码示例,展示了Attribute.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.getName()方法的具体详情如下:
包路径:javax.management.Attribute
类名称:Attribute
方法名:getName

Attribute.getName介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

private ImmutableMap<String, Optional<Object>> getAttributes(Set<String> uniqueColumnNames, String name)
    throws JMException
{
  ObjectName objectName = new ObjectName(name);
  String[] columnNamesArray = uniqueColumnNames.toArray(new String[uniqueColumnNames.size()]);
  ImmutableMap.Builder<String, Optional<Object>> attributes = ImmutableMap.builder();
  for (Attribute attribute : mbeanServer.getAttributes(objectName, columnNamesArray).asList()) {
    attributes.put(attribute.getName(), Optional.ofNullable(attribute.getValue()));
  }
  return attributes.build();
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

@Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
  if (attribute.getName().equals("LOG_RESOLUTION")) {
    setLogResolution((Long) attribute.getValue());
  }
  //do nothing - not allowed
}

代码示例来源:origin: apache/geode

@Override
public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute)
  throws MBeanException, RuntimeOperationsException {
 if (oldAttribute == null || newAttribute == null)
  throw new RuntimeOperationsException(new IllegalArgumentException(
    "Attribute cannot be null."));
 if (!oldAttribute.getName().equals(newAttribute.getName()))
  throw new RuntimeOperationsException(new IllegalArgumentException(
    "Attribute names cannot be different."));
 // TODO: the source must be the object name of the MBean if the listener was registered through
 // MBeanServer
 Object oldValue = oldAttribute.getValue();
 AttributeChangeNotification n = new AttributeChangeNotification(this, 1,
   System.currentTimeMillis(), "Attribute value changed", oldAttribute.getName(),
   oldValue == null ? null : oldValue.getClass().getName(), oldValue, newAttribute.getValue());
 sendAttributeChangeNotification(n);
}

代码示例来源:origin: apache/hive

@Override
public void setAttribute(Attribute attr) throws AttributeNotFoundException,
    InvalidAttributeValueException, MBeanException, ReflectionException {
  try {
    put(attr.getName(),attr.getValue());
  } catch (Exception e) {
    throw new MBeanException(e);
  }
}

代码示例来源:origin: log4j/log4j

" with null attribute");
String name = attribute.getName();
Object value = attribute.getValue();

代码示例来源:origin: jmxtrans/jmxtrans

public ImmutableList<Result> getResults() {
  ResultsBuilder builder = new ResultsBuilder();
  for (Attribute attribute : attributes) {
    builder.add(attribute.getName(), attribute.getValue());
  }
  return builder.build();
}

代码示例来源:origin: log4j/log4j

" with null attribute");
String name = attribute.getName();
Object value = attribute.getValue();

代码示例来源:origin: log4j/log4j

" with null attribute");
String name = attribute.getName();
Object value = attribute.getValue();

代码示例来源:origin: wildfly/wildfly

protected boolean setNamedAttribute(Attribute attribute) {
  AttributeEntry entry=atts.get(attribute.getName());
  if(entry != null) {
    try {
      entry.setter.invoke(attribute.getValue());
      return true;
    }
    catch(Throwable e) {
      log.warn(Util.getMessage("AttrWriteFailure"), attribute.getName(), e);
    }            
  }
  else {
    log.warn(Util.getMessage("MissingAttribute"), attribute.getName());
  }
  return false;
}

代码示例来源:origin: vipshop/vjtools

private synchronized NameValueMap getCachedAttributes(ObjectName objName, Set<String> attrNames)
    throws InstanceNotFoundException, ReflectionException, IOException {
  NameValueMap values = cachedValues.get(objName);
  if (values != null && values.keySet().containsAll(attrNames)) {
    return values;
  }
  attrNames = new TreeSet<String>(attrNames);
  Set<String> oldNames = cachedNames.get(objName);
  if (oldNames != null) {
    attrNames.addAll(oldNames);
  }
  values = new NameValueMap();
  final AttributeList attrs = conn.getAttributes(objName, attrNames.toArray(new String[attrNames.size()]));
  for (Attribute attr : attrs.asList()) {
    values.put(attr.getName(), attr.getValue());
  }
  cachedValues.put(objName, values);
  cachedNames.put(objName, attrNames);
  return values;
}

代码示例来源:origin: wildfly/wildfly

private Map<String, String> getMBeanValues(MBeanServerConnection cnx, ObjectName on, String ... attributeNames)
    throws InstanceNotFoundException, IOException, ReflectionException, IntrospectionException {
  if (attributeNames == null) {
    MBeanInfo info = cnx.getMBeanInfo( on );
    MBeanAttributeInfo[] attributeArray = info.getAttributes();
    int i = 0;
    attributeNames = new String[attributeArray.length];
    for (MBeanAttributeInfo ai : attributeArray)
      attributeNames[i++] = ai.getName();
  }
  AttributeList attributes = cnx.getAttributes(on, attributeNames);
  Map<String, String> values = new HashMap<String, String>();
  for (javax.management.Attribute attribute : attributes.asList()) {
    Object value = attribute.getValue();
    values.put(attribute.getName(), value == null ? "" : value.toString());
  }
  return values;
}

代码示例来源:origin: log4j/log4j

"Cannot invoke a setter of "+dClassName+" with null attribute");
String name = attribute.getName();
Object value = attribute.getValue();

代码示例来源:origin: apache/flume

if (localAttr.getName().equalsIgnoreCase("type")) {
 component = localAttr.getValue() + "." + component;
attrMap.put(localAttr.getName(), localAttr.getValue().toString());

代码示例来源:origin: wildfly/wildfly

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;
}

代码示例来源:origin: Netflix/servo

private static Metric toMetric(long t, ObjectName name, Attribute attribute, Tag dsType) {
 Tag id = Tags.newTag("id", name.getKeyProperty("name"));
 Tag clazz = Tags.newTag("class", name.getKeyProperty("type"));
 TagList list = BasicTagList.of(id, clazz, dsType);
 return new Metric(normalizeName(attribute.getName()), list, t, attribute.getValue());
}

代码示例来源:origin: patric-r/jvmtop

private synchronized NameValueMap getCachedAttributes(
    ObjectName objName, Set<String> attrNames) throws
    InstanceNotFoundException, ReflectionException, IOException {
  NameValueMap values = cachedValues.get(objName);
  if (values != null && values.keySet().containsAll(attrNames)) {
    return values;
  }
  attrNames = new TreeSet<String>(attrNames);
  Set<String> oldNames = cachedNames.get(objName);
  if (oldNames != null) {
    attrNames.addAll(oldNames);
  }
  values = new NameValueMap();
  final AttributeList attrs = conn.getAttributes(
      objName,
      attrNames.toArray(new String[attrNames.size()]));
  for (Attribute attr : attrs.asList()) {
    values.put(attr.getName(), attr.getValue());
  }
  cachedValues.put(objName, values);
  cachedNames.put(objName, attrNames);
  return values;
}

代码示例来源:origin: jmxtrans/jmxtrans

public void walkTree(MBeanServerConnection connection) throws Exception {
  // key here is null, null returns everything!
  Set<ObjectName> mbeans = connection.queryNames(null, null);
  for (ObjectName name : mbeans) {
    MBeanInfo info = connection.getMBeanInfo(name);
    MBeanAttributeInfo[] attrs = info.getAttributes();
    String[] attrNames = new String[attrs.length];
    for (int i = 0; i < attrs.length; i++) {
      attrNames[i] = attrs[i].getName();
    }
    try {
      AttributeList attributes = connection.getAttributes(name, attrNames);
      for (Attribute attribute : attributes.asList()) {
        output(name.getCanonicalName() + "%" + attribute.getName(), attribute.getValue());
      }
    } catch (Exception e) {
      log.error("error getting " + name + ":" + e.getMessage(), e);
    }
  }
}

代码示例来源:origin: javamelody/javamelody

for (final Object object : attributes) {
  final Attribute attribute = (Attribute) object;
  final Object value = convertValueIfNeeded(attribute.getValue());
  final String attributeDescription = getAttributeDescription(attribute.getName(),
      attributeInfos);
  final String formattedAttributeValue = formatAttributeValue(value);
  final MBeanAttribute mbeanAttribute = new MBeanAttribute(attribute.getName(),
      attributeDescription, formattedAttributeValue);
  result.add(mbeanAttribute);

代码示例来源:origin: Netflix/servo

private static void fetchThreadPoolMetrics(long now, MBeanServer mbs, List<Metric> metrics)
  throws JMException {
 final ObjectName threadPoolName = new ObjectName("Catalina:type=ThreadPool,*");
 final Set<ObjectName> names = mbs.queryNames(threadPoolName, null);
 if (names == null) {
  return;
 }
 for (ObjectName name : names) {
  AttributeList list = mbs.getAttributes(name, THREAD_POOL_ATTRS);
  // determine whether the shared threadPool is used
  boolean isUsed = true;
  for (Attribute a : list.asList()) {
   if (a.getName().equals("maxThreads")) {
    Number v = (Number) a.getValue();
    isUsed = v.doubleValue() >= 0.0;
    break;
   }
  }
  if (isUsed) {
   // only add the attributes if the metric is used.
   for (Attribute a : list.asList()) {
    addMetric(metrics, toGauge(now, name, a));
   }
  }
 }
}

代码示例来源:origin: vipshop/vjtools

for (Iterator ii = list.iterator(); ii.hasNext();) {
  Attribute a = (Attribute) ii.next();
  buffer.append(a.getName());
  buffer.append(": ");
  buffer.append(a.getValue());
  buffer.append("\n");

相关文章

微信公众号

最新文章

更多