Skip to content

Instantly share code, notes, and snippets.

@electrical electrical/client.java Secret
Created Dec 22, 2015

Embed
What would you like to do?
package io.atomix.examples.clientconnection;
import io.atomix.Atomix;
import io.atomix.AtomixClient;
import io.atomix.catalyst.transport.Address;
import io.atomix.catalyst.transport.NettyTransport;
import java.util.ArrayList;
import java.util.List;
/**
* Client connection example.
*
* @author <a href="http://github.com/kuujo>Jordan Halterman</a>
*/
public class ClientConnection {
/**
* Starts the server.
*/
public static void main(String[] args) throws Exception {
if (args.length < 1)
throw new IllegalArgumentException("must supply a set of host:port tuples");
List<Address> members = new ArrayList<>();
for (int i = 0; i < args.length; i++) {
String[] parts = args[i].split(":");
members.add(new Address(parts[0], Integer.valueOf(parts[1])));
}
AtomixClient client = AtomixClient.builder(members)
.withTransport(new NettyTransport())
.build();
client.open().get();
client.open().thenRun(() -> {
System.out.println("Client started!");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.