[ 
https://issues.apache.org/jira/browse/YARN-11349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17641004#comment-17641004
 ] 

ASF GitHub Bot commented on YARN-11349:
---------------------------------------

slfan1989 commented on code in PR #5169:
URL: https://github.com/apache/hadoop/pull/5169#discussion_r1035403985


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterStoreTokenPBImpl.java:
##########
@@ -164,6 +170,40 @@ public void setRenewDate(Long renewDate) {
     this.builder.setRenewDate(renewDate);
   }
 
+  @Override
+  public byte[] toByteArray() throws IOException {
+    return builder.build().toByteArray();
+  }
+
+  @Override
+  public void readFields(DataInput in) throws IOException {
+    builder.mergeFrom((DataInputStream) in);
+  }
+
+  @Override
+  public String getTokenInfo() {
+    RouterStoreTokenProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.tokenInfo != null) {
+      return this.tokenInfo;
+    }
+    if (!p.hasTokenInfo()) {
+      return null;
+    }
+    this.tokenInfo = p.getTokenInfo();
+    return this.tokenInfo;
+  }
+
+  @Override
+  protected void setTokenInfo(String tokenInfo) {
+    maybeInitBuilder();
+    if(tokenInfo == null) {

Review Comment:
   i will fix it.



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/utils/FederationRouterRMTokenInputValidator.java:
##########
@@ -0,0 +1,104 @@
+/**
+ * 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.yarn.server.federation.store.utils;
+
+import org.apache.hadoop.yarn.security.client.YARNDelegationTokenIdentifier;
+import 
org.apache.hadoop.yarn.server.federation.store.exception.FederationStateStoreInvalidInputException;
+import org.apache.hadoop.yarn.server.federation.store.records.RouterMasterKey;
+import 
org.apache.hadoop.yarn.server.federation.store.records.RouterMasterKeyRequest;
+import 
org.apache.hadoop.yarn.server.federation.store.records.RouterRMTokenRequest;
+import org.apache.hadoop.yarn.server.federation.store.records.RouterStoreToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class FederationRouterRMTokenInputValidator {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(FederationRouterRMTokenInputValidator.class);
+
+  private FederationRouterRMTokenInputValidator() {
+  }
+
+  /**
+   * We will check with the RouterRMTokenRequest{@link RouterRMTokenRequest}
+   * to ensure that the request object is not empty and that the 
RouterStoreToken is not empty.
+   *
+   * @param request RouterRMTokenRequest Request.
+   * @throws FederationStateStoreInvalidInputException if the request is 
invalid.
+   */
+  public static void validate(RouterRMTokenRequest request)
+      throws FederationStateStoreInvalidInputException {
+
+    if (request == null) {
+      String message = "Missing RouterRMToken Request."
+          + " Please try again by specifying a router rm token information.";
+      LOG.warn(message);
+      throw new FederationStateStoreInvalidInputException(message);
+    }
+
+    RouterStoreToken storeToken = request.getRouterStoreToken();
+    if (storeToken == null) {
+      String message = "Missing RouterStoreToken."
+          + " Please try again by specifying a router rm token information.";
+      LOG.warn(message);
+      throw new FederationStateStoreInvalidInputException(message);
+    }
+
+    try {
+      YARNDelegationTokenIdentifier identifier = 
storeToken.getTokenIdentifier();
+      if (identifier == null) {
+        String message = "Missing YARNDelegationTokenIdentifier."
+            + " Please try again by specifying a router rm token information.";
+        LOG.warn(message);
+        throw new FederationStateStoreInvalidInputException(message);
+      }
+    } catch (Exception e) {
+      throw new FederationStateStoreInvalidInputException(e);
+    }
+  }
+
+  /**
+   * We will check with the RouterMasterKeyRequest{@link 
RouterMasterKeyRequest}
+   * to ensure that the request object is not empty and that the 
RouterMasterKey is not empty.
+   *
+   * @param request RouterMasterKey Request.
+   * @throws FederationStateStoreInvalidInputException if the request is 
invalid.
+   */
+  public static void validate(RouterMasterKeyRequest request)
+      throws FederationStateStoreInvalidInputException {
+
+        // Verify the request to ensure that the request is not empty,

Review Comment:
   i will fix it.





> [Federation] Router Support DelegationToken With SQL
> ----------------------------------------------------
>
>                 Key: YARN-11349
>                 URL: https://issues.apache.org/jira/browse/YARN-11349
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>          Components: federation, router
>    Affects Versions: 3.4.0
>            Reporter: Shilun Fan
>            Assignee: Shilun Fan
>            Priority: Major
>              Labels: pull-request-available
>
> Router Support DelegationToken With SQLFederationStateStore.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to