pkumarsinha commented on a change in pull request #2005:
URL: https://github.com/apache/hive/pull/2005#discussion_r581672838



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplLoadTask.java
##########
@@ -499,6 +500,20 @@ private void dropTablesExcludedInReplScope(ReplScope 
replScope) throws HiveExcep
         dbName);
   }
 
+  private void createNotificationFileTask() {
+    if (((work.isIncrementalLoad() && 
!work.incrementalLoadTasksBuilder().hasMoreWork() )
+            || (!work.isIncrementalLoad()))  && !work.hasBootstrapLoadTasks()) 
{
+      //All repl load tasks are executed and status is 0, create the task to 
add the acknowledgement
+      NotificationFileWork notification_Work = new NotificationFileWork(new 
Path(work.dumpDirectory, "_notification_id"), work.getMetricCollector());

Review comment:
       File name should be a constant defined

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/NotificationFileTask.java
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.Path;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
+import org.apache.hadoop.hive.ql.plan.api.StageType;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.Serializable;
+
+public class NotificationFileTask extends Task<NotificationFileWork> 
implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Logger LOG = LoggerFactory.getLogger(AckTask.class);
+
+    @Override
+    public int execute() {
+        try {
+            HiveMetaStoreClient metaStoreClient = new 
HiveMetaStoreClient(conf);
+            long currentNotificationID = 
metaStoreClient.getCurrentNotificationEventId().getEventId();

Review comment:
       Check if this is retry-able call

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
##########
@@ -263,6 +266,21 @@ WarehouseInstance runFailure(String command, int 
errorCode) throws Throwable {
     }
   }
 
+  WarehouseInstance verifyNotificationID(String dumpLocation) throws Exception 
{
+    FileSystem fs = new Path(dumpLocation).getFileSystem(hiveConf);
+    long currentNotificationID = getCurrentNotificationEventId().getEventId();
+    Path notifyFilePath = new Path(dumpLocation + "/hive/", 
"_notification_id");
+    assertTrue(fs.exists(notifyFilePath));
+    InputStream inputStream = fs.open(notifyFilePath);
+
+    BufferedReader reader = new BufferedReader(new 
InputStreamReader(inputStream));
+    for (String line = reader.readLine(); line != null; line = 
reader.readLine()) {

Review comment:
       if line == null, assertion will get skipped. We should be sure about the 
value being present.

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/BaseReplicationScenariosAcidTables.java
##########
@@ -224,6 +224,38 @@ void verifyLoadExecution(String replicatedDbName, String 
lastReplId, boolean inc
     }
   }
 
+  void verifyBootLoadNotification(String replicatedDbName, String lastReplId, 
String dumpLocation, boolean includeAcid)
+          throws Throwable {
+    List<String> tableNames = new LinkedList<>(nonAcidTableNames);
+    if (includeAcid) {

Review comment:
       We do not need this distinction? 

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
##########
@@ -263,6 +266,21 @@ WarehouseInstance runFailure(String command, int 
errorCode) throws Throwable {
     }
   }
 
+  WarehouseInstance verifyNotificationID(String dumpLocation) throws Exception 
{
+    FileSystem fs = new Path(dumpLocation).getFileSystem(hiveConf);
+    long currentNotificationID = getCurrentNotificationEventId().getEventId();
+    Path notifyFilePath = new Path(dumpLocation + "/hive/", 
"_notification_id");

Review comment:
       Use constant for file name, hive dir. Prefer File.separator whenever 
possible

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/NotificationFileTask.java
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.Path;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
+import org.apache.hadoop.hive.ql.plan.api.StageType;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.Serializable;
+
+public class NotificationFileTask extends Task<NotificationFileWork> 
implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Logger LOG = LoggerFactory.getLogger(AckTask.class);
+
+    @Override
+    public int execute() {
+        try {
+            HiveMetaStoreClient metaStoreClient = new 
HiveMetaStoreClient(conf);
+            long currentNotificationID = 
metaStoreClient.getCurrentNotificationEventId().getEventId();
+            Path notificationPath = work.getNotificationFilePath();
+            Utils.writeOutput(String.valueOf(currentNotificationID), 
notificationPath, conf);
+            LOG.info("Created Notification file : {} ", notificationPath);

Review comment:
       Add currentNotificationID also as a part of log statement.

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
##########
@@ -263,6 +266,21 @@ WarehouseInstance runFailure(String command, int 
errorCode) throws Throwable {
     }
   }
 
+  WarehouseInstance verifyNotificationID(String dumpLocation) throws Exception 
{
+    FileSystem fs = new Path(dumpLocation).getFileSystem(hiveConf);
+    long currentNotificationID = getCurrentNotificationEventId().getEventId();
+    Path notifyFilePath = new Path(dumpLocation + "/hive/", 
"_notification_id");
+    assertTrue(fs.exists(notifyFilePath));
+    InputStream inputStream = fs.open(notifyFilePath);
+
+    BufferedReader reader = new BufferedReader(new 
InputStreamReader(inputStream));
+    for (String line = reader.readLine(); line != null; line = 
reader.readLine()) {
+      assertTrue(currentNotificationID > Long.parseLong(line));

Review comment:
       This may pass for 0 as well. What we need to make sure is that we are 
making progress on each iteration of dump-load.
   Store the currently stored notification id in a variable. And perform an 
additional assertion that the current one is greater than previously stored one.




----------------------------------------------------------------
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:
[email protected]



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

Reply via email to