Java源码示例:javax.management.AttributeNotFoundException
示例1
public Object getAttribute(ObjectName name,
String attribute)
throws MBeanException,
AttributeNotFoundException,
InstanceNotFoundException,
ReflectionException,
IOException {
if (logger.debugOn()) logger.debug("getAttribute",
"name=" + name + ", attribute="
+ attribute);
final ClassLoader old = pushDefaultClassLoader();
try {
return connection.getAttribute(name,
attribute,
delegationSubject);
} catch (IOException ioe) {
communicatorAdmin.gotIOException(ioe);
return connection.getAttribute(name,
attribute,
delegationSubject);
} finally {
popDefaultClassLoader(old);
}
}
示例2
/**
* Remove items from a map if they are of the given type. This is
* used to remove overridden filters from the Heritrix profile before
* applying the overrides.
*
* @param complexElementName The name of the map.
* @param type The classname of the type of object to remove.
*/
public void removeFromMapByType(String complexElementName, String type) {
MapType mt = null;
try {
ComplexProfileElement ct = (ComplexProfileElement) getElement(complexElementName);
mt = (MapType) ct.getValue();
List<ProfileElement> childList = ct.getChildren(true);
Iterator<ProfileElement> children = childList.iterator();
while(children.hasNext()) {
ProfileElement elem = children.next();
if(elem.getValue().getClass().getName().equals(type)) {
mt.removeElement(crawlerSettings, elem.getName());
}
}
}
catch(AttributeNotFoundException ex) {
//TODO Should this be thrown or ignored?
log.error("Could not find map with name " + complexElementName);
}
}
示例3
/**
* Checks if metrics have correct values with given delay mode.
*
* @param res Should contains the result of transaction completion - start time, completion time and MX bean
* from which metrics can be received.
* @param userDelayMode If true, we are checking metrics after transaction with user delay. Otherwise,
* we are checking metrics after transaction with system delay.
* @throws MBeanException If getting of metric attribute failed.
* @throws AttributeNotFoundException If getting of metric attribute failed.
* @throws ReflectionException If getting of metric attribute failed.
*/
private void checkTxDelays(ClientTxTestResult res, boolean userDelayMode)
throws MBeanException, AttributeNotFoundException, ReflectionException {
long userTime = (Long)res.mBean.getAttribute(METRIC_TOTAL_USER_TIME);
long sysTime = (Long)res.mBean.getAttribute(METRIC_TOTAL_SYSTEM_TIME);
if (userDelayMode) {
assertTrue(userTime >= USER_DELAY);
assertTrue(userTime < res.completionTime - res.startTime - sysTime + EPSILON);
assertTrue(sysTime >= 0);
assertTrue(sysTime < EPSILON);
}
else {
assertTrue(userTime >= 0);
assertTrue(userTime < EPSILON);
assertTrue(sysTime >= SYSTEM_DELAY);
assertTrue(sysTime < res.completionTime - res.startTime - userTime + EPSILON);
}
checkHistogram((long[])res.mBean.getAttribute(METRIC_SYSTEM_TIME_HISTOGRAM), 2);
checkHistogram((long[])res.mBean.getAttribute(METRIC_USER_TIME_HISTOGRAM), 2);
}
示例4
public Object getAttribute(ObjectName name,
String attribute)
throws MBeanException,
AttributeNotFoundException,
InstanceNotFoundException,
ReflectionException,
IOException {
if (logger.debugOn()) logger.debug("getAttribute",
"name=" + name + ", attribute="
+ attribute);
final ClassLoader old = pushDefaultClassLoader();
try {
return connection.getAttribute(name,
attribute,
delegationSubject);
} catch (IOException ioe) {
communicatorAdmin.gotIOException(ioe);
return connection.getAttribute(name,
attribute,
delegationSubject);
} finally {
popDefaultClassLoader(old);
}
}
示例5
/**
* Returns members for mentioned group. Scans groups list of memberMbeans
* If group is null returns all members
* @param connection
* @param group
* @return
* @throws NullPointerException
* @throws MalformedObjectNameException
* @throws IOException
* @throws ReflectionException
* @throws MBeanException
* @throws InstanceNotFoundException
* @throws AttributeNotFoundException
*/
public static Set<String> getMembersForGroup(MBeanServerConnection connection, String group) throws MalformedObjectNameException, NullPointerException, InstanceNotFoundException, MBeanException, ReflectionException, IOException, AttributeNotFoundException {
Set<String> memberSet = new HashSet<String>();
ObjectName ds = new ObjectName("GemFire:service=System,type=Distributed");
String[] memberList = (String[]) connection.invoke(ds, "listMembers", null, null);
for(String member : memberList){
ObjectName memberMBean = new ObjectName("GemFire:type=Member,member="+member);
String groups[] = (String[]) connection.getAttribute(memberMBean, "Groups");
for(String g : groups){
if(g.equals(group) || group==null){
memberSet.add(member);
}
}
}
return memberSet;
}
示例6
Object getAttribute(Object resource, String attribute, Object cookie)
throws AttributeNotFoundException,
MBeanException,
ReflectionException {
final M cm = getters.get(attribute);
if (cm == null) {
final String msg;
if (setters.containsKey(attribute))
msg = "Write-only attribute: " + attribute;
else
msg = "No such attribute: " + attribute;
throw new AttributeNotFoundException(msg);
}
return introspector.invokeM(cm, resource, (Object[]) null, cookie);
}
示例7
private void verifyAttributes(ObjectName wrapper)
throws AttributeNotFoundException, InstanceNotFoundException,
MBeanException, ReflectionException, IOException {
logWriter.fine("Entered MemberInfoWithStatsMBeanGFEValidationDUnitTest.verifyAttributes() ...");
String id = (String) mbsc.getAttribute(wrapper, "Id");
String version = (String) mbsc.getAttribute(wrapper, "Version");
Integer refreshInterval = (Integer) mbsc.getAttribute(wrapper, "RefreshInterval");
AdminDistributedSystem adminDS = agent.getDistributedSystem();
String actualId = adminDS.getId();
String actualVersion = GemFireVersion.getGemFireVersion();
int actualRefreshInterval = adminDS.getConfig().getRefreshInterval();
assertTrue("AdminDistributedSystem id shown by MemberInfoWithStatsMBean " +
"(as: "+id+") and actual (as: "+actualId+") do not match.",
actualId.equals(id));
assertTrue("GemFire Version shown by MemberInfoWithStatsMBean " +
"(as: "+version+") and actual(as: "+actualVersion+") do not match.",
actualVersion.equals(version));
assertTrue("Refresh Interval shown by MemberInfoWithStatsMBean (as: "+
refreshInterval+") and actual (as :"+actualRefreshInterval+") do not match.",
actualRefreshInterval == refreshInterval);//use auto-boxing
logWriter.fine("Exited MemberInfoWithStatsMBeanGFEValidationDUnitTest.verifyAttributes() ...");
}
示例8
public Object getAttribute(ObjectName name,
String attribute)
throws MBeanException,
AttributeNotFoundException,
InstanceNotFoundException,
ReflectionException,
IOException {
if (logger.debugOn()) logger.debug("getAttribute",
"name=" + name + ", attribute="
+ attribute);
final ClassLoader old = pushDefaultClassLoader();
try {
return connection.getAttribute(name,
attribute,
delegationSubject);
} catch (IOException ioe) {
communicatorAdmin.gotIOException(ioe);
return connection.getAttribute(name,
attribute,
delegationSubject);
} finally {
popDefaultClassLoader(old);
}
}
示例9
Object getAttribute(Object resource, String attribute, Object cookie)
throws AttributeNotFoundException,
MBeanException,
ReflectionException {
final M cm = getters.get(attribute);
if (cm == null) {
final String msg;
if (setters.containsKey(attribute))
msg = "Write-only attribute: " + attribute;
else
msg = "No such attribute: " + attribute;
throw new AttributeNotFoundException(msg);
}
return introspector.invokeM(cm, resource, (Object[]) null, cookie);
}
示例10
void setAttribute(Object resource, String attribute, Object value,
Object cookie)
throws AttributeNotFoundException,
InvalidAttributeValueException,
MBeanException,
ReflectionException {
final M cm = setters.get(attribute);
if (cm == null) {
final String msg;
if (getters.containsKey(attribute))
msg = "Read-only attribute: " + attribute;
else
msg = "No such attribute: " + attribute;
throw new AttributeNotFoundException(msg);
}
introspector.invokeSetter(attribute, cm, resource, value, cookie);
}
示例11
public Object getAttribute(String attribute)
throws AttributeNotFoundException, MBeanException, ReflectionException {
AttrMethods am = attrMap.get(attribute);
if (am == null || am.getter == null)
throw new AttributeNotFoundException(attribute);
return invokeMethod(am.getter);
}
示例12
private Number validateTableAttr(String tableName, MBeanServerConnection mBeanServer, ObjectName name, Attribute attribute, String sql, OutputType type) throws TestException, AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException {
mbeanHelper.runQueryAndPrintValue(sql);
Number expected = (Number)mbeanHelper.runQueryAndGetValue(sql, type);
Number actual = ((Number)mBeanServer.getAttribute(name, attribute.getName()));
if(!actual.toString().equals(expected.toString())) {
saveError(attribute.getName() + " attribute did not match for " + tableName + " where expected = " + expected + " and actual : " + actual);
} else {
Log.getLogWriter().info(attribute.getName() + " attribute match for " + tableName + " where expected = " + expected + " and actual : " + actual);
}
return actual;
}
示例13
/**
* Set the value of a specific attribute of this MBean.
*
* @param attribute The identification of the attribute to be set
* and the new value
*
* @exception AttributeNotFoundException if this attribute is not
* supported by this MBean
* @exception MBeanException if the initializer of an object
* throws an exception
* @exception ReflectionException if a Java reflection exception
* occurs when invoking the getter
*/
@Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
ReflectionException {
// Validate the input parameters
if (attribute == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException("Attribute is null"),
"Attribute is null");
}
String name = attribute.getName();
Object value = attribute.getValue();
if (name == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException("Attribute name is null"),
"Attribute name is null");
}
ContextResourceLink crl = doGetManagedResource();
if ("global".equals(name)) {
crl.setGlobal((String) value);
} else if ("description".equals(name)) {
crl.setDescription((String) value);
} else if ("name".equals(name)) {
crl.setName((String) value);
} else if ("type".equals(name)) {
crl.setType((String) value);
} else {
crl.setProperty(name, "" + value);
}
// cannot use side-effects. It's removed and added back each time
// there is a modification in a resource.
NamingResources nr = crl.getNamingResources();
nr.removeResourceLink(crl.getName());
nr.addResourceLink(crl);
}
示例14
public Object getAttribute(ObjectName name, String attribute)
throws MBeanException, AttributeNotFoundException,
InstanceNotFoundException, ReflectionException {
if (name == null) {
throw new RuntimeOperationsException(new
IllegalArgumentException("Object name cannot be null"),
"Exception occurred trying to invoke the getter on the MBean");
}
if (attribute == null) {
throw new RuntimeOperationsException(new
IllegalArgumentException("Attribute cannot be null"),
"Exception occurred trying to invoke the getter on the MBean");
}
name = nonDefaultDomain(name);
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER,
DefaultMBeanServerInterceptor.class.getName(),
"getAttribute",
"Attribute = " + attribute + ", ObjectName = " + name);
}
final DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, attribute, name, "getAttribute");
try {
return instance.getAttribute(attribute);
} catch (AttributeNotFoundException e) {
throw e;
} catch (Throwable t) {
rethrowMaybeMBeanException(t);
throw new AssertionError(); // not reached
}
}
示例15
public Object getAttribute(ObjectName name, String attribute)
throws MBeanException, AttributeNotFoundException,
InstanceNotFoundException, ReflectionException {
if (name == null) {
throw new RuntimeOperationsException(new
IllegalArgumentException("Object name cannot be null"),
"Exception occurred trying to invoke the getter on the MBean");
}
if (attribute == null) {
throw new RuntimeOperationsException(new
IllegalArgumentException("Attribute cannot be null"),
"Exception occurred trying to invoke the getter on the MBean");
}
name = nonDefaultDomain(name);
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER,
DefaultMBeanServerInterceptor.class.getName(),
"getAttribute",
"Attribute = " + attribute + ", ObjectName = " + name);
}
final DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, attribute, name, "getAttribute");
try {
return instance.getAttribute(attribute);
} catch (AttributeNotFoundException e) {
throw e;
} catch (Throwable t) {
rethrowMaybeMBeanException(t);
throw new AssertionError(); // not reached
}
}
示例16
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
String name = attribute.getName();
AttrMethods am = attrMap.get(name);
if (am == null || am.setter == null)
throw new AttributeNotFoundException(name);
invokeMethod(am.setter, attribute.getValue());
}
示例17
@Override
public void setAttribute( Attribute attribute )
throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
{
UnitOfWork uow = uowf.newUnitOfWork();
try
{
EntityComposite configuration = uow.get( EntityComposite.class, identity );
AssociationStateHolder state = spi.stateOf( configuration );
AccessibleObject accessor = propertyNames.get( attribute.getName() );
Property<Object> property = state.propertyFor( accessor );
PropertyDescriptor propertyDescriptor = spi.propertyDescriptorFor( property );
if( EnumType.isEnum( propertyDescriptor.type() ) )
{
//noinspection unchecked
property.set( Enum.valueOf( (Class<Enum>) propertyDescriptor.type(),
attribute.getValue().toString() ) );
}
else
{
property.set( attribute.getValue() );
}
try
{
uow.complete();
}
catch( UnitOfWorkCompletionException e )
{
throw new ReflectionException( e );
}
}
finally
{
uow.discard();
}
}
示例18
/**
* This method always fail since all MBeanServerDelegateMBean attributes
* are read-only.
*
* @param attribute The identification of the attribute to
* be set and the value it is to be set to.
*
* @exception AttributeNotFoundException
*/
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
// Now we will always fail:
// Either because the attribute is null or because it is not
// accessible (or does not exist).
//
final String attname = (attribute==null?null:attribute.getName());
if (attname == null) {
final RuntimeException r =
new IllegalArgumentException("Attribute name cannot be null");
throw new RuntimeOperationsException(r,
"Exception occurred trying to invoke the setter on the MBean");
}
// This is a hack: we call getAttribute in order to generate an
// AttributeNotFoundException if the attribute does not exist.
//
Object val = getAttribute(attname);
// If we reach this point, we know that the requested attribute
// exists. However, since all attributes are read-only, we throw
// an AttributeNotFoundException.
//
throw new AttributeNotFoundException(attname + " not accessible");
}
示例19
/**
* Get an element based on its absolute name.
* @param anAbsoluteName The absolute name of the element to retrieve.
* @return The element.
* @throws AttributeNotFoundException if the element cannot be found.
*/
public ProfileElement getElement(String anAbsoluteName) throws AttributeNotFoundException {
try {
return new ComplexProfileElement(settingsHandler.getComplexTypeByAbsoluteName(crawlerSettings, anAbsoluteName));
}
catch(AttributeNotFoundException ex) {
// Perhaps it is not a complex element.
String parentName = anAbsoluteName.substring(0, anAbsoluteName.lastIndexOf('/'));
String myName = anAbsoluteName.substring(anAbsoluteName.lastIndexOf('/') + 1);
ComplexType parent = settingsHandler.getComplexTypeByAbsoluteName(crawlerSettings, parentName);
return new SimpleProfileElement(parent, myName);
}
}
示例20
@SuppressWarnings("unchecked")
@Override
public T getValue() {
try {
return (T) server.getAttribute(objectName, attributeName);
} catch (MBeanException | AttributeNotFoundException | InstanceNotFoundException | ReflectionException e) {
LOG.warn("Could not read attribute {}.", attributeName, e);
return errorValue;
}
}
示例21
public Object getAttribute(ObjectName name, String attribute)
throws MBeanException, AttributeNotFoundException,
InstanceNotFoundException, ReflectionException {
if (name == null) {
throw new RuntimeOperationsException(new
IllegalArgumentException("Object name cannot be null"),
"Exception occurred trying to invoke the getter on the MBean");
}
if (attribute == null) {
throw new RuntimeOperationsException(new
IllegalArgumentException("Attribute cannot be null"),
"Exception occurred trying to invoke the getter on the MBean");
}
name = nonDefaultDomain(name);
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER,
DefaultMBeanServerInterceptor.class.getName(),
"getAttribute",
"Attribute = " + attribute + ", ObjectName = " + name);
}
final DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, attribute, name, "getAttribute");
try {
return instance.getAttribute(attribute);
} catch (AttributeNotFoundException e) {
throw e;
} catch (Throwable t) {
rethrowMaybeMBeanException(t);
throw new AssertionError(); // not reached
}
}
示例22
/**
* This method always fail since all MBeanServerDelegateMBean attributes
* are read-only.
*
* @param attribute The identification of the attribute to
* be set and the value it is to be set to.
*
* @exception AttributeNotFoundException
*/
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
// Now we will always fail:
// Either because the attribute is null or because it is not
// accessible (or does not exist).
//
final String attname = (attribute==null?null:attribute.getName());
if (attname == null) {
final RuntimeException r =
new IllegalArgumentException("Attribute name cannot be null");
throw new RuntimeOperationsException(r,
"Exception occurred trying to invoke the setter on the MBean");
}
// This is a hack: we call getAttribute in order to generate an
// AttributeNotFoundException if the attribute does not exist.
//
Object val = getAttribute(attname);
// If we reach this point, we know that the requested attribute
// exists. However, since all attributes are read-only, we throw
// an AttributeNotFoundException.
//
throw new AttributeNotFoundException(attname + " not accessible");
}
示例23
/**
* Set the number of toe thread to run.
* @param toeThreadCount The number of toe threads to run.
*/
public void setToeThreads(int toeThreadCount) {
try {
setSimpleType("/crawl-order/max-toe-threads", toeThreadCount);
}
catch(AttributeNotFoundException ex) {
throw new WCTRuntimeException("Attribute max-toe-threads not found in profile", ex);
}
}
示例24
Comparable<?> getComparableFromAttribute(ObjectName object,
String attribute,
Object value)
throws AttributeNotFoundException {
if (isComplexTypeAttribute) {
Object v = value;
for (String attr : remainingAttributes)
v = Introspector.elementFromComplex(v, attr);
return (Comparable<?>) v;
} else {
return (Comparable<?>) value;
}
}
示例25
/**
* This method always fail since all MBeanServerDelegateMBean attributes
* are read-only.
*
* @param attribute The identification of the attribute to
* be set and the value it is to be set to.
*
* @exception AttributeNotFoundException
*/
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
// Now we will always fail:
// Either because the attribute is null or because it is not
// accessible (or does not exist).
//
final String attname = (attribute==null?null:attribute.getName());
if (attname == null) {
final RuntimeException r =
new IllegalArgumentException("Attribute name cannot be null");
throw new RuntimeOperationsException(r,
"Exception occurred trying to invoke the setter on the MBean");
}
// This is a hack: we call getAttribute in order to generate an
// AttributeNotFoundException if the attribute does not exist.
//
Object val = getAttribute(attname);
// If we reach this point, we know that the requested attribute
// exists. However, since all attributes are read-only, we throw
// an AttributeNotFoundException.
//
throw new AttributeNotFoundException(attname + " not accessible");
}
示例26
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
String name = attribute.getName();
AttrMethods am = attrMap.get(name);
if (am == null || am.setter == null)
throw new AttributeNotFoundException(name);
invokeMethod(am.setter, attribute.getValue());
}
示例27
private String findAttributeName(Set<String> attributes, String attributeName) throws AttributeNotFoundException{
if (attributes.contains(attributeName)) {
return attributeName;
}
for (String key : attributes) {
if (NameConverter.convertToCamelCase(key).equals(attributeName)) {
return key;
}
}
throw JmxLogger.ROOT_LOGGER.attributeNotFound(attributeName);
}
示例28
public Object getAttribute(String attribute)
throws AttributeNotFoundException, MBeanException, ReflectionException {
AttrMethods am = attrMap.get(attribute);
if (am == null || am.getter == null)
throw new AttributeNotFoundException(attribute);
return invokeMethod(am.getter);
}
示例29
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
public Object getAttribute(ObjectName name, String attribute)
throws
MBeanException,
AttributeNotFoundException,
InstanceNotFoundException,
ReflectionException {
checkRead();
return getMBeanServer().getAttribute(name, attribute);
}
示例30
/**
* Call <code>checkWrite()</code>, then forward this method to the
* wrapped object.
*/
public void setAttribute(ObjectName name, Attribute attribute)
throws
InstanceNotFoundException,
AttributeNotFoundException,
InvalidAttributeValueException,
MBeanException,
ReflectionException {
checkWrite();
getMBeanServer().setAttribute(name, attribute);
}