From c92de8209d1c7da9e7ce607abeecb777c4a52c6a Mon Sep 17 00:00:00 2001 From: Ayush Saxena Date: Fri, 23 Aug 2019 18:41:33 +0530 Subject: [PATCH] HDFS-14747. RBF: IsFileClosed should be return false when the file is open in multiple destination. Contributed by xuzq. --- .../router/RouterClientProtocol.java | 2 +- .../router/TestRouterRpcMultiDestination.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java index 95787a1b01..7df54c1dd8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java @@ -870,7 +870,7 @@ public boolean isFileClosed(String src) throws IOException { RemoteMethod method = new RemoteMethod("isFileClosed", new Class[] {String.class}, new RemoteParam()); return rpcClient.invokeSequential(locations, method, Boolean.class, - Boolean.TRUE); + null); } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpcMultiDestination.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpcMultiDestination.java index 62e90770eb..20548d51c9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpcMultiDestination.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpcMultiDestination.java @@ -255,6 +255,28 @@ public void testRecoverLease() throws Exception { } } + /** + * 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 =