Java Code Examples for org.xnio.XnioWorker#getMXBean()

The following examples show how to use org.xnio.XnioWorker#getMXBean() . 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: WorkerServerDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    XnioWorker worker = getXnioWorker(context);
    if (worker == null || worker.getMXBean() == null) {
        context.getResult().set(IOExtension.NO_METRICS);
        return;
    }
    XnioWorkerMXBean metrics = worker.getMXBean();
    Optional<XnioServerMXBean> serverMetrics = Optional.empty();
    for (XnioServerMXBean xnioServerMXBean : metrics.getServerMXBeans()) {
        if (xnioServerMXBean.getBindAddress().equals(context.getCurrentAddressValue())) {
            serverMetrics = Optional.of(xnioServerMXBean);
            break;
        }
    }
    if (serverMetrics.isPresent()) {
        context.getResult().set(getMetricValue(serverMetrics.get()));
    } else {
        context.getResult().set(IOExtension.NO_METRICS);
    }
}
 
Example 2
Source File: WorkerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static XnioWorkerMXBean getMetrics(ServiceRegistry serviceRegistry, String name) {
    XnioWorker worker = getXnioWorker(serviceRegistry, name);
    if (worker != null && worker.getMXBean() != null) {
        return worker.getMXBean();
    }
    return null;
}
 
Example 3
Source File: WorkerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
void executeWithWorker(OperationContext context, ModelNode operation, XnioWorker worker) throws OperationFailedException {
    XnioWorkerMXBean metrics = worker.getMXBean();
    String name = operation.require(ModelDescriptionConstants.NAME).asString();
    context.getResult().set(getMetricValue(name, metrics));
}