echonesis commented on code in PR #11067: URL: https://github.com/apache/ozone/pull/11067#discussion_r3853710838
########## hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/O3DtFetcher.java: ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.ozone; + +import java.net.URI; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.ozone.OzoneConsts; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.security.token.Token; + +/** + * A DT fetcher for Ozone RPC URLs. + */ +public class O3DtFetcher extends AbstractOzoneDtFetcher { + @Override + public Text getServiceName() { + return new Text(OzoneConsts.OZONE_RPC_SCHEME); + } + + @Override + public Token<?> addDelegationTokens(Configuration conf, Credentials creds, + String renewer, String url) throws Exception { + String serviceName = getServiceName().toString(); + if (!url.startsWith(serviceName + "://")) { + url = serviceName + "://" + url; + } + URI uri = URI.create(url); + if (uri.getAuthority() == null) { + throw new IllegalArgumentException( + "OM authority is required in Ozone RPC URL: " + url); + } + URI ofsUri = new URI(OzoneConsts.OZONE_OFS_URI_SCHEME, + uri.getAuthority(), "/", null, null); + return addDelegationTokens(conf, creds, renewer, ofsUri); Review Comment: Yes, that is cleaner. I’ll have O3DtFetcher override the protected URI-based addDelegationTokens method instead. The superclass will handle URL normalization, while O3DtFetcher will only validate the OM authority, convert the URI to ofs://<authority>/, and delegate the token fetching to the superclass. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
