use of org.wildfly.clustering.group.Group in project wildfly by wildfly.
the class BeanExpirationSchedulerTestCase method testExpire.
@Test
public void testExpire() throws InterruptedException {
Group group = mock(Group.class);
Batcher<TransactionBatch> batcher = mock(Batcher.class);
TransactionBatch batch = mock(TransactionBatch.class);
BeanFactory<String, Object> factory = mock(BeanFactory.class);
ExpirationConfiguration<Object> config = mock(ExpirationConfiguration.class);
RemoveListener<Object> listener = mock(RemoveListener.class);
BeanEntry<String> entry = mock(BeanEntry.class);
BeanRemover<String, Object> remover = mock(BeanRemover.class);
String beanId = "expiring";
Duration timeout = Duration.ofMillis(10L);
when(group.isSingleton()).thenReturn(true);
when(batcher.createBatch()).thenReturn(batch);
when(config.getTimeout()).thenReturn(timeout);
when(config.getRemoveListener()).thenReturn(listener);
when(entry.getLastAccessedTime()).thenReturn(Instant.now());
when(remover.remove(beanId, listener)).thenReturn(true);
try (Scheduler<String, ImmutableBeanEntry<String>> scheduler = new BeanExpirationScheduler<>(group, batcher, factory, config, remover, Duration.ZERO)) {
scheduler.schedule(beanId, entry);
Thread.sleep(500);
}
verify(batch).close();
}
use of org.wildfly.clustering.group.Group in project wildfly by wildfly.
the class CacheGroupServiceConfigurator method build.
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
ServiceName name = this.getServiceName();
ServiceBuilder<?> builder = new AsyncServiceConfigurator(name).build(target);
Consumer<Group> group = new CompositeDependency(this.cache, this.factory).register(builder).provides(name);
Service service = new FunctionalService<>(group, Functions.identity(), this, Consumers.close());
return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
use of org.wildfly.clustering.group.Group in project wildfly by wildfly.
the class ChannelGroupServiceConfigurator method build.
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = target.addService(this.getServiceName());
Consumer<Group> group = this.factory.register(builder).provides(this.getServiceName());
Service service = new FunctionalService<>(group, Function.identity(), this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
use of org.wildfly.clustering.group.Group in project wildfly by wildfly.
the class ConcurrentBroadcastCommandDispatcherFactoryTestCase method getGroup.
@Test
public void getGroup() {
Group group = mock(Group.class);
CommandDispatcherFactory factory = new ConcurrentBroadcastCommandDispatcherFactory(this.factory);
when(this.factory.getGroup()).thenReturn(group);
Group result = factory.getGroup();
Assert.assertSame(group, result);
}
use of org.wildfly.clustering.group.Group in project wildfly by wildfly.
the class NodeServiceActivator method install.
private static void install(ServiceTarget target, SingletonServiceBuilderFactory factory, ServiceName name, int quorum) {
InjectedValue<Group> group = new InjectedValue<>();
NodeService service = new NodeService(group);
factory.createSingletonServiceBuilder(name, service).electionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference(PREFERRED_NODE))).requireQuorum(quorum).build(target).addDependency(ServiceName.parse("org.wildfly.clustering.default-group"), Group.class, group).install();
}
Aggregations