You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ay...@apache.org on 2019/08/01 03:36:50 UTC
[hadoop] branch trunk updated: HDFS-14661. RBF:
updateMountTableEntry shouldn't update mountTableEntry if targetPath not
exist. Contributed by xuzq.
This is an automated email from the ASF dual-hosted git repository.
ayushsaxena pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 89b102f HDFS-14661. RBF: updateMountTableEntry shouldn't update mountTableEntry if targetPath not exist. Contributed by xuzq.
89b102f is described below
commit 89b102f916cf28b16b2a0a5009472a01b7f38484
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Thu Aug 1 08:43:39 2019 +0530
HDFS-14661. RBF: updateMountTableEntry shouldn't update mountTableEntry if targetPath not exist. Contributed by xuzq.
---
.../federation/router/RouterAdminServer.java | 18 ++++++----
.../server/federation/router/TestRouterQuota.java | 41 ++++++++++++++++------
2 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java
index 97d4d16..0cc6d90 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java
@@ -269,12 +269,18 @@ public class RouterAdminServer extends AbstractService
UpdateMountTableEntryRequest request) throws IOException {
UpdateMountTableEntryResponse response =
getMountTableStore().updateMountTableEntry(request);
-
- MountTable mountTable = request.getEntry();
- if (mountTable != null && router.isQuotaEnabled()) {
- synchronizeQuota(mountTable.getSourcePath(),
- mountTable.getQuota().getQuota(),
- mountTable.getQuota().getSpaceQuota());
+ try {
+ MountTable mountTable = request.getEntry();
+ if (mountTable != null && router.isQuotaEnabled()) {
+ synchronizeQuota(mountTable.getSourcePath(),
+ mountTable.getQuota().getQuota(),
+ mountTable.getQuota().getSpaceQuota());
+ }
+ } catch (Exception e) {
+ // Ignore exception, if any while reseting quota. Specifically to handle
+ // if the actual destination doesn't exist.
+ LOG.warn("Unable to reset quota at the destinations for {}: {}",
+ request.getEntry().toString(), e.getMessage());
}
return response;
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterQuota.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterQuota.java
index 6dc98b8..075e529 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterQuota.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterQuota.java
@@ -59,6 +59,7 @@ import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntr
import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryRequest;
import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryResponse;
import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryRequest;
+import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryResponse;
import org.apache.hadoop.hdfs.server.federation.store.records.MountTable;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.Time;
@@ -245,6 +246,25 @@ public class TestRouterQuota {
}
/**
+ * Update a mount table entry to the mount table through the admin API.
+ * @param entry Mount table entry to update.
+ * @return If it was successfully updated
+ * @throws IOException Problems update entries
+ */
+ private boolean updateMountTable(final MountTable entry) throws IOException {
+ RouterClient client = routerContext.getAdminClient();
+ MountTableManager mountTableManager = client.getMountTableManager();
+ UpdateMountTableEntryRequest updateRequest =
+ UpdateMountTableEntryRequest.newInstance(entry);
+ UpdateMountTableEntryResponse updateResponse =
+ mountTableManager.updateMountTableEntry(updateRequest);
+
+ // Reload the Router cache
+ resolver.loadCache(true);
+ return updateResponse.getStatus();
+ }
+
+ /**
* Append data in specified file.
* @param path Path of file.
* @param client DFS Client.
@@ -496,11 +516,7 @@ public class TestRouterQuota {
mountTable.setQuota(new RouterQuotaUsage.Builder().quota(updateNsQuota)
.spaceQuota(updateSsQuota).build());
- UpdateMountTableEntryRequest updateRequest = UpdateMountTableEntryRequest
- .newInstance(mountTable);
- RouterClient client = routerContext.getAdminClient();
- MountTableManager mountTableManager = client.getMountTableManager();
- mountTableManager.updateMountTableEntry(updateRequest);
+ updateMountTable(mountTable);
// verify if the quota is updated in real path
realQuota = nnContext1.getFileSystem().getQuotaUsage(
@@ -512,18 +528,21 @@ public class TestRouterQuota {
mountTable.setQuota(new RouterQuotaUsage.Builder()
.quota(HdfsConstants.QUOTA_RESET)
.spaceQuota(HdfsConstants.QUOTA_RESET).build());
-
- updateRequest = UpdateMountTableEntryRequest
- .newInstance(mountTable);
- client = routerContext.getAdminClient();
- mountTableManager = client.getMountTableManager();
- mountTableManager.updateMountTableEntry(updateRequest);
+ updateMountTable(mountTable);
// verify if the quota is updated in real path
realQuota = nnContext1.getFileSystem().getQuotaUsage(
new Path("/testsync"));
assertEquals(HdfsConstants.QUOTA_RESET, realQuota.getQuota());
assertEquals(HdfsConstants.QUOTA_RESET, realQuota.getSpaceQuota());
+
+ // Verify updating mount entry with actual destinations not present.
+ mountTable = MountTable.newInstance("/testupdate",
+ Collections.singletonMap("ns0", "/testupdate"), Time.now(), Time.now());
+ addMountTable(mountTable);
+ mountTable.setQuota(new RouterQuotaUsage.Builder().quota(1)
+ .spaceQuota(2).build());
+ assertTrue(updateMountTable(mountTable));
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org