Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDFS-16861. RBF. Truncate API always fails when dirs use AllResolver oder on Router #5184

Merged
merged 6 commits into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,8 @@ public boolean setReplication(String src, short replication)
RemoteMethod method = new RemoteMethod("setReplication",
new Class<?>[] {String.class, short.class}, new RemoteParam(),
replication);
if (rpcServer.isInvokeConcurrent(src)) {
return !rpcClient.invokeConcurrent(locations, method, Boolean.class)
.containsValue(false);
if (rpcServer.isPathAll(src)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will affect the original logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic of setReplication api should be consistent with delete api. This change will ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I have add setReplication unit tests and It run well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic of setReplication api should be consistent with delete api. This change will ok.

This will be a problem if the path is a mount point. Or you could roll back the change for setReplication and open a new JIRA for it. If only the truncate is changed, I will +1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my late reply. I got sick last week. I have roll back the change for setReplicaion and will open a new JIRA for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Neilxzn for updating this.

return rpcClient.invokeAll(locations, method);
} else {
return rpcClient.invokeSequential(locations, method, Boolean.class,
Boolean.TRUE);
Expand Down Expand Up @@ -702,8 +701,9 @@ public boolean truncate(String src, long newLength, String clientName)
RemoteMethod method = new RemoteMethod("truncate",
new Class<?>[] {String.class, long.class, String.class},
new RemoteParam(), newLength, clientName);
// Truncate can return true/false, so don't expect a result
return rpcClient.invokeSequential(locations, method, Boolean.class,
Boolean.TRUE);
null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder;
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.NamenodeContext;
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext;
Expand All @@ -46,6 +47,7 @@
import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesRequest;
import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesResponse;
import org.apache.hadoop.hdfs.server.federation.store.records.MountTable;
import org.apache.hadoop.hdfs.server.namenode.TestFileTruncate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -191,6 +193,21 @@ private void testAll(final String path) throws Exception {
assertDirsEverywhere(path, 9);
assertFilesDistributed(path, 15);

// Test truncate
String testTruncateFile = path + "/dir2/dir22/dir220/file-truncate.txt";
createTestFile(routerFs, testTruncateFile);
Path testTruncateFilePath = new Path(testTruncateFile);
routerFs.truncate(testTruncateFilePath, 10);
TestFileTruncate.checkBlockRecovery(testTruncateFilePath,
(DistributedFileSystem) routerFs);
assertEquals("Truncate file fails", 10,
routerFs.getFileStatus(testTruncateFilePath).getLen());

// Test setReplication
assertTrue(routerFs.setReplication(testTruncateFilePath,(short)2));
assertEquals("SetReplication file fails", 2,
routerFs.getFileStatus(testTruncateFilePath).getReplication());

// Removing a directory should remove it from every subcluster
routerFs.delete(new Path(path + "/dir2/dir22/dir220"), true);
assertDirsEverywhere(path, 8);
Expand Down