예제 #1
0
  @Override
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {

    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final PathElement element = address.getLastElement();
    final String serverName = element.getValue();

    final ModelNode subModel = context.readModel(PathAddress.EMPTY_ADDRESS);
    final boolean isStart;
    if (subModel.hasDefined(AUTO_START)) {
      isStart = subModel.get(AUTO_START).asBoolean();
    } else {
      isStart = true;
    }

    ServerStatus status = serverInventory.determineServerStatus(serverName);

    if (status == ServerStatus.STOPPED) {
      status = isStart ? status : ServerStatus.DISABLED;
    }

    if (status != null) {
      context.getResult().set(status.toString());
      context.completeStep();
    } else {
      throw new OperationFailedException(new ModelNode().set("Failed to get server status"));
    }
  }
예제 #2
0
 public void execute(OperationContext context, ModelNode operation)
     throws OperationFailedException {
   ModelNode model = context.readModel(PathAddress.EMPTY_ADDRESS);
   context
       .getResult()
       .add(createAddOperation(model.require(CommonAttributes.DEFAULT_DATASOURCE).asString()));
   context.completeStep();
 }
예제 #3
0
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
    final List<byte[]> removedHashes = DeploymentUtils.getDeploymentHash(resource);

    final ModelNode model = context.readModel(PathAddress.EMPTY_ADDRESS);

    context.removeResource(PathAddress.EMPTY_ADDRESS);

    if (context.getType() == OperationContext.Type.SERVER) {
      context.addStep(
          new OperationStepHandler() {
            public void execute(OperationContext context, ModelNode operation)
                throws OperationFailedException {
              String deploymentUnitName = null;

              boolean enabled = model.hasDefined(ENABLED) ? model.get(ENABLED).asBoolean() : true;
              if (enabled) {
                final ModelNode opAddr = operation.get(OP_ADDR);
                final PathAddress address = PathAddress.pathAddress(opAddr);
                final String name = address.getLastElement().getValue();
                deploymentUnitName =
                    model.hasDefined(RUNTIME_NAME) ? model.get(RUNTIME_NAME).asString() : name;
                final ServiceName deploymentUnitServiceName =
                    Services.deploymentUnitName(deploymentUnitName);
                context.removeService(deploymentUnitServiceName);
                context.removeService(deploymentUnitServiceName.append("contents"));
              }
              if (context.completeStep() == OperationContext.ResultAction.ROLLBACK) {
                recoverServices(context, operation, model);

                if (enabled && context.hasFailureDescription()) {
                  ServerLogger.ROOT_LOGGER.undeploymentRolledBack(
                      deploymentUnitName, context.getFailureDescription().asString());
                } else if (enabled) {
                  ServerLogger.ROOT_LOGGER.undeploymentRolledBackWithNoMessage(deploymentUnitName);
                }
              } else {
                if (enabled) {
                  ServerLogger.ROOT_LOGGER.deploymentUndeployed(deploymentUnitName);
                }
                if (standalone) {
                  for (byte[] hash : removedHashes) {
                    try {
                      contentRepository.removeContent(hash);
                    } catch (Exception e) {
                      // TODO
                      log.infof(e, "Exception occurred removing %s", hash);
                    }
                  }
                }
              }
            }
          },
          OperationContext.Stage.RUNTIME);
    }
    context.completeStep();
  }
예제 #4
0
  @Override
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {

    final ModelNode subModel = context.readModel(PathAddress.EMPTY_ADDRESS);
    boolean master =
        subModel
            .get(ModelDescriptionConstants.DOMAIN_CONTROLLER)
            .hasDefined(ModelDescriptionConstants.LOCAL);
    context.getResult().set(master);
    context.completeStep();
  }
예제 #5
0
    public void execute(OperationContext context, ModelNode operation)
        throws OperationFailedException {
      final ModelNode add = createEmptyAddOperation();
      final ModelNode model = context.readModel(PathAddress.EMPTY_ADDRESS);

      if (model.hasDefined(BEAN_VALIDATION_ENABLED)) {
        add.get(BEAN_VALIDATION_ENABLED).set(model.get(BEAN_VALIDATION_ENABLED));
      }
      if (model.hasDefined(ARCHIVE_VALIDATION_ENABLED)) {
        add.get(ARCHIVE_VALIDATION_ENABLED).set(model.get(ARCHIVE_VALIDATION_ENABLED));
      }
      if (model.hasDefined(ARCHIVE_VALIDATION_FAIL_ON_ERROR)) {
        add.get(ARCHIVE_VALIDATION_FAIL_ON_ERROR).set(model.get(ARCHIVE_VALIDATION_FAIL_ON_ERROR));
      }
      if (model.hasDefined(ARCHIVE_VALIDATION_FAIL_ON_WARN)) {
        add.get(ARCHIVE_VALIDATION_FAIL_ON_WARN).set(model.get(ARCHIVE_VALIDATION_FAIL_ON_WARN));
      }
      if (model.hasDefined(CACHED_CONNECTION_MANAGER_DEBUG)) {
        add.get(CACHED_CONNECTION_MANAGER_DEBUG).set(model.get(CACHED_CONNECTION_MANAGER_DEBUG));
      }
      if (model.hasDefined(CACHED_CONNECTION_MANAGER_ERROR)) {
        add.get(CACHED_CONNECTION_MANAGER_ERROR).set(model.get(CACHED_CONNECTION_MANAGER_ERROR));
      }

      final ModelNode result = context.getResult();
      result.add(add);

      if (model.hasDefined(THREAD_POOL)) {
        ModelNode pools = model.get(THREAD_POOL);
        for (Property poolProp : pools.asPropertyList()) {
          if (poolProp.getName().equals(LONG_RUNNING_THREADS)) {
            addBoundedQueueThreadPool(
                result,
                poolProp.getValue(),
                PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME),
                PathElement.pathElement(THREAD_POOL, LONG_RUNNING_THREADS));
          } else if (poolProp.getName().equals(SHORT_RUNNING_THREADS)) {
            addBoundedQueueThreadPool(
                result,
                poolProp.getValue(),
                PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME),
                PathElement.pathElement(THREAD_POOL, SHORT_RUNNING_THREADS));
          }
        }
      }

      context.completeStep();
    }