Skip to content

Commit 443e14c

Browse files
ayushtknahussein
authored andcommitted
HDFS-14741. RBF: RecoverLease should be return false when the file is open in multiple destination. Contributed by xuzq
1 parent a194aab commit 443e14c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public boolean recoverLease(String src, String clientName)
363363
new Class<?>[] {String.class, String.class}, new RemoteParam(),
364364
clientName);
365365
Object result = rpcClient.invokeSequential(
366-
locations, method, Boolean.class, Boolean.TRUE);
366+
locations, method, Boolean.class, null);
367367
return (boolean) result;
368368
}
369369

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.createFile;
2121
import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.verifyFileExists;
2222
import static org.junit.Assert.assertEquals;
23+
import static org.junit.Assert.assertFalse;
2324
import static org.junit.Assert.assertTrue;
2425
import static org.junit.Assert.fail;
2526
import static org.mockito.Matchers.any;
@@ -38,6 +39,7 @@
3839
import java.util.Set;
3940
import java.util.TreeSet;
4041

42+
import org.apache.hadoop.fs.FSDataOutputStream;
4143
import org.apache.hadoop.fs.FileStatus;
4244
import org.apache.hadoop.fs.FileSystem;
4345
import org.apache.hadoop.fs.Path;
@@ -55,6 +57,7 @@
5557
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
5658
import org.apache.hadoop.hdfs.server.namenode.NameNode;
5759
import org.apache.hadoop.hdfs.server.namenode.ha.HAContext;
60+
import org.apache.hadoop.io.IOUtils;
5861
import org.apache.hadoop.ipc.RemoteException;
5962
import org.apache.hadoop.ipc.StandbyException;
6063
import org.apache.hadoop.test.GenericTestUtils;
@@ -230,6 +233,28 @@ public void testProxyRenameFiles() throws IOException, InterruptedException {
230233
testRename2(getRouterContext(), filename1, renamedFile, false);
231234
}
232235

236+
/**
237+
* Test recoverLease when the result is false.
238+
*/
239+
@Test
240+
public void testRecoverLease() throws Exception {
241+
Path testPath = new Path("/recovery/test_recovery_lease");
242+
DistributedFileSystem routerFs =
243+
(DistributedFileSystem) getRouterFileSystem();
244+
FSDataOutputStream fsDataOutputStream = null;
245+
try {
246+
fsDataOutputStream = routerFs.create(testPath);
247+
fsDataOutputStream.write("hello world".getBytes());
248+
fsDataOutputStream.hflush();
249+
250+
boolean result = routerFs.recoverLease(testPath);
251+
assertFalse(result);
252+
} finally {
253+
IOUtils.closeStream(fsDataOutputStream);
254+
routerFs.delete(testPath, true);
255+
}
256+
}
257+
233258
@Test
234259
public void testGetContentSummaryEc() throws Exception {
235260
DistributedFileSystem routerDFS =

0 commit comments

Comments
 (0)