Move ensureAtomicMoveSupported to NodeEnvironment (#36975)
Atomic move support is needed not only for GatewayMetaState to work correctly
This commit is contained in:
parent
6aae7c8516
commit
6259ccb1cf
|
@ -305,6 +305,10 @@ public final class NodeEnvironment implements Closeable {
|
||||||
|
|
||||||
applySegmentInfosTrace(settings);
|
applySegmentInfosTrace(settings);
|
||||||
assertCanWrite();
|
assertCanWrite();
|
||||||
|
|
||||||
|
if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) {
|
||||||
|
ensureAtomicMoveSupported(nodePaths);
|
||||||
|
}
|
||||||
success = true;
|
success = true;
|
||||||
} finally {
|
} finally {
|
||||||
if (success == false) {
|
if (success == false) {
|
||||||
|
@ -1003,8 +1007,7 @@ public final class NodeEnvironment implements Closeable {
|
||||||
* not supported by the filesystem. This test is executed on each of the data directories.
|
* not supported by the filesystem. This test is executed on each of the data directories.
|
||||||
* This method cleans up all files even in the case of an error.
|
* This method cleans up all files even in the case of an error.
|
||||||
*/
|
*/
|
||||||
public void ensureAtomicMoveSupported() throws IOException {
|
private static void ensureAtomicMoveSupported(final NodePath[] nodePaths) throws IOException {
|
||||||
final NodePath[] nodePaths = nodePaths();
|
|
||||||
for (NodePath nodePath : nodePaths) {
|
for (NodePath nodePath : nodePaths) {
|
||||||
assert Files.isDirectory(nodePath.path) : nodePath.path + " is not a directory";
|
assert Files.isDirectory(nodePath.path) : nodePath.path + " is not a directory";
|
||||||
final Path src = nodePath.path.resolve(TEMP_FILE_NAME + ".tmp");
|
final Path src = nodePath.path.resolve(TEMP_FILE_NAME + ".tmp");
|
||||||
|
|
|
@ -102,7 +102,6 @@ public class GatewayMetaState implements ClusterStateApplier, CoordinationState.
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.indicesService = indicesService;
|
this.indicesService = indicesService;
|
||||||
|
|
||||||
ensureAtomicMoveSupported(); //TODO move this check to NodeEnvironment, because it's related to all types of metadata
|
|
||||||
upgradeMetaData(metaDataIndexUpgradeService, metaDataUpgrader);
|
upgradeMetaData(metaDataIndexUpgradeService, metaDataUpgrader);
|
||||||
initializeClusterState(ClusterName.CLUSTER_NAME_SETTING.get(settings));
|
initializeClusterState(ClusterName.CLUSTER_NAME_SETTING.get(settings));
|
||||||
incrementalWrite = false;
|
incrementalWrite = false;
|
||||||
|
@ -194,12 +193,6 @@ public class GatewayMetaState implements ClusterStateApplier, CoordinationState.
|
||||||
return DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings);
|
return DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureAtomicMoveSupported() throws IOException {
|
|
||||||
if (isMasterOrDataNode()) {
|
|
||||||
nodeEnv.ensureAtomicMoveSupported();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MetaData getMetaData() {
|
public MetaData getMetaData() {
|
||||||
return previousClusterState.metaData();
|
return previousClusterState.metaData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.IndexSettingsModule;
|
import org.elasticsearch.test.IndexSettingsModule;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.AtomicMoveNotSupportedException;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -457,12 +456,8 @@ public class NodeEnvironmentTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NodeEnvironment env = newNodeEnvironment(paths, Settings.EMPTY);
|
NodeEnvironment env = newNodeEnvironment(paths, Settings.EMPTY);
|
||||||
try {
|
|
||||||
env.ensureAtomicMoveSupported();
|
|
||||||
} catch (AtomicMoveNotSupportedException e) {
|
|
||||||
// that's OK :)
|
|
||||||
}
|
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
// check we clean up
|
// check we clean up
|
||||||
for (String path: paths) {
|
for (String path: paths) {
|
||||||
final Path nodePath = NodeEnvironment.resolveNodePath(PathUtils.get(path), 0);
|
final Path nodePath = NodeEnvironment.resolveNodePath(PathUtils.get(path), 0);
|
||||||
|
|
Loading…
Reference in New Issue