bharatviswa504 commented on a change in pull request #752: HDDS-3319. Handle HA 
for BasicOzoneClientAdapterImpl#renew/cancel().
URL: https://github.com/apache/hadoop-ozone/pull/752#discussion_r402050759
 
 

 ##########
 File path: 
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientFactory.java
 ##########
 @@ -159,6 +163,47 @@ private static OzoneClient getRpcClient(ClientProtocol 
clientProtocol,
     return new OzoneClient(config, proxy);
   }
 
+  /**
+   * Create OzoneClient for token renew/cancel operations.
+   * @param conf Configuration to be used for OzoneCient creation
+   * @param token ozone token is involved
+   * @return
+   * @throws IOException
+   */
+  public static OzoneClient getOzoneClient(Configuration conf,
+      Token<OzoneTokenIdentifier> token) throws IOException {
+    Preconditions.checkNotNull(token, "Null token is not allowed");
+    String omServiceId = token.decodeIdentifier().getOmServiceId();
+    if (StringUtils.isNotEmpty(omServiceId)) {
+      // new OM should always issue token with omServiceId
+      if (omServiceId.equals(OzoneConsts.OM_SERVICE_ID_DEFAULT)) {
+        // Non-HA
+        return OzoneClientFactory.getRpcClient(conf);
+      } else if (OmUtils.isOmHAServiceId(conf, omServiceId)) {
+        // HA with matching service id
+        return OzoneClientFactory.getRpcClient(omServiceId, conf);
+      } else {
+        // HA with mismatched service id
+        throw new IOException("Service ID specified does not match" +
+            " with " + OZONE_OM_SERVICE_IDS_KEY + " defined in the " +
+            "configuration. Configured " + OZONE_OM_SERVICE_IDS_KEY +
+            " are" + conf.getTrimmedStringCollection(
+            OZONE_OM_SERVICE_IDS_KEY));
+      }
+    } else {
+      // Old OM may issue token without omServiceId that should work
+      // with non-HA case
+      if (!OmUtils.isServiceIdsDefined(conf)) {
+        return OzoneClientFactory.getRpcClient(conf);
+      } else {
 
 Review comment:
   This else, says when new client talking to old OM with HA, we are failing is 
my understanding correct here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to