You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/04/02 06:49:40 UTC
[GitHub] [hadoop-ozone] xiaoyuyao commented on a change in pull request
#752: HDDS-3319. Handle HA for BasicOzoneClientAdapterImpl#renew/cancel().
xiaoyuyao 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_r402087161
##########
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:
The serviceID must be unique to support distcp cross clusters. In the case when token does not provide omServiceId or only the default serviceID is provided. Token renew/cancel may not be able to figure out the right OM clusters to talk to. That's the main reason that we fail 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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org