Skip to content

Commit 28134b5

Browse files
authored
Merge pull request wildfly#19272 from bstansberry/WFLY-20997
[WFLY-20997][WFLY-21007] Upgrade wildfly-clustering to 8.0.1.Final; fix marshalling classloading issues during undeploy
2 parents fc6bc6e + bec3782 commit 28134b5

File tree

77 files changed

+844
-848
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+844
-848
lines changed

clustering/common/src/main/java/org/jboss/as/clustering/service/DecoratedService.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

clustering/common/src/main/java/org/jboss/as/clustering/service/SuspendableService.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,22 @@
1414
import org.jboss.as.server.suspend.ServerSuspendController;
1515
import org.jboss.as.server.suspend.SuspendableActivity;
1616
import org.jboss.as.server.suspend.SuspendableActivityRegistry;
17-
import org.wildfly.clustering.server.manager.Service;
17+
import org.wildfly.clustering.server.service.Service;
1818

1919
/**
2020
* A {@link Service} decorator that auto-stops on server suspend and auto-starts on server resume.
2121
* @author Paul Ferraro
2222
*/
23-
public class SuspendableService implements Service {
23+
public class SuspendableService implements Service, SuspendableActivity {
2424

2525
private final Service service;
2626
private final SuspendableActivityRegistry registry;
27-
private final SuspendableActivity activity;
27+
private final Executor executor;
2828

2929
public SuspendableService(Service service, SuspendableActivityRegistry registry, Executor executor) {
3030
this.service = service;
3131
this.registry = registry;
32-
this.activity = new SuspendableActivity() {
33-
@Override
34-
public CompletionStage<Void> suspend(ServerSuspendContext context) {
35-
// Avoid spurious stop on startup during activity registration
36-
if (context.isStarting()) return SuspendableActivity.COMPLETED;
37-
return CompletableFuture.runAsync(service::stop, executor);
38-
}
39-
40-
@Override
41-
public CompletionStage<Void> resume(ServerResumeContext context) {
42-
return CompletableFuture.runAsync(service::start, executor);
43-
}
44-
};
32+
this.executor = executor;
4533
}
4634

4735
@Override
@@ -51,19 +39,29 @@ public boolean isStarted() {
5139

5240
@Override
5341
public void start() {
54-
this.registry.registerActivity(this.activity);
55-
// Only start now if we are not suspended
42+
this.registry.registerActivity(this);
43+
// If we are suspended, defer start until SuspendableActivity.resume(...)
5644
if (this.registry.getState() == ServerSuspendController.State.RUNNING) {
5745
this.service.start();
5846
}
5947
}
6048

6149
@Override
6250
public void stop() {
63-
// Only stop if we are not already suspended
51+
// If we are suspended, SuspendableActivity.suspend(...) will have already stopped the service
6452
if (this.registry.getState() == ServerSuspendController.State.RUNNING) {
6553
this.service.stop();
6654
}
67-
this.registry.unregisterActivity(this.activity);
55+
this.registry.unregisterActivity(this);
56+
}
57+
58+
@Override
59+
public CompletionStage<Void> suspend(ServerSuspendContext context) {
60+
return this.service.isStarted() ? CompletableFuture.runAsync(this.service::stop, this.executor) : SuspendableActivity.COMPLETED;
61+
}
62+
63+
@Override
64+
public CompletionStage<Void> resume(ServerResumeContext context) {
65+
return !this.service.isStarted() ? CompletableFuture.runAsync(this.service::start, this.executor) : SuspendableActivity.COMPLETED;
6866
}
6967
}

clustering/ejb/cache/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@
8282
<groupId>org.wildfly.clustering</groupId>
8383
<artifactId>wildfly-clustering-server-spi</artifactId>
8484
</dependency>
85-
<dependency>
86-
<groupId>org.wildfly.common</groupId>
87-
<artifactId>wildfly-common</artifactId>
88-
</dependency>
8985
<dependency>
9086
<groupId>org.wildfly.security</groupId>
9187
<artifactId>wildfly-elytron-security-manager</artifactId>

clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/bean/DefaultBeanGroupManager.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@
99
import java.util.Map;
1010
import java.util.concurrent.ConcurrentHashMap;
1111
import java.util.function.BiFunction;
12-
import java.util.function.Consumer;
1312

1413
import org.jboss.logging.Logger;
1514
import org.wildfly.clustering.cache.CacheEntryCreator;
1615
import org.wildfly.clustering.cache.CacheEntryMutator;
1716
import org.wildfly.clustering.cache.CacheEntryMutatorFactory;
1817
import org.wildfly.clustering.cache.CacheEntryRemover;
1918
import org.wildfly.clustering.ejb.bean.BeanInstance;
19+
import org.wildfly.clustering.function.Consumer;
2020
import org.wildfly.clustering.marshalling.MarshalledValue;
2121
import org.wildfly.clustering.marshalling.MarshalledValueFactory;
2222
import org.wildfly.clustering.server.cache.Cache;
2323
import org.wildfly.clustering.server.cache.CacheStrategy;
2424
import org.wildfly.clustering.server.manager.Manager;
25-
import org.wildfly.common.function.Functions;
2625

2726
/**
2827
* A manager for bean groups that leverages a {@link Manager} to handle bean group lifecycle.
@@ -47,9 +46,9 @@ public DefaultBeanGroupManager(DefaultBeanGroupManagerConfiguration<K, V, C> con
4746
this.mutatorFactory = configuration.getMutatorFactory();
4847
this.factory = configuration.getMarshalledValueFactory();
4948
boolean persistent = configuration.getCacheProperties().isPersistent();
50-
this.postActivateTask = persistent ? new MapValuesTask<>(BeanInstance::postActivate) : Functions.discardingConsumer();
51-
this.prePassivateTask = persistent ? new MapValuesTask<>(BeanInstance::prePassivate) : Functions.discardingConsumer();
52-
this.cache = CacheStrategy.CONCURRENT.createCache(Functions.discardingConsumer(), new NewBeanGroupCloseTask<>(configuration.getRemover()));
49+
this.postActivateTask = persistent ? new MapValuesTask<>(BeanInstance::postActivate) : Consumer.empty();
50+
this.prePassivateTask = persistent ? new MapValuesTask<>(BeanInstance::prePassivate) : Consumer.empty();
51+
this.cache = CacheStrategy.CONCURRENT.createCache(Consumer.empty(), new NewBeanGroupCloseTask<>(configuration.getRemover()));
5352
this.beanGroupFactory = (id, closeTask) -> {
5453
Map<K, V> instances = new ConcurrentHashMap<>();
5554
MarshalledValue<Map<K, V>, C> newValue = this.factory.createMarshalledValue(instances);

clustering/ejb/cache/src/main/java/org/wildfly/clustering/ejb/cache/timer/TimerMetaDataEntryFunction.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@
66
package org.wildfly.clustering.ejb.cache.timer;
77

88
import java.time.Duration;
9-
import java.util.function.Supplier;
109

1110
import org.wildfly.clustering.cache.function.RemappingFunction;
11+
import org.wildfly.clustering.function.Supplier;
1212
import org.wildfly.clustering.server.offset.Offset;
1313
import org.wildfly.clustering.server.offset.OffsetValue;
14-
import org.wildfly.common.function.Functions;
1514

1615
/**
1716
* @author Paul Ferraro
1817
* @param <C> the timer context type
1918
*/
20-
public class TimerMetaDataEntryFunction<C> extends RemappingFunction<RemappableTimerMetaDataEntry<C>, Supplier<Offset<Duration>>> {
19+
public class TimerMetaDataEntryFunction<C> extends RemappingFunction<RemappableTimerMetaDataEntry<C>, java.util.function.Supplier<Offset<Duration>>> {
2120

2221
public TimerMetaDataEntryFunction(OffsetValue<Duration> lastTimeoutDelta) {
2322
super(lastTimeoutDelta::getOffset);
2423
}
2524

2625
TimerMetaDataEntryFunction(Offset<Duration> lastTimeoutOffsetDelta) {
27-
super(Functions.constantSupplier(lastTimeoutOffsetDelta));
26+
super(Supplier.of(lastTimeoutOffsetDelta));
2827
}
2928

3029
Offset<Duration> getOffset() {

clustering/ejb/client/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
<groupId>org.wildfly.clustering</groupId>
5454
<artifactId>wildfly-clustering-marshalling-protostream</artifactId>
5555
</dependency>
56-
<dependency>
57-
<groupId>org.wildfly.common</groupId>
58-
<artifactId>wildfly-common</artifactId>
59-
</dependency>
6056

6157
<!-- External test dependencies -->
6258
<dependency>

clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/bean/BeanExpirationScheduler.java

Lines changed: 0 additions & 130 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright The WildFly Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.wildfly.clustering.ejb.infinispan.bean;
7+
8+
import java.util.function.Consumer;
9+
import java.util.function.Predicate;
10+
import java.util.function.Supplier;
11+
12+
import org.wildfly.clustering.cache.batch.Batch;
13+
import org.wildfly.clustering.ejb.bean.Bean;
14+
import org.wildfly.clustering.ejb.bean.BeanInstance;
15+
import org.wildfly.clustering.ejb.cache.bean.BeanFactory;
16+
import org.wildfly.clustering.ejb.infinispan.logging.InfinispanEjbLogger;
17+
18+
/**
19+
* The bean expiration task triggered by the expiration scheduler.
20+
* @author Paul Ferraro
21+
*/
22+
public class BeanExpirationTask<K, V extends BeanInstance<K>, M> implements Predicate<K> {
23+
private final BeanFactory<K, V, M> beanFactory;
24+
private final Supplier<Batch> batchFactory;
25+
private final Consumer<V> expirationListener;
26+
27+
BeanExpirationTask(BeanFactory<K, V, M> beanFactory, Supplier<Batch> batchFactory, Consumer<V> expirationListener) {
28+
this.beanFactory = beanFactory;
29+
this.batchFactory = batchFactory;
30+
this.expirationListener = expirationListener;
31+
}
32+
33+
@Override
34+
public boolean test(K id) {
35+
InfinispanEjbLogger.ROOT_LOGGER.tracef("Expiring stateful session bean %s", id);
36+
try (Batch batch = this.batchFactory.get()) {
37+
try {
38+
M value = this.beanFactory.tryValue(id);
39+
if (value != null) {
40+
try (Bean<K, V> bean = this.beanFactory.createBean(id, value)) {
41+
// Ensure bean is actually expired
42+
if (bean.getMetaData().isExpired()) {
43+
bean.remove(this.expirationListener);
44+
}
45+
}
46+
}
47+
return true;
48+
} catch (RuntimeException e) {
49+
batch.discard();
50+
throw e;
51+
}
52+
} catch (RuntimeException e) {
53+
InfinispanEjbLogger.ROOT_LOGGER.failedToExpireBean(e, id);
54+
return false;
55+
}
56+
}
57+
}

clustering/ejb/infinispan/src/main/java/org/wildfly/clustering/ejb/infinispan/bean/InfinispanBeanGroupListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public InfinispanBeanGroupListener(EmbeddedCacheConfiguration configuration, C c
4141
this.context = context;
4242
// We only need to listen for activation/passivation events for non-persistent caches
4343
// pre-passivate/post-activate callbacks for persistent caches are triggered via GroupManager
44-
this.executor = !configuration.getCacheProperties().isPersistent() ? configuration.getBlockingManager().asExecutor(this.getClass().getName()) : null;
44+
this.executor = !configuration.getCacheProperties().isPersistent() ? configuration.getExecutor() : null;
4545
this.postActivateListenerRegistration = (this.executor != null) ? new PostActivateBlockingListener<>(configuration.getCache(), this::postActivate).register(BeanGroupKey.class) : null;
4646
this.prePassivateListenerRegistration = (this.executor != null) ? new PrePassivateBlockingListener<>(configuration.getCache(), this::prePassivate).register(BeanGroupKey.class) : null;
4747
}

0 commit comments

Comments
 (0)