use of io.atomix.cluster.impl.DefaultClusterMembershipService in project zeppelin by apache.
the class ClusterManagerServer method initThread.
private void initThread() {
// RaftServer Thread
new Thread(new Runnable() {
@Override
public void run() {
LOGGER.info("RaftServer run() >>>");
Address address = Address.from(zeplServerHost, raftServerPort);
Member member = Member.builder(MemberId.from(zeplServerHost + ":" + raftServerPort)).withAddress(address).build();
messagingService = NettyMessagingService.builder().withAddress(address).build().start().join();
RaftServerProtocol protocol = new RaftServerMessagingProtocol(messagingService, ClusterManager.protocolSerializer, raftAddressMap::get);
BootstrapService bootstrapService = new BootstrapService() {
@Override
public MessagingService getMessagingService() {
return messagingService;
}
@Override
public BroadcastService getBroadcastService() {
return new BroadcastServiceAdapter();
}
};
ManagedClusterMembershipService clusterService = new DefaultClusterMembershipService(member, new DefaultNodeDiscoveryService(bootstrapService, member, new BootstrapDiscoveryProvider(clusterNodes)), bootstrapService, new MembershipConfig());
File atomixDateDir = com.google.common.io.Files.createTempDir();
atomixDateDir.deleteOnExit();
RaftServer.Builder builder = RaftServer.builder(member.id()).withMembershipService(clusterService).withProtocol(protocol).withStorage(RaftStorage.builder().withStorageLevel(StorageLevel.MEMORY).withDirectory(atomixDateDir).withSerializer(storageSerializer).withMaxSegmentSize(1024 * 1024).build());
raftServer = builder.build();
raftServer.bootstrap(clusterMemberIds);
messagingService.registerHandler(CLUSTER_INTP_EVENT_TOPIC, subscribeClusterIntpEvent, MoreExecutors.directExecutor());
messagingService.registerHandler(CLUSTER_NOTE_EVENT_TOPIC, subscribeClusterNoteEvent, MoreExecutors.directExecutor());
messagingService.registerHandler(CLUSTER_AUTH_EVENT_TOPIC, subscribeClusterAuthEvent, MoreExecutors.directExecutor());
messagingService.registerHandler(CLUSTER_INTP_SETTING_EVENT_TOPIC, subscribeIntpSettingEvent, MoreExecutors.directExecutor());
HashMap<String, Object> meta = new HashMap<String, Object>();
String nodeName = getClusterNodeName();
meta.put(ClusterMeta.NODE_NAME, nodeName);
meta.put(ClusterMeta.SERVER_HOST, zeplServerHost);
meta.put(ClusterMeta.SERVER_PORT, raftServerPort);
meta.put(ClusterMeta.SERVER_START_TIME, LocalDateTime.now());
putClusterMeta(SERVER_META, nodeName, meta);
LOGGER.info("RaftServer run() <<<");
}
}).start();
}
Aggregations