瀏覽代碼

HDFS-14747. RBF: IsFileClosed should be return false when the file is open in multiple destination. Contributed by xuzq.

Ayush Saxena 5 年之前
父節點
當前提交
c92de8209d

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java

@@ -870,7 +870,7 @@ public class RouterClientProtocol implements ClientProtocol {
     RemoteMethod method = new RemoteMethod("isFileClosed",
         new Class<?>[] {String.class}, new RemoteParam());
     return rpcClient.invokeSequential(locations, method, Boolean.class,
-        Boolean.TRUE);
+        null);
   }
 
   @Override

+ 22 - 0
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpcMultiDestination.java

@@ -255,6 +255,28 @@ public class TestRouterRpcMultiDestination extends TestRouterRpc {
     }
   }
 
+  /**
+   * Test isFileClosed when the result is false.
+   */
+  @Test
+  public void testIsFileClosed() throws Exception {
+    Path testPath = new Path("/is_file_closed.txt");
+    DistributedFileSystem routerFs =
+        (DistributedFileSystem) getRouterFileSystem();
+    FSDataOutputStream fsDataOutputStream = null;
+    try {
+      fsDataOutputStream = routerFs.create(testPath);
+      fsDataOutputStream.write("hello world".getBytes());
+      fsDataOutputStream.hflush();
+
+      boolean result = routerFs.isFileClosed(testPath);
+      assertFalse(result);
+    } finally {
+      IOUtils.closeStream(fsDataOutputStream);
+      routerFs.delete(testPath, true);
+    }
+  }
+
   @Test
   public void testGetContentSummaryEc() throws Exception {
     DistributedFileSystem routerDFS =