Java Code Examples for org.jboss.as.controller.OperationContext#isBooting()

The following examples show how to use org.jboss.as.controller.OperationContext#isBooting() . 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: DomainControllerWriteAttributeHandler.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 {
    super.execute(context, operation);
    final ModelNode model = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();
    ModelNode dc = model.get(DOMAIN_CONTROLLER);
    if (operation.hasDefined(VALUE, LOCAL)) {
        dc.get(LOCAL).setEmptyObject();
        if (dc.has(REMOTE)) {
            dc.remove(REMOTE);
        }
        if (context.isBooting()) {
            initializeLocalDomain(null);
        }
    } else if (operation.hasDefined(VALUE, REMOTE)) {
        if (dc.has(LOCAL)) {
            dc.remove(LOCAL);
        }
        final ModelNode remoteDC = dc.get(REMOTE);
        secureRemoteDomain(context, operation, remoteDC);
        if (context.isBooting()) {
            initializeRemoteDomain(context, remoteDC);
        }
    }
}
 
Example 2
Source File: PrepareStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void executeDirectOperation(OperationContext context, ModelNode operation, boolean checkPrivate) throws OperationFailedException {
    final String operationName =  operation.require(OP).asString();

    final ImmutableManagementResourceRegistration registration = context.getResourceRegistration();
    PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
    final OperationEntry stepEntry = context.getRootResourceRegistration().getOperationEntry(pathAddress, operationName);
    if (stepEntry != null) {
        boolean illegalPrivateStep = checkPrivate
                && stepEntry.getType() == OperationEntry.EntryType.PRIVATE
                && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE)
                && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString());
        if (illegalPrivateStep) {
            context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
        } else {
            context.addModelStep(stepEntry.getOperationDefinition(), stepEntry.getOperationHandler(), false);
        }
    } else {
        if (! context.isBooting()) {
            if (registration == null) {
                context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noSuchResourceType(pathAddress));
            } else {
                context.getFailureDescription().set(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
            }
        }
    }
}
 
Example 3
Source File: DeploymentHandlerUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static byte[] addFromHash(ContentRepository contentRepository, ModelNode contentItemNode, String deploymentName, PathAddress address, OperationContext context) throws OperationFailedException {
    byte[] hash = contentItemNode.require(CONTENT_HASH.getName()).asBytes();
    ContentReference reference = ModelContentReference.fromModelAddress(address, hash);
    if (!contentRepository.syncContent(reference)) {
        if (context.isBooting()) {
            if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
                // The deployment content is missing, which would be a fatal boot error if we were going to actually
                // install services. In ADMIN-ONLY mode we allow it to give the admin a chance to correct the problem
                ServerLogger.ROOT_LOGGER.reportAdminOnlyMissingDeploymentContent(reference.getHexHash(), deploymentName);
            } else {
                throw ServerLogger.ROOT_LOGGER.noSuchDeploymentContentAtBoot(reference.getHexHash(), deploymentName);
            }
        } else {
            throw ServerLogger.ROOT_LOGGER.noSuchDeploymentContent(reference.getHexHash());
        }
    }
    return hash;
}
 
Example 4
Source File: AbstractDeploymentChainStep.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public final void execute(final OperationContext context, final ModelNode operation) {
    if (context.isBooting()) {
        execute(TARGET);
    } else {
        // WFCORE-1781 We should not be called post-boot as the DUP chain can only be modified in boot
        // Check and see if the OperationDefinition for this op declares reload/restart required and if so
        // trigger that; otherwise fail.
        ImmutableManagementResourceRegistration mrr = context.getResourceRegistration();
        OperationEntry oe = mrr.getOperationEntry(PathAddress.EMPTY_ADDRESS, operation.get(ModelDescriptionConstants.OP).asString());
        Set<OperationEntry.Flag> flags = oe == null ? Collections.emptySet() : oe.getOperationDefinition().getFlags();
        if (flags.contains(OperationEntry.Flag.RESTART_JVM)) {
            context.restartRequired();
            context.completeStep((ctx, op) -> ctx.revertRestartRequired());
        } else if (flags.contains(OperationEntry.Flag.RESTART_ALL_SERVICES)) {
            context.reloadRequired();
            context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
        } else {
            // Coding error we cannot recover from
            throw new IllegalStateException();
        }
    }
}
 
Example 5
Source File: PrepareStepHandler.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 {

    if (context.isBooting()) {
        executeDirect(context, operation);
    } else if (operation.hasDefined(OPERATION_HEADERS)
            && operation.get(OPERATION_HEADERS).hasDefined(EXECUTE_FOR_COORDINATOR)
            && operation.get(OPERATION_HEADERS).get(EXECUTE_FOR_COORDINATOR).asBoolean()) {
        // Coordinator wants us to execute locally and send result including the steps needed for execution on the servers
        slaveHandler.execute(context, operation);
    } else {
        // Assign a unique id to this operation to allow tying together of audit logs from various hosts/servers
        // impacted by it

        if (isServerOperation(operation)) {
            // Pass direct requests for the server through whether they come from the master or not
            // First, attach a domainUUID for audit logging
            configureDomainUUID(operation);
            executeDirect(context, operation);
        } else {
            coordinatorHandler.execute(context, operation);
        }
    }
}
 
Example 6
Source File: SecurityRealmAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    // Install another RUNTIME handler to actually install the services. This will run after the
    // RUNTIME handler for any child resources. Doing this will ensure that child resource handlers don't
    // see the installed services and can just ignore doing any RUNTIME stage work
    if(!context.isBooting() && context.getProcessType() == ProcessType.EMBEDDED_SERVER && context.getRunningMode() == RunningMode.ADMIN_ONLY) {
        context.reloadRequired();
    } else {
        context.addStep(ServiceInstallStepHandler.INSTANCE, OperationContext.Stage.RUNTIME);
    }
}
 
Example 7
Source File: OperationSlaveStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Directly handles the op in the standard way the default prepare step handler would
 * @param context the operation execution context
 * @param operation the operation
 * @throws OperationFailedException if no handler is registered for the operation
 */
private void addBasicStep(OperationContext context, ModelNode operation, ModelNode localReponse) throws OperationFailedException {
    final String operationName = operation.require(OP).asString();
    final PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
    final OperationEntry entry = context.getRootResourceRegistration().getOperationEntry(pathAddress, operationName);
    if (entry != null) {
        if (!context.isBooting()
                && entry.getType() == OperationEntry.EntryType.PRIVATE
                && operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE)
                && USER.equals(operation.get(OPERATION_HEADERS, CALLER_TYPE).asString())) {
            throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
        }
        if (context.isBooting() || localHostControllerInfo.isMasterDomainController()) {
            context.addModelStep(localReponse, operation, entry.getOperationDefinition(), entry.getOperationHandler(), false);
        } else {
            final OperationStepHandler wrapper;
            // For slave host controllers wrap the operation handler to synchronize missing configuration
            // TODO better configuration of ignore unaffected configuration
            if (localHostControllerInfo.isRemoteDomainControllerIgnoreUnaffectedConfiguration()) {
                final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
                wrapper = SyncModelOperationHandlerWrapper.wrapHandler(localHostControllerInfo.getLocalHostName(), operationName, address, entry);
            } else {
                wrapper = entry.getOperationHandler();
            }
            context.addModelStep(localReponse, operation, entry.getOperationDefinition(), wrapper, false);
        }
    } else {
        throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.noHandlerForOperation(operationName, pathAddress));
    }
}
 
Example 8
Source File: StaticDiscoveryAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    if (context.isBooting()) {
        populateHostControllerInfo(hostControllerInfo, context, operation);
    } else {
        context.reloadRequired();
    }
}
 
Example 9
Source File: DomainModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public HostControllerInfo getHostControllerInfo(OperationContext context) throws OperationFailedException {
    if (context.isBooting() && context.getCurrentStage() == OperationContext.Stage.MODEL) {
        throw ControllerLogger.ROOT_LOGGER.onlyAccessHostControllerInfoInRuntimeStage();
    }
    return new HostControllerInfo() {
        public boolean isMasterHc() {
            return hostControllerInfo.isMasterDomainController();
        }
    };
}
 
Example 10
Source File: SetServerGroupHostHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (!context.isBooting()) {
        throw new IllegalStateException();
    }

    ModelNode model = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();

    ServerRootResourceDefinition.SERVER_GROUP.validateAndSet(operation, model);
    ServerRootResourceDefinition.HOST.validateAndSet(operation, model);
}
 
Example 11
Source File: AccessAuthorizationProviderWriteAttributeHander.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
        ModelNode resolvedValue, ModelNode currentValue,
        org.jboss.as.controller.AbstractWriteAttributeHandler.HandbackHolder<Void> handbackHolder)
        throws OperationFailedException {
    if (!resolvedValue.equals(currentValue)) {
        if (!context.isBooting()) {
            return true;
        }
        updateAuthorizer(resolvedValue, configurableAuthorizer);
    }

    return false;
}
 
Example 12
Source File: AccessAuthorizationUseIdentityRolesWriteAttributeHander.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
        ModelNode resolvedValue, ModelNode currentValue,
        org.jboss.as.controller.AbstractWriteAttributeHandler.HandbackHolder<Void> handbackHolder)
        throws OperationFailedException {
    if (!resolvedValue.equals(currentValue)) {
        if (!context.isBooting()) {
            return true;
        }
        updateAuthorizer(resolvedValue, writableConfiguration);
    }

    return false;
}
 
Example 13
Source File: SecurityRealmChildRemoveHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
    // verify that the resource exist before removing it
    context.readResource(PathAddress.EMPTY_ADDRESS, false);
    Resource resource = context.removeResource(PathAddress.EMPTY_ADDRESS);
    recordCapabilitiesAndRequirements(context, operation, resource);

    if (validateAuthentication && !context.isBooting()) {
        ModelNode validationOp = AuthenticationValidatingHandler.createOperation(operation);
        context.addStep(validationOp, AuthenticationValidatingHandler.INSTANCE, OperationContext.Stage.MODEL);
    } // else we know the SecurityRealmAddHandler is part of this overall set of ops and it added AuthenticationValidatingHandler
}
 
Example 14
Source File: AccessIdentityResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected boolean requiresRuntime(OperationContext context) {
    return context.isBooting() == false;
}
 
Example 15
Source File: StaticDiscoveryWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected boolean requiresRuntime(OperationContext context) {
    // HCs may connect to the in either RunningMode.NORMAL or ADMIN_ONLY,
    // so the running mode doesn't figure in whether reload is required
    return !context.isBooting();
}
 
Example 16
Source File: DiscoveryWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected boolean requiresRuntime(OperationContext context) {
    // HCs may connect to the in either RunningMode.NORMAL or ADMIN_ONLY,
    // so the running mode doesn't figure in whether reload is required
    return !context.isBooting();
}
 
Example 17
Source File: SyncModelOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
OrderedOperationsCollection(OperationContext context) {
    this.booting = context.isBooting();
}
 
Example 18
Source File: SyslogAuditLogProtocolResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected boolean requiresRuntime(OperationContext context) {
    //On boot, the parent add will pick up these changes
    return !context.isBooting();
}
 
Example 19
Source File: ManagementInterfaceAddStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void addVerifyInstallationStep(OperationContext context, List<ServiceName> requiredServices) {
    if(context.isBooting()) {
        context.addStep(new LenientVerifyInstallationStep(requiredServices), OperationContext.Stage.VERIFY);
    }
}
 
Example 20
Source File: ManagementWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected boolean requiresRuntime(OperationContext context) {
    // Management interfaces run in all modes including ADMIN_ONLY
    return !context.isBooting();
}