@Override protected void handleNode(OperationContext context, ModClusterStatus.LoadBalancer ctx, ModelNode operation) throws OperationFailedException { final String stickySessionPath = ctx.getStickySessionPath(); if(stickySessionPath == null) { context.getResult().set(new ModelNode()); } else { context.getResult().set(new ModelNode(stickySessionPath)); } } });
@Override protected void executeReadMetricStep(final OperationContext context, final ModelNode operation, final EJBComponent component) throws OperationFailedException { context.getResult().setEmptyObject(); for (final Map.Entry<String, InvocationMetrics.Values> entry : component.getInvocationMetrics().getMethods().entrySet()) { final InvocationMetrics.Values values = entry.getValue(); final ModelNode result = new ModelNode(); result.get("execution-time").set(values.getExecutionTime()); result.get("invocations").set(values.getInvocations()); result.get("wait-time").set(values.getWaitTime()); context.getResult().get(entry.getKey()).set(result); } } });
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final boolean defaults = INCLUDE_DEFAULTS.resolveModelAttribute(context,operation).asBoolean(); final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false); final ModelNode subModel = resource.getModel(); if (subModel.hasDefined(aliasedAttribute.getName())) { final ModelNode result = subModel.get(aliasedAttribute.getName()); context.getResult().set(result); } else if (defaults && aliasedAttribute.getDefaultValue() != null) { // No defined value in the model. See if we should reply with a default from the metadata, // reply with undefined, or fail because it's a non-existent attribute name context.getResult().set(aliasedAttribute.getDefaultValue()); } else { // model had no defined value, but we treat its existence in the model or the metadata // as proof that it's a legit attribute name context.getResult(); // this initializes the "result" to ModelType.UNDEFINED } } }
@Override protected void execute(final OperationContext context, final ModelNode operation, final WildFlyJobOperator jobOperator) throws OperationFailedException { // Resolve the job XML name final String jobName = resolveValue(context, operation, JOB_XML_NAME).asString(); final Properties properties = resolvePropertyValue(context, operation, PROPERTIES); try { final long executionId = jobOperator.start(jobName, properties); context.getResult().set(executionId); } catch (JobStartException | JobSecurityException e) { throw createOperationFailure(e); } } });
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String name = address.getLastElement().getValue(); context.getResult().set(name); context.stepCompleted(); } }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String attributeName = operation.require(NAME).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); if (managementRepoService != null) { try { setModelValue(context.getResult(), attributeName); } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage())); } } } }, OperationContext.Stage.RUNTIME);
private void addOpenjdkExtension(final OperationContext context, final Map<PathAddress, ModelNode> migrateOperations) { final PathAddress extensionAddress = PathAddress.EMPTY_ADDRESS.append(OPENJDK_EXTENSION_ELEMENT); OperationEntry addEntry = context.getRootResourceRegistration().getOperationEntry(extensionAddress, ADD); final ModelNode addOperation = Util.createAddOperation(extensionAddress); if (describe) { migrateOperations.put(extensionAddress, addOperation); } else { context.addStep(context.getResult().get(extensionAddress.toString()), addOperation, addEntry.getOperationHandler(), MODEL); } }
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode opAddr = operation.require(OP_ADDR); PathAddress address = PathAddress.pathAddress(opAddr); final String securityDomain = address.getLastElement().getValue(); ServiceController<SecurityDomainContext> controller = getSecurityDomainService(context, securityDomain); if (controller != null) { // FIXME this is nasty. waitForService(controller); SecurityDomainContext sdc = controller.getValue(); @SuppressWarnings("unchecked") CacheableManager<?, Principal> manager = (CacheableManager<?, Principal>) sdc .getAuthenticationManager(); Set<Principal> cachedPrincipals = manager.getCachedKeys(); ModelNode result = context.getResult(); for (Principal principal : cachedPrincipals) { result.add(principal.getName()); } if (!result.isDefined()) result.setEmptyList(); } else { throw SecurityLogger.ROOT_LOGGER.noAuthenticationCacheAvailable(securityDomain); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String parameterName = operation.require(NAME).asString(); final ModelNode submodel = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel(); final ModelNode currentValue = submodel.hasDefined(parameterName) ? submodel.get(parameterName).clone() : new ModelNode(); context.getResult().set(currentValue); } }
@Override protected void handleNode(OperationContext context, ModClusterStatus.LoadBalancer ctx, ModelNode operation) throws OperationFailedException { final String stickySessionCookie = ctx.getStickySessionCookie(); if(stickySessionCookie == null) { context.getResult().set(new ModelNode()); } else { context.getResult().set(new ModelNode(stickySessionCookie)); } } });
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(false); JdrReportCollector jdrCollector = JdrReportCollector.class.cast(registry.getRequiredService(JdrReportService.SERVICE_NAME).getValue()); ModelNode response = context.getResult(); JdrReport report = jdrCollector.collect(); if (report.getStartTime() != null) { response.get("start-time").set(report.getStartTime()); } if (report.getEndTime() != null) { response.get("end-time").set(report.getEndTime()); } response.get("report-location").set(report.getLocation()); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); final ModelNode filter = CommonAttributes.FILTER_SPEC.resolveModelAttribute(context, model); if (filter.isDefined()) { context.getResult().set(Filters.filterSpecToFilter(filter.asString())); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String name = address.getLastElement().getValue(); context.getResult().set(name); context.stepCompleted(); } }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String attributeName = operation.require(NAME).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); if (managementRepoService != null) { try { setModelValue(context.getResult(), attributeName); } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage())); } } } }, OperationContext.Stage.RUNTIME);
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String attributeName = operation.require(NAME).asString(); try { final ModelNode result = context.getResult(); switch (attributeName) { case ModelDescriptionConstants.STATISTICS_ENABLED: { result.set(stats.isEnabled()); break; } } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage())); } } }, OperationContext.Stage.RUNTIME);
@Override protected void handleNode(OperationContext context, ModClusterStatus.Node ctx, ModelNode operation) throws OperationFailedException { final String domain = ctx.getDomain(); if (domain == null) { context.getResult().set(new ModelNode()); } else { context.getResult().set(new ModelNode(domain)); } } });
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (this.readHandler != null) { this.readHandler.execute(context, operation); } else { try { // If attribute has no read handler, simulate one ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel(); ModelNode result = context.getResult(); if (model.hasDefined(this.targetAttribute.getName())) { result.set(model.get(this.targetAttribute.getName())); } else if (Operations.isIncludeDefaults(operation)) { result.set(this.targetAttribute.getDefinition().getDefaultValue()); } } catch (Resource.NoSuchResourceException ignore) { // If the target resource does not exist return UNDEFINED return; } } ModelNode result = context.getResult(); result.set(this.translator.translate(context, result)); } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); final ModelNode filter = CommonAttributes.FILTER_SPEC.resolveModelAttribute(context, model); if (filter.isDefined()) { context.getResult().set(Filters.filterSpecToFilter(filter.asString())); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { validator.validate(operation); try { long id = operation.require(PlatformMBeanConstants.ID).asLong(); context.getResult().set(ManagementFactory.getThreadMXBean().getThreadCpuTime(id)); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } } }