use of org.jgroups.JChannel in project JGroups by belaban.
the class TCPGOSSIP_Test method createTcpgossipChannel.
protected JChannel createTcpgossipChannel(String name) throws Exception {
TCPGOSSIP gossip = new TCPGOSSIP();
List<InetSocketAddress> initial_hosts = new ArrayList<>();
initial_hosts.add(new InetSocketAddress(bind_addr, gossip_router_port));
gossip.setInitialHosts(initial_hosts);
JChannel ch = new JChannel(new TCP().setSockConnTimeout(300).setBindAddress(bind_addr), gossip, new MERGE3().setMinInterval(1000).setMaxInterval(3000), new FD_ALL3().setTimeout(5000).setInterval(1500), new VERIFY_SUSPECT(), new NAKACK2().useMcastXmit(false), new UNICAST3(), new STABLE(), new GMS().setJoinTimeout(1000));
if (name != null)
ch.setName(name);
return ch;
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class TCPGOSSIP_Test method testConnectThreeChannelsWithGRAlreadyDown.
public void testConnectThreeChannelsWithGRAlreadyDown() throws Exception {
JChannel third = null;
try {
coordinator = createTcpgossipChannel("A");
channel = createTcpgossipChannel("B");
// kill router
gossipRouter.stop();
// cannot discover others since GR is down
coordinator.connect("testConnectThreeChannelsWithGRAlreadyDown");
channel.connect("testConnectThreeChannelsWithGRAlreadyDown");
third = createTcpgossipChannel("C");
third.connect("testConnectThreeChannelsWithGRAlreadyDown");
// restart and....
gossipRouter.start();
Util.waitUntilAllChannelsHaveSameView(60000, 1000, coordinator, channel, third);
// confirm they found each other
View view = channel.getView();
assert channel.getView().size() == 3;
assert third.getView().size() == 3;
assert view.containsMember(channel.getAddress());
assert view.containsMember(coordinator.getAddress());
} finally {
Util.close(third);
}
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class InfinispanStackMerge3Test method main.
public static void main(String[] args) throws Exception {
Map<String, List<Long>> results = new HashMap<>();
for (Supplier<TP> transport : TRANSPORTS) {
results.put(transport.get().getClass().getSimpleName(), new LinkedList<>());
for (int run = 0; run < RUNS; run++) {
JChannel[] channels = new JChannel[MEMBERS];
// Setup
for (int member = 0; member < MEMBERS; member++) channels[member] = createChannel(transport.get(), String.valueOf(member + 1));
Util.waitUntilAllChannelsHaveSameView(10_000, 500, channels);
System.out.printf("-- run #%d: cluster formed:\n%s\n", run + 1, printViews(channels));
// Partition
Stream.of(channels).forEach(channel -> {
GMS gms = channel.getProtocolStack().findProtocol(GMS.class);
View view = View.create(channel.getAddress(), gms.getViewId().getId() + 1, channel.getAddress());
gms.installView(view);
});
System.out.printf("-- injected partition (waiting for merge):\n%s\n", printViews(channels));
// Merge
long timeBeforeMerge = System.currentTimeMillis();
Util.waitUntilAllChannelsHaveSameView(360_000, 100, channels);
long timeAfterMerge = System.currentTimeMillis();
System.out.printf("-- run #%d: %s cluster merged in %d ms:\n%s\n", run + 1, transport.get().getClass().getSimpleName(), timeAfterMerge - timeBeforeMerge, printViews(channels));
// Cleanup
Stream.of(channels).forEach(JChannel::close);
results.get(transport.get().getClass().getSimpleName()).add(timeAfterMerge - timeBeforeMerge);
}
}
printStats(results);
}
use of org.jgroups.JChannel in project JGroups by belaban.
the class RemoteGetStressTest method createChannel.
protected static JChannel createChannel(String name) throws Exception {
SHARED_LOOPBACK sl = new SHARED_LOOPBACK();
sl.getThreadPool().setMinThreads(1).setMaxThreads(5);
Protocol[] protocols = { sl, new SHARED_LOOPBACK_PING(), new NAKACK2(), new UNICAST3(), new STABLE(), new GMS(), new UFC(), new MFC().setMaxCredits(2000000).setMinThreshold(0.4), new FRAG2().setFragSize(8000) };
return new JChannel(protocols).name(name);
}
use of org.jgroups.JChannel in project wildfly by wildfly.
the class RelayConfigurationBuilder method accept.
@Override
public void accept(RELAY2 protocol) {
String localSite = this.siteName;
List<RemoteSiteConfiguration> remoteSites = this.getRemoteSites();
List<String> sites = new ArrayList<>(remoteSites.size() + 1);
sites.add(localSite);
// Collect bridges, eliminating duplicates
Map<String, RelayConfig.BridgeConfig> bridges = new HashMap<>();
for (final RemoteSiteConfiguration remoteSite : remoteSites) {
String siteName = remoteSite.getName();
sites.add(siteName);
String clusterName = remoteSite.getClusterName();
RelayConfig.BridgeConfig bridge = new RelayConfig.BridgeConfig(clusterName) {
@Override
public JChannel createChannel() throws Exception {
JChannel channel = (JChannel) remoteSite.getChannelFactory().createChannel(siteName);
// Don't use FORK in bridge stack
channel.getProtocolStack().removeProtocol(FORK.class);
return channel;
}
};
bridges.put(clusterName, bridge);
}
protocol.site(localSite);
for (String site : sites) {
RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
protocol.addSite(site, siteConfig);
if (site.equals(localSite)) {
for (RelayConfig.BridgeConfig bridge : bridges.values()) {
siteConfig.addBridge(bridge);
}
}
}
}
Aggregations