This is an automated email from the ASF dual-hosted git repository. anishek pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push: new ae7e595 HIVE-23362: Repl dump returns dump location and repl id but doesn't write the ack in s3a FS (Aasha Medhi, reviewed by Anishek Agarwal) ae7e595 is described below commit ae7e595dee187bfc4e9796867c38241c43e8b707 Author: Aasha Medhi <aasha.medhi2...@gmail.com> AuthorDate: Mon May 11 10:17:45 2020 +0530 HIVE-23362: Repl dump returns dump location and repl id but doesn't write the ack in s3a FS (Aasha Medhi, reviewed by Anishek Agarwal) --- .../hadoop/hive/ql/exec/repl/ReplDumpTask.java | 2 +- .../hadoop/hive/ql/parse/repl/dump/Utils.java | 2 +- .../hadoop/hive/ql/exec/repl/dump/TestUtils.java | 59 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java index 055decd..062f367 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java @@ -203,11 +203,11 @@ public class ReplDumpTask extends Task<ReplDumpWork> implements Serializable { } private void finishRemainingTasks() throws SemanticException { - prepareReturnValues(work.getResultValues()); Path dumpAckFile = new Path(work.getCurrentDumpPath(), ReplUtils.REPL_HIVE_BASE_DIR + File.separator + ReplAck.DUMP_ACKNOWLEDGEMENT.toString()); Utils.create(dumpAckFile, conf); + prepareReturnValues(work.getResultValues()); deleteAllPreviousDumpMeta(work.getCurrentDumpPath()); } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java index 3b49801..44320a5 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java @@ -127,7 +127,7 @@ public class Utils { @Override public Void execute() throws IOException { FileSystem fs = outputFile.getFileSystem(hiveConf); - fs.create(outputFile); + fs.create(outputFile).close(); return null; } }; diff --git a/ql/src/test/org/apache/hadoop/hive/ql/exec/repl/dump/TestUtils.java b/ql/src/test/org/apache/hadoop/hive/ql/exec/repl/dump/TestUtils.java new file mode 100644 index 0000000..3303f95 --- /dev/null +++ b/ql/src/test/org/apache/hadoop/hive/ql/exec/repl/dump/TestUtils.java @@ -0,0 +1,59 @@ +/* + * 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.dump; + +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.ql.parse.SemanticException; +import org.apache.hadoop.hive.ql.parse.repl.dump.Utils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +import java.io.IOException; +import static org.mockito.Mockito.times; + +/** + * Test class to test dump utils. + */ +@RunWith(MockitoJUnitRunner.class) +public class TestUtils { + + @Mock + Path outputFile; + + @Mock + FileSystem fileSystem; + + @Mock + FSDataOutputStream outputStream; + + @Test + public void testCreate() throws SemanticException, IOException { + HiveConf conf = new HiveConf(); + Mockito.when(outputFile.getFileSystem(conf)).thenReturn(fileSystem); + Mockito.when(fileSystem.create(outputFile)).thenReturn(outputStream); + Utils.create(outputFile, conf); + Mockito.verify(outputStream, times(1)).close(); + } +}