Navigation Menu

Skip to content

Commit

Permalink
ISPN-6815 Utilise WFLY capabilities to obtain socket bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanemerson authored and tristantarrant committed Mar 13, 2017
1 parent 0bcfeb2 commit cdea8b5
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
Expand Up @@ -21,6 +21,7 @@
import org.infinispan.server.endpoint.Constants;
import org.jboss.as.controller.Extension;
import org.jboss.as.controller.ExtensionContext;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
Expand All @@ -35,7 +36,6 @@ public class EndpointExtension implements Extension {

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 2;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;
private static final String RESOURCE_NAME = EndpointExtension.class.getPackage().getName() + ".LocalDescriptions";

static ResourceDescriptionResolver getResourceDescriptionResolver(String keyPrefix) {
Expand All @@ -47,7 +47,8 @@ static ResourceDescriptionResolver getResourceDescriptionResolver(String keyPref
public final void initialize(ExtensionContext context) {
final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();

final SubsystemRegistration subsystem = context.registerSubsystem(Constants.SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
final SubsystemRegistration subsystem = context.registerSubsystem(Constants.SUBSYSTEM_NAME,
ModelVersion.create(MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION));
subsystem.registerSubsystemModel(new EndpointSubsystemRootResource(registerRuntimeOnly));
subsystem.registerXMLElementWriter(new EndpointSubsystemWriter());
}
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.server.infinispan.spi.service.CacheContainerServiceName;
import org.infinispan.server.infinispan.spi.service.CacheServiceName;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.core.security.ServerSecurityManager;
Expand Down Expand Up @@ -92,11 +93,12 @@ public static void addRestDependency(ServiceBuilder<?> builder, String protocolS
builder.addDependency(protocolServerServiceName, NettyRestServer.class, target);
}

public static void addSocketBindingDependency(ServiceBuilder<?> builder, String socketBindingName, InjectedValue<SocketBinding> target) {
public static void addSocketBindingDependency(OperationContext context, ServiceBuilder<?> builder, String socketBindingName,
InjectedValue<SocketBinding> target) {
// socket binding can be disabled in multi tenant router scenarios
if(socketBindingName != null) {
ServiceName socketName = SocketBinding.JBOSS_BINDING_NAME.append(socketBindingName);
builder.addDependency(socketName, SocketBinding.class, target);
ServiceName serviceName = context.getCapabilityServiceName(ProtocolServerConnectorResource.SOCKET_CAPABILITY_NAME, socketBindingName, SocketBinding.class);
builder.addDependency(serviceName, SocketBinding.class, target);
}
}

Expand Down
Expand Up @@ -78,7 +78,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
EndpointUtils.addCacheContainerConfigurationDependency(builder, cacheContainerName, service.getCacheManagerConfiguration());
EndpointUtils.addCacheContainerDependency(builder, cacheContainerName, service.getCacheManager());
EndpointUtils.addCacheDependency(builder, cacheContainerName, null);
EndpointUtils.addSocketBindingDependency(builder, getSocketBindingName(operation), service.getSocketBinding());
EndpointUtils.addSocketBindingDependency(context, builder, getSocketBindingName(operation), service.getSocketBinding());

EncryptableSubsystemHelper.processEncryption(context, config, service, builder);
processAuthentication(context, configurationBuilder, service, builder, config);
Expand Down
Expand Up @@ -69,7 +69,8 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
EndpointUtils.addCacheContainerDependency(builder, cacheContainerName, service.getCacheManager());
EndpointUtils.addCacheDependency(builder, cacheContainerName, cacheName);
EndpointUtils.addCacheDependency(builder, cacheContainerName, null);
EndpointUtils.addSocketBindingDependency(builder, getSocketBindingName(operation), service.getSocketBinding());
EndpointUtils.addSocketBindingDependency(context, builder, getSocketBindingName(operation), service.getSocketBinding());

builder.install();
}

Expand Down
Expand Up @@ -18,23 +18,30 @@
*/
package org.infinispan.server.endpoint.subsystem;

import org.infinispan.server.endpoint.Constants;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

public class ProtocolServerConnectorResource extends CommonConnectorResource {

static final String SOCKET_CAPABILITY_NAME = "org.wildfly.network.socket-binding";
private static final RuntimeCapability<Void> CONNECTOR_CAPABILITY =
RuntimeCapability.Builder.of(Constants.DATAGRID.getCanonicalName(), true).build();

static final SimpleAttributeDefinition SOCKET_BINDING =
new SimpleAttributeDefinitionBuilder(ModelKeys.SOCKET_BINDING, ModelType.STRING, true)
.setAllowExpression(true)
.setXmlName(ModelKeys.SOCKET_BINDING)
.setCapabilityReference(SOCKET_CAPABILITY_NAME, CONNECTOR_CAPABILITY)
.setRestartAllServices()
.build();

Expand Down
Expand Up @@ -72,7 +72,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
String cacheContainerName = config.hasDefined(ModelKeys.CACHE_CONTAINER) ? config.get(ModelKeys.CACHE_CONTAINER).asString() : null;
EndpointUtils.addCacheContainerDependency(builder, cacheContainerName, service.getCacheManager());
EndpointUtils.addCacheDependency(builder, cacheContainerName, null);
EndpointUtils.addSocketBindingDependency(builder, getSocketBindingName(operation), service.getSocketBinding());
EndpointUtils.addSocketBindingDependency(context, builder, getSocketBindingName(operation), service.getSocketBinding());

builder.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, service.getPathManagerInjector());

Expand Down
Expand Up @@ -52,8 +52,8 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod

final ServiceName MultitenantRouterServiceName = EndpointUtils.getServiceName(operation, "router");
ServiceBuilder<?> builder = context.getServiceTarget().addService(MultitenantRouterServiceName, routerService);
EndpointUtils.addSocketBindingDependency(builder, operation.get(ModelKeys.HOTROD_SOCKET_BINDING).asString(), routerService.getHotrodSocketBinding());
EndpointUtils.addSocketBindingDependency(builder, operation.get(ModelKeys.REST_SOCKET_BINDING).asString(), routerService.getRestSocketBinding());
EndpointUtils.addSocketBindingDependency(context, builder, operation.get(ModelKeys.HOTROD_SOCKET_BINDING).asString(), routerService.getHotrodSocketBinding());
EndpointUtils.addSocketBindingDependency(context, builder, operation.get(ModelKeys.REST_SOCKET_BINDING).asString(), routerService.getRestSocketBinding());

ModelNode multiTenancyInnerConfiguration = config.get(ModelKeys.MULTI_TENANCY, ModelKeys.MULTI_TENANCY_NAME);

Expand Down
Expand Up @@ -64,7 +64,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod

String cacheContainerName = getCacheContainerName(operation);
EndpointUtils.addCacheContainerDependency(builder, cacheContainerName, service.getCacheManager());
EndpointUtils.addSocketBindingDependency(builder, getSocketBindingName(operation), service.getSocketBinding());
EndpointUtils.addSocketBindingDependency(context, builder, getSocketBindingName(operation), service.getSocketBinding());
EndpointUtils.addCacheDependency(builder, cacheContainerName, null);
builder.install();
}
Expand Down

0 comments on commit cdea8b5

Please sign in to comment.