use of org.wildfly.clustering.singleton.Singleton in project wildfly by wildfly.
the class SingletonMetricExecutor method execute.
@Override
public ModelNode execute(OperationContext context, Metric<Singleton> metric) throws OperationFailedException {
ServiceName name = this.serviceNameFactory.apply(context.getCurrentAddressValue());
FunctionExecutor<Singleton> executor = this.executors.get(name.append("singleton"));
return ((executor != null) ? executor : new LegacySingletonFunctionExecutor(context, name)).execute(new MetricFunction<>(Function.identity(), metric));
}
use of org.wildfly.clustering.singleton.Singleton in project quickstart by wildfly.
the class QueryingService method start.
@Override
public void start(StartContext context) {
Singleton singleton = this.singleton.get();
this.executor = Executors.newSingleThreadScheduledExecutor();
this.executor.scheduleAtFixedRate(() -> {
Node primary = singleton.getPrimaryProvider();
if (primary != null) {
this.log.infof("Singleton service running on %s.", primary);
} else {
this.log.infof("Singleton service not running anywhere.");
}
}, 5, 5, TimeUnit.SECONDS);
this.log.info("Querying service started");
}
use of org.wildfly.clustering.singleton.Singleton in project wildfly by wildfly.
the class SingletonPolicyResourceDefinition method register.
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addCapabilities(Capability.class).addRequiredSingletonChildren(SimpleElectionPolicyResourceDefinition.PATH).setResourceTransformation(SingletonPolicyResource::new);
ServiceValueExecutorRegistry<Singleton> executors = new ServiceValueExecutorRegistry<>();
ResourceServiceHandler handler = new SingletonPolicyServiceHandler(executors);
new SimpleResourceRegistration(descriptor, handler).register(registration);
new RandomElectionPolicyResourceDefinition().register(registration);
new SimpleElectionPolicyResourceDefinition().register(registration);
if (registration.isRuntimeOnlyRegistrationValid()) {
new SingletonDeploymentResourceDefinition(executors).register(registration);
new SingletonServiceResourceDefinition(executors).register(registration);
}
return registration;
}
use of org.wildfly.clustering.singleton.Singleton in project wildfly by wildfly.
the class DistributedSingletonServiceConfigurator method build.
@Override
public SingletonServiceBuilder<?> build(ServiceTarget target) {
ServiceName name = this.getServiceName().append("singleton");
ServiceBuilder<?> builder = new AsyncServiceConfigurator(name).build(target);
Consumer<Singleton> singleton = builder.provides(name);
return new DistributedSingletonServiceBuilder<>(this, new CompositeDependency(this.registry, this.dispatcherFactory).register(builder), singleton);
}
Aggregations