[
https://issues.apache.org/jira/browse/HDFS-13507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17727845#comment-17727845
]
ASF GitHub Bot commented on HDFS-13507:
---------------------------------------
ayushtkn commented on code in PR #4990:
URL: https://github.com/apache/hadoop/pull/4990#discussion_r1211229496
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java:
##########
@@ -699,32 +697,52 @@ public boolean addMount(AddMountAttributes
addMountAttributes)
// Get the existing entry
MountTableManager mountTable = client.getMountTableManager();
MountTable existingEntry = getMountEntry(mount, mountTable);
- MountTable existingOrNewEntry =
-
addMountAttributes.getNewOrUpdatedMountTableEntryWithAttributes(existingEntry);
- if (existingOrNewEntry == null) {
+ if (existingEntry != null) {
+ System.err.println("MountTable entry:" + mount + " already exists.");
return false;
}
- if (existingEntry == null) {
- AddMountTableEntryRequest request = AddMountTableEntryRequest
- .newInstance(existingOrNewEntry);
- AddMountTableEntryResponse addResponse =
mountTable.addMountTableEntry(request);
- boolean added = addResponse.getStatus();
- if (!added) {
- System.err.println("Cannot add mount point " + mount);
- }
- return added;
- } else {
- UpdateMountTableEntryRequest updateRequest =
- UpdateMountTableEntryRequest.newInstance(existingOrNewEntry);
- UpdateMountTableEntryResponse updateResponse =
- mountTable.updateMountTableEntry(updateRequest);
- boolean updated = updateResponse.getStatus();
- if (!updated) {
- System.err.println("Cannot update mount point " + mount);
- }
- return updated;
+ MountTable mountEntry =
addMountAttributes.getMountTableEntryWithAttributes();
+ AddMountTableEntryRequest request =
AddMountTableEntryRequest.newInstance(mountEntry);
+ AddMountTableEntryResponse addResponse =
mountTable.addMountTableEntry(request);
+ boolean added = addResponse.getStatus();
+ if (!added) {
+ System.err.println("Cannot add mount point " + mount);
}
+ return added;
+ }
+
+ /**
+ * Return the map from namespace to destination.
+ * @param nss input namespaces.
+ * @param destinations input destinations.
+ * @return one map from namespace to destination.
+ * @throws IOException throw IOException if the destinations is invalida.
Review Comment:
typo ``invalida``
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java:
##########
@@ -699,32 +697,52 @@ public boolean addMount(AddMountAttributes
addMountAttributes)
// Get the existing entry
MountTableManager mountTable = client.getMountTableManager();
MountTable existingEntry = getMountEntry(mount, mountTable);
- MountTable existingOrNewEntry =
-
addMountAttributes.getNewOrUpdatedMountTableEntryWithAttributes(existingEntry);
- if (existingOrNewEntry == null) {
+ if (existingEntry != null) {
+ System.err.println("MountTable entry:" + mount + " already exists.");
return false;
}
- if (existingEntry == null) {
- AddMountTableEntryRequest request = AddMountTableEntryRequest
- .newInstance(existingOrNewEntry);
- AddMountTableEntryResponse addResponse =
mountTable.addMountTableEntry(request);
- boolean added = addResponse.getStatus();
- if (!added) {
- System.err.println("Cannot add mount point " + mount);
- }
- return added;
- } else {
- UpdateMountTableEntryRequest updateRequest =
- UpdateMountTableEntryRequest.newInstance(existingOrNewEntry);
- UpdateMountTableEntryResponse updateResponse =
- mountTable.updateMountTableEntry(updateRequest);
- boolean updated = updateResponse.getStatus();
- if (!updated) {
- System.err.println("Cannot update mount point " + mount);
- }
- return updated;
+ MountTable mountEntry =
addMountAttributes.getMountTableEntryWithAttributes();
+ AddMountTableEntryRequest request =
AddMountTableEntryRequest.newInstance(mountEntry);
+ AddMountTableEntryResponse addResponse =
mountTable.addMountTableEntry(request);
+ boolean added = addResponse.getStatus();
+ if (!added) {
+ System.err.println("Cannot add mount point " + mount);
}
+ return added;
+ }
+
+ /**
+ * Return the map from namespace to destination.
+ * @param nss input namespaces.
+ * @param destinations input destinations.
+ * @return one map from namespace to destination.
+ * @throws IOException throw IOException if the destinations is invalida.
+ */
+ public static Map<String, String> getDestMap(String[] nss, String[]
destinations)
+ throws IOException {
+ if (isInvalidDestinations(nss, destinations)) {
+ String message = "Invalid number of namespaces and destinations. The
number of destinations: "
+ + destinations.length + " is not equal to the number of namespaces:
" + nss.length;
+ throw new IOException(message);
+ }
+ Map<String, String> destMap = new LinkedHashMap<>();
+ boolean multiDest = destinations.length > 1;
+ for (int nsIndex = 0; nsIndex < nss.length; nsIndex++) {
+ int destIndex = multiDest ? nsIndex : 0;
+ destMap.put(nss[nsIndex], destinations[destIndex]);
+ }
+ return destMap;
+ }
+
+ private static boolean isInvalidDestinations(String[] nss, String[]
destinations) {
Review Comment:
Can change the name may be, areDestinationsInvalid() should sound more
appropriate
> RBF: Remove update functionality from routeradmin's add cmd
> -----------------------------------------------------------
>
> Key: HDFS-13507
> URL: https://issues.apache.org/jira/browse/HDFS-13507
> Project: Hadoop HDFS
> Issue Type: Sub-task
> Reporter: Wei Yan
> Assignee: Gang Li
> Priority: Minor
> Labels: incompatible, pull-request-available
> Attachments: HDFS-13507-HDFS-13891.003.patch,
> HDFS-13507-HDFS-13891.004.patch, HDFS-13507.000.patch, HDFS-13507.001.patch,
> HDFS-13507.002.patch, HDFS-13507.003.patch
>
>
> Follow up the discussion in HDFS-13326. We should remove the "update"
> functionality from routeradmin's add cmd, to make it consistent with RPC
> calls.
> Note that: this is an incompatible change.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]