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