[ 
https://issues.apache.org/jira/browse/HIVE-23353?focusedWorklogId=434418&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-434418
 ]

ASF GitHub Bot logged work on HIVE-23353:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/May/20 14:36
            Start Date: 18/May/20 14:36
    Worklog Time Spent: 10m 
      Work Description: pkumarsinha commented on a change in pull request #1021:
URL: https://github.com/apache/hive/pull/1021#discussion_r426673131



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/atlas/RESTClientBuilder.java
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.hive.ql.exec.repl.atlas;
+
+import org.apache.atlas.ApplicationProperties;
+import org.apache.atlas.AtlasClientV2;
+import org.apache.atlas.AtlasException;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationConverter;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Properties;
+
+/**
+ * RestClientBuilder for AtlasRESTClient.
+ */
+public class RESTClientBuilder {
+  private static final Logger LOG = 
LoggerFactory.getLogger(RESTClientBuilder.class);
+  private static final String ATLAS_PROPERTY_CLIENT_HA_RETRIES_KEY = 
"atlas.client.ha.retries";
+  private static final String ATLAS_PROPERTY_CLIENT_HA_SLEEP_INTERVAL_MS_KEY = 
"atlas.client.ha.sleep.interval.ms";
+  private static final String ATLAS_PROPERTY_REST_ADDRESS = 
"atlas.rest.address";
+  private static final String ATLAS_PROPERTY_AUTH_KERBEROS = 
"atlas.authentication.method.kerberos";
+  private static final String URL_SEPERATOR = ",";
+
+  private AuthStrategy authStrategy;
+  private UserGroupInformation userGroupInformation;
+  protected String incomingUrl;
+  protected String[] baseUrls;
+
+  enum AuthStrategy {
+    KERBEROS
+  }
+
+  public RESTClientBuilder() {
+  }
+
+  public RESTClientBuilder baseUrl(String urls) {
+    this.incomingUrl = urls;
+    if (urls.contains(URL_SEPERATOR)) {
+      this.baseUrls = urls.split(URL_SEPERATOR);
+    } else {
+      this.baseUrls = new String[]{urls};
+    }
+
+    return this;
+  }
+
+  public RESTClientBuilder setAuthStrategy() throws SemanticException {
+    return inferKerberosAuthStrategy();
+  }
+
+  private RESTClientBuilder inferKerberosAuthStrategy() throws 
SemanticException {
+    try {
+      authStrategy = AuthStrategy.KERBEROS;
+      this.userGroupInformation = UserGroupInformation.getLoginUser();
+      LOG.info("HiveAtlasPlugin: authStrategy: {} : urls: {}: 
userGroupInformation: {}",
+              authStrategy, baseUrls, userGroupInformation);
+    } catch (Exception e) {
+      throw new SemanticException("Error: setAuthStrategy: 
UserGroupInformation.getLoginUser: failed!", e);
+    }
+    return this;
+  }
+
+  public AtlasRESTClient create() throws SemanticException {
+    if (baseUrls == null || baseUrls.length == 0) {
+      throw new SemanticException("baseUrls is not set.");
+    }
+    setAuthStrategy();
+    initializeAtlasApplicationProperties();
+    AtlasClientV2 clientV2;
+    LOG.info("HiveAtlasPlugin: authStrategyUsed: {} : {}", authStrategy, 
baseUrls);
+    switch (authStrategy) {
+      case KERBEROS:
+        clientV2 = new AtlasClientV2(this.userGroupInformation,
+                this.userGroupInformation.getShortUserName(), baseUrls);
+        return new AtlasRESTClientImpl(clientV2);
+      default:
+        throw new SemanticException("AtlasRESTClient: unsupported auth 
strategy:" + authStrategy);
+    }
+  }
+
+  private void initializeAtlasApplicationProperties() throws SemanticException 
{
+    try {
+      ApplicationProperties.set(getClientProperties());

Review comment:
       Yes, that's Atlas' interface. 




----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 434418)
    Time Spent: 2h  (was: 1h 50m)

> Atlas metadata replication scheduling
> -------------------------------------
>
>                 Key: HIVE-23353
>                 URL: https://issues.apache.org/jira/browse/HIVE-23353
>             Project: Hive
>          Issue Type: Task
>            Reporter: PRAVIN KUMAR SINHA
>            Assignee: PRAVIN KUMAR SINHA
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-23353.01.patch
>
>          Time Spent: 2h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to