Refine search
/** * This is the constructor to use for 9.0.x subsystem tests */ protected ModelTestModelControllerService(final ProcessType processType, final RunningModeControl runningModeControl, final TransformerRegistry transformerRegistry, final StringConfigurationPersister persister, final ModelTestOperationValidatorFilter validateOpsFilter, final ResourceDefinition resourceDefinition, ControlledProcessState processState, Controller90x version) { super(processType, runningModeControl, persister, processState == null ? new ControlledProcessState(true) : processState, resourceDefinition, null, ExpressionResolver.TEST_RESOLVER); this.persister = persister; this.transformerRegistry = transformerRegistry; this.validateOpsFilter = validateOpsFilter; this.runningModeControl = runningModeControl; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { String name = operation.get(NAME).asString(); // WFCORE-43 introduces a new attribute "runtime-configuration-state" // rather than introduce a new value into the ControlledProcessState enum, we map the new value here // this could be add in a future major release to be part of the enum. if (RUNTIME_CONFIGURATION_STATE.equals(name)) { if (processState.getState() == ControlledProcessState.State.RUNNING) { context.getResult().set(ClientConstants.CONTROLLER_PROCESS_STATE_OK); return; } } context.getResult().set(processState.getState().toString()); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { processState.setStopping(); final Thread thread = new Thread(new Runnable() { public void run() { System.exit(restart ? ExitCodes.RESTART_PROCESS_FROM_STARTUP_SCRIPT : ExitCodes.NORMAL); } }); // The intention is that this shutdown is graceful, and so the client gets a reply. // At the time of writing we did not yet have graceful shutdown. thread.setName("Management Triggered Shutdown"); thread.start(); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
@Override public final void reloadRequired() { if (processState.isReloadSupported()) { activeStep.restartStamp = processState.setReloadRequired(); activeStep.response.get(RESPONSE_HEADERS, OPERATION_REQUIRES_RELOAD).set(true); } else { restartRequired(); } }
@Override public final void revertReloadRequired() { if (processState.isReloadSupported()) { processState.revertReloadRequired(this.activeStep.restartStamp); if (activeStep.response.get(RESPONSE_HEADERS).hasDefined(OPERATION_REQUIRES_RELOAD)) { activeStep.response.get(RESPONSE_HEADERS).remove(OPERATION_REQUIRES_RELOAD); if (activeStep.response.get(RESPONSE_HEADERS).asInt() == 0) { activeStep.response.remove(RESPONSE_HEADERS); } } } else { revertRestartRequired(); } }
final ModelNode headers = operation.has(OPERATION_HEADERS) ? operation.get(OPERATION_HEADERS) : null; final boolean rollbackOnFailure = headers == null || !headers.hasDefined(ROLLBACK_ON_RUNTIME_FAILURE) || headers.get(ROLLBACK_ON_RUNTIME_FAILURE).asBoolean(); final EnumSet<OperationContextImpl.ContextFlag> contextFlags = rollbackOnFailure ? EnumSet.of(OperationContextImpl.ContextFlag.ROLLBACK_ON_FAIL) : EnumSet.noneOf(OperationContextImpl.ContextFlag.class); final boolean restartResourceServices = headers != null && headers.hasDefined(ALLOW_RESOURCE_SERVICE_RESTART) && headers.get(ALLOW_RESOURCE_SERVICE_RESTART).asBoolean(); if (!response.hasDefined(RESPONSE_HEADERS) || !response.get(RESPONSE_HEADERS).hasDefined(PROCESS_STATE)) { ControlledProcessState.State state = processState.getState(); switch (state) { case RELOAD_REQUIRED:
protected ModelNode executeReadOnlyOperation(final ModelNode operation, final ManagementModelImpl model, final OperationTransactionControl control, final OperationStepHandler prepareStep, AbstractOperationContext delegateContext) { final ModelNode response = new ModelNode(); @SuppressWarnings("deprecation") final int operationId = CurrentOperationIdHolder.getCurrentOperationID(); final OperationTransactionControl txControl = control == null ? null : new OperationTransactionControl() { @Override public void operationPrepared(OperationTransaction transaction, ModelNode result) { control.operationPrepared(transaction, response); } }; // Use a read-only context final ReadOnlyContext context = new ReadOnlyContext(processType, runningModeControl.getRunningMode(), txControl, processState, false, model, delegateContext, this, operationId, securityIdentitySupplier); context.addStep(response, operation, prepareStep, OperationContext.Stage.MODEL); context.executeOperation(); if (!response.hasDefined(RESPONSE_HEADERS) || !response.get(RESPONSE_HEADERS).hasDefined(PROCESS_STATE)) { ControlledProcessState.State state = processState.getState(); switch (state) { case RELOAD_REQUIRED: case RESTART_REQUIRED: response.get(RESPONSE_HEADERS, PROCESS_STATE).set(state.toString()); break; default: break; } } return response; }
@Override public final void revertRestartRequired() { processState.revertRestartRequired(this.activeStep.restartStamp); if (activeStep.response.get(RESPONSE_HEADERS).hasDefined(OPERATION_REQUIRES_RESTART)) { activeStep.response.get(RESPONSE_HEADERS).remove(OPERATION_REQUIRES_RESTART); if (activeStep.response.get(RESPONSE_HEADERS).asInt() == 0) { activeStep.response.remove(RESPONSE_HEADERS); } } }
@Override public ControlledProcessState.State getProcessState() { return processState.getState(); }
if (!failed && ps.getState() == ControlledProcessState.State.RUNNING) { suspend(sc); ps.setStopping();
controller = null; stabilityMonitor = null; processState.setStopping(); Runnable r = new Runnable() { @Override processState.setStopped(); context.asynchronous();
@Override public void start(StartContext context) throws StartException { processState.setStarting();
public void revertReloadRequired(Object stamp) { if (!reloadSupported) { revertRestartRequired(stamp); } // If 'state' still has the state we last set in restartRequired(), change to RUNNING Integer theirStamp = Integer.class.cast(stamp); synchronized (service) { if (state.compareAndSet(State.RELOAD_REQUIRED, State.RUNNING, theirStamp, this.stamp.incrementAndGet())) { service.stateChanged(State.RUNNING); } } }
public static ServiceController<ControlledProcessStateService> addService(ServiceTarget target, ControlledProcessState processState) { ControlledProcessStateService service = processState.getService(); return target.addService(SERVICE_NAME, service).install(); }
final ModelNode headers = operation.has(OPERATION_HEADERS) ? operation.get(OPERATION_HEADERS) : null; final boolean rollbackOnFailure = headers == null || !headers.hasDefined(ROLLBACK_ON_RUNTIME_FAILURE) || headers.get(ROLLBACK_ON_RUNTIME_FAILURE).asBoolean(); final EnumSet<OperationContextImpl.ContextFlag> contextFlags = rollbackOnFailure ? EnumSet.of(OperationContextImpl.ContextFlag.ROLLBACK_ON_FAIL) : EnumSet.noneOf(OperationContextImpl.ContextFlag.class); final boolean restartResourceServices = headers != null && headers.hasDefined(ALLOW_RESOURCE_SERVICE_RESTART) && headers.get(ALLOW_RESOURCE_SERVICE_RESTART).asBoolean(); if (!response.hasDefined(RESPONSE_HEADERS) || !response.get(RESPONSE_HEADERS).hasDefined(PROCESS_STATE)) { ControlledProcessState.State state = processState.getState(); switch (state) { case RELOAD_REQUIRED:
protected ModelNode executeReadOnlyOperation(final ModelNode operation, final ManagementModelImpl model, final OperationTransactionControl control, final OperationStepHandler prepareStep, AbstractOperationContext delegateContext) { final ModelNode response = new ModelNode(); @SuppressWarnings("deprecation") final int operationId = CurrentOperationIdHolder.getCurrentOperationID(); final OperationTransactionControl txControl = control == null ? null : new OperationTransactionControl() { @Override public void operationPrepared(OperationTransaction transaction, ModelNode result) { control.operationPrepared(transaction, response); } }; // Use a read-only context final ReadOnlyContext context = new ReadOnlyContext(processType, runningModeControl.getRunningMode(), txControl, processState, false, model, delegateContext, this, operationId, securityIdentitySupplier); context.addStep(response, operation, prepareStep, OperationContext.Stage.MODEL); context.executeOperation(); if (!response.hasDefined(RESPONSE_HEADERS) || !response.get(RESPONSE_HEADERS).hasDefined(PROCESS_STATE)) { ControlledProcessState.State state = processState.getState(); switch (state) { case RELOAD_REQUIRED: case RESTART_REQUIRED: response.get(RESPONSE_HEADERS, PROCESS_STATE).set(state.toString()); break; default: break; } } return response; }
@Override public final void revertReloadRequired() { if (processState.isReloadSupported()) { processState.revertReloadRequired(this.activeStep.restartStamp); if (activeStep.response.get(RESPONSE_HEADERS).hasDefined(OPERATION_REQUIRES_RELOAD)) { activeStep.response.get(RESPONSE_HEADERS).remove(OPERATION_REQUIRES_RELOAD); if (activeStep.response.get(RESPONSE_HEADERS).asInt() == 0) { activeStep.response.remove(RESPONSE_HEADERS); } } } else { revertRestartRequired(); } }
@Override public final void revertRestartRequired() { processState.revertRestartRequired(this.activeStep.restartStamp); if (activeStep.response.get(RESPONSE_HEADERS).hasDefined(OPERATION_REQUIRES_RESTART)) { activeStep.response.get(RESPONSE_HEADERS).remove(OPERATION_REQUIRES_RESTART); if (activeStep.response.get(RESPONSE_HEADERS).asInt() == 0) { activeStep.response.remove(RESPONSE_HEADERS); } } }
@Override public final void reloadRequired() { if (processState.isReloadSupported()) { activeStep.restartStamp = processState.setReloadRequired(); activeStep.response.get(RESPONSE_HEADERS, OPERATION_REQUIRES_RELOAD).set(true); } else { restartRequired(); } }