Skip to content

Commit

Permalink
WFLY-8473 Fix mod_cluster service name when used with capability
Browse files Browse the repository at this point in the history
  • Loading branch information
ctomc committed Apr 3, 2017
1 parent 5b32c04 commit 2650eff
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Expand Up @@ -40,7 +40,7 @@
*/
public class ContainerEventHandlerService implements Service<ModClusterService> {

public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append(ModClusterExtension.SUBSYSTEM_NAME);
public static final ServiceName SERVICE_NAME = ModClusterConfigResourceDefinition.MOD_CLUSTER_CAPABILITY.getCapabilityServiceName();
public static final ServiceName CONFIG_SERVICE_NAME = SERVICE_NAME.append("config");

private LoadBalanceFactorProvider load;
Expand Down
Expand Up @@ -70,7 +70,7 @@ class ModClusterConfigResourceDefinition extends SimpleResourceDefinition {
static final String UNDERTOW_LISTENER_CAPABILITY_NAME = "org.wildfly.undertow.listener";

private static final String MOD_CLUSTER_CAPABILITY_NAME = "org.wildfly.mod_cluster";
private static final RuntimeCapability<Void> MOD_CLUSTER_CAPABILITY = RuntimeCapability.Builder.of(MOD_CLUSTER_CAPABILITY_NAME, false, Void.class).build();
static final RuntimeCapability<Void> MOD_CLUSTER_CAPABILITY = RuntimeCapability.Builder.of(MOD_CLUSTER_CAPABILITY_NAME, false, Void.class).build();

static final PathElement PATH = PathElement.pathElement(CommonAttributes.MOD_CLUSTER_CONFIG, CommonAttributes.CONFIGURATION);

Expand Down
Expand Up @@ -53,6 +53,7 @@
import org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider;
import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.msc.service.ServiceController.Mode;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.value.InjectedValue;
import org.wildfly.clustering.service.AsynchronousServiceBuilder;
Expand Down Expand Up @@ -95,6 +96,8 @@ public void performBoottime(OperationContext context, ModelNode operation, Model
new AsynchronousServiceBuilder<>(ContainerEventHandlerService.SERVICE_NAME, service).build(target)
.addDependency(configurationBuilder.getServiceName(), ModClusterConfiguration.class, modClusterConfiguration)
.setInitialMode(Mode.ACTIVE)
//temporary in case anyone is using old service name
.addAliases(ServiceName.JBOSS.append(ModClusterExtension.SUBSYSTEM_NAME))
.install();

// Install services for web container integration
Expand Down
Expand Up @@ -126,6 +126,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
builder.addCapabilityRequirement(Capabilities.REF_HTTP_AUTHENTICATION_FACTORY, HttpAuthenticationFactory.class, service.getHttpAuthenticationFactoryInjectedValue(), httpAuthenticationFactory);
}
if (context.hasOptionalCapability(REF_MOD_CLUSTER, HTTP_INVOKER_HOST_CAPABILITY.getDynamicName(address), null )){
//todo add builder#addCapabilityRequirement variant to core
builder.addCapabilityRequirement(REF_MOD_CLUSTER, Void.class);
}

Expand Down
Expand Up @@ -116,21 +116,21 @@ public static void testRuntime(KernelServices mainServices, final String virtual
ServiceController<FilterService> connectionLimiter = (ServiceController<FilterService>) mainServices.getContainer()
.getService(UndertowService.FILTER.append("limit-connections"));
connectionLimiter.setMode(ServiceController.Mode.ACTIVE);
FilterService connectionLimiterService = connectionLimiter.getService().getValue();
FilterService connectionLimiterService = connectionLimiter.awaitValue();
HttpHandler result = connectionLimiterService.createHttpHandler(Predicates.truePredicate(), new PathHandler());
Assert.assertNotNull("handler should have been created", result);

ServiceController headersFilter = mainServices.getContainer().getService(UndertowService.FILTER.append("headers"));
headersFilter.setMode(ServiceController.Mode.ACTIVE);
FilterService headersService = (FilterService)headersFilter.getService().getValue();
FilterService headersService = (FilterService)headersFilter.awaitValue();
HttpHandler headerHandler = headersService.createHttpHandler(Predicates.truePredicate(), new PathHandler());
Assert.assertNotNull("handler should have been created", headerHandler);

if (flag > 0) {
ServiceController modClusterServiceServiceController = mainServices.getContainer()
.getService(UndertowService.FILTER.append("mod-cluster"));
modClusterServiceServiceController.setMode(ServiceController.Mode.ACTIVE);
ModClusterService modClusterService = (ModClusterService)modClusterServiceServiceController.getService().getValue();
ModClusterService modClusterService = (ModClusterService)modClusterServiceServiceController.awaitValue();
Assert.assertNotNull(modClusterService);
Assert.assertNotNull(modClusterService.getModCluster());

Expand All @@ -143,7 +143,6 @@ public static void testRuntime(KernelServices mainServices, final String virtual
Assert.assertNotNull(hostSC);
hostSC.setMode(ServiceController.Mode.ACTIVE);
Host host = (Host) hostSC.awaitValue();
Assert.assertEquals(1, host.getFilters().size());
if (flag == 1) {
Assert.assertEquals(3, host.getAllAliases().size());
Assert.assertEquals("default-alias", new ArrayList<>(host.getAllAliases()).get(1));
Expand All @@ -159,17 +158,18 @@ public static void testRuntime(KernelServices mainServices, final String virtual
final ServiceName servletContainerServiceName = UndertowService.SERVLET_CONTAINER.append("myContainer");
ServiceController servletContainerService = mainServices.getContainer().getService(servletContainerServiceName);
Assert.assertNotNull(servletContainerService);
JSPConfig jspConfig = ((ServletContainerService)servletContainerService.getService().getValue()).getJspConfig();
JSPConfig jspConfig = ((ServletContainerService)servletContainerService.awaitValue()).getJspConfig();
Assert.assertNotNull(jspConfig);
Assert.assertNotNull(jspConfig.createJSPServletInfo());

final ServiceName filterRefName = UndertowService.filterRefName(virtualHostName, "other-host", "/", "static-gzip");

ServiceController gzipFilterController = mainServices.getContainer().getService(filterRefName);
gzipFilterController.setMode(ServiceController.Mode.ACTIVE);
FilterRef gzipFilterRef = (FilterRef)gzipFilterController.getService().getValue();
FilterRef gzipFilterRef = (FilterRef)gzipFilterController.awaitValue();
HttpHandler gzipHandler = gzipFilterRef.createHttpHandler(new PathHandler());
Assert.assertNotNull("handler should have been created", gzipHandler);
Assert.assertEquals(1, host.getFilters().size());
}

public static void testRuntimeOther(KernelServices mainServices) {
Expand Down

0 comments on commit 2650eff

Please sign in to comment.