Getting started in Java
Write simple Getting started instructions for Java including:
- repo location (sonatype for now, will be maven central)
- artifact coordinates for Maven
- start a simple cluster
+1 I'm interested in using your raft implementation from java. can you help me with this ?
Thanks.
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!
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 ^^