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

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

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



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/atlas/AtlasProcess.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.model.impexp.AtlasServer;
+import org.apache.atlas.model.instance.AtlasObjectId;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Base class for Atlas Processes, viz. Export & Import
+ */
+public abstract class AtlasProcess {
+  private static final String CLUSTER_NAME_SEPARATOR = "$";
+  protected static final Logger LOG = 
LoggerFactory.getLogger(AtlasProcess.class);
+
+  private RESTClientBuilder builder = new RESTClientBuilder();
+  protected AtlasRequestBuilder atlasRequestBuilder = new 
AtlasRequestBuilder();
+
+  protected AtlasRESTClient getClient(String atlasEndpoint, HiveConf conf) 
throws SemanticException {
+    if (conf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST_REPL)) {
+      return new DummyAtlasRESTClient();
+    }
+    return builder.baseUrl(atlasEndpoint).create();
+  }
+
+  public String getEntityGuid(String atlasEndpoint, String typeName, String 
attributeName,
+                              String attributeValue, HiveConf conf) throws 
SemanticException {
+    return getClient(atlasEndpoint, conf).getEntityGuid(typeName, 
attributeName, attributeValue);
+  }
+
+  public boolean getStatus(String atlasEndpoint, HiveConf conf) throws 
SemanticException {
+    return getClient(atlasEndpoint, conf).getStatus();
+  }
+
+  public abstract void run(AtlasReplInfo atlasReplInfo) throws 
SemanticException;
+
+  public long getCurrentTimestamp(AtlasReplInfo atlasReplInfo, String 
entityGuid) throws SemanticException {
+    AtlasRESTClient client = getClient(atlasReplInfo.getAtlasEndpoint(), 
atlasReplInfo.getConf());
+    AtlasServer atlasServer = client.getServer(atlasReplInfo.getSrcCluster());
+    long ret = (atlasServer == null || 
atlasServer.getAdditionalInfoRepl(entityGuid) == null)
+            ? 0L : (long) atlasServer.getAdditionalInfoRepl(entityGuid);
+    LOG.debug("HiveAtlasPlugin: fromTimestamp: {}", ret);
+    return ret;
+  }
+
+  public String checkHiveEntityGuid(String atlasEndpoint, String 
fullyQualifiedClusterName, String srcDb, HiveConf conf)
+          throws SemanticException {
+    String clusterName = getAtlasClusterName(fullyQualifiedClusterName);
+    AtlasObjectId objectId = atlasRequestBuilder.getItemToExport(clusterName, 
srcDb);
+    Set<Map.Entry<String, Object>> entries = 
objectId.getUniqueAttributes().entrySet();
+    if (entries == null || entries.isEmpty()) {
+      throw new SemanticException("HiveAtlasPlugin: Could find entries in 
objectId for:" + clusterName);
+    }
+    Map.Entry<String, Object> item = entries.iterator().next();
+    String guid = getEntityGuid(atlasEndpoint, objectId.getTypeName(), 
item.getKey(), (String) item.getValue(), conf);
+    if (guid == null || guid.isEmpty()) {
+      throw new SemanticException("HiveAtlasPlugin: Entity not found:" + 
objectId);
+    }
+    return guid;
+  }
+
+  protected static String getAtlasClusterName(String clusterName) {

Review comment:
       Yes, if orchestration engine adds dc in cluster name. Have retained the 
behavior. 




----------------------------------------------------------------
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: 434416)
    Time Spent: 1h 40m  (was: 1.5h)

> 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: 1h 40m
>  Remaining Estimate: 0h
>




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

Reply via email to