ckite icon indicating copy to clipboard operation
ckite copied to clipboard

Getting started in Java

Open pablosmedina opened this issue 11 years ago • 3 comments

Write simple Getting started instructions for Java including:

  1. repo location (sonatype for now, will be maven central)
  2. artifact coordinates for Maven
  3. start a simple cluster

pablosmedina avatar Feb 12 '14 17:02 pablosmedina

+1 I'm interested in using your raft implementation from java. can you help me with this ?

Thanks.

ejemba avatar Feb 06 '15 17:02 ejemba

Hi ejemba,

The getting started is pretty much the same as in Scala with some minor changes:

If you are using Maven, you have to get the library dependency from Maven central:

<dependency>
    <groupId>io.ckite</groupId>
    <artifactId>ckite</artifactId>
    <version>0.1.6</version>
</dependency>

Then you have to instantiate a builder and configure it following the instructions in the README.

Example:

        Raft raft = new RaftBuilder().stateMachine(new MyStateMachine())
                         .listenAddress("someListenAddress").dataDir("someDataDir").build();

You'll have to create your StateMachine class implementing the StateMachine interface:

public class MyStateMachine implements StateMachine {
    @Override
    public void deserialize(ByteBuffer byteBuffer) {
    }

    @Override
    public ByteBuffer serialize() {
        //TODO
    }

    @Override
    public Object applyWrite(long index, WriteCommand<?> write) {
        //TODO
    }

    @Override
    public Object applyRead(ReadCommand<?> read) {
        //TODO
    }

    @Override
    public long lastAppliedIndex() {
        //TODO
    }
}

Follow the instructions in README to know the semantics of each configuration in the builder and the methods to be implemented in your state machine.

Just curious. I would like to know about how are you planning to use CKite, what kind of application are you working on so I can help you. Btw, I'm working on a new version of CKite with a modularized architecture so different log storages and rpc mechanisms can be plugged into CKite. I'm planning to implement a Chronicle based log storage.

Hope this helps. Let me know you have more questions.

Thanks!

pablosmedina avatar Feb 06 '15 18:02 pablosmedina

Hi @pablosmedina thank you for the sample. I'll try this asap .

In fact, I'm planning to implement a demo of my java lib nuun.io an IOC microlib (https://github.com/nuun-io/kernel ) by implementing a simple framework around raft consensus algo, so I had to choose a viable java/jvm raft implementation. Nuun is quite new in the place so I have to find usable use cases to demonstrate its "awesomeness" (this is the difficult part) . So make raft algo even more easy to access can be the use case ^^

ejemba avatar Feb 06 '15 20:02 ejemba