Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stevenschlansker/9e293f89e47ebce9d4ba7f6e3e641ac7 to your computer and use it in GitHub Desktop.
Save stevenschlansker/9e293f89e47ebce9d4ba7f6e3e641ac7 to your computer and use it in GitHub Desktop.
TP tp = new KeepaliveTCP();
tp.setBindAddress(bindHost != null ? InetAddress.getByName(bindHost) : InetAddress.getLocalHost());
tp.setBindPort(port);
tp.bundler("no-bundler");
// Discover peers by connecting over TCP. AWS doesn't do multicast UDP.
// Also our network is suspect so TCP will give us better diagnostics for lost packets
TCPPING tcpping = new TCPPING();
tcpping.setPortRange(0);
// If we only know of one cluster member via Singularity, don't wait long
// to initialize a new cluster
GMS gms = new GMS();
gms.setJoinTimeout(members.size() == 1 ? 1000 : 20000);
gms.setMaxJoinAttempts(4);
FD_ALL2 fd = new FD_ALL2();
fd.setInterval(1000);
fd.setTimeout(5000);
channel = new JChannel(
tp,
tcpping,
new MERGE3(), // Detect and merge partitions together
fd, // Detect failures of peer nodes
new BARRIER(), // State transfer also inhibits messages
new NAKACK2().setUseMcastXmit(false), // Reliable delivery; Multicast doesn't work in AWS
new UNICAST3(), // Reliable delivery (required for STABLE)
new STABLE(), // Garbage collect old messages
new SEQUENCER(), // Create a total ordering over all messages
gms, // Maintain cluster membership
new STATE(), // New members get existing state
new FLUSH()); // Inhibit message delivery during topology changes
channel.setName(id);
channel.setReceiver(this);
tcpping.setInitialHosts(members);
channel.connect("discovery", null, 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment