本文整理匯總了Java中org.rhq.plugins.jmx.JMXComponent類的典型用法代碼示例。如果您正苦於以下問題:Java JMXComponent類的具體用法?Java JMXComponent怎麽用?Java JMXComponent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JMXComponent類屬於org.rhq.plugins.jmx包,在下文中一共展示了JMXComponent類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: discoverResources
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
@Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) throws Exception {
Set<DiscoveredResourceDetails> detailsSet = super.discoverResources(context);
// for JMX connection type to PARENT for JMX Server embedded in Fuse Servers
for (DiscoveredResourceDetails details : detailsSet) {
// remove the connector address created by the base class when using Manual Add
// the base class does this when it sees the jmxremote.port command line option
// disregarding the parent component's connection!!!
details.getPluginConfiguration().setSimpleValue(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY,
null);
details.getPluginConfiguration().setSimpleValue(JMXDiscoveryComponent.CONNECTION_TYPE,
JMXDiscoveryComponent.PARENT_TYPE);
}
return detailsSet;
}
開發者ID:rh-messaging,項目名稱:Artemis-JON-plugin,代碼行數:19,代碼來源:ArtemisEmbeddedJMXServerDiscoveryComponent.java
示例2: discoverResources
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
@Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context)
throws Exception {
JMXComponent<?> component = context.getParentResourceComponent();
Configuration pluginConfig = context.getDefaultPluginConfiguration();
EmsConnection emsConnection = component.getEmsConnection();
if (!hasApplicationMBeans(pluginConfig, emsConnection)) {
return Collections.emptySet();
}
return Collections.singleton(new DiscoveredResourceDetails(context.getResourceType(),
getResourceKey(context, pluginConfig),
getResourceName(context, pluginConfig),
getResourceVersion(context, pluginConfig),
getResourceDescription(context, pluginConfig), pluginConfig, null));
}
示例3: setConfiguration
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
@Override
protected void setConfiguration(Configuration configuration, ResourceType resourceType) {
if (remote) {
set(configuration, JMXDiscoveryComponent.CONNECTION_TYPE, J2SE5ConnectionTypeDescriptor.class.getName());
set2(configuration, JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, "hadoop.connectorAddress");
set2(configuration, JMXComponent.PRINCIPAL_CONFIG_PROP, "hadoop.principal");
set2(configuration, JMXComponent.CREDENTIALS_CONFIG_PROP, "hadoop.credentials");
}
if (resourceType.getName().equals("NameNode")) {
configuration.getSimple("dfs.test.bytes").setStringValue("1000");
configuration.getSimple("dfs.test.files").setStringValue("1");
}
}
示例4: start
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
@Override
public void start(ResourceContext<JMXComponent<?>> resourceContext) throws InvalidPluginConfigurationException, Exception {
this.resourceContext = resourceContext;
this.parent = resourceContext.getParentResourceComponent();
Configuration pluginConfig = resourceContext.getPluginConfiguration();
this.beansQueryString = new ApplicationMBeansDiscoveryComponent().getBeansQueryString(pluginConfig);
}
示例5: discoverResourceDetails
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
protected DiscoveredResourceDetails discoverResourceDetails(ResourceDiscoveryContext context, ProcessInfo process) {
Configuration pluginConfig;
// Start up a JMX agent within the JVM via the Sun Attach API, and return a URL that can be used to connect
// to that agent.
// Note, this will only work if the remote JVM is Java 6 or later, and maybe some 64 bit Java 5 - see
// JBNADM-3332. Also, the RHQ Agent will have to be running on a JDK, not a JRE, so that we can access
// the JDK's tools.jar, which contains the Sun JVM Attach API classes.
JMXServiceURL jmxServiceURL;
try {
jmxServiceURL = JvmUtility.extractJMXServiceURL(process);
} catch (RuntimeException e) {
// avoid loading AttachNotSupportedException class, since its optional
if (e.getCause() != null &&
e.getCause().getClass().getName().equals(ATTACH_NOT_SUPPORTED_EXCEPTION_CLASS_NAME)) {
// try connecting using jvmstat
jmxServiceURL = JvmStatUtility.extractJMXServiceURL(process);
} else {
// re-throw
throw e;
}
}
if (jmxServiceURL != null) {
pluginConfig = context.getDefaultPluginConfiguration();
// do not use the default connector address, principal or credentials
pluginConfig.setSimpleValue(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, null);
pluginConfig.setSimpleValue(JMXComponent.PRINCIPAL_CONFIG_PROP, null);
pluginConfig.setSimpleValue(JMXComponent.CREDENTIALS_CONFIG_PROP, null);
} else {
// create plugin config with JMX connection properties
pluginConfig = getConfigWithJmxServiceUrl(context, process);
}
// log the JMX URL being used
if (log.isDebugEnabled()) {
log.debug("JMX service URL for java process [" + process + "] is [" +
(jmxServiceURL != null ? jmxServiceURL :
pluginConfig.getSimpleValue(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY))
+ "].");
}
return buildResourceDetails(pluginConfig, context, process,
pluginConfig.getSimpleValue(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY));
}
示例6: internalStart
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
protected void internalStart() throws Exception {
Configuration pluginConfig = context.getPluginConfiguration();
String connectionTypeDescriptorClassName = pluginConfig.getSimple(JMXDiscoveryComponent.CONNECTION_TYPE)
.getStringValue();
if (JMXDiscoveryComponent.PARENT_TYPE.equals(connectionTypeDescriptorClassName)) {
// Our parent is itself a JMX component, so just reuse its connection.
this.connection = ((JMXComponent) context.getParentResourceComponent()).getEmsConnection();
this.connectionProvider = this.connection.getConnectionProvider();
} else {
final File tempDir = this.context.getTemporaryDirectory();
try {
this.connectionProvider = ConnectionProviderFactory.createConnectionProvider(pluginConfig,
this.context.getNativeProcess(), tempDir);
} catch (RuntimeException e) {
// check if Attach API failed, since this resource may have been discovered using jvmstat API
// avoid loading AttachNotSupportedException class, since its optional
if (e.getCause() != null &&
e.getCause().getClass().getName().equals(
ArtemisServerDiscoveryComponent.ATTACH_NOT_SUPPORTED_EXCEPTION_CLASS_NAME)) {
// create a connection provider using JvmStatUtility
final Class<?> connectionTypeDescriptorClass;
connectionTypeDescriptorClass = Class.forName(connectionTypeDescriptorClassName);
ConnectionTypeDescriptor connectionType =
(ConnectionTypeDescriptor) connectionTypeDescriptorClass.newInstance();
// create connection provider settings
ConnectionSettings settings = new ConnectionSettings();
if (!(connectionType instanceof J2SE5ConnectionTypeDescriptor)) {
throw new Exception("Unsupported connection type descriptor " + connectionTypeDescriptorClass);
}
settings.setConnectionType(connectionType);
// get service URL using jvmstat
final JMXServiceURL jmxServiceURL = JvmStatUtility.extractJMXServiceURL(context.getNativeProcess());
if (jmxServiceURL == null) {
throw new Exception("Failed to get JMX service URL using jvmstat");
}
settings.setServerUrl(jmxServiceURL.toString());
settings.getControlProperties().setProperty(
ConnectionFactory.COPY_JARS_TO_TEMP, String.valueOf(Boolean.TRUE));
settings.getControlProperties().setProperty(
ConnectionFactory.JAR_TEMP_DIR, tempDir.getAbsolutePath());
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.discoverServerClasses(settings);
connectionProvider = connectionFactory.getConnectionProvider(settings);
} else {
// re-throw
throw e;
}
}
this.connection = this.connectionProvider.connect();
this.connection.loadSynchronous(false);
}
}
示例7: getResourceKey
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
/**
* Returns a resource key for config name 'resourceKey', default is 'key'.
*/
protected String getResourceKey(ResourceDiscoveryContext<JMXComponent<?>> context, Configuration config) {
return config.getSimpleValue("resourceKey", "key");
}
示例8: getResourceName
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
/**
* Returns a resource name for config key 'resourceName', default is the resource type name.
*/
protected String getResourceName(ResourceDiscoveryContext<JMXComponent<?>> context, Configuration config) {
return config.getSimpleValue("resourceName", context.getResourceType().getName());
}
示例9: getResourceDescription
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
/**
* Returns a resource description for config key 'resourceName', default is the resource type description.
*/
protected String getResourceDescription(ResourceDiscoveryContext<JMXComponent<?>> context, Configuration config) {
return config.getSimpleValue("resourceDescription", context.getResourceType().getDescription());
}
示例10: getResourceVersion
import org.rhq.plugins.jmx.JMXComponent; //導入依賴的package包/類
/**
* Returns a resource version for config key 'resourceVersion', default is null.
*/
protected String getResourceVersion(ResourceDiscoveryContext<JMXComponent<?>> context, Configuration config) {
return config.getSimpleValue("resourceVersion", null);
}