-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the new local-jmx managed server - so you don't have to go …
…over jolokia if you are monitoring the same VM as where the agent is installed
- Loading branch information
1 parent
667a368
commit bf116f2
Showing
20 changed files
with
892 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
hawkular-wildfly-agent/src/main/java/org/hawkular/agent/monitor/extension/LocalJMXAdd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright 2015-2016 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.agent.monitor.extension; | ||
|
||
import org.hawkular.agent.monitor.extension.MonitorServiceConfiguration.EndpointConfiguration; | ||
import org.hawkular.agent.monitor.log.AgentLoggers; | ||
import org.hawkular.agent.monitor.log.MsgLogger; | ||
import org.hawkular.agent.monitor.protocol.EndpointService; | ||
import org.hawkular.agent.monitor.protocol.ProtocolService; | ||
import org.hawkular.agent.monitor.protocol.ProtocolServices; | ||
import org.hawkular.agent.monitor.protocol.jmx.JMXNodeLocation; | ||
import org.hawkular.agent.monitor.protocol.jmx.JMXSession; | ||
import org.hawkular.agent.monitor.service.MonitorService; | ||
import org.hawkular.agent.monitor.util.Util; | ||
import org.jboss.as.controller.OperationContext; | ||
import org.jboss.as.controller.OperationFailedException; | ||
import org.jboss.dmr.ModelNode; | ||
|
||
public class LocalJMXAdd extends MonitorServiceAddStepHandler { | ||
private static final MsgLogger log = AgentLoggers.getLogger(LocalJMXAdd.class); | ||
|
||
public static final LocalJMXAdd INSTANCE = new LocalJMXAdd(); | ||
|
||
private LocalJMXAdd() { | ||
super(LocalJMXAttributes.ATTRIBUTES); | ||
} | ||
|
||
@Override | ||
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) | ||
throws OperationFailedException { | ||
|
||
if (context.isBooting()) { | ||
return; | ||
} | ||
|
||
MonitorService monitorService = getMonitorService(context); | ||
if (monitorService == null) { | ||
return; // the agent wasn't enabled, nothing to do | ||
} | ||
|
||
MonitorServiceConfiguration config = Util.getMonitorServiceConfiguration(context); | ||
String newEndpointName = context.getCurrentAddressValue(); | ||
|
||
// Register the feed under the tenant of the new managed server. | ||
// If endpoint has a null tenant then there is nothing to do since it will just reuse the agent's tenant ID | ||
EndpointConfiguration endpointConfig = config.getJmxConfiguration().getEndpoints().get(newEndpointName); | ||
boolean isEnabled = endpointConfig.isEnabled(); | ||
|
||
String newTenantId = endpointConfig.getTenantId(); | ||
if (newTenantId != null) { | ||
try { | ||
monitorService.registerFeed(newTenantId, 0); | ||
} catch (Exception e) { | ||
isEnabled = false; | ||
log.warnCannotRegisterFeedForNewManagedServer(newTenantId, newEndpointName, e.toString()); | ||
} | ||
} | ||
|
||
if (isEnabled) { | ||
// create a new endpoint service | ||
ProtocolServices newServices = monitorService.createProtocolServicesBuilder() | ||
.jmxProtocolService(config.getJmxConfiguration()).build(); | ||
EndpointService<JMXNodeLocation, JMXSession> endpointService = newServices.getJmxProtocolService() | ||
.getEndpointServices().get(newEndpointName); | ||
|
||
// put the new endpoint service in the original protocol services container | ||
ProtocolService<JMXNodeLocation, JMXSession> jmxService = monitorService.getProtocolServices() | ||
.getJmxProtocolService(); | ||
jmxService.add(endpointService); | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...-wildfly-agent/src/main/java/org/hawkular/agent/monitor/extension/LocalJMXAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2015-2016 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.agent.monitor.extension; | ||
|
||
import org.hawkular.agent.monitor.api.Avail; | ||
import org.jboss.as.controller.AttributeDefinition; | ||
import org.jboss.as.controller.SimpleAttributeDefinition; | ||
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; | ||
import org.jboss.as.controller.operations.validation.EnumValidator; | ||
import org.jboss.as.controller.registry.AttributeAccess; | ||
import org.jboss.dmr.ModelNode; | ||
import org.jboss.dmr.ModelType; | ||
|
||
public interface LocalJMXAttributes { | ||
|
||
SimpleAttributeDefinition ENABLED = new SimpleAttributeDefinitionBuilder("enabled", | ||
ModelType.BOOLEAN) | ||
.setAllowNull(true) | ||
.setDefaultValue(new ModelNode(true)) | ||
.setAllowExpression(true) | ||
.addFlag(AttributeAccess.Flag.RESTART_NONE) | ||
.build(); | ||
|
||
SimpleAttributeDefinition MBEAN_SERVER_NAME = new SimpleAttributeDefinitionBuilder("mbean-server-name", | ||
ModelType.STRING) | ||
.setAllowNull(true) | ||
.setAllowExpression(true) | ||
.addFlag(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
.build(); | ||
|
||
SimpleAttributeDefinition SET_AVAIL_ON_SHUTDOWN = new SimpleAttributeDefinitionBuilder("set-avail-on-shutdown", | ||
ModelType.STRING) | ||
.setAllowNull(true) | ||
.setValidator(EnumValidator.create(Avail.class, true, true)) | ||
.setAllowExpression(true) | ||
.addFlag(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
.build(); | ||
|
||
SimpleAttributeDefinition RESOURCE_TYPE_SETS = new SimpleAttributeDefinitionBuilder("resource-type-sets", | ||
ModelType.STRING) | ||
.setAllowNull(true) | ||
.setAllowExpression(true) | ||
.addFlag(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
.build(); | ||
|
||
SimpleAttributeDefinition TENANT_ID = new SimpleAttributeDefinitionBuilder("tenant-id", | ||
ModelType.STRING) | ||
.setAllowNull(true) | ||
.setAllowExpression(true) | ||
.addFlag(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
.build(); | ||
|
||
SimpleAttributeDefinition METRIC_ID_TEMPLATE = new SimpleAttributeDefinitionBuilder("metric-id-template", | ||
ModelType.STRING) | ||
.setAllowNull(true) | ||
.setAllowExpression(true) | ||
.addFlag(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
.build(); | ||
|
||
SimpleAttributeDefinition METRIC_TAGS = new SimpleAttributeDefinitionBuilder("metric-tags", | ||
ModelType.STRING) | ||
.setAllowNull(true) | ||
.setAllowExpression(true) | ||
.addFlag(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) | ||
.build(); | ||
|
||
AttributeDefinition[] ATTRIBUTES = { | ||
ENABLED, | ||
MBEAN_SERVER_NAME, | ||
SET_AVAIL_ON_SHUTDOWN, | ||
RESOURCE_TYPE_SETS, | ||
TENANT_ID, | ||
METRIC_ID_TEMPLATE, | ||
METRIC_TAGS | ||
}; | ||
} |
Oops, something went wrong.