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

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

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/repl/AtlasDumpWork.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.utils.StringUtils;
+import org.apache.hadoop.hive.ql.exec.repl.atlas.AtlasReplInfo;
+import org.apache.hadoop.hive.ql.exec.repl.util.ReplUtils;
+import org.apache.hadoop.hive.ql.parse.EximUtil;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.plan.Explain;
+import org.apache.hadoop.hive.ql.plan.Explain.Level;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.nio.charset.Charset;
+
+/**
+ * Atlas metadata replication work.
+ */
+@Explain(displayName = "Atlas Meta Data Dump Work", explainLevels = { 
Level.USER, Level.DEFAULT, Level.EXTENDED })
+public class AtlasDumpWork implements Serializable {
+  private static final long serialVersionUID = 1L;
+  private final String srcDB;
+  private final Path stagingDir;
+  private final HiveConf conf;
+  private final boolean bootstrap;
+  private final Path prevAtlasDumpDir;
+
+
+  public AtlasDumpWork(String srcDB, Path stagingDir, boolean bootstrap, Path 
prevAtlasDumpDir, HiveConf conf) {
+    this.srcDB = srcDB;
+    this.stagingDir = stagingDir;
+    this.bootstrap = bootstrap;
+    this.prevAtlasDumpDir = prevAtlasDumpDir;
+    this.conf = conf;
+  }
+
+  public AtlasReplInfo getAtlasReplInfo() throws SemanticException{
+    String endpoint = 
getNonEmpty(HiveConf.ConfVars.REPL_ATLAS_ENDPOINT.varname);
+    String tgtDB = 
getNonEmpty(HiveConf.ConfVars.REPL_ATLAS_REPLICATED_TO_DB.varname);
+    String srcCluster = 
getNonEmpty(HiveConf.ConfVars.REPL_SOURCE_CLUSTER_NAME.varname);
+    String tgtCluster = 
getNonEmpty(HiveConf.ConfVars.REPL_TARGET_CLUSTER_NAME.varname);
+    AtlasReplInfo atlasReplInfo = new AtlasReplInfo(endpoint, srcDB, tgtDB, 
srcCluster, tgtCluster, stagingDir, conf);
+    atlasReplInfo.setSrcFsUri(conf.get(ReplUtils.DEFAULT_FS_CONFIG));
+    long lastTimeStamp = isBootstrap() ? 0L : lastStoredTimeStamp();
+    atlasReplInfo.setTimeStamp(lastTimeStamp);
+    return atlasReplInfo;
+  }
+
+  private long lastStoredTimeStamp() throws SemanticException {
+    Path prevMetadataPath = new Path(getPrevAtlasDumpDir(), 
EximUtil.METADATA_NAME);
+    BufferedReader br = null;
+    try {
+      FileSystem fs = prevMetadataPath.getFileSystem(conf);
+      br = new BufferedReader(new InputStreamReader(fs.open(prevMetadataPath), 
Charset.defaultCharset()));
+      String[] lineContents = br.readLine().split("\t", 5);
+      return Long.parseLong(lineContents[1]);
+    } catch (Exception ex) {
+      throw new SemanticException(ex);
+    } finally {
+      if (br != null) {
+        try {
+          br.close();
+        } catch (IOException e) {
+          throw new SemanticException(e);
+        }
+      }
+    }
+  }
+
+  private String getNonEmpty(String config) throws SemanticException {
+    String val = conf.get(config);
+    if (StringUtils.isEmpty(val)) {
+      throw new SemanticException(config + " is mandatory config for Atlas 
metadata replication");
+    }
+    return val;
+  }
+
+  public boolean isBootstrap() {
+    return bootstrap;
+  }
+
+  public Path getPrevAtlasDumpDir() {

Review comment:
       During incremental we load the changeMarker info from prev dump.




----------------------------------------------------------------
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: 434410)
    Time Spent: 1h 10m  (was: 1h)

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




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

Reply via email to