@Override public SocketBindingManager getSocketBindingManager() { return this.parentStack.getSocketBindingManager(); } }
@Override public boolean isUnknownForkResponse(ByteBuffer response) { return this.parentFactory.isUnknownForkResponse(response); }
@Override public Optional<RelayConfiguration> getRelay() { return this.parentStack.getRelay(); }
@Override public TransportConfiguration get() { ChannelFactory factory = this.factory.get(); ProtocolStackConfiguration stack = factory.getProtocolStackConfiguration(); org.wildfly.clustering.jgroups.spi.TransportConfiguration.Topology topology = stack.getTransport().getTopology(); TransportConfigurationBuilder builder = new GlobalConfigurationBuilder().transport() .clusterName(this.cluster.get()) .distributedSyncTimeout(this.lockTimeout) .transport(new ChannelFactoryTransport(factory)) ; if (topology != null) { builder.siteId(topology.getSite()).rackId(topology.getRack()).machineId(topology.getMachine()); } return builder.create(); }
@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(true); JChannel channel = new PassiveServiceSupplier<JChannel>(registry, JGroupsRequirement.CHANNEL.getServiceName(context, channelName)).get(); if (channel != null) { ChannelFactory factory = new PassiveServiceSupplier<ChannelFactory>(registry, JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channelName)).get(); if (factory != null) { ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration(); ProtocolConfiguration<? extends TP> transport = configuration.getTransport(); if (transport.getName().equals(protocolName)) { Class<? extends Protocol> protocolClass = transport.createProtocol(configuration).getClass(); return channel.getProtocolStack().findProtocol(protocolClass); } for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) { if (protocol.getName().equals(protocolName)) { Class<? extends Protocol> protocolClass = protocol.createProtocol(configuration).getClass(); return channel.getProtocolStack().findProtocol(protocolClass); } } } } return null; }
@Override public ServiceConfigurator configure(CapabilityServiceSupport support) { this.channel = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL.getServiceName(support, this.group)); this.channelFactory = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(support, this.group)); this.module = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_MODULE.getServiceName(support, this.group)); return this; }
@Override public Address generateAddress() { ExtendedUUID uuid = ExtendedUUID.randomUUID(); uuid.put(SITE, Util.stringToBytes(this.topology.getSite())); uuid.put(RACK, Util.stringToBytes(this.topology.getRack())); uuid.put(MACHINE, Util.stringToBytes(this.topology.getMachine())); return uuid; } }
@Override public SiteConfiguration get() { SiteConfigurationBuilder builder = new GlobalConfigurationBuilder().site(); if (this.factory != null) { RelayConfiguration relay = this.factory.get().getProtocolStackConfiguration().getRelay().orElse(null); if (relay != null) { builder.localSite(relay.getSiteName()); } } return builder.create(); } }
@Override public JChannel createChannel() throws Exception { JChannel channel = remoteSite.getChannelFactory().createChannel(siteName); // Don't use FORK in bridge stack channel.getProtocolStack().removeProtocol(FORK.class); return channel; } };
@Override public ProtocolStackConfiguration getProtocolStackConfiguration() { ProtocolStackConfiguration parentStack = this.parentFactory.getProtocolStackConfiguration(); return new ForkProtocolStackConfiguration(this.channel.getClusterName(), parentStack, Stream.concat(parentStack.getProtocols().stream(), this.protocols.stream()).collect(Collectors.toList())); }
@Override public JChannel createChannel(String id) throws Exception { JGroupsLogger.ROOT_LOGGER.debugf("Creating fork channel %s from channel %s", id, this.channel.getClusterName()); String stackName = this.protocols.isEmpty() ? this.channel.getClusterName() : id; Protocol[] protocols = new Protocol[this.protocols.size()]; for (int i = 0; i < protocols.length; ++i) { protocols[i] = this.protocols.get(i).createProtocol(this.parentFactory.getProtocolStackConfiguration()); } return new ForkChannel(this.channel, stackName, id, protocols); }
@Override public TransportConfiguration<? extends TP> getTransport() { return this.parentStack.getTransport(); }
@Override public boolean isStatisticsEnabled() { return this.parentStack.isStatisticsEnabled(); }
@Override public String getNodeName() { return this.parentStack.getNodeName(); }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { String channel = CHANNEL.resolveModelAttribute(context, model).asString(); this.cluster = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_CLUSTER.getServiceName(context, channel)); this.factory = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channel)); return this; }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.cluster = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_CLUSTER.getServiceName(context, this.name)); this.factory = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, this.name)); this.server = context.hasOptionalCapability(CommonRequirement.MBEAN_SERVER.getName(), null, null) ? new ServiceSupplierDependency<>(CommonRequirement.MBEAN_SERVER.getServiceName(context)) : null; return this; }
@Override public JGroupsTransportServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.lockTimeout = LOCK_TIMEOUT.resolveModelAttribute(context, model).asLong(); this.channel = CHANNEL.resolveModelAttribute(context, model).asStringOrNull(); this.factory = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, this.channel)); this.cluster = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_CLUSTER.getServiceName(context, this.channel)); return this; }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { String channel = CHANNEL.resolveModelAttribute(context, model).asStringOrNull(); this.factory = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channel)); return this; }
@Override public ModelNode execute(OperationContext context, Metric<JChannel> metric) throws OperationFailedException { String channelName = context.getCurrentAddressValue(); ServiceName serviceName = JGroupsRequirement.CHANNEL.getServiceName(context, channelName); JChannel channel = new PassiveServiceSupplier<JChannel>(context.getServiceRegistry(true), serviceName).get(); return (channel != null) ? metric.execute(channel) : null; } }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<ChannelFactory> executable) throws OperationFailedException { String stackName = context.getCurrentAddressValue(); ServiceName serviceName = JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stackName); ChannelFactory factory = new ActiveServiceSupplier<ChannelFactory>(context.getServiceRegistry(true), serviceName).get(); return executable.execute(context, operation, factory); } }