From 83dd14aa84ad697ad32c51007ac31ad39feb4288 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 11 May 2017 14:09:44 -0700 Subject: [PATCH] HDFS-11757. Query StreamCapabilities when creating balancer's lock file. Contributed by SammiChen. --- .../hadoop/hdfs/server/balancer/NameNodeConnector.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java index 88e40ee0f9a..e1b100531f9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/NameNodeConnector.java @@ -41,6 +41,7 @@ import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FsServerDefaults; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.StreamCapabilities.StreamCapability; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.NameNodeProxies; import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException; @@ -250,8 +251,10 @@ public class NameNodeConnector implements Closeable { .setFlags(EnumSet.of(CreateFlag.CREATE)) .build(); - Preconditions.checkState(!fs.getFileStatus(idPath).isErasureCoded(), - "Id File should be a replicate file"); + Preconditions.checkState( + fsout.hasCapability(StreamCapability.HFLUSH.getValue()) + && fsout.hasCapability(StreamCapability.HSYNC.getValue()), + "Id lock file should support hflush and hsync"); // mark balancer idPath to be deleted during filesystem closure fs.deleteOnExit(idPath);