Charlatan is a library created for Apache Kafka in order to substitute real Zookeeper with Zookeeper imitation. Charlatan was tested only with Apache Kafka version 0.11.0.1.
Kafka is a great product, but it requires running Zookeeper cluster. This means that to manage
Kafka cluster we also need to manage Zookeeper cluster.
This complicates Kafka usage especially in case when we already have a service similar to Zookeeper.
For example etcd, consul, etc. or your own highly available service.
Charlatan provides two options to use Kafka without Zookeeper:
Charlatan contains from few sub-projects
Sub-project | Description |
---|---|
Charlatan-common | Watch management, session management, common dao interfaces. |
Charlatan-server | Netty based server implementation, Zookeeper messaging protocol implementation. |
Charlatan-adapter | Fake Zookeeper driver, it can be used as a Kafka dependency instead of Zookeeper.jar. |
Charlatan-sqlite | Simple implementation of Charlatan DAO interfaces using sqlite. It is not suitable for the production usage and it was build mainly for the demonstration and testing purposes. |
Charlatan-remote | Simple netty based implementation of Charlatan DAO interfaces that sends DAO requests to the remote server. |
In order to replace Zookeeper Charlatan library has to handle all the Zookeeper features.
Apache Kafka uses Zookeeper mainly to:
All these features are implemented in the Charlatan-common.
This option implies that standard Kafka distribution is used and instead of real Zookeeper
Kafka is pointed to the Charlatan server. The schema could look like:
Note that as long as same database is used multiple Charlatan server can be running.
One or multiple Kafka instances can be connected to the Charlatan server.
Kafka broker isn't aware that it doesn't connect to a real Zookeeper.
Standard Kafka setting Zookeeper.connect
is used in order to point Kafka to Charlatan server.
In this example we are starting Charlatan server with sqlite DAO implementations and default implementation of WatchService and SessionService.
String host = "localhost";
int port = 2181;
CharlatanNettyServer server = new CharlatanServerBuilder()
// Charlatan server host
.setHost(host)
// Charlatan server port
.setPort(port)
// Charlatan server id must be unique per Charlatan cluster
.setId("server"+port)
.setWorkerCount(5)
// Node DAO implementation
.setNodeDao(new NodeDaoSqlite())
// Watch service implementation
.setWatchService(new WatchServiceImpl(NodeUpdateDaoSqlite(), new NamedThreadFactory("charlatan-watch-service")))
// Session service implementation
.setSessionService(new SessionServiceImpl(new SessionDaoSqlite()))
.setThreadFactory(new NamedThreadFactory("charlatan-service"))
.build();
server.start();
This option implies that in standard Kafka distribution Zookeeper.jar library will be replaced by the charlatan-adapter.jar and charlatan dao implementation will be provided. What do we need to make it work?
In case Charlatan DAO interfaces were implemented for relational database the schema would look like:
In a more general approach Charlatan DAO interfaces implementation is a client to your highly available service.
This project was created for testing purposes and contains basic Charlatan DAO implementations for sqlite database.
This project was created for demonstration purposes only and contains Charlatan DAO implementation that acts as a client to the remote REST-ful service.