use of org.elasticsearch.gateway.PersistedClusterStateService in project crate by crate.
the class NodeRepurposeCommand method processMasterNoDataNode.
private void processMasterNoDataNode(Terminal terminal, Path[] dataPaths, Environment env) throws IOException {
NodeEnvironment.NodePath[] nodePaths = toNodePaths(dataPaths);
terminal.println(Terminal.Verbosity.VERBOSE, "Collecting shard data paths");
List<Path> shardDataPaths = NodeEnvironment.collectShardDataPaths(nodePaths);
if (shardDataPaths.isEmpty()) {
terminal.println(NO_SHARD_DATA_TO_CLEAN_UP_FOUND);
return;
}
final PersistedClusterStateService persistedClusterStateService = createPersistedClusterStateService(env.settings(), dataPaths);
final Metadata metadata = loadClusterState(terminal, env, persistedClusterStateService).metadata();
final Set<Path> indexPaths = uniqueParentPaths(shardDataPaths);
final Set<String> indexUUIDs = indexUUIDsFor(indexPaths);
outputVerboseInformation(terminal, shardDataPaths, indexUUIDs, metadata);
terminal.println(shardMessage(shardDataPaths.size(), indexUUIDs.size()));
outputHowToSeeVerboseInformation(terminal);
terminal.println("Node is being re-purposed as master and no-data. Clean-up of shard data will be performed.");
confirm(terminal, "Do you want to proceed?");
// clean-up shard dirs
removePaths(terminal, shardDataPaths);
terminal.println("Node successfully repurposed to master and no-data.");
}
use of org.elasticsearch.gateway.PersistedClusterStateService in project crate by crate.
the class NodeRepurposeCommandTests method createNodePaths.
@Before
public void createNodePaths() throws IOException {
dataMasterSettings = buildEnvSettings(Settings.EMPTY);
environment = TestEnvironment.newEnvironment(dataMasterSettings);
try (NodeEnvironment nodeEnvironment = new NodeEnvironment(dataMasterSettings, environment)) {
nodePaths = nodeEnvironment.nodeDataPaths();
final String nodeId = randomAlphaOfLength(10);
try (PersistedClusterStateService.Writer writer = new PersistedClusterStateService(nodePaths, nodeId, xContentRegistry(), BigArrays.NON_RECYCLING_INSTANCE, new ClusterSettings(dataMasterSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), () -> 0L, true).createWriter()) {
writer.writeFullStateAndCommit(1L, ClusterState.EMPTY_STATE);
}
}
dataNoMasterSettings = Settings.builder().put(dataMasterSettings).put(Node.NODE_MASTER_SETTING.getKey(), false).build();
noDataNoMasterSettings = Settings.builder().put(dataMasterSettings).put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), false).build();
noDataMasterSettings = Settings.builder().put(dataMasterSettings).put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true).build();
}
use of org.elasticsearch.gateway.PersistedClusterStateService in project crate by crate.
the class OverrideNodeVersionCommandTests method createNodePaths.
@Before
public void createNodePaths() throws IOException {
final Settings settings = buildEnvSettings(Settings.EMPTY);
environment = TestEnvironment.newEnvironment(settings);
try (NodeEnvironment nodeEnvironment = new NodeEnvironment(settings, environment)) {
nodePaths = nodeEnvironment.nodeDataPaths();
nodeId = nodeEnvironment.nodeId();
try (PersistedClusterStateService.Writer writer = new PersistedClusterStateService(nodePaths, nodeId, xContentRegistry(), BigArrays.NON_RECYCLING_INSTANCE, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), () -> 0L, true).createWriter()) {
writer.writeFullStateAndCommit(1L, ClusterState.builder(ClusterName.DEFAULT).metadata(Metadata.builder().persistentSettings(Settings.builder().put(Metadata.SETTING_READ_ONLY_SETTING.getKey(), true).build()).build()).build());
}
}
}
Aggregations