use of org.apache.ignite.internal.metastorage.client.MetaStorageServiceImpl in project ignite-3 by apache.
the class MetaStorageManager method start.
/**
* {@inheritDoc}
*/
@Override
public void start() {
String[] metastorageNodes = this.locCfgMgr.configurationRegistry().getConfiguration(NodeConfiguration.KEY).metastorageNodes().value();
Predicate<ClusterNode> metaStorageNodesContainsLocPred = clusterNode -> Arrays.asList(metastorageNodes).contains(clusterNode.name());
if (metastorageNodes.length > 0) {
metaStorageNodesOnStart = true;
List<ClusterNode> metaStorageMembers = clusterNetSvc.topologyService().allMembers().stream().filter(metaStorageNodesContainsLocPred).collect(Collectors.toList());
// without hosting metastorage, this will be rewritten in init phase https://issues.apache.org/jira/browse/IGNITE-15114
if (metaStorageMembers.isEmpty()) {
throw new IgniteException("Cannot start meta storage manager because there is no node in the cluster that hosts meta storage.");
}
// This will be rewritten in init phase https://issues.apache.org/jira/browse/IGNITE-15114
if (metastorageNodes.length > 1) {
throw new IgniteException("Cannot start meta storage manager because it is not allowed to start several metastorage nodes.");
}
storage.start();
try {
raftGroupServiceFut = raftMgr.prepareRaftGroup(METASTORAGE_RAFT_GROUP_NAME, metaStorageMembers, () -> new MetaStorageListener(storage));
} catch (NodeStoppingException e) {
throw new AssertionError("Loza was stopped before Meta Storage manager", e);
}
this.metaStorageSvcFut = raftGroupServiceFut.thenApply(service -> new MetaStorageServiceImpl(service, clusterNetSvc.topologyService().localMember().id()));
if (hasMetastorageLocally(locCfgMgr)) {
clusterNetSvc.topologyService().addEventHandler(new TopologyEventHandler() {
@Override
public void onAppeared(ClusterNode member) {
// No-op.
}
@Override
public void onDisappeared(ClusterNode member) {
metaStorageSvcFut.thenCompose(svc -> svc.closeCursors(member.id()));
}
});
}
} else {
this.metaStorageSvcFut = new CompletableFuture<>();
}
// TODO: IGNITE-15114 Cluster initialization flow. Here we should complete metaStorageServiceFuture.
// clusterNetSvc.messagingService().addMessageHandler((message, senderAddr, correlationId) -> {});
}
Aggregations