From common-issues-return-183602-apmail-hadoop-common-issues-archive=hadoop.apache.org@hadoop.apache.org Tue Aug 20 22:06:02 2019 Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id D7DC019375 for ; Tue, 20 Aug 2019 22:06:01 +0000 (UTC) Received: (qmail 11171 invoked by uid 500); 20 Aug 2019 22:06:01 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 11139 invoked by uid 500); 20 Aug 2019 22:06:01 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 11120 invoked by uid 99); 20 Aug 2019 22:06:00 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Aug 2019 22:06:00 +0000 From: GitBox To: common-issues@hadoop.apache.org Subject: [GitHub] [hadoop] bharatviswa504 commented on a change in pull request #1316: HDDS-1973. Implement OM RenewDelegationToken request to use Cache and DoubleBuffer. Message-ID: <156633876083.3002.4696128485446705560.gitbox@gitbox.apache.org> Date: Tue, 20 Aug 2019 22:06:00 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit bharatviswa504 commented on a change in pull request #1316: HDDS-1973. Implement OM RenewDelegationToken request to use Cache and DoubleBuffer. URL: https://github.com/apache/hadoop/pull/1316#discussion_r315924477 ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/security/OMRenewDelegationTokenRequest.java ########## @@ -0,0 +1,164 @@ +/** + * 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.ozone.om.request.security; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Optional; +import org.apache.hadoop.ozone.om.OMMetadataManager; +import org.apache.hadoop.ozone.om.OzoneManager; +import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper; +import org.apache.hadoop.ozone.om.request.OMClientRequest; +import org.apache.hadoop.ozone.om.response.OMClientResponse; +import org.apache.hadoop.ozone.om.response.security.OMRenewDelegationTokenResponse; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenewDelegationTokenResponseProto; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UpdateRenewDelegationTokenRequest; +import org.apache.hadoop.ozone.protocolPB.OMPBHelper; +import org.apache.hadoop.ozone.security.OzoneTokenIdentifier; +import org.apache.hadoop.security.proto.SecurityProtos.RenewDelegationTokenRequestProto; +import org.apache.hadoop.security.token.Token; +import org.apache.hadoop.utils.db.cache.CacheKey; +import org.apache.hadoop.utils.db.cache.CacheValue; + +/** + * Handle RenewDelegationToken Request. + */ +public class OMRenewDelegationTokenRequest extends OMClientRequest { + + private static final Logger LOG = + LoggerFactory.getLogger(OMGetDelegationTokenRequest.class); + + public OMRenewDelegationTokenRequest(OMRequest omRequest) { + super(omRequest); + } + + @Override + public OMRequest preExecute(OzoneManager ozoneManager) throws IOException { + RenewDelegationTokenRequestProto renewDelegationTokenRequest = + getOmRequest().getRenewDelegationTokenRequest(); + + // Call OM to renew token + long renewTime = ozoneManager.renewDelegationToken( + OMPBHelper.convertToDelegationToken( + renewDelegationTokenRequest.getToken())); + + RenewDelegationTokenResponseProto.Builder renewResponse = + RenewDelegationTokenResponseProto.newBuilder(); + + renewResponse.setResponse(org.apache.hadoop.security.proto.SecurityProtos + .RenewDelegationTokenResponseProto.newBuilder() + .setNewExpiryTime(renewTime)); + + + // Client issues RenewDelegationToken request, when received by OM leader + // it will renew the token. Original RenewDelegationToken request is + // converted to UpdateRenewDelegationToken request with the token and renew + // information. This updated request will be submitted to Ratis. In this + // way delegation token renewd by leader, will be replicated across all + // OMs. With this approach, original RenewDelegationToken request from + // client does not need any proto changes. + + // Create UpdateRenewDelegationTokenRequest with original request and + // expiry time. + OMRequest.Builder omRequest = OMRequest.newBuilder() + .setUserInfo(getUserInfo()) + .setUpdatedRenewDelegationTokenRequest( + UpdateRenewDelegationTokenRequest.newBuilder() + .setRenewDelegationTokenRequest(renewDelegationTokenRequest) + .setRenewDelegationTokenResponse(renewResponse)) + .setCmdType(getOmRequest().getCmdType()) Review comment: Ya can understand that. Otherwise, we need some changes in createClientRequest in ratis to act upon UpdateRenewDelegationTokenRequest or RenewDelegationTokenRequest to return OMGetDelegationTokenRequest object or have separate new classes for both of them. And for one only preExecute will be needed, for other validateAndUpdateCache only will be needed. So, I will leave this as it is. ---------------------------------------------------------------- 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: common-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-issues-help@hadoop.apache.org