These are chat archives for atomix/atomix

31st
Oct 2018
coopci
@coopci
Oct 31 2018 05:44

I started 30 clients with this code:


public class PClient {

    private String memberId;
    private String address;

    public PClient(String nodeid, String address) {
        this.memberId = nodeid;
        this.address = address;

    }
    DistributedMap<Object, Object> map = null;
    public void start() {
        Atomix atomix = Atomix.builder()
                .withMemberId(this.memberId)
                .withAddress(this.address)
                .withMembershipProvider(BootstrapDiscoveryProvider.builder()
                        .withNodes(
                          Node.builder()
                            .withId("raft-1")
                            .withAddress("localhost:8701")
                            .build(),
                          Node.builder()
                            .withId("raft-2")
                            .withAddress("localhost:8702")
                            .build(),
                          Node.builder()
                            .withId("raft-3")
                            .withAddress("localhost:8703")
                            .build())
                        .build()).build();
        atomix.start().join();

        this.map = atomix.getMap("map1");

        this.map.addListener(new MapEventListener<Object, Object>(){
            @Override
            public void event(MapEvent<Object, Object> event) {
                System.out.println("MapEventListener.event: " + event);
            }
        } );
    }


    public static void start (int n) {
        for (int i = 1; i <= n; ++i) {
            String memberId = "client-" + i;
            int port = 8710 + i;
            String address = "localhost:" + port;
            PClient client = new PClient(memberId, address);
            client.start();
        }
    }

    public static void main(String[] args) {

        start(30);
    }
}

And found the process occupies very high CPU util around 200%, is this expected?

The function looks correct.