This is an automated email from the ASF dual-hosted git repository.
zabetak 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 faf0a9e HIVE-25655: Remove ElapsedTimeLoggingWrapper from tests
(Stamatis Zampetakis, reviewed by Krisztian Kasa)
faf0a9e is described below
commit faf0a9ec1b505df225940e8c8c8ec868b689d310
Author: Stamatis Zampetakis <[email protected]>
AuthorDate: Wed Oct 27 16:13:17 2021 +0200
HIVE-25655: Remove ElapsedTimeLoggingWrapper from tests (Stamatis
Zampetakis, reviewed by Krisztian Kasa)
The benefit of logging times in before/after of CoreCliDriver methods
is subtle and the presence of the wrapper makes the code less readable.
Closes #2755
---
.../hadoop/hive/cli/control/CoreCliDriver.java | 53 ++++++----------------
.../hive/util/ElapsedTimeLoggingWrapper.java | 43 ------------------
2 files changed, 14 insertions(+), 82 deletions(-)
diff --git
a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java
b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java
index b1ee326..c7430e8 100644
---
a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java
+++
b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java
@@ -30,7 +30,6 @@ import org.apache.hadoop.hive.ql.QTestProcessExecResult;
import org.apache.hadoop.hive.ql.QTestUtil;
import org.apache.hadoop.hive.ql.QTestMiniClusters.MiniClusterType;
import org.apache.hadoop.hive.ql.processors.CommandProcessorException;
-import org.apache.hadoop.hive.util.ElapsedTimeLoggingWrapper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -63,59 +62,35 @@ public class CoreCliDriver extends CliAdapter {
String initScript = cliConfig.getInitScript();
String cleanupScript = cliConfig.getCleanupScript();
- qt = new ElapsedTimeLoggingWrapper<QTestUtil>() {
- @Override
- public QTestUtil invokeInternal() throws Exception {
- return new QTestUtil(
- QTestArguments.QTestArgumentsBuilder.instance()
- .withOutDir(cliConfig.getResultsDir())
- .withLogDir(cliConfig.getLogDir())
- .withClusterType(miniMR)
- .withConfDir(hiveConfDir)
- .withInitScript(initScript)
- .withCleanupScript(cleanupScript)
- .withLlapIo(true)
- .withFsType(cliConfig.getFsType())
- .build());
- }
- }.invoke("QtestUtil instance created", LOG, true);
+ qt = new QTestUtil(QTestArguments.QTestArgumentsBuilder.instance()
+ .withOutDir(cliConfig.getResultsDir())
+ .withLogDir(cliConfig.getLogDir())
+ .withClusterType(miniMR)
+ .withConfDir(hiveConfDir)
+ .withInitScript(initScript)
+ .withCleanupScript(cleanupScript)
+ .withLlapIo(true)
+ .withFsType(cliConfig.getFsType())
+ .build());
}
@Override
@Before
public void setUp() throws Exception {
- new ElapsedTimeLoggingWrapper<Void>() {
- @Override
- public Void invokeInternal() throws Exception {
- qt.newSession();
- return null;
- }
- }.invoke("PerTestSetup done.", LOG, false);
+ qt.newSession();
}
@Override
@After
public void tearDown() throws Exception {
- new ElapsedTimeLoggingWrapper<Void>() {
- @Override
- public Void invokeInternal() throws Exception {
- qt.clearPostTestEffects();
- qt.clearTestSideEffects();
- return null;
- }
- }.invoke("PerTestTearDown done.", LOG, false);
+ qt.clearPostTestEffects();
+ qt.clearTestSideEffects();
}
@Override
@AfterClass
public void shutdown() throws Exception {
- new ElapsedTimeLoggingWrapper<Void>() {
- @Override
- public Void invokeInternal() throws Exception {
- qt.shutdown();
- return null;
- }
- }.invoke("Teardown done.", LOG, false);
+ qt.shutdown();
}
@Override
diff --git
a/itests/util/src/main/java/org/apache/hadoop/hive/util/ElapsedTimeLoggingWrapper.java
b/itests/util/src/main/java/org/apache/hadoop/hive/util/ElapsedTimeLoggingWrapper.java
deleted file mode 100644
index b793b1a..0000000
---
a/itests/util/src/main/java/org/apache/hadoop/hive/util/ElapsedTimeLoggingWrapper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.util;
-
-import java.util.concurrent.TimeUnit;
-
-import com.google.common.base.Stopwatch;
-import org.slf4j.Logger;
-
-public abstract class ElapsedTimeLoggingWrapper<T> {
-
- public abstract T invokeInternal() throws Exception;
-
- public T invoke(String message, Logger LOG, boolean toStdErr) throws
Exception {
- Stopwatch sw = Stopwatch.createStarted();
- try {
- T retVal = invokeInternal();
- return retVal;
- } finally {
- String logMessage = message + " ElapsedTime(ms)=" +
sw.stop().elapsed(TimeUnit.MILLISECONDS);
- LOG.info(logMessage);
- if (toStdErr) {
- System.err.println(logMessage);
- }
- }
- }
-}