Java Code Examples for org.jboss.as.controller.registry.ManagementResourceRegistration#registerMetric()

The following examples show how to use org.jboss.as.controller.registry.ManagementResourceRegistration#registerMetric() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerConfigResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {

    resourceRegistration.registerReadOnlyAttribute(NAME, ReadResourceNameOperationStepHandler.INSTANCE);

    resourceRegistration.registerReadWriteAttribute(AUTO_START, null, new ModelOnlyWriteAttributeHandler(AUTO_START));
    resourceRegistration.registerReadWriteAttribute(UPDATE_AUTO_START_WITH_SERVER_STATUS, null, new ModelOnlyWriteAttributeHandler(UPDATE_AUTO_START_WITH_SERVER_STATUS));
    resourceRegistration.registerReadWriteAttribute(SOCKET_BINDING_GROUP, null, ServerRestartRequiredServerConfigWriteAttributeHandler.INSTANCE);
    resourceRegistration.registerReadWriteAttribute(SOCKET_BINDING_DEFAULT_INTERFACE, null, ServerRestartRequiredServerConfigWriteAttributeHandler.INSTANCE);
    resourceRegistration.registerReadWriteAttribute(SOCKET_BINDING_PORT_OFFSET, null, ServerRestartRequiredServerConfigWriteAttributeHandler.INSTANCE);
    resourceRegistration.registerReadWriteAttribute(GROUP, null, ServerRestartRequiredServerConfigWriteAttributeHandler.INSTANCE);

    // For compatibility, register these should-be-removed attributes, with no-op handlers
    resourceRegistration.registerReadWriteAttribute(PRIORITY, NoopOperationStepHandler.WITH_RESULT, NoopOperationStepHandler.WITHOUT_RESULT);
    resourceRegistration.registerReadWriteAttribute(CPU_AFFINITY, NoopOperationStepHandler.WITH_RESULT, NoopOperationStepHandler.WITHOUT_RESULT);

    if (serverInventory != null) {
        resourceRegistration.registerMetric(STATUS, new ServerStatusHandler(serverInventory));
    }
}
 
Example 2
Source File: DeploymentResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {

    for (AttributeDefinition attr : parent.getResourceAttributes()) {
        if (attr.getName().equals(DeploymentAttributes.STATUS.getName())) {
            resourceRegistration.registerMetric(attr, DeploymentStatusHandler.INSTANCE);
        } else if (attr.getName().equals(DeploymentAttributes.NAME.getName())) {
            resourceRegistration.registerReadOnlyAttribute(DeploymentAttributes.NAME, ReadResourceNameOperationStepHandler.INSTANCE);
        } else if (DeploymentAttributes.MANAGED.getName().equals(attr.getName())) {
            resourceRegistration.registerReadOnlyAttribute(DeploymentAttributes.MANAGED, new OperationStepHandler() {
                @Override
                public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                    ModelNode deployment = context.readResource(PathAddress.EMPTY_ADDRESS, true).getModel();
                    if(deployment.hasDefined(CONTENT_RESOURCE_ALL.getName())) {
                        ModelNode content = deployment.get(CONTENT_RESOURCE_ALL.getName()).asList().get(0);
                        context.getResult().set(!isUnmanagedContent(content));
                    }
                }
            });
        } else {
            resourceRegistration.registerReadOnlyAttribute(attr, null);
        }
    }
}
 
Example 3
Source File: RequestControllerRootDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    MaxRequestsWriteHandler handler = new MaxRequestsWriteHandler(MAX_REQUESTS);
    resourceRegistration.registerReadWriteAttribute(MAX_REQUESTS, null, handler);
    resourceRegistration.registerReadWriteAttribute(TRACK_INDIVIDUAL_ENDPOINTS, null, new ReloadRequiredWriteAttributeHandler(TRACK_INDIVIDUAL_ENDPOINTS));
    if(registerRuntimeOnly) {
        resourceRegistration.registerMetric(ACTIVE_REQUESTS, new ActiveRequestsReadHandler());
    }
}
 
Example 4
Source File: ResourceBuilderRoot.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
void register(ManagementResourceRegistration registration) {
    if (accessType == AttributeAccess.AccessType.READ_ONLY) {
        registration.registerReadOnlyAttribute(attribute, readOp);
    } else if (accessType == AttributeAccess.AccessType.READ_WRITE) {
        registration.registerReadWriteAttribute(attribute, readOp, writeOp);
    } else if (accessType == AttributeAccess.AccessType.METRIC) {
        registration.registerMetric(attribute, readOp);
    }
}
 
Example 5
Source File: MetricsRegistrationTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    resourceRegistration.registerMetric(METRIC, (context, operation) -> context.getResult().set(1000));
    resourceRegistration.registerMetric(METRIC_2, (context, operation) -> context.getResult().set(2000));
    resourceRegistration.registerReadOnlyAttribute(RUNTIME_ATTRIBUTE, ((context, operation) -> context.getResult().set(3000)));
    resourceRegistration.registerReadOnlyAttribute(RUNTIME_ATTRIBUTE_2, ((context, operation) -> context.getResult().set(4000)));
}
 
Example 6
Source File: MetricsUndefinedValueUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testRegisterNonNillableAndDefinedMetricsValueMetricRegistration() throws Exception {
    ManagementResourceRegistration reg = setupController(new TestResourceDefinition());
    SimpleAttributeDefinition def = new SimpleAttributeDefinitionBuilder(TEST_METRIC, ModelType.STRING)
            .setStorageRuntime()
            .setUndefinedMetricValue(new ModelNode(TEST_METRIC))
            .build();
    reg.registerMetric(def, new EmptyHandler());
}
 
Example 7
Source File: MetricsUndefinedValueUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testReadMetricDefinedByHandler() throws Exception {
    ManagementResourceRegistration reg = setupController(new TestResourceDefinition());
    SimpleAttributeDefinition def = new SimpleAttributeDefinitionBuilder(TEST_METRIC, ModelType.STRING)
            .setStorageRuntime()
            .setUndefinedMetricValue(new ModelNode("test"))
            .build();
    reg.registerMetric(def, new HardCodedValueHandler(new ModelNode("test2")));

    checkTestMetric("test2", null);
}
 
Example 8
Source File: MetricsUndefinedValueUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testReadMetricNotDefinedByHandler() throws Exception {
    ManagementResourceRegistration reg = setupController(new TestResourceDefinition());
    SimpleAttributeDefinition def = new SimpleAttributeDefinitionBuilder(TEST_METRIC, ModelType.STRING)
            .setStorageRuntime()
            .setUndefinedMetricValue(new ModelNode("test"))
            .build();
    reg.registerMetric(def, new EmptyHandler());

    checkTestMetric("test", null);
}
 
Example 9
Source File: MetricsUndefinedValueUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testReadMetricNotDefinedByHandlerWithIncludeUndefinedMetric() throws Exception {
    ManagementResourceRegistration reg = setupController(new TestResourceDefinition());
    SimpleAttributeDefinition def = new SimpleAttributeDefinitionBuilder(TEST_METRIC, ModelType.STRING)
            .setStorageRuntime()
            .setUndefinedMetricValue(new ModelNode("test"))
            .build();
    reg.registerMetric(def, new EmptyHandler());

    checkTestMetric("test", true);
}
 
Example 10
Source File: MetricsUndefinedValueUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void registerFailingMetric(ManagementResourceRegistration reg, AttributeDefinition def, OperationStepHandler handler) {
    boolean worked = false;
    try {
        reg.registerMetric(def, new EmptyHandler());
        worked = true;
    } catch (AssertionError expected) {
    }
    Assert.assertFalse("Should not have worked registering a non-nillable metric with no undefined metrics value", worked);
}
 
Example 11
Source File: Subsystem1RootResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration profileSub1Reg) {
    super.registerAttributes(profileSub1Reg);

    profileSub1Reg.registerReadOnlyAttribute(new PrimitiveListAttributeDefinition.Builder("attr1", ModelType.INT).setRequired(true).build(), null);

    profileSub1Reg.registerReadOnlyAttribute(createAttribute("read-only", ModelType.INT, null, false, false, true), null);
    final AttributeDefinition attribute = createAttribute("read-write", ModelType.INT, null, false, false, true);
    profileSub1Reg.registerReadWriteAttribute(attribute, null, new ModelOnlyWriteAttributeHandler(attribute));
    profileSub1Reg.registerMetric(createMetric("metric1", ModelType.INT), TestMetricHandler.INSTANCE);
    profileSub1Reg.registerMetric(createMetric("metric2", ModelType.INT), TestMetricHandler.INSTANCE);


}
 
Example 12
Source File: MemoryManagerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration registration) {
    super.registerAttributes(registration);
    registration.registerReadOnlyAttribute(PlatformMBeanConstants.OBJECT_NAME, MemoryManagerMXBeanAttributeHandler.INSTANCE);

    for (AttributeDefinition attribute : METRICS) {
        registration.registerMetric(attribute, MemoryManagerMXBeanAttributeHandler.INSTANCE);
    }
}
 
Example 13
Source File: OpTypesExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    resourceRegistration.registerReadOnlyAttribute(RUNTIME_ONLY_ATTR, RuntimeOnlyHandler.INSTANCE);
    resourceRegistration.registerMetric(METRIC, RuntimeOnlyHandler.INSTANCE);
}
 
Example 14
Source File: ThreadPoolMetricsHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void registerAttributes(final ManagementResourceRegistration registration) {
    for (AttributeDefinition metric : metrics) {
        registration.registerMetric(metric, this);
    }
}