package ch.digitalfondue.synckv;

import java.nio.charset.StandardCharsets;

public class SyncKVTest {

    public static void main(String[] args) throws Exception {


        SyncKV syncKV = new SyncKV(null, null, null);

        SyncKVTable table = syncKV.getTable("test");

        table.put("my_key", "my value 1".getBytes(StandardCharsets.UTF_8));
        byte[] res1 = table.get("my_key");

        System.err.println("res1 is " + new String(res1, StandardCharsets.UTF_8));

        table.put("my_key", "my value 2".getBytes(StandardCharsets.UTF_8));
        byte[] res2 = table.get("my_key");
        System.err.println("res2 is " + new String(res2, StandardCharsets.UTF_8));
    }
}

@@ -38,132 +38,1685 @@
 ort 
-java.nio.charset.StandardCharsets;%0A%0Apublic class SyncKVTest %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B
+org.jgroups.JChannel;%0Aimport org.jgroups.Message;%0Aimport org.jgroups.ReceiverAdapter;%0Aimport org.jgroups.View;%0Aimport org.jgroups.protocols.*;%0Aimport org.jgroups.protocols.pbcast.GMS;%0Aimport org.jgroups.protocols.pbcast.NAKACK2;%0Aimport org.jgroups.protocols.pbcast.STABLE;%0Aimport org.jgroups.stack.Protocol;%0Aimport org.jgroups.util.Util;%0A%0Aimport java.nio.charset.StandardCharsets;%0A%0Apublic class SyncKVTest %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A%0A        //for programmatic configuration, imported from https://github.com/belaban/JGroups/blob/master/src/org/jgroups/demos/ProgrammaticChat.java%0A        // switched to TCP_NIO2 and MPING%0A        // TODO: custom encryption provider for loading the encryption key from memory and not from  a keystore%0A        Protocol%5B%5D prot_stack = %7B%0A                new TCP_NIO2(),%0A                new MPING(),%0A                new MERGE3(),%0A                new FD_SOCK(),%0A                new FD_ALL(),%0A                new VERIFY_SUSPECT(),%0A                new BARRIER(),%0A                new NAKACK2(),%0A                new UNICAST3(),%0A                new STABLE(),%0A                new GMS(),%0A                new UFC(),%0A                new MFC(),%0A                new FRAG2()%7D;%0A        JChannel channel = new JChannel(prot_stack).name(%22SyncKV%22);%0A%0A%0A        channel.setReceiver(new ReceiverAdapter() %7B%0A            public void viewAccepted(View new_view) %7B%0A                System.out.println(%22view: %22 + new_view);%0A            %7D%0A%0A            public void receive(Message msg) %7B%0A                System.out.println(%22%3C%3C %22 + msg.getObject() + %22 %5B%22 + msg.getSrc() + %22%5D%22);%0A            %7D%0A        %7D);%0A%0A        channel.connect(%22SyncKV%22);
 %0A%0A%0A 
@@ -1761,19 +1761,22 @@
 , null, 
-nul
+channe
 l);%0A%0A   
@@ -2227,21 +2227,149 @@
 ets.UTF_8));
+%0A%0A        for (; ; ) %7B%0A            String line = Util.readStringFromStdin(%22: %22);%0A            channel.send(null, line);%0A        %7D
 %0A    %7D%0A%7D%0A

add initial trial with jchannel (tcp+programmatic conf)