use of org.wildfly.clustering.singleton.election.NamePreference in project wildfly by wildfly.
the class NodeServiceActivator method install.
private static void install(ServiceTarget target, SingletonServiceConfiguratorFactory factory, ServiceName name, int quorum) {
ServiceBuilder<?> builder = target.addService(name);
SingletonElectionListenerService listenerService = new SingletonElectionListenerService(builder.provides(name));
builder.setInstance(listenerService).install();
factory.createSingletonServiceConfigurator(name.append("singleton")).electionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference(PREFERRED_NODE))).electionListener(listenerService).requireQuorum(quorum).build(target).install();
}
use of org.wildfly.clustering.singleton.election.NamePreference in project wildfly by wildfly.
the class SingletonServiceActivator method install.
private static void install(ServiceTarget target, SingletonServiceConfiguratorFactory factory, ServiceName name, String preferredNode) {
ServiceBuilder<?> builder = target.addService(name);
SingletonElectionListenerService listenerService = new SingletonElectionListenerService(builder.provides(name));
builder.setInstance(listenerService).install();
factory.createSingletonServiceConfigurator(name.append("singleton")).electionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference(preferredNode))).electionListener(listenerService).build(target).install();
}
use of org.wildfly.clustering.singleton.election.NamePreference in project wildfly by wildfly.
the class NamePreferenceTestCase method test.
@Test
public void test() {
Preference preference = new NamePreference("node1");
Node node1 = mock(Node.class);
Node node2 = mock(Node.class);
when(node1.getName()).thenReturn("node1");
when(node2.getName()).thenReturn("node2");
assertTrue(preference.preferred(node1));
assertFalse(preference.preferred(node2));
}
use of org.wildfly.clustering.singleton.election.NamePreference in project eap-additional-testsuite by jboss-set.
the class HATimerServiceActivator4 method activate.
@Override
public void activate(ServiceActivatorContext context) {
log.info("HATimerService 4 will be installed!");
HATimerService4 service = new HATimerService4();
ServiceName factoryServiceName = SingletonServiceName.BUILDER.getServiceName("server", "default");
ServiceController<?> factoryService = context.getServiceRegistry().getRequiredService(factoryServiceName);
SingletonServiceBuilderFactory factory = (SingletonServiceBuilderFactory) factoryService.getValue();
factory.createSingletonServiceBuilder(HATimerService4.SINGLETON_SERVICE_NAME4, service).electionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference("node1/singleton"))).build(new DelegatingServiceContainer(context.getServiceTarget(), context.getServiceRegistry())).setInitialMode(ServiceController.Mode.ACTIVE).install();
}
use of org.wildfly.clustering.singleton.election.NamePreference in project eap-additional-testsuite by jboss-set.
the class HATimerServiceActivator2 method activate.
@Override
public void activate(ServiceActivatorContext context) {
log.info("HATimerService 2 will be installed!");
HATimerService2 service = new HATimerService2();
ServiceName factoryServiceName = SingletonServiceName.BUILDER.getServiceName("server", "default");
ServiceController<?> factoryService = context.getServiceRegistry().getRequiredService(factoryServiceName);
SingletonServiceBuilderFactory factory = (SingletonServiceBuilderFactory) factoryService.getValue();
factory.createSingletonServiceBuilder(HATimerService2.SINGLETON_SERVICE_NAME2, service).electionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference("node1/singleton"))).build(new DelegatingServiceContainer(context.getServiceTarget(), context.getServiceRegistry())).setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Aggregations