use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method findProtocol.
@Override
public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException {
PathAddress address = context.getCurrentAddress();
String channelName = address.getParent().getLastElement().getValue();
String protocolName = address.getLastElement().getValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceController<?> controller = registry.getService(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
if (controller != null) {
Channel channel = (Channel) controller.getValue();
if (channel != null) {
controller = registry.getService(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channelName));
ChannelFactory factory = (ChannelFactory) controller.getValue();
if (factory != null) {
ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration();
ProtocolConfiguration<? extends TP> transport = configuration.getTransport();
if (transport.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = transport.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) {
if (protocol.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = protocol.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
}
}
}
}
return null;
}
use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.
the class ForkProtocolResourceRegistrationHandler method findProtocol.
@Override
public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException {
PathAddress address = context.getCurrentAddress();
String channelName = address.getElement(address.size() - 3).getValue();
String forkName = address.getElement(address.size() - 2).getValue();
String protocolName = address.getElement(address.size() - 1).getValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceController<?> controller = registry.getService(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
if (controller != null) {
Channel channel = (Channel) controller.getValue();
if (channel != null) {
FORK fork = (FORK) channel.getProtocolStack().findProtocol(FORK.class);
if (fork != null) {
controller = registry.getService(JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, channelName));
if (controller != null) {
ChannelFactory factory = (ChannelFactory) controller.getValue();
if (factory != null) {
ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration();
ProtocolConfiguration<? extends TP> transport = configuration.getTransport();
if (transport.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = transport.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) {
if (protocol.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = protocol.createProtocol().getClass();
return fork.get(forkName).getProtocolStack().findProtocol(protocolClass);
}
}
}
}
}
}
}
return null;
}
use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.
the class ForkResourceDefinition method register.
@Override
public void register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addCapabilities(Capability.class).addCapabilities(CLUSTERING_CAPABILITIES.values());
ResourceServiceBuilderFactory<ChannelFactory> builderFactory = address -> new ForkChannelFactoryBuilder(Capability.FORK_CHANNEL_FACTORY.getServiceName(address), address.getParent().getLastElement().getValue());
ResourceServiceHandler handler = new ForkServiceHandler(builderFactory);
new SimpleResourceRegistration(descriptor, handler).register(registration);
new ProtocolRegistration(builderFactory, new ForkProtocolResourceRegistrationHandler()).register(registration);
}
use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.
the class DistributedWorkManagerService method start.
@Override
public void start(StartContext context) throws StartException {
ROOT_LOGGER.debugf("Starting JCA DistributedWorkManager: ", value.getName());
ChannelFactory factory = this.jGroupsChannelFactory.getValue();
JGroupsTransport transport = new ForkChannelTransport(factory);
try {
transport.setChannel(factory.createChannel(this.value.getName()));
transport.setClusterName(this.value.getName());
this.value.setTransport(transport);
} catch (Exception e) {
ROOT_LOGGER.trace("failed to start JGroups channel", e);
throw ROOT_LOGGER.failedToStartJGroupsChannel(this.value.getName(), this.value.getName());
}
BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue();
if (longRunning != null) {
this.value.setLongRunningThreadPool(longRunning);
this.value.setShortRunningThreadPool((BlockingExecutor) executorShort.getValue());
} else {
this.value.setLongRunningThreadPool((BlockingExecutor) executorShort.getValue());
this.value.setShortRunningThreadPool((BlockingExecutor) executorShort.getValue());
}
this.value.setXATerminator(new XATerminatorImpl(xaTerminator.getValue()));
WorkManagerCoordinator.getInstance().registerWorkManager(value);
try {
transport.startup();
} catch (Throwable throwable) {
ROOT_LOGGER.trace("failed to start DWM transport:", throwable);
throw ROOT_LOGGER.failedToStartDWMTransport(this.value.getName());
}
if (this.value.isElytronEnabled()) {
this.value.setSecurityIntegration(new ElytronSecurityIntegration());
} else {
this.value.setSecurityIntegration(new PicketBoxSecurityIntegration());
}
ROOT_LOGGER.debugf("Started JCA DistributedWorkManager: ", value.getName());
}
use of org.wildfly.clustering.jgroups.spi.ChannelFactory in project wildfly by wildfly.
the class JGroupsTransportBuilder method getValue.
@Override
public TransportConfiguration getValue() {
ChannelFactory factory = this.factory.getValue();
ProtocolStackConfiguration stack = factory.getProtocolStackConfiguration();
org.wildfly.clustering.jgroups.spi.TransportConfiguration.Topology topology = stack.getTransport().getTopology();
TransportConfigurationBuilder builder = new GlobalConfigurationBuilder().transport().clusterName(this.containerName).distributedSyncTimeout(this.lockTimeout).transport(new ChannelFactoryTransport(factory));
if (topology != null) {
builder.siteId(topology.getSite()).rackId(topology.getRack()).machineId(topology.getMachine());
}
return builder.create();
}
Aggregations