Esempio n. 1
0
  /**
   * [AS7-5850] Core queues created with ActiveMQ API does not create WildFly resources
   *
   * <p>For backwards compatibility if an operation is invoked on a queue that has no corresponding
   * resources, we forward the operation to the corresponding runtime-queue resource (which *does*
   * exist).
   *
   * @return true if the operation is forwarded to the corresponding runtime-queue resource, false
   *     else.
   */
  static boolean forwardToRuntimeQueue(
      OperationContext context, ModelNode operation, OperationStepHandler handler) {
    PathAddress address =
        PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));

    // do not forward if the current operation is for a runtime-queue already:
    if (RUNTIME_QUEUE.equals(address.getLastElement().getKey())) {
      return false;
    }

    String queueName = address.getLastElement().getValue();

    PathAddress activeMQPathAddress = MessagingServices.getActiveMQServerPathAddress(address);
    Resource serverResource = context.readResourceFromRoot(activeMQPathAddress);
    boolean hasChild = serverResource.hasChild(address.getLastElement());
    if (hasChild) {
      return false;
    } else {
      // there is no registered queue resource, forward to the runtime-queue address instead
      ModelNode forwardOperation = operation.clone();
      forwardOperation
          .get(ModelDescriptionConstants.OP_ADDR)
          .set(activeMQPathAddress.append(RUNTIME_QUEUE, queueName).toModelNode());
      context.addStep(forwardOperation, handler, OperationContext.Stage.RUNTIME, true);
      return true;
    }
  }
Esempio n. 2
0
  void removeRuntimeServices(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {
    // get container and cache addresses
    final PathAddress cacheAddress = getCacheAddressFromOperation(operation);
    final PathAddress containerAddress = getCacheContainerAddressFromOperation(operation);
    // get container and cache names
    final String cacheName = cacheAddress.getLastElement().getValue();
    final String containerName = containerAddress.getLastElement().getValue();

    // remove all services started by CacheAdd, in reverse order
    // remove the binder service
    ModelNode resolvedValue = null;
    final String jndiNameString =
        (resolvedValue = CommonAttributes.JNDI_NAME.resolveModelAttribute(context, model))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    final String jndiName =
        InfinispanJndiName.createCacheJndiNameOrDefault(jndiNameString, containerName, cacheName);
    ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
    context.removeService(bindInfo.getBinderServiceName());
    // remove the CacheService instance
    context.removeService(CacheService.getServiceName(containerName, cacheName));
    // remove the cache configuration service
    context.removeService(CacheConfigurationService.getServiceName(containerName, cacheName));

    log.debugf("cache %s removed for container %s", cacheName, containerName);
  }
 @Override
 public int compare(final PathAddress o1, final PathAddress o2) {
   final String key1 = o1.getLastElement().getKey();
   final String key2 = o2.getLastElement().getKey();
   int result = key1.compareTo(key2);
   if (result != EQUAL) {
     if (LoggingProfileOperations.isLoggingProfileAddress(o1)
         && !LoggingProfileOperations.isLoggingProfileAddress(o2)) {
       result = GREATER;
     } else if (!LoggingProfileOperations.isLoggingProfileAddress(o1)
         && LoggingProfileOperations.isLoggingProfileAddress(o2)) {
       result = LESS;
     } else if (LoggingProfileOperations.isLoggingProfileAddress(o1)
         && LoggingProfileOperations.isLoggingProfileAddress(o2)) {
       if (CommonAttributes.LOGGING_PROFILE.equals(key1)
           && !CommonAttributes.LOGGING_PROFILE.equals(key2)) {
         result = LESS;
       } else if (!CommonAttributes.LOGGING_PROFILE.equals(key1)
           && CommonAttributes.LOGGING_PROFILE.equals(key2)) {
         result = GREATER;
       } else {
         result = compare(key1, key2);
       }
     } else {
       result = compare(key1, key2);
     }
   }
   return result;
 }
 @Override
 public RuntimeCapability<Void> resolve(PathAddress address) {
   PathAddress cacheAddress = address.getParent();
   PathAddress containerAddress = cacheAddress.getParent();
   return this.definition.fromBaseCapability(
       containerAddress.getLastElement().getValue()
           + "."
           + cacheAddress.getLastElement().getValue());
 }
Esempio n. 5
0
  @Override
  protected void performRuntime(
      OperationContext context,
      ModelNode operation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final PathAddress parent = address.subAddress(0, address.size() - 1);
    String name = address.getLastElement().getValue();
    String bindingRef =
        ListenerResourceDefinition.SOCKET_BINDING.resolveModelAttribute(context, model).asString();
    String workerName =
        ListenerResourceDefinition.WORKER.resolveModelAttribute(context, model).asString();
    String bufferPoolName =
        ListenerResourceDefinition.BUFFER_POOL.resolveModelAttribute(context, model).asString();
    boolean enabled =
        ListenerResourceDefinition.ENABLED.resolveModelAttribute(context, model).asBoolean();
    OptionMap listenerOptions =
        OptionList.resolveOptions(context, model, ListenerResourceDefinition.LISTENER_OPTIONS);
    OptionMap socketOptions =
        OptionList.resolveOptions(context, model, ListenerResourceDefinition.SOCKET_OPTIONS);
    String serverName = parent.getLastElement().getValue();
    final ServiceName listenerServiceName = UndertowService.listenerName(name);
    final ListenerService<? extends ListenerService> service =
        createService(name, serverName, context, model, listenerOptions, socketOptions);
    final ServiceBuilder<? extends ListenerService> serviceBuilder =
        context.getServiceTarget().addService(listenerServiceName, service);
    serviceBuilder
        .addDependency(IOServices.WORKER.append(workerName), XnioWorker.class, service.getWorker())
        .addDependency(
            SocketBinding.JBOSS_BINDING_NAME.append(bindingRef),
            SocketBinding.class,
            service.getBinding())
        .addDependency(
            IOServices.BUFFER_POOL.append(bufferPoolName), Pool.class, service.getBufferPool())
        .addDependency(
            UndertowService.SERVER.append(serverName), Server.class, service.getServerService());

    configureAdditionalDependencies(context, serviceBuilder, model, service);
    serviceBuilder.setInitialMode(
        enabled ? ServiceController.Mode.ACTIVE : ServiceController.Mode.NEVER);

    serviceBuilder.addListener(verificationHandler);
    final ServiceController<? extends ListenerService> serviceController = serviceBuilder.install();
    if (newControllers != null) {
      newControllers.add(serviceController);
    }
  }
Esempio n. 6
0
  void removeRuntimeServices(
      OperationContext context, ModelNode operation, ModelNode containerModel, ModelNode cacheModel)
      throws OperationFailedException {
    // get container and cache addresses
    final PathAddress cacheAddress = getCacheAddressFromOperation(operation);
    final PathAddress containerAddress = getCacheContainerAddressFromOperation(operation);

    // get container and cache names
    final String cacheName = cacheAddress.getLastElement().getValue();
    final String containerName = containerAddress.getLastElement().getValue();

    // remove all services started by CacheAdd, in reverse order
    // remove the binder service
    ModelNode resolvedValue = null;
    final String jndiName =
        (resolvedValue =
                    CacheResourceDefinition.JNDI_NAME.resolveModelAttribute(context, cacheModel))
                .isDefined()
            ? resolvedValue.asString()
            : null;

    String defaultCacheName =
        CacheContainerResourceDefinition.DEFAULT_CACHE
            .resolveModelAttribute(context, containerModel)
            .asString();
    boolean defaultCache = cacheName.equals(defaultCacheName);

    ContextNames.BindInfo binding =
        createCacheBinding(
            (jndiName != null)
                ? JndiNameFactory.parse(jndiName)
                : createJndiName(containerName, cacheName));
    context.removeService(binding.getBinderServiceName());
    // remove the CacheService instance
    context.removeService(CacheService.getServiceName(containerName, cacheName));
    // remove the cache configuration service
    context.removeService(CacheConfigurationService.getServiceName(containerName, cacheName));

    for (CacheServiceProvider provider :
        ServiceLoader.load(
            CacheServiceProvider.class, CacheServiceProvider.class.getClassLoader())) {
      for (ServiceName name : provider.getServiceNames(containerName, cacheName, defaultCache)) {
        context.removeService(name);
      }
    }

    log.debugf("cache %s removed for container %s", cacheName, containerName);
  }
Esempio n. 7
0
 @Override
 protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
     throws OperationFailedException {
   final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
   final String name = address.getLastElement().getValue();
   ModClusterService.install(name, context.getServiceTarget(), model, context);
 }
  @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"));
    }
  }
    /** {@inheritDoc} */
    @Override
    public void execute(OperationContext context, ModelNode operation)
        throws OperationFailedException {
      final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
      final PathElement element = address.getLastElement();

      context.addStep(
          new OperationStepHandler() {
            @Override
            public void execute(final OperationContext context, final ModelNode operation)
                throws OperationFailedException {
              final ModelNode result = context.getResult();
              final ServiceController<?> controller =
                  context
                      .getServiceRegistry(false)
                      .getRequiredService(SOCKET_BINDING.append(element.getValue()));
              if (controller != null && controller.getState() == ServiceController.State.UP) {
                final SocketBinding binding = SocketBinding.class.cast(controller.getValue());
                AbstractBindingMetricsHandler.this.execute(operation, binding, result);
              } else {
                result.set(getNoMetrics());
              }

              context.stepCompleted();
            }
          },
          OperationContext.Stage.RUNTIME);

      context.stepCompleted();
    }
 String getServerGroupName(final ModelNode operation) {
   final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
   if (address.size() == 0) {
     return null;
   }
   return address.getLastElement().getValue();
 }
Esempio n. 11
0
  @Override
  protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String name = address.getLastElement().getValue();
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final ServiceName serviceName =
        MessagingServices.getActiveMQServiceName(
            PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));

    final ModelNode selectorNode = SELECTOR.resolveModelAttribute(context, model);
    final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean();

    final String selector = selectorNode.isDefined() ? selectorNode.asString() : null;

    // Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the
    // dependencies from the BinderServices to the JMSQueueService are not broken
    Service<Queue> queueService =
        JMSQueueService.installService(
            name, serviceTarget, serviceName, selector, durable, new String[0]);

    final ModelNode entries =
        CommonAttributes.DESTINATION_ENTRIES.resolveModelAttribute(context, model);
    final ServiceName jmsQueueServiceName =
        JMSServices.getJmsQueueBaseServiceName(serviceName).append(name);
    final String[] jndiBindings = JMSServices.getJndiBindings(entries);
    for (String jndiBinding : jndiBindings) {
      // install a binder service which depends on the JMS queue service
      BinderServiceUtil.installBinderService(
          serviceTarget, jndiBinding, queueService, jmsQueueServiceName);
    }
  }
  public static void createServerAddOperations(
      final List<ModelNode> addOps, final PathAddress protocolAddress, final ModelNode protocol) {
    addOps.add(createProtocolAddOperation(protocolAddress, protocol));

    final SyslogAuditLogHandler.Transport transport =
        SyslogAuditLogHandler.Transport.valueOf(
            protocolAddress.getLastElement().getValue().toUpperCase(Locale.ENGLISH));
    if (transport == SyslogAuditLogHandler.Transport.TLS) {
      if (protocol.hasDefined(AUTHENTICATION)) {
        final ModelNode auth = protocol.get(AUTHENTICATION);
        if (auth.hasDefined(TRUSTSTORE)) {
          addOps.add(
              createKeystoreAddOperation(
                  protocolAddress.append(AUTHENTICATION, TRUSTSTORE),
                  protocol.get(AUTHENTICATION, TRUSTSTORE)));
        }
        if (auth.hasDefined(CLIENT_CERT_STORE)) {
          addOps.add(
              createKeystoreAddOperation(
                  protocolAddress.append(AUTHENTICATION, CLIENT_CERT_STORE),
                  protocol.get(AUTHENTICATION, CLIENT_CERT_STORE)));
        }
      }
    }
  }
Esempio n. 13
0
  @Override
  protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {

    ServiceRegistry registry = context.getServiceRegistry(false);
    final ServiceName serviceName =
        MessagingServices.getActiveMQServiceName(
            PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
      context.reloadRequired();
    } else {
      final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
      final String name = address.getLastElement().getValue();

      final ServiceTarget target = context.getServiceTarget();
      if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
        // nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
      } else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
        final GroupBindingService bindingService = new GroupBindingService();
        target
            .addService(
                GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name),
                bindingService)
            .addDependency(
                SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()),
                SocketBinding.class,
                bindingService.getBindingRef())
            .install();
      }
    }
  }
Esempio n. 14
0
  protected void performRuntime(
      OperationContext context,
      ModelNode operation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String name = address.getLastElement().getValue();
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final ServiceName hqServiceName =
        MessagingServices.getHornetQServiceName(
            PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));

    final ModelNode selectorNode = SELECTOR.resolveModelAttribute(context, model);
    final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean();

    final String selector = selectorNode.isDefined() ? selectorNode.asString() : null;
    final ModelNode entries =
        CommonAttributes.DESTINATION_ENTRIES.resolveModelAttribute(context, model);
    final String[] jndiBindings = JMSServices.getJndiBindings(entries);
    installServices(
        verificationHandler,
        newControllers,
        name,
        serviceTarget,
        hqServiceName,
        selector,
        durable,
        jndiBindings);
  }
  private static DescribedOp getDescribedOp(
      OperationContext context, String operationName, ModelNode operation, boolean lenient)
      throws OperationFailedException {
    DescribedOp result = null;
    OperationEntry operationEntry;
    // First try to get the current resource registration to give authz a chance to reject this
    // request
    ImmutableManagementResourceRegistration registry = context.getResourceRegistration();
    if (registry != null) {
      operationEntry = registry.getOperationEntry(PathAddress.EMPTY_ADDRESS, operationName);
    } else {
      // We know the user is authorized to read this address.
      // There's no MRR at that address, but see if the MRR tree can resolve an operation entry
      // (e.g. an inherited one)
      operationEntry =
          context
              .getRootResourceRegistration()
              .getOperationEntry(context.getCurrentAddress(), operationName);
    }

    if (operationEntry != null) {
      Locale locale = GlobalOperationHandlers.getLocale(context, operation);
      result = new DescribedOp(operationEntry, locale);
    } else if (lenient) {
      // For wildcard elements, check specific registrations where the same OSH is used
      // for all such registrations
      PathAddress address = context.getCurrentAddress();
      if (address.size() > 0) {
        PathElement pe = address.getLastElement();
        if (pe.isWildcard()) {
          ImmutableManagementResourceRegistration rootRegistration =
              context.getRootResourceRegistration();
          String type = pe.getKey();
          PathAddress parent = address.subAddress(0, address.size() - 1);
          Set<PathElement> children = rootRegistration.getChildAddresses(parent);
          if (children != null) {
            Locale locale = GlobalOperationHandlers.getLocale(context, operation);
            DescribedOp found = null;
            for (PathElement child : children) {
              if (type.equals(child.getKey())) {
                OperationEntry oe =
                    rootRegistration.getOperationEntry(parent.append(child), operationName);
                DescribedOp describedOp = oe == null ? null : new DescribedOp(oe, locale);
                if (describedOp == null || (found != null && !found.equals(describedOp))) {
                  // Not all children have the same handler; give up
                  found = null;
                  break;
                }
                // We have a candidate OSH
                found = describedOp;
              }
            }
            result = found;
          }
        }
      }
    }
    return result;
  }
Esempio n. 16
0
 /** {@inheritDoc} */
 public void convertAttribute(
     PathAddress address,
     String name,
     ModelNode attributeValue,
     TransformationContext context) {
   PathElement element = address.getLastElement();
   attributeValue.set(element.getValue());
 }
        public ProxyController getProxyController(PathAddress address) {
          if (address.getLastElement().getKey().equals(SERVER)
              && !address.getLastElement().getValue().equals("server-two")) {
            return new ProxyController() {
              public PathAddress getProxyNodeAddress() {
                return null;
              }

              public void execute(
                  ModelNode operation,
                  OperationMessageHandler handler,
                  ProxyOperationControl control,
                  OperationAttachments attachments) {}
            };
          }
          return null;
        }
 private void assertOperation(
     final ModelNode operation, final String operationName, final PathElement lastElement) {
   assertEquals(operationName, operation.get(OP).asString());
   final PathAddress addr = PathAddress.pathAddress(operation.get(OP_ADDR));
   final PathElement element = addr.getLastElement();
   assertEquals(lastElement.getKey(), element.getKey());
   assertEquals(lastElement.getValue(), element.getValue());
 }
 @Override
 List<ServiceName> servicesToRemove(ModelNode operation, ModelNode model) {
   // Get the service addresses ...
   final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
   // Get the repository name ...
   final String textExtractorName = serviceAddress.getLastElement().getValue();
   return Arrays.asList(
       ModeShapeServiceNames.textExtractorServiceName(
           repositoryName(operation), textExtractorName));
 }
Esempio n. 20
0
  @Override
  protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {

    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String name = address.getLastElement().getValue();

    context.removeService(WSServices.CLIENT_CONFIG_SERVICE.append(name));
    context.reloadRequired();
  }
Esempio n. 21
0
  @Override
  protected void populateModel(ModelNode operation, ModelNode model)
      throws OperationFailedException {
    // the name attribute is required, and can always be found from the operation address
    PathAddress cacheAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
    String cacheName = cacheAddress.getLastElement().getValue();
    model.get(ModelKeys.NAME).set(cacheName);

    this.populateCacheMode(operation, model);
    this.populate(operation, model);
  }
Esempio n. 22
0
  @Override
  protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {
    super.performRuntime(context, operation, model);

    PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    String hornetqServerName = address.getElement(address.size() - 2).getValue();
    String acceptorName = address.getLastElement().getValue();
    final ModelNode fullModel =
        Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));

    launchServices(context, hornetqServerName, acceptorName, fullModel);
  }
 @Override
 protected void performRuntime(
     OperationContext context,
     ModelNode operation,
     ModelNode model,
     final ServiceVerificationHandler verificationHandler,
     final List<ServiceController<?>> newControllers)
     throws OperationFailedException {
   PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
   final String federationName = address.getLastElement().getValue();
   ModelNode partitionManager = Resource.Tools.readModel(context.readResource(EMPTY_ADDRESS));
   createPartitionManagerService(
       context, federationName, partitionManager, verificationHandler, newControllers, false);
 }
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    ModelNode model = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();
    final String deploymentUnitName = RUNTIME_NAME.resolveModelAttribute(context, model).asString();
    model.get(ENABLED.getName()).set(false);

    final ModelNode opAddr = operation.get(OP_ADDR);
    PathAddress address = PathAddress.pathAddress(opAddr);
    final String managementName = address.getLastElement().getValue();

    DeploymentHandlerUtil.undeploy(context, managementName, deploymentUnitName, vaultReader);

    context.stepCompleted();
  }
Esempio n. 25
0
  protected void performRuntime(
      OperationContext context,
      ModelNode operation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    // TODO SASL and properties
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String connectorName = address.getLastElement().getValue();

    final ServiceTarget target = context.getServiceTarget();

    ServiceName socketBindingName =
        SocketBinding.JBOSS_BINDING_NAME.append(
            ConnectorResource.SOCKET_BINDING_ATTRIBUTE.validateOperation(model).asString());
    RemotingServices.installConnectorServicesForSocketBinding(
        target,
        RemotingServices.SUBSYSTEM_ENDPOINT,
        connectorName,
        socketBindingName,
        null,
        null,
        verificationHandler,
        newControllers);

    // TODO AuthenticationHandler
    //
    //        final ConnectorService connectorService = new ConnectorService();
    //        connectorService.setOptionMap(createOptionMap(operation));
    //
    //        // Register the service with the container and inject dependencies.
    //        final ServiceName connectorName = RemotingServices.connectorServiceName(name);
    //        try {
    //            newControllers.add(target.addService(connectorName, connectorService)
    //                    .addDependency(connectorName.append("auth-provider"),
    // ServerAuthenticationProvider.class, connectorService.getAuthenticationProviderInjector())
    //                    .addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class,
    // connectorService.getEndpointInjector())
    //                    .addListener(verificationHandler)
    //                    .setInitialMode(ServiceController.Mode.ACTIVE)
    //                    .install());
    //
    //            // TODO create XNIO connector service from socket-binding, with dependency on
    // connectorName
    //        } catch (ServiceRegistryException e) {
    //            throw new OperationFailedException(new ModelNode().set(e.getLocalizedMessage()));
    //        }
  }
 private void checkNoOtherProtocol(OperationContext context, ModelNode operation)
     throws OperationFailedException {
   PathAddress opAddr = PathAddress.pathAddress(operation.require(OP_ADDR));
   PathAddress addr = opAddr.subAddress(0, opAddr.size() - 1);
   Resource resource = context.readResourceFromRoot(addr);
   Set<ResourceEntry> existing = resource.getChildren(ModelDescriptionConstants.PROTOCOL);
   if (existing.size() > 1) {
     for (ResourceEntry entry : existing) {
       PathElement mine = addr.getLastElement();
       if (!entry.getPathElement().equals(mine)) {
         throw DomainManagementLogger.ROOT_LOGGER.sysLogProtocolAlreadyConfigured(
             addr.append(mine));
       }
     }
   }
 }
Esempio n. 27
0
 @Override
 protected void performRuntime(
     final OperationContext context,
     final ModelNode operation,
     final ModelNode model,
     final ServiceVerificationHandler verificationHandler,
     final List<ServiceController<?>> newControllers)
     throws OperationFailedException {
   final HornetQServer server = getHornetQServer(context, operation);
   if (server != null) {
     final PathAddress address =
         PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
     final AddressSettings settings = createSettings(context, model);
     server.getAddressSettingsRepository().addMatch(address.getLastElement().getValue(), settings);
   }
 }
Esempio n. 28
0
  void removeRuntimeServices(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {

    final PathAddress address = getCacheContainerAddressFromOperation(operation);
    final String containerName = address.getLastElement().getValue();

    // need to remove all container-related services started, in reverse order
    context.removeService(KeyAffinityServiceFactoryService.getServiceName(containerName));

    // remove the BinderService entry
    ModelNode resolvedValue = null;
    final String jndiName =
        (resolvedValue =
                    CacheContainerResourceDefinition.JNDI_NAME.resolveModelAttribute(
                        context, model))
                .isDefined()
            ? resolvedValue.asString()
            : null;
    context.removeService(
        createCacheContainerBinding(jndiName, containerName).getBinderServiceName());

    // remove the cache container
    context.removeService(EmbeddedCacheManagerService.getServiceName(containerName));
    context.removeService(EmbeddedCacheManagerConfigurationService.getServiceName(containerName));
    context.removeService(GlobalComponentRegistryService.getServiceName(containerName));

    // check if a channel was installed
    final ServiceName channelServiceName = ChannelService.getServiceName(containerName);
    final ServiceController<?> channelServiceController =
        context.getServiceRegistry(false).getService(channelServiceName);
    if (channelServiceController != null) {
      for (ChannelServiceProvider provider :
          ServiceLoader.load(
              ChannelServiceProvider.class, ChannelServiceProvider.class.getClassLoader())) {
        for (ServiceName name : provider.getServiceNames(containerName)) {
          context.removeService(name);
        }
      }
      // unregister the protocol metrics by adding a step
      ChannelInstanceResourceDefinition.addChannelProtocolMetricsDeregistrationStep(
          context, containerName);

      context.removeService(createChannelBinding(containerName).getBinderServiceName());
      context.removeService(channelServiceName);
    }
  }
  public static ModelNode createProtocolAddOperation(
      final PathAddress protocolAddress, final ModelNode protocol) {
    ModelNode protocolAdd = Util.createAddOperation(protocolAddress);
    protocolAdd.get(HOST.getName()).set(protocol.get(HOST.getName()));
    protocolAdd.get(PORT.getName()).set(protocol.get(PORT.getName()));

    SyslogAuditLogHandler.Transport transport =
        SyslogAuditLogHandler.Transport.valueOf(
            protocolAddress.getLastElement().getValue().toUpperCase(Locale.ENGLISH));
    if (transport != SyslogAuditLogHandler.Transport.UDP) {
      protocolAdd
          .get(Tcp.MESSAGE_TRANSFER.getName())
          .set(protocol.get(Tcp.MESSAGE_TRANSFER.getName()));
    }

    return protocolAdd;
  }
Esempio n. 30
0
  @Override
  protected List<ModelNode> adjustForVersion(DomainClient client, PathAddress profileAddress)
      throws Exception {
    List<ModelNode> result = super.adjustForVersion(client, profileAddress);

    enableDatasourceStatistics(profileAddress, result);

    if ("full-ha".equals(profileAddress.getLastElement().getValue())) {
      workAroundWFLY2335(profileAddress, result);
    }

    // DO NOT INTRODUCE NEW ADJUSTMENTS HERE WITHOUT SOME SORT OF PUBLIC DISCUSSION.
    // CAREFULLY DOCUMENT IN THIS CLASS WHY ANY ADJUSTMENT IS NEEDED AND IS THE BEST APPROACH.
    // If an adjustment is needed here, that means our users will need to do the same
    // just to get an existing profile to work, and we want to minimize that.

    return result;
  }