You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by pr...@apache.org on 2015/05/27 16:31:54 UTC
[3/3] incubator-lens git commit: LENS-551: Cleanup testcases of
exception stack traces
LENS-551: Cleanup testcases of exception stack traces
Project: http://git-wip-us.apache.org/repos/asf/incubator-lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-lens/commit/b0783db7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-lens/tree/b0783db7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-lens/diff/b0783db7
Branch: refs/heads/master
Commit: b0783db7976d207b6544dcf2d9f8e5685994f9b4
Parents: 82553db
Author: Yash Sharma <ya...@gmail.com>
Authored: Wed May 27 20:01:26 2015 +0530
Committer: Rajat Khandelwal <ra...@gmail.com>
Committed: Wed May 27 20:01:26 2015 +0530
----------------------------------------------------------------------
checkstyle/src/main/resources/checkstyle.xml | 7 +
.../lens/cli/commands/BaseLensCommand.java | 10 +-
.../cli/commands/LensConnectionCommands.java | 7 +-
.../lens/cli/TestLensDimensionCommands.java | 16 +-
.../cli/TestLensDimensionTableCommands.java | 24 ++-
.../apache/lens/cli/TestLensFactCommands.java | 27 ++-
.../apache/lens/cli/TestLensQueryCommands.java | 31 ++-
.../apache/lens/client/jdbc/LensJdbcDriver.java | 6 +-
.../org/apache/lens/cube/parse/HQLParser.java | 7 +-
.../timeline/TestPartitionTimelines.java | 6 +-
.../apache/lens/cube/parse/CubeTestSetup.java | 6 +-
.../lens/cube/parse/TestCubeRewriter.java | 7 +-
.../apache/lens/cube/parse/TestDateUtil.java | 6 +-
.../apache/lens/cube/parse/TestHQLParser.java | 6 +-
.../lens/cube/parse/TestMaxUpdateInterval.java | 6 +-
.../lens/cube/parse/TestQueryRewrite.java | 3 +-
.../lens/cube/parse/TestTimeRangeWriter.java | 5 +-
.../parse/TestTimeRangeWriterWithQuery.java | 6 +-
.../org/apache/lens/driver/hive/HiveDriver.java | 95 +++++----
.../lens/driver/hive/HiveInMemoryResultSet.java | 5 +-
.../apache/lens/driver/hive/HiveQueryPlan.java | 5 +-
.../lens/driver/hive/TestRemoteHiveDriver.java | 27 ++-
.../driver/jdbc/TestColumnarSQLRewriter.java | 7 +-
.../jdbc/TestDataSourceConnectionProvider.java | 15 +-
.../apache/lens/driver/jdbc/TestJdbcDriver.java | 32 ++--
.../apache/lens/examples/SampleMetastore.java | 6 +-
.../org/apache/lens/client/LensMLClient.java | 9 +-
.../apache/lens/ml/algo/lib/AlgoArgParser.java | 11 +-
.../org/apache/lens/ml/impl/LensMLImpl.java | 71 ++++---
.../java/org/apache/lens/ml/TestMLResource.java | 25 ++-
.../apache/lens/server/LensRequestListener.java | 5 +-
.../lens/server/LensServletContextListener.java | 5 +-
.../metastore/CubeMetastoreServiceImpl.java | 76 ++++----
.../apache/lens/server/metastore/JAXBUtils.java | 12 +-
.../lens/server/metrics/MetricsServiceImpl.java | 17 +-
.../apache/lens/server/query/LensServerDAO.java | 21 +-
.../server/query/QueryExecutionServiceImpl.java | 191 +++++++++----------
.../lens/server/query/QueryServiceResource.java | 16 +-
.../lens/server/session/HiveSessionService.java | 50 +++--
.../event/query/QueryExecutionStatistics.java | 6 +-
.../org/apache/lens/server/LensTestUtil.java | 6 +-
.../server/metastore/TestMetastoreService.java | 18 +-
.../lens/server/query/TestQueryService.java | 22 +--
.../session/TestDatabaseResourceService.java | 10 +-
.../stats/TestStatisticsLogFileScannerTask.java | 5 +-
45 files changed, 498 insertions(+), 456 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/checkstyle/src/main/resources/checkstyle.xml
----------------------------------------------------------------------
diff --git a/checkstyle/src/main/resources/checkstyle.xml b/checkstyle/src/main/resources/checkstyle.xml
index d6ff839..031d664 100644
--- a/checkstyle/src/main/resources/checkstyle.xml
+++ b/checkstyle/src/main/resources/checkstyle.xml
@@ -245,6 +245,13 @@
<property name="checkFormat" value="ParameterNumberCheck|VisibilityModifierCheck|HiddenFieldCheck|MethodName|HideUtilityClassConstructorCheck|DoubleCheckedLockingCheck|InnerAssignmentCheck"/>
</module>
+ <module name="RegexpSingleline">
+ <property name="severity" value="error" />
+ <property name="format" value="\w*.printStackTrace\w*" />
+ <property name="message" value="Print stack trace not allowed. Use Logger." />
+ <property name="fileExtensions" value="java" />
+ </module>
+
<!--module name="SuppressionFilter">
<property name="file" value="checkstyle/src/main/resources/suppressions.xml"/>
</module-->
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
index d6055cd..3deddfa 100644
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/BaseLensCommand.java
@@ -27,8 +27,6 @@ import java.util.Date;
import org.apache.lens.client.LensClient;
import org.apache.lens.client.LensClientSingletonWrapper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
@@ -41,9 +39,12 @@ import org.springframework.shell.event.ParseResult;
import com.google.common.collect.Sets;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class BaseLensCommand.
*/
+@Slf4j
public class BaseLensCommand implements ExecutionProcessor {
/** The mapper. */
@@ -52,9 +53,6 @@ public class BaseLensCommand implements ExecutionProcessor {
/** The pp. */
protected DefaultPrettyPrinter pp;
- /** The Constant LOG. */
- public static final Log LOG = LogFactory.getLog(BaseLensCommand.class);
-
/** The is connection active. */
protected static boolean isConnectionActive;
public static final String DATE_FMT = "yyyy-MM-dd'T'HH:mm:ss:SSS";
@@ -84,7 +82,7 @@ public class BaseLensCommand implements ExecutionProcessor {
*/
protected static synchronized void closeClientConnection() {
if (isConnectionActive) {
- LOG.debug("Request for stopping lens cli received");
+ log.debug("Request for stopping lens cli received");
getClient().closeConnection();
isConnectionActive = false;
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
index d727ecc..675e6c8 100644
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensConnectionCommands.java
@@ -32,9 +32,13 @@ import org.springframework.stereotype.Component;
import com.google.common.base.Joiner;
+import lombok.extern.slf4j.Slf4j;
+
+
/**
* The Class LensConnectionCommands.
*/
+@Slf4j
@Component
@UserDocumentation(title = "Session management",
description = "Opening the lens CLI shell is equivalent to open a session with lens server."
@@ -159,8 +163,7 @@ public class LensConnectionCommands extends BaseLensCommand {
closeClientConnection();
return ExitShellRequest.NORMAL_EXIT;
} catch (ProcessingException e) {
- System.out.println(e.getMessage());
- LOG.error(e);
+ log.error("Error while closing client connection.", e);
return ExitShellRequest.FATAL_EXIT;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
index 5df3486..208eb78 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
@@ -25,19 +25,17 @@ import java.net.URL;
import org.apache.lens.cli.commands.LensDimensionCommands;
import org.apache.lens.client.LensClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestLensDimensionCommands.
*/
+@Slf4j
public class TestLensDimensionCommands extends LensCliApplicationTest {
- /** The Constant LOG. */
- private static final Logger LOG = LoggerFactory.getLogger(TestLensDimensionCommands.class);
-
/** The command. */
private static LensDimensionCommands command = null;
@@ -69,7 +67,7 @@ public class TestLensDimensionCommands extends LensCliApplicationTest {
*/
@Test
public void testDimensionCommands() throws Exception {
- LOG.debug("Starting to test dimension commands");
+ log.debug("Starting to test dimension commands");
URL dimensionSpec = TestLensDimensionCommands.class.getClassLoader().getResource("test-dimension.xml");
String dimensionList = getCommand().showDimensions();
Assert.assertFalse(dimensionList.contains("test_dim"));
@@ -114,14 +112,14 @@ public class TestLensDimensionCommands extends LensCliApplicationTest {
writer.close();
String desc = command.describeDimension("test_dim");
- LOG.debug(desc);
+ log.debug(desc);
String propString = "name : test_dim.prop value : test";
String propString1 = "name : test_dim.prop1 value : test1";
Assert.assertTrue(desc.contains(propString));
command.updateDimension("test_dim", "/tmp/test_dim1.xml");
desc = command.describeDimension("test_dim");
- LOG.debug(desc);
+ log.debug(desc);
Assert.assertTrue(desc.contains(propString));
Assert.assertTrue(desc.contains(propString1));
@@ -129,7 +127,7 @@ public class TestLensDimensionCommands extends LensCliApplicationTest {
newFile.delete();
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Testing update dimension failed with exception", t);
Assert.fail("Testing update dimension failed with exception" + t.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
index a98f183..a87d0b7 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
@@ -28,19 +28,17 @@ import org.apache.lens.cli.commands.LensDimensionCommands;
import org.apache.lens.cli.commands.LensDimensionTableCommands;
import org.apache.lens.client.LensClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestLensDimensionTableCommands.
*/
+@Slf4j
public class TestLensDimensionTableCommands extends LensCliApplicationTest {
- /** The Constant LOG. */
- private static final Logger LOG = LoggerFactory.getLogger(TestLensDimensionTableCommands.class);
-
/** The Constant DIM_LOCAL. */
public static final String DIM_LOCAL = "dim_local";
@@ -116,7 +114,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
try {
command.createDimensionTable(new File(dimSpec.toURI()).getAbsolutePath());
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Unable to create dimtable", e);
Assert.fail("Unable to create dimtable" + e.getMessage());
}
@@ -126,13 +124,13 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
Assert.assertEquals(command.showDimensionTables("blah"), dimList);
Assert.fail();
} catch (NotFoundException e) {
- LOG.info("blah is not a table", e);
+ log.info("blah is not a table", e);
}
try {
Assert.assertEquals(command.showDimensionTables("dim_table2"), dimList);
Assert.fail();
} catch (NotFoundException e) {
- LOG.info("dim_table2 is a table, but not a dimension", e);
+ log.info("dim_table2 is a table, but not a dimension", e);
}
Assert.assertTrue(dimList.contains(tableName), "dim_table table should be found");
}
@@ -166,7 +164,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
writer.close();
String desc = command.describeDimensionTable("dim_table2");
- LOG.debug(desc);
+ log.debug(desc);
String propString = "name : dim2.prop value : d2";
String propString1 = "name : dim2.prop value : d1";
String propString2 = "name : dim2.prop1 value : d2";
@@ -174,7 +172,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
command.updateDimensionTable("dim_table2", "/tmp/local-dim1.xml");
desc = command.describeDimensionTable("dim_table2");
- LOG.debug(desc);
+ log.debug(desc);
Assert.assertTrue(desc.contains(propString1));
Assert.assertTrue(desc.contains(propString2));
@@ -234,7 +232,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
command.addPartitionToDimtable("dim_table2", DIM_LOCAL, new File(
TestLensFactCommands.class.getClassLoader().getResource("dim1-local-part.xml").toURI()).getAbsolutePath());
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Unable to locate the storage part file for adding new storage to dim table dim_table2", t);
Assert.fail("Unable to locate the storage part file for adding new storage to dim table dim_table2");
}
verifyAndDeletePartition();
@@ -242,7 +240,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
command.addPartitionsToDimtable("dim_table2", DIM_LOCAL, new File(
TestLensFactCommands.class.getClassLoader().getResource("dim1-local-parts.xml").toURI()).getAbsolutePath());
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Unable to locate the storage part file for adding new storage to dim table dim_table2", t);
Assert.fail("Unable to locate the storage part file for adding new storage to dim table dim_table2");
}
verifyAndDeletePartition();
@@ -270,7 +268,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
try {
command.addPartitionToDimtable(tableName, storageName, new File(resource.toURI()).getAbsolutePath());
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Unable to locate the storage part file for adding new storage to dim table dim_table2", t);
Assert.fail("Unable to locate the storage part file for adding new storage to dim table dim_table2");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
index 19979cc..1ad234d 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
@@ -31,18 +31,16 @@ import org.apache.lens.cli.commands.LensCubeCommands;
import org.apache.lens.cli.commands.LensFactCommands;
import org.apache.lens.client.LensClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestLensFactCommands.
*/
+@Slf4j
public class TestLensFactCommands extends LensCliApplicationTest {
- /** The Constant LOG. */
- private static final Logger LOG = LoggerFactory.getLogger(TestLensFactCommands.class);
-
/** The Constant FACT_LOCAL. */
public static final String FACT_LOCAL = "fact_local";
@@ -119,13 +117,13 @@ public class TestLensFactCommands extends LensCliApplicationTest {
assertEquals(command.showFacts("blah"), factList);
fail();
} catch (NotFoundException e) {
- LOG.info("blah is not a table", e);
+ log.info("blah is not a table", e);
}
try {
assertEquals(command.showFacts("fact1"), factList);
fail();
} catch (NotFoundException e) {
- LOG.info("fact1 is a table, but not a cube table", e);
+ log.info("fact1 is a table, but not a cube table", e);
}
assertEquals("fact1", factList, "Fact1 table should be found");
}
@@ -157,7 +155,7 @@ public class TestLensFactCommands extends LensCliApplicationTest {
writer.close();
String desc = command.describeFactTable("fact1");
- LOG.debug(desc);
+ log.debug(desc);
String propString = "name : fact1.prop value : f1";
String propString1 = "name : fact1.prop1 value : f2";
@@ -165,15 +163,14 @@ public class TestLensFactCommands extends LensCliApplicationTest {
command.updateFactTable("fact1", "/tmp/local-fact1.xml");
desc = command.describeFactTable("fact1");
- LOG.debug(desc);
+ log.debug(desc);
assertTrue(desc.contains(propString), "The sample property value is not set");
-
assertTrue(desc.contains(propString1), "The sample property value is not set");
newFile.delete();
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Updating of the fact1 table failed with ", t);
fail("Updating of the fact1 table failed with " + t.getMessage());
}
@@ -208,7 +205,7 @@ public class TestLensFactCommands extends LensCliApplicationTest {
try {
command.addNewFactStorage("fact1", new File(resource.toURI()).getAbsolutePath());
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Unable to locate the storage part file for adding new storage to fact table fact1", t);
fail("Unable to locate the storage part file for adding new storage to fact table fact1");
}
result = command.getFactStorages("fact1");
@@ -233,15 +230,15 @@ public class TestLensFactCommands extends LensCliApplicationTest {
command.addPartitionToFact("fact1", FACT_LOCAL, new File(
TestLensFactCommands.class.getClassLoader().getResource("fact1-local-part.xml").toURI()).getAbsolutePath());
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Unable to locate the storage part file for adding new storage to fact table fact1", t);
fail("Unable to locate the storage part file for adding new storage to fact table fact1");
}
verifyAndDeletePartitions();
try {
command.addPartitionsToFact("fact1", FACT_LOCAL, new File(
- TestLensFactCommands.class.getClassLoader().getResource("fact1-local-parts.xml").toURI()).getAbsolutePath());
+ TestLensFactCommands.class.getClassLoader().getResource("fact1-local-parts.xml").toURI()).getAbsolutePath());
} catch (Throwable t) {
- t.printStackTrace();
+ log.error("Unable to locate the storage part file for adding new storage to fact table fact1", t);
fail("Unable to locate the storage part file for adding new storage to fact table fact1");
}
verifyAndDeletePartitions();
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
index 5724d24..32a89ac 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
@@ -43,18 +43,16 @@ import org.apache.lens.driver.hive.TestHiveDriver;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.fs.Path;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestLensQueryCommands.
*/
+@Slf4j
public class TestLensQueryCommands extends LensCliApplicationTest {
- /** The Constant LOG. */
- private static final Logger LOG = LoggerFactory.getLogger(TestLensQueryCommands.class);
-
/** The client. */
private LensClient client;
@@ -130,29 +128,29 @@ public class TestLensQueryCommands extends LensCliApplicationTest {
result = qCom.executePreparedQuery(qh, false, "testPrepQuery1");
- LOG.warn("XXXXXX Prepared query sync result is " + result);
+ log.warn("XXXXXX Prepared query sync result is " + result);
assertTrue(result.contains("1\tfirst"));
String handle = qCom.executePreparedQuery(qh, true, "testPrepQuery2");
- LOG.debug("Perpared query handle is " + handle);
+ log.debug("Perpared query handle is " + handle);
while (!client.getQueryStatus(handle).finished()) {
Thread.sleep(5000);
}
String status = qCom.getStatus(handle);
- LOG.debug("Prepared Query Status is " + status);
+ log.debug("Prepared Query Status is " + status);
assertTrue(status.contains("Status : SUCCESSFUL"));
result = qCom.getQueryResults(handle, null);
- LOG.debug("Prepared Query Result is " + result);
+ log.debug("Prepared Query Result is " + result);
assertTrue(result.contains("1\tfirst"));
// Fetch again.
result = qCom.getQueryResults(handle, null);
- LOG.debug("Prepared Query Result is " + result);
+ log.debug("Prepared Query Result is " + result);
assertTrue(result.contains("1\tfirst"));
result = qCom.destroyPreparedQuery(qh);
- LOG.debug("destroy result is " + result);
+ log.debug("destroy result is " + result);
assertEquals("Successfully destroyed " + qh, result);
result = qCom.getAllPreparedQueries("testPreparedName", "all", submitTime, Long.MAX_VALUE);
@@ -195,9 +193,8 @@ public class TestLensQueryCommands extends LensCliApplicationTest {
String sql = "cube select id, name from test_dim";
String result = qCom.explainQuery(sql, "");
- LOG.debug(result);
+ log.debug(result);
assertTrue(result.contains(explainPlan));
-
}
/**
@@ -210,7 +207,7 @@ public class TestLensQueryCommands extends LensCliApplicationTest {
String sql = "cube select id2, name from test_dim";
String result = qCom.explainQuery(sql, "");
- LOG.debug(result);
+ log.debug(result);
assertTrue(result.contains("Explain FAILED:"));
result = qCom.explainAndPrepare(sql, "");
@@ -318,7 +315,7 @@ public class TestLensQueryCommands extends LensCliApplicationTest {
LensCubeCommands command = new LensCubeCommands();
command.setClient(client);
- LOG.debug("Starting to test cube commands");
+ log.debug("Starting to test cube commands");
URL cubeSpec = TestLensQueryCommands.class.getClassLoader().getResource("sample-cube.xml");
command.createCube(new File(cubeSpec.toURI()).getAbsolutePath());
TestLensDimensionCommands.createDimension();
@@ -367,7 +364,7 @@ public class TestLensQueryCommands extends LensCliApplicationTest {
assertNotNull(result);
assertFalse(result.contains("Failed to get resultset"));
} catch (Exception exc) {
- exc.printStackTrace();
+ log.error("Exception not expected while getting resultset.", exc);
fail("Exception not expected: " + exc.getMessage());
}
System.out.println("@@END_PERSISTENT_RESULT_TEST-------------");
@@ -397,7 +394,7 @@ public class TestLensQueryCommands extends LensCliApplicationTest {
// This is to check for positive processing time
assertFalse(result.contains("(-"));
} catch (Exception exc) {
- exc.printStackTrace();
+ log.error("Exception not expected while purging resultset.", exc);
fail("Exception not expected: " + exc.getMessage());
}
System.out.println("@@END_FINISHED_PURGED_RESULT_TEST-------------");
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-client/src/main/java/org/apache/lens/client/jdbc/LensJdbcDriver.java
----------------------------------------------------------------------
diff --git a/lens-client/src/main/java/org/apache/lens/client/jdbc/LensJdbcDriver.java b/lens-client/src/main/java/org/apache/lens/client/jdbc/LensJdbcDriver.java
index a6fae87..056a0b2 100644
--- a/lens-client/src/main/java/org/apache/lens/client/jdbc/LensJdbcDriver.java
+++ b/lens-client/src/main/java/org/apache/lens/client/jdbc/LensJdbcDriver.java
@@ -23,16 +23,20 @@ import java.util.Properties;
import java.util.logging.Logger;
import java.util.regex.Pattern;
+import lombok.extern.slf4j.Slf4j;
+
/**
* Top level JDBC driver for Lens.
*/
+@Slf4j
public class LensJdbcDriver implements Driver {
+
static {
try {
DriverManager.registerDriver(new LensJdbcDriver());
} catch (SQLException e) {
- e.printStackTrace();
+ log.error("Error in registering jdbc driver", e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
index 1c375ed..7b99310 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
@@ -40,7 +40,12 @@ import org.antlr.runtime.tree.Tree;
import com.google.common.base.Optional;
+import lombok.extern.slf4j.Slf4j;
+
+
+@Slf4j
public final class HQLParser {
+
private HQLParser() {
}
@@ -168,7 +173,7 @@ public final class HQLParser {
try {
printAST(getHiveTokenMapping(), node, 0, 0);
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Error in printing AST.", e);
}
System.out.println();
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/metadata/timeline/TestPartitionTimelines.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/metadata/timeline/TestPartitionTimelines.java b/lens-cube/src/test/java/org/apache/lens/cube/metadata/timeline/TestPartitionTimelines.java
index 0231e8b..0268bbf 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/metadata/timeline/TestPartitionTimelines.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/metadata/timeline/TestPartitionTimelines.java
@@ -30,7 +30,11 @@ import org.testng.annotations.Test;
import com.beust.jcommander.internal.Lists;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
public class TestPartitionTimelines {
+
private static final String TABLE_NAME = "storage_fact";
public static final UpdatePeriod PERIOD = UpdatePeriod.HOURLY;
private static final String PART_COL = "pt";
@@ -103,7 +107,7 @@ public class TestPartitionTimelines {
return clz.getConstructor(String.class, UpdatePeriod.class, String.class)
.newInstance(TABLE_NAME, PERIOD, PART_COL);
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Error while getting instance.", e);
}
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java
index 1fb8556..914fe1b 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/CubeTestSetup.java
@@ -1331,9 +1331,9 @@ public class CubeTestSetup {
try {
client.addPartition(sPartSpec, c1);
} catch (HiveException e) {
- e.printStackTrace();
+ log.error("Encountered Hive exception.", e);
} catch (LensException e) {
- e.printStackTrace();
+ log.error("Encountered Lens exception.", e);
}
cal.add(Calendar.HOUR_OF_DAY, 1);
temp = cal.getTime();
@@ -2047,7 +2047,7 @@ public class CubeTestSetup {
createStateTable(client);
createCubeFactsWithValidColumns(client);
} catch (Exception exc) {
- exc.printStackTrace();
+ log.error("Exception while creating sources.", exc);
throw exc;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java
index 9274ccf..0f1ad6e 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestCubeRewriter.java
@@ -44,6 +44,9 @@ import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
public class TestCubeRewriter extends TestQueryRewrite {
private final String cubeName = CubeTestSetup.TEST_CUBE_NAME;
@@ -1451,7 +1454,7 @@ public class TestCubeRewriter extends TestQueryRewrite {
assertTrue(hql.contains("`a measure`"));
System.out.println("@@ hql: " + hql);
} catch (NullPointerException npe) {
- npe.printStackTrace();
+ log.error("Not expecting null pointer exception", npe);
fail("Not expecting null pointer exception");
}
}
@@ -1502,7 +1505,7 @@ public class TestCubeRewriter extends TestQueryRewrite {
System.out.println("@@HQL " + hql);
} catch (NullPointerException npe) {
fail(npe.getMessage());
- npe.printStackTrace();
+ log.error("Not expecting null pointer exception", npe);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDateUtil.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDateUtil.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDateUtil.java
index a916dbf..6717b5b 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDateUtil.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestDateUtil.java
@@ -45,10 +45,14 @@ import org.testng.annotations.Test;
import com.beust.jcommander.internal.Sets;
import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+
/**
* Unit tests for cube DateUtil class TestDateUtil.
*/
+@Slf4j
public class TestDateUtil {
+
public static final String[] TEST_PAIRS = {
"2013-Jan-01", "2013-Jan-31", "2013-Jan-01", "2013-May-31",
"2013-Jan-01", "2013-Dec-31", "2013-Feb-01", "2013-Apr-25",
@@ -67,7 +71,7 @@ public class TestDateUtil {
try {
pairs[i] = DATE_FMT.parse(TEST_PAIRS[i]);
} catch (ParseException e) {
- e.printStackTrace();
+ log.error("Parsing exception while setup.", e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
index fef634d..b0b2e88 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
@@ -31,7 +31,11 @@ import org.apache.hadoop.hive.ql.parse.ParseException;
import org.testng.Assert;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
public class TestHQLParser {
+
HiveConf conf = new HiveConf();
@Test
public void testGroupByOrderByGetString() throws Exception {
@@ -238,7 +242,7 @@ public class TestHQLParser {
try {
ASTNode tree = HQLParser.parseHQL(query, conf);
} catch (NullPointerException exc) {
- exc.printStackTrace();
+ log.error("should not have thrown npe", exc);
Assert.fail("should not have thrown npe");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/TestMaxUpdateInterval.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestMaxUpdateInterval.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestMaxUpdateInterval.java
index a5f64ec..7e5f38d 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestMaxUpdateInterval.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestMaxUpdateInterval.java
@@ -32,10 +32,14 @@ import org.apache.lens.cube.metadata.UpdatePeriod;
import org.testng.Assert;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/*
* Unit test for maxUpdateIntervalIn method in CubeFactTable
*/
+@Slf4j
public class TestMaxUpdateInterval {
+
public static final String[] TEST_PAIRS = {
"2013-Jan-01", "2013-Jan-31", "2013-Jan-01", "2013-May-31",
"2013-Jan-01", "2013-Dec-31", "2013-Feb-01", "2013-Apr-25",
@@ -54,7 +58,7 @@ public class TestMaxUpdateInterval {
pairs[i] = DATE_FMT.parse(TEST_PAIRS[i]);
System.out.println(pairs[i].toString());
} catch (ParseException e) {
- e.printStackTrace();
+ log.error("Parsing exception while testing max update interval.", e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/TestQueryRewrite.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestQueryRewrite.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestQueryRewrite.java
index 994a244..d16f6a5 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestQueryRewrite.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestQueryRewrite.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.hive.ql.session.SessionState;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
+
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
@@ -103,7 +104,7 @@ public abstract class TestQueryRewrite {
// unreachable
return null;
} catch (SemanticException e) {
- e.printStackTrace();
+ log.error("Semantic exception in Rewrite.", e);
return e;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriter.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriter.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriter.java
index 106660e..453a102 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriter.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriter.java
@@ -33,6 +33,9 @@ import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.testng.Assert;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
public abstract class TestTimeRangeWriter {
public abstract TimeRangeWriter getTimerangeWriter();
@@ -59,7 +62,7 @@ public abstract class TestTimeRangeWriter {
try {
whereClause = getTimerangeWriter().getTimeRangeWhereClause(null, "test", answeringParts);
} catch (SemanticException e) {
- e.printStackTrace();
+ log.error("Semantic exception while testing disjoint parts.", e);
th = e;
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriterWithQuery.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriterWithQuery.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriterWithQuery.java
index b5aaeb2..0e22ce2 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriterWithQuery.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestTimeRangeWriterWithQuery.java
@@ -36,6 +36,10 @@ import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
+
+@Slf4j
public class TestTimeRangeWriterWithQuery extends TestQueryRewrite {
private Configuration conf;
@@ -76,7 +80,7 @@ public class TestTimeRangeWriterWithQuery extends TestQueryRewrite {
rewrite("cube select" + " SUM(msr2) from testCube where " + TWO_DAYS_RANGE, conf);
} catch (SemanticException e) {
th = e;
- e.printStackTrace();
+ log.error("Semantic exception while testing cube query.", e);
}
if (!CubeTestSetup.isZerothHour()) {
Assert.assertNotNull(th);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java
----------------------------------------------------------------------
diff --git a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java
index 8bec5e0..052d0e2 100644
--- a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java
+++ b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveDriver.java
@@ -61,19 +61,18 @@ import org.apache.hive.service.cli.*;
import org.apache.hive.service.cli.thrift.TOperationHandle;
import org.apache.hive.service.cli.thrift.TProtocolVersion;
import org.apache.hive.service.cli.thrift.TSessionHandle;
-import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class HiveDriver.
*/
+@Slf4j
public class HiveDriver implements LensDriver {
- /** The Constant LOG. */
- public static final Logger LOG = Logger.getLogger(HiveDriver.class);
-
/** The Constant HIVE_CONNECTION_CLASS. */
public static final String HIVE_CONNECTION_CLASS = "lens.driver.hive.connection.class";
@@ -186,15 +185,15 @@ public class HiveDriver implements LensDriver {
if (thConn != null) {
try {
- LOG.info("Closed connection:" + expired.getConnId());
+ log.info("Closed connection:" + expired.getConnId());
thConn.close();
} catch (IOException e) {
- LOG.error("Error closing connection", e);
+ log.error("Error closing connection", e);
}
}
}
} catch (InterruptedException intr) {
- LOG.warn("Connection expiry thread interrupted", intr);
+ log.warn("Connection expiry thread interrupted", intr);
return;
}
}
@@ -309,7 +308,7 @@ public class HiveDriver implements LensDriver {
connectionExpiryThread.setName("HiveDriver-ConnectionExpiryThread");
connectionExpiryThread.start();
driverListeners = new ArrayList<LensEventListener<DriverEvent>>();
- LOG.info("Hive driver inited");
+ log.info("Hive driver inited");
}
@Override
@@ -350,7 +349,7 @@ public class HiveDriver implements LensDriver {
@Override
public QueryCost estimate(AbstractQueryContext qctx) throws LensException {
- LOG.info("Estimate: " + qctx.getDriverQuery(this));
+ log.info("Estimate: " + qctx.getDriverQuery(this));
if (qctx.getDriverQuery(this) == null) {
throw new NullPointerException("Null driver query for " + qctx.getUserQuery());
}
@@ -382,7 +381,7 @@ public class HiveDriver implements LensDriver {
// explain called again and again
return (HiveQueryPlan) explainCtx.getDriverContext().getDriverQueryPlan(this);
}
- LOG.info("Explain: " + explainCtx.getDriverQuery(this));
+ log.info("Explain: " + explainCtx.getDriverQuery(this));
Configuration explainConf = new Configuration(explainCtx.getDriverConf(this));
explainConf.setClassLoader(explainCtx.getConf().getClassLoader());
explainConf.setBoolean(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, false);
@@ -461,7 +460,7 @@ public class HiveDriver implements LensDriver {
qdconf.set("mapred.job.name", ctx.getQueryHandle().toString());
OperationHandle op = getClient().executeStatement(getSession(ctx), ctx.getSelectedDriverQuery(),
qdconf.getValByRegex(".*"));
- LOG.info("The hive operation handle: " + op);
+ log.info("The hive operation handle: " + op);
ctx.setDriverOpHandle(op.toString());
hiveHandles.put(ctx.getQueryHandle(), op);
updateStatus(ctx);
@@ -498,24 +497,24 @@ public class HiveDriver implements LensDriver {
Configuration qdconf = ctx.getDriverConf(this);
qdconf.set("mapred.job.name", ctx.getQueryHandle().toString());
//Query is already explained.
- LOG.info("whetherCalculatePriority: " + whetherCalculatePriority);
+ log.info("whetherCalculatePriority: " + whetherCalculatePriority);
if (whetherCalculatePriority) {
try {
// Inside try since non-data fetching queries can also be executed by async method.
String priority = queryPriorityDecider.decidePriority(ctx).toString();
qdconf.set("mapred.job.priority", priority);
- LOG.info("set priority to " + priority);
+ log.info("set priority to " + priority);
} catch (Exception e) {
// not failing query launch when setting priority fails
// priority will be set to usually NORMAL - the default in underlying system.
- LOG.error("could not set priority for lens session id:" + ctx.getLensSessionIdentifier()
+ log.error("could not set priority for lens session id:" + ctx.getLensSessionIdentifier()
+ "User query: " + ctx.getUserQuery(), e);
}
}
OperationHandle op = getClient().executeStatementAsync(getSession(ctx), ctx.getSelectedDriverQuery(),
qdconf.getValByRegex(".*"));
ctx.setDriverOpHandle(op.toString());
- LOG.info("QueryHandle: " + ctx.getQueryHandle() + " HiveHandle:" + op);
+ log.info("QueryHandle: " + ctx.getQueryHandle() + " HiveHandle:" + op);
hiveHandles.put(ctx.getQueryHandle(), op);
} catch (IOException e) {
throw new LensException("Error adding persistent path", e);
@@ -532,7 +531,7 @@ public class HiveDriver implements LensDriver {
*/
@Override
public void updateStatus(QueryContext context) throws LensException {
- LOG.debug("GetStatus: " + context.getQueryHandle());
+ log.debug("GetStatus: " + context.getQueryHandle());
if (context.getDriverStatus().isFinished()) {
return;
}
@@ -540,9 +539,9 @@ public class HiveDriver implements LensDriver {
ByteArrayInputStream in = null;
try {
// Get operation status from hive server
- LOG.debug("GetStatus hiveHandle: " + hiveHandle);
+ log.debug("GetStatus hiveHandle: " + hiveHandle);
OperationStatus opStatus = getClient().getOperationStatus(hiveHandle);
- LOG.debug("GetStatus on hiveHandle: " + hiveHandle + " returned state:" + opStatus.getState().name());
+ log.debug("GetStatus on hiveHandle: " + hiveHandle + " returned state:" + opStatus.getState().name());
switch (opStatus.getState()) {
case CANCELED:
@@ -605,7 +604,7 @@ public class HiveDriver implements LensDriver {
progress = taskStatuses.size() == 0 ? 0 : (float) completedTasks / taskStatuses.size();
errorMsg = errorMessage.toString();
} else {
- LOG.warn("Empty task statuses");
+ log.warn("Empty task statuses");
}
String error = null;
if (StringUtils.isNotBlank(errorMsg)) {
@@ -619,7 +618,7 @@ public class HiveDriver implements LensDriver {
context.getDriverStatus().setDriverStartTime(opStatus.getOperationStarted());
context.getDriverStatus().setDriverFinishTime(opStatus.getOperationCompleted());
} catch (Exception e) {
- LOG.error("Error getting query status", e);
+ log.error("Error getting query status", e);
handleHiveServerError(context, e);
throw new LensException("Error getting query status", e);
} finally {
@@ -627,7 +626,7 @@ public class HiveDriver implements LensDriver {
try {
in.close();
} catch (IOException e) {
- e.printStackTrace();
+ log.error("Error closing stream.", e);
}
}
}
@@ -654,7 +653,7 @@ public class HiveDriver implements LensDriver {
*/
@Override
public LensResultSet fetchResultSet(QueryContext ctx) throws LensException {
- LOG.info("FetchResultSet: " + ctx.getQueryHandle());
+ log.info("FetchResultSet: " + ctx.getQueryHandle());
// This should be applicable only for a async query
return createResultSet(ctx, false);
}
@@ -679,10 +678,10 @@ public class HiveDriver implements LensDriver {
if (handle == null) {
return;
}
- LOG.info("CloseQuery: " + handle);
+ log.info("CloseQuery: " + handle);
OperationHandle opHandle = hiveHandles.remove(handle);
if (opHandle != null) {
- LOG.info("CloseQuery: " + opHandle);
+ log.info("CloseQuery: " + opHandle);
try {
getClient().closeOperation(opHandle);
} catch (HiveSQLException e) {
@@ -699,10 +698,10 @@ public class HiveDriver implements LensDriver {
*/
@Override
public boolean cancelQuery(QueryHandle handle) throws LensException {
- LOG.info("CancelQuery: " + handle);
+ log.info("CancelQuery: " + handle);
OperationHandle hiveHandle = getHiveHandle(handle);
try {
- LOG.info("CancelQuery hiveHandle: " + hiveHandle);
+ log.info("CancelQuery hiveHandle: " + hiveHandle);
getClient().cancelOperation(hiveHandle);
return true;
} catch (HiveSQLException e) {
@@ -718,7 +717,7 @@ public class HiveDriver implements LensDriver {
*/
@Override
public void close() {
- LOG.info("CloseDriver");
+ log.info("CloseDriver");
// Close this driver and release all resources
sessionLock.lock();
try {
@@ -727,7 +726,7 @@ public class HiveDriver implements LensDriver {
getClient().closeSession(lensToHiveSession.get(lensSessionDbKey));
} catch (Exception e) {
checkInvalidSession(e);
- LOG.warn("Error closing session for lens session: " + lensSessionDbKey + ", hive session: "
+ log.warn("Error closing session for lens session: " + lensSessionDbKey + ", hive session: "
+ lensToHiveSession.get(lensSessionDbKey), e);
}
}
@@ -756,7 +755,7 @@ public class HiveDriver implements LensDriver {
} catch (Exception e) {
throw new LensException(e);
}
- LOG.info("New thrift connection " + connectionClass);
+ log.info("New thrift connection " + connectionClass);
}
return embeddedConnection.getClient();
} else {
@@ -774,7 +773,7 @@ public class HiveDriver implements LensDriver {
connection = new ExpirableConnection(tconn, connectionExpiryTimeout);
thriftConnExpiryQueue.offer(connection);
threadConnections.put(connectionKey, connection);
- LOG.info("New thrift connection " + connectionClass + " for thread:" + Thread.currentThread().getId()
+ log.info("New thrift connection " + connectionClass + " for thread:" + Thread.currentThread().getId()
+ " for user:" + user + " connection ID=" + connection.getConnId());
} catch (Exception e) {
throw new LensException(e);
@@ -799,7 +798,7 @@ public class HiveDriver implements LensDriver {
*/
private LensResultSet createResultSet(QueryContext context, boolean closeAfterFetch) throws LensException {
OperationHandle op = getHiveHandle(context.getQueryHandle());
- LOG.info("Creating result set for hiveHandle:" + op);
+ log.info("Creating result set for hiveHandle:" + op);
try {
if (context.isDriverPersistent()) {
return new HivePersistentResultSet(new Path(context.getHdfsoutPath()), op, getClient());
@@ -846,7 +845,7 @@ public class HiveDriver implements LensDriver {
context.unSetDriverPersistent();
hiveQuery = context.getSelectedDriverQuery();
}
- LOG.info("Hive driver query:" + hiveQuery);
+ log.info("Hive driver query:" + hiveQuery);
context.setSelectedDriverQuery(hiveQuery);
}
@@ -875,14 +874,14 @@ public class HiveDriver implements LensDriver {
try {
hiveSession = getClient().openSession(ctx.getClusterUser(), "");
lensToHiveSession.put(sessionDbKey, hiveSession);
- LOG.info("New hive session for user: " + ctx.getClusterUser() + ", lens session: " + sessionDbKey
+ log.info("New hive session for user: " + ctx.getClusterUser() + ", lens session: " + sessionDbKey
+ " hive session handle: " + hiveSession.getHandleIdentifier());
for (LensEventListener<DriverEvent> eventListener : driverListeners) {
try {
eventListener.onEvent(new DriverSessionStarted(System.currentTimeMillis(), this, lensSession, hiveSession
.getSessionId().toString()));
} catch (Exception exc) {
- LOG.error("Error sending driver start event to listener " + eventListener, exc);
+ log.error("Error sending driver start event to listener " + eventListener, exc);
}
}
} catch (Exception e) {
@@ -969,7 +968,7 @@ public class HiveDriver implements LensDriver {
}
error = "timedout";
} catch (Exception e) {
- LOG.warn("Error while polling for status", e);
+ log.warn("Error while polling for status", e);
error = "error polling";
}
listener.onError(handle, error);
@@ -1025,9 +1024,9 @@ public class HiveDriver implements LensDriver {
QueryHandle qhandle = (QueryHandle) in.readObject();
OperationHandle opHandle = new OperationHandle((TOperationHandle) in.readObject());
hiveHandles.put(qhandle, opHandle);
- LOG.debug("Hive driver recovered " + qhandle + ":" + opHandle);
+ log.debug("Hive driver recovered " + qhandle + ":" + opHandle);
}
- LOG.info("HiveDriver recovered " + hiveHandles.size() + " queries");
+ log.info("HiveDriver recovered " + hiveHandles.size() + " queries");
int numSessions = in.readInt();
for (int i = 0; i < numSessions; i++) {
String lensId = in.readUTF();
@@ -1035,7 +1034,7 @@ public class HiveDriver implements LensDriver {
TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6);
lensToHiveSession.put(lensId, sHandle);
}
- LOG.info("HiveDriver recovered " + lensToHiveSession.size() + " sessions");
+ log.info("HiveDriver recovered " + lensToHiveSession.size() + " sessions");
}
}
@@ -1052,15 +1051,15 @@ public class HiveDriver implements LensDriver {
for (Map.Entry<QueryHandle, OperationHandle> entry : hiveHandles.entrySet()) {
out.writeObject(entry.getKey());
out.writeObject(entry.getValue().toTOperationHandle());
- LOG.debug("Hive driver persisted " + entry.getKey() + ":" + entry.getValue());
+ log.debug("Hive driver persisted " + entry.getKey() + ":" + entry.getValue());
}
- LOG.info("HiveDriver persisted " + hiveHandles.size() + " queries");
+ log.info("HiveDriver persisted " + hiveHandles.size() + " queries");
out.writeInt(lensToHiveSession.size());
for (Map.Entry<String, SessionHandle> entry : lensToHiveSession.entrySet()) {
out.writeUTF(entry.getKey());
out.writeObject(entry.getValue().toTSessionHandle());
}
- LOG.info("HiveDriver persisted " + lensToHiveSession.size() + " sessions");
+ log.info("HiveDriver persisted " + lensToHiveSession.size() + " sessions");
}
}
@@ -1122,14 +1121,14 @@ public class HiveDriver implements LensDriver {
for (SessionHandle session : hiveSessionsToCheck) {
if (isSessionInvalid(exc, session)) {
// We have to expire previous session
- LOG.info("Hive server session " + session + " for lens session " + lensSession + " has become invalid");
+ log.info("Hive server session " + session + " for lens session " + lensSession + " has become invalid");
sessionLock.lock();
try {
// We should close all connections and clear the session map since
// most likely all sessions are gone
closeAllConnections();
lensToHiveSession.clear();
- LOG.info("Cleared all sessions");
+ log.info("Cleared all sessions");
} finally {
sessionLock.unlock();
}
@@ -1146,12 +1145,12 @@ public class HiveDriver implements LensDriver {
protected void checkInvalidOperation(QueryHandle queryHandle, HiveSQLException exc) {
final OperationHandle operation = hiveHandles.get(queryHandle);
if (operation == null) {
- LOG.info("No hive operation available for " + queryHandle);
+ log.info("No hive operation available for " + queryHandle);
return;
}
if (exc.getMessage() != null && exc.getMessage().contains("Invalid OperationHandle:")
&& exc.getMessage().contains(operation.toString())) {
- LOG.info("Hive operation " + operation + " for query " + queryHandle + " has become invalid");
+ log.info("Hive operation " + operation + " for query " + queryHandle + " has become invalid");
hiveHandles.remove(queryHandle);
return;
}
@@ -1193,10 +1192,10 @@ public class HiveDriver implements LensDriver {
if (hiveSession != null) {
try {
getClient().closeSession(hiveSession);
- LOG.info("Closed Hive session " + hiveSession.getHandleIdentifier() + " for lens session "
+ log.info("Closed Hive session " + hiveSession.getHandleIdentifier() + " for lens session "
+ sessionDbKey);
} catch (Exception e) {
- LOG.error("Error closing hive session " + hiveSession.getHandleIdentifier()
+ log.error("Error closing hive session " + hiveSession.getHandleIdentifier()
+ " for lens session " + sessionDbKey, e);
}
resourcesAddedForSession.remove(hiveSession);
@@ -1217,7 +1216,7 @@ public class HiveDriver implements LensDriver {
try {
connection.getConnection().close();
} catch (Exception ce) {
- LOG.warn("Error closing connection to hive server");
+ log.warn("Error closing connection to hive server");
}
}
threadConnections.clear();
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveInMemoryResultSet.java
----------------------------------------------------------------------
diff --git a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveInMemoryResultSet.java b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveInMemoryResultSet.java
index 4d631ec..3d1f20a 100644
--- a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveInMemoryResultSet.java
+++ b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveInMemoryResultSet.java
@@ -30,9 +30,12 @@ import org.apache.lens.server.api.error.LensException;
import org.apache.hive.service.cli.*;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class HiveInMemoryResultSet.
*/
+@Slf4j
public class HiveInMemoryResultSet extends InMemoryResultSet {
/** The client. */
@@ -120,7 +123,7 @@ public class HiveInMemoryResultSet extends InMemoryResultSet {
noMoreResults = rowSet.numRows() == 0;
if (noMoreResults) {
if (closeAfterFecth) {
- HiveDriver.LOG.info("No more results closing the query");
+ log.info("No more results closing the query");
client.closeOperation(opHandle);
}
return false;
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveQueryPlan.java
----------------------------------------------------------------------
diff --git a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveQueryPlan.java b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveQueryPlan.java
index 9d43fa8..b0a04df 100644
--- a/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveQueryPlan.java
+++ b/lens-driver-hive/src/main/java/org/apache/lens/driver/hive/HiveQueryPlan.java
@@ -34,9 +34,12 @@ import org.apache.hadoop.hive.ql.metadata.Hive;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.metadata.Table;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class HiveQueryPlan.
*/
+@Slf4j
public class HiveQueryPlan extends DriverQueryPlan {
/** The explain output. */
@@ -164,7 +167,7 @@ public class HiveQueryPlan extends DriverQueryPlan {
Table tbl = metastore.getTable(table, false);
if (tbl == null) {
// table not found, possible case if query is create table
- HiveDriver.LOG.info("Table " + table + " not found while extracting plan details");
+ log.info("Table " + table + " not found while extracting plan details");
continue;
}
tablesQueried.add(table);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-driver-hive/src/test/java/org/apache/lens/driver/hive/TestRemoteHiveDriver.java
----------------------------------------------------------------------
diff --git a/lens-driver-hive/src/test/java/org/apache/lens/driver/hive/TestRemoteHiveDriver.java b/lens-driver-hive/src/test/java/org/apache/lens/driver/hive/TestRemoteHiveDriver.java
index f0566c8..b4086b8 100644
--- a/lens-driver-hive/src/test/java/org/apache/lens/driver/hive/TestRemoteHiveDriver.java
+++ b/lens-driver-hive/src/test/java/org/apache/lens/driver/hive/TestRemoteHiveDriver.java
@@ -35,8 +35,6 @@ import org.apache.lens.server.api.error.LensException;
import org.apache.lens.server.api.query.QueryContext;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.session.SessionState;
import org.apache.hive.service.Service;
@@ -47,14 +45,14 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestRemoteHiveDriver.
*/
+@Slf4j
public class TestRemoteHiveDriver extends TestHiveDriver {
- /** The Constant LOG. */
- public static final Log LOG = LogFactory.getLog(TestRemoteHiveDriver.class);
-
/** The Constant HS2_HOST. */
static final String HS2_HOST = "localhost";
@@ -121,7 +119,7 @@ public class TestRemoteHiveDriver extends TestHiveDriver {
try {
server.stop();
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Error stopping hive service", e);
}
}
@@ -151,7 +149,7 @@ public class TestRemoteHiveDriver extends TestHiveDriver {
*/
@Test
public void testMultiThreadClient() throws Exception {
- LOG.info("@@ Starting multi thread test");
+ log.info("@@ Starting multi thread test");
// Launch two threads
createTestTable("test_multithreads");
HiveConf thConf = new HiveConf(conf, TestRemoteHiveDriver.class);
@@ -175,10 +173,10 @@ public class TestRemoteHiveDriver extends TestHiveDriver {
thrDriver.executeAsync(qctx);
} catch (LensException e) {
errCount.incrementAndGet();
- LOG.info(q + " executeAsync error: " + e.getCause());
+ log.info(q + " executeAsync error: " + e.getCause());
continue;
}
- LOG.info("@@ Launched query: " + q + " " + qctx.getQueryHandle());
+ log.info("@@ Launched query: " + q + " " + qctx.getQueryHandle());
launchedQueries++;
// Launch many threads to poll for status
final QueryHandle handle = qctx.getQueryHandle();
@@ -192,18 +190,17 @@ public class TestRemoteHiveDriver extends TestHiveDriver {
try {
thrDriver.updateStatus(qctx);
if (qctx.getDriverStatus().isFinished()) {
- LOG.info("@@ " + handle.getHandleId() + " >> " + qctx.getDriverStatus().getState());
+ log.info("@@ " + handle.getHandleId() + " >> " + qctx.getDriverStatus().getState());
thrDriver.closeQuery(handle);
break;
}
Thread.sleep(POLL_DELAY);
} catch (LensException e) {
- LOG.error("Got Exception", e.getCause());
- e.printStackTrace();
+ log.error("Got Exception " +e.getCause(), e);
errCount.incrementAndGet();
break;
} catch (InterruptedException e) {
- e.printStackTrace();
+ log.error("Encountred Interrupted exception", e);
break;
}
}
@@ -219,11 +216,11 @@ public class TestRemoteHiveDriver extends TestHiveDriver {
try {
th.join(10000);
} catch (InterruptedException e) {
- LOG.warn("Not ended yet: " + th.getName());
+ log.warn("Not ended yet: " + th.getName());
}
}
Assert.assertEquals(0, thrDriver.getHiveHandleSize());
- LOG.info("@@ Completed all pollers. Total thrift errors: " + errCount.get());
+ log.info("@@ Completed all pollers. Total thrift errors: " + errCount.get());
assertEquals(launchedQueries, QUERIES);
assertEquals(thrs.size(), QUERIES * THREADS);
assertEquals(errCount.get(), 0);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestColumnarSQLRewriter.java
----------------------------------------------------------------------
diff --git a/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestColumnarSQLRewriter.java b/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestColumnarSQLRewriter.java
index dc30bb9..556ca2c 100644
--- a/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestColumnarSQLRewriter.java
+++ b/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestColumnarSQLRewriter.java
@@ -46,9 +46,12 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestColumnarSQLRewriter.
*/
+@Slf4j
public class TestColumnarSQLRewriter {
HiveConf hconf = new HiveConf();
@@ -186,7 +189,7 @@ public class TestColumnarSQLRewriter {
createHiveTable("default", "branch_dim", branchdimColumns);
createHiveTable("default", "location_dim", locationdimColumns);
} catch (HiveException e) {
- e.printStackTrace();
+ log.error("Encountered hive exception.", e);
}
}
@@ -204,7 +207,7 @@ public class TestColumnarSQLRewriter {
Hive.get().dropTable("default.branch_dim");
Hive.get().dropTable("default.location_dim");
} catch (HiveException e) {
- e.printStackTrace();
+ log.error("Encountered hive exception", e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestDataSourceConnectionProvider.java
----------------------------------------------------------------------
diff --git a/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestDataSourceConnectionProvider.java b/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestDataSourceConnectionProvider.java
index e526700..21e5f50 100644
--- a/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestDataSourceConnectionProvider.java
+++ b/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestDataSourceConnectionProvider.java
@@ -28,19 +28,18 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
-import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestDataSourceConnectionProvider.
*/
+@Slf4j
public class TestDataSourceConnectionProvider {
- /** The Constant LOG. */
- public static final Logger LOG = Logger.getLogger(TestDataSourceConnectionProvider.class);
-
/**
* Test get connection hsql.
*
@@ -75,20 +74,20 @@ public class TestDataSourceConnectionProvider {
Assert.assertNotNull(st);
passed.incrementAndGet();
} catch (SQLException e) {
- LOG.error("error getting connection to db!", e);
+ log.error("error getting connection to db!", e);
} finally {
if (st != null) {
try {
st.close();
} catch (SQLException e) {
- e.printStackTrace();
+ log.error("Encountered SQL ecxception", e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
- e.printStackTrace();
+ log.error("Encountered SQL exception", e);
}
}
}
@@ -134,7 +133,7 @@ public class TestDataSourceConnectionProvider {
}
} catch (SQLException sqlEx) {
if (i != MAX_CONNECTIONS) {
- LOG.error("Unexpected getConnection error", sqlEx);
+ log.error("Unexpected getConnection error", sqlEx);
}
assertEquals(i, MAX_CONNECTIONS, "Failed before last getConnection call: " + sqlEx.getMessage());
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestJdbcDriver.java
----------------------------------------------------------------------
diff --git a/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestJdbcDriver.java b/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestJdbcDriver.java
index 75c428a..4f03f23 100644
--- a/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestJdbcDriver.java
+++ b/lens-driver-jdbc/src/test/java/org/apache/lens/driver/jdbc/TestJdbcDriver.java
@@ -46,8 +46,6 @@ import org.apache.lens.server.api.query.PreparedQueryContext;
import org.apache.lens.server.api.query.QueryContext;
import org.apache.lens.server.api.util.LensUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.session.SessionState;
@@ -62,11 +60,13 @@ import org.testng.annotations.Test;
import com.codahale.metrics.MetricRegistry;
import com.mchange.v2.c3p0.ComboPooledDataSource;
+import lombok.extern.slf4j.Slf4j;
+
/**
* The Class TestJdbcDriver.
*/
+@Slf4j
public class TestJdbcDriver {
- public static final Log LOG = LogFactory.getLog(TestJdbcDriver.class);
/** The base conf. */
Configuration baseConf;
@@ -211,7 +211,7 @@ public class TestJdbcDriver {
try {
driver.rewriteQuery(createQueryContext(query));
} catch (LensException e) {
- e.printStackTrace();
+ log.error("Error running DDL query.", e);
th = e;
}
Assert.assertNotNull(th);
@@ -222,7 +222,7 @@ public class TestJdbcDriver {
try {
driver.rewriteQuery(createQueryContext(query));
} catch (LensException e) {
- e.printStackTrace();
+ log.error("Error running DDL query", e);
th = e;
}
Assert.assertNotNull(th);
@@ -233,7 +233,7 @@ public class TestJdbcDriver {
try {
driver.rewriteQuery(createQueryContext(query));
} catch (LensException e) {
- e.printStackTrace();
+ log.error("Error running DDL query", e);
th = e;
}
Assert.assertNotNull(th);
@@ -244,7 +244,7 @@ public class TestJdbcDriver {
try {
driver.rewriteQuery(createQueryContext(query));
} catch (LensException e) {
- e.printStackTrace();
+ log.error("Error running DDL query", e);
th = e;
}
Assert.assertNotNull(th);
@@ -272,7 +272,7 @@ public class TestJdbcDriver {
driver.getEstimateConnectionConf().getInt(JDBCDriverConfConstants.JDBC_POOL_MAX_SIZE, 50);
for (int i = 0; i < maxEstimateConnections + 10; i++) {
try {
- LOG.info("Iteration#" + (i + 1));
+ log.info("Iteration#" + (i + 1));
String query = i > maxEstimateConnections ? "SELECT * FROM estimate_test" : "CREATE TABLE FOO(ID INT)";
ExplainQueryContext context = createExplainContext(query, baseConf);
cost = driver.estimate(context);
@@ -578,8 +578,8 @@ public class TestJdbcDriver {
try {
listenerNotificationLatch.await(1, TimeUnit.SECONDS);
} catch (Exception e) {
- fail("query completion listener was not notified - " + e.getMessage());
- e.printStackTrace();
+ fail("Query completion listener was not notified - " + e.getMessage());
+ log.error("Query completion listener was not notified.", e);
}
LensResultSet grs = driver.fetchResultSet(context);
@@ -738,7 +738,7 @@ public class TestJdbcDriver {
LensResultSet rs = driver.execute(ctx);
fail("Should have thrown exception");
} catch (LensException e) {
- e.printStackTrace();
+ log.error("Encountered Lens exception.", e);
}
final CountDownLatch listenerNotificationLatch = new CountDownLatch(1);
@@ -778,7 +778,7 @@ public class TestJdbcDriver {
driver.fetchResultSet(ctx);
fail("should have thrown error");
} catch (LensException e) {
- e.printStackTrace();
+ log.error("Encountered Lens exception", e);
}
driver.closeQuery(handle);
}
@@ -816,8 +816,8 @@ public class TestJdbcDriver {
DataSourceConnectionProvider.DriverConfig queryCfg =
queryCp.getDriverConfigfromConf(driver.getConf());
- LOG.info("@@@ ESTIMATE_CFG " + estimateCfg);
- LOG.info("@@@ QUERY CFG " + queryCfg);
+ log.info("@@@ ESTIMATE_CFG " + estimateCfg);
+ log.info("@@@ QUERY CFG " + queryCfg);
// Get connection from each so that pools get initialized
try {
@@ -825,14 +825,14 @@ public class TestJdbcDriver {
estimateConn.close();
} catch (SQLException e) {
// Ignore exception
- LOG.error("Error getting connection from estimate pool", e);
+ log.error("Error getting connection from estimate pool", e);
}
try {
Connection queryConn = queryCp.getConnection(driver.getConf());
queryConn.close();
} catch (SQLException e) {
- LOG.error("Error getting connection from query pool", e);
+ log.error("Error getting connection from query pool", e);
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
index 2f28e5d..dee43ef 100644
--- a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
+++ b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
@@ -31,7 +31,11 @@ import org.apache.lens.api.metastore.ObjectFactory;
import org.apache.lens.client.LensClientSingletonWrapper;
import org.apache.lens.client.LensMetadataClient;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
public class SampleMetastore {
+
private LensMetadataClient metaClient;
public static final Unmarshaller JAXB_UNMARSHALLER;
private APIResult result;
@@ -117,7 +121,7 @@ public class SampleMetastore {
System.out.println("Created DB storages");
} catch (Exception e) {
retCode = 1;
- e.printStackTrace();
+ log.error("Creating DB storage failed", e);
System.err.println("Creating DB storage failed");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-ml-lib/src/main/java/org/apache/lens/client/LensMLClient.java
----------------------------------------------------------------------
diff --git a/lens-ml-lib/src/main/java/org/apache/lens/client/LensMLClient.java b/lens-ml-lib/src/main/java/org/apache/lens/client/LensMLClient.java
index 8ffe853..6dd0ecf 100644
--- a/lens-ml-lib/src/main/java/org/apache/lens/client/LensMLClient.java
+++ b/lens-ml-lib/src/main/java/org/apache/lens/client/LensMLClient.java
@@ -40,16 +40,17 @@ import org.apache.lens.ml.api.TestReport;
import org.apache.lens.server.api.error.LensException;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import lombok.extern.slf4j.Slf4j;
+
/**
* Client side implementation of LensML
*/
+@Slf4j
public class LensMLClient implements LensML, Closeable {
- private static final Log LOG = LogFactory.getLog(LensMLClient.class);
/** The client. */
private LensMLJerseyClient client;
@@ -179,7 +180,7 @@ public class LensMLClient implements LensML, Closeable {
try {
in.close();
} catch (IOException e) {
- e.printStackTrace();
+ log.error("Error closing stream.", e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-ml-lib/src/main/java/org/apache/lens/ml/algo/lib/AlgoArgParser.java
----------------------------------------------------------------------
diff --git a/lens-ml-lib/src/main/java/org/apache/lens/ml/algo/lib/AlgoArgParser.java b/lens-ml-lib/src/main/java/org/apache/lens/ml/algo/lib/AlgoArgParser.java
index 51979d8..00f20fc 100644
--- a/lens-ml-lib/src/main/java/org/apache/lens/ml/algo/lib/AlgoArgParser.java
+++ b/lens-ml-lib/src/main/java/org/apache/lens/ml/algo/lib/AlgoArgParser.java
@@ -27,12 +27,12 @@ import java.util.Map;
import org.apache.lens.ml.algo.api.AlgoParam;
import org.apache.lens.ml.algo.api.MLAlgo;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import lombok.extern.slf4j.Slf4j;
/**
* The Class AlgoArgParser.
*/
+@Slf4j
public final class AlgoArgParser {
private AlgoArgParser() {
}
@@ -53,9 +53,6 @@ public final class AlgoArgParser {
public abstract E parse(String value);
}
- /** The Constant LOG. */
- public static final Log LOG = LogFactory.getLog(AlgoArgParser.class);
-
/**
* Extracts feature names. If the algo has any parameters associated with @AlgoParam annotation, those are set
* as well.
@@ -104,12 +101,12 @@ public final class AlgoArgParser {
CustomArgParser<?> parser = clz.newInstance();
f.set(algo, parser.parse(value));
} else {
- LOG.warn("Ignored param " + key + "=" + value + " as no parser found");
+ log.warn("Ignored param " + key + "=" + value + " as no parser found");
}
}
}
} catch (Exception exc) {
- LOG.error("Error while setting param " + key + " to " + value + " for algo " + algo);
+ log.error("Error while setting param " + key + " to " + value + " for algo " + algo, exc);
}
}
return featureColumns;
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/b0783db7/lens-ml-lib/src/main/java/org/apache/lens/ml/impl/LensMLImpl.java
----------------------------------------------------------------------
diff --git a/lens-ml-lib/src/main/java/org/apache/lens/ml/impl/LensMLImpl.java b/lens-ml-lib/src/main/java/org/apache/lens/ml/impl/LensMLImpl.java
index e4c03c8..de76603 100644
--- a/lens-ml-lib/src/main/java/org/apache/lens/ml/impl/LensMLImpl.java
+++ b/lens-ml-lib/src/main/java/org/apache/lens/ml/impl/LensMLImpl.java
@@ -52,8 +52,6 @@ import org.apache.lens.server.api.error.LensException;
import org.apache.lens.server.api.session.SessionService;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -66,15 +64,14 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import lombok.extern.slf4j.Slf4j;
/**
* The Class LensMLImpl.
*/
+@Slf4j
public class LensMLImpl implements LensML {
- /** The Constant LOG. */
- public static final Log LOG = LogFactory.getLog(LensMLImpl.class);
-
/** The drivers. */
protected List<MLDriver> drivers;
@@ -144,7 +141,7 @@ public class LensMLImpl implements LensML {
String modelId = UUID.randomUUID().toString();
- LOG.info("Begin training model " + modelId + ", algo=" + algorithm + ", table=" + table + ", params="
+ log.info("Begin training model " + modelId + ", algo=" + algorithm + ", table=" + table + ", params="
+ Arrays.toString(args));
String database = null;
@@ -156,7 +153,7 @@ public class LensMLImpl implements LensML {
MLModel model = algo.train(toLensConf(conf), database, table, modelId, args);
- LOG.info("Done training model: " + modelId);
+ log.info("Done training model: " + modelId);
model.setCreatedAt(new Date());
model.setAlgoName(algorithm);
@@ -164,7 +161,7 @@ public class LensMLImpl implements LensML {
Path modelLocation = null;
try {
modelLocation = persistModel(model);
- LOG.info("Model saved: " + modelId + ", algo: " + algorithm + ", path: " + modelLocation);
+ log.info("Model saved: " + modelId + ", algo: " + algorithm + ", path: " + modelLocation);
return model.getId();
} catch (IOException e) {
throw new LensException("Error saving model " + modelId + " for algo " + algorithm, e);
@@ -207,7 +204,7 @@ public class LensMLImpl implements LensML {
outputStream.writeObject(model);
outputStream.flush();
} catch (IOException io) {
- LOG.error("Error saving model " + model.getId() + " reason: " + io.getMessage());
+ log.error("Error saving model " + model.getId() + " reason: " + io.getMessage(), io);
throw io;
} finally {
IOUtils.closeQuietly(outputStream);
@@ -272,7 +269,7 @@ public class LensMLImpl implements LensML {
throw new RuntimeException("No ML Drivers specified in conf");
}
- LOG.info("Loading drivers " + Arrays.toString(driverClasses));
+ log.info("Loading drivers " + Arrays.toString(driverClasses));
drivers = new ArrayList<MLDriver>(driverClasses.length);
for (String driverClass : driverClasses) {
@@ -280,12 +277,12 @@ public class LensMLImpl implements LensML {
try {
cls = Class.forName(driverClass);
} catch (ClassNotFoundException e) {
- LOG.error("Driver class not found " + driverClass);
+ log.error("Driver class not found " + driverClass, e);
continue;
}
if (!MLDriver.class.isAssignableFrom(cls)) {
- LOG.warn("Not a driver class " + driverClass);
+ log.warn("Not a driver class " + driverClass);
continue;
}
@@ -294,16 +291,16 @@ public class LensMLImpl implements LensML {
MLDriver driver = mlDriverClass.newInstance();
driver.init(toLensConf(conf));
drivers.add(driver);
- LOG.info("Added driver " + driverClass);
+ log.info("Added driver " + driverClass);
} catch (Exception e) {
- LOG.error("Failed to create driver " + driverClass + " reason: " + e.getMessage(), e);
+ log.error("Failed to create driver " + driverClass + " reason: " + e.getMessage(), e);
}
}
if (drivers.isEmpty()) {
throw new RuntimeException("No ML drivers loaded");
}
- LOG.info("Inited ML service");
+ log.info("Inited ML service");
}
/**
@@ -317,14 +314,14 @@ public class LensMLImpl implements LensML {
}
driver.start();
} catch (LensException e) {
- LOG.error("Failed to start driver " + driver, e);
+ log.error("Failed to start driver " + driver, e);
}
}
udfStatusExpirySvc = Executors.newSingleThreadScheduledExecutor();
udfStatusExpirySvc.scheduleAtFixedRate(new UDFStatusExpiryRunnable(), 60, 60, TimeUnit.SECONDS);
- LOG.info("Started ML service");
+ log.info("Started ML service");
}
/**
@@ -335,12 +332,12 @@ public class LensMLImpl implements LensML {
try {
driver.stop();
} catch (LensException e) {
- LOG.error("Failed to stop driver " + driver, e);
+ log.error("Failed to stop driver " + driver, e);
}
}
drivers.clear();
udfStatusExpirySvc.shutdownNow();
- LOG.info("Stopped ML service");
+ log.info("Stopped ML service");
}
public synchronized HiveConf getHiveConf() {
@@ -455,18 +452,18 @@ public class LensMLImpl implements LensML {
}
if (!spec.isOutputTableExists()) {
- LOG.info("Output table '" + testTable + "' does not exist for test algorithm = " + algorithm + " modelid="
+ log.info("Output table '" + testTable + "' does not exist for test algorithm = " + algorithm + " modelid="
+ modelID + ", Creating table using query: " + spec.getCreateOutputTableQuery());
// create the output table
String createOutputTableQuery = spec.getCreateOutputTableQuery();
queryRunner.runQuery(createOutputTableQuery);
- LOG.info("Table created " + testTable);
+ log.info("Table created " + testTable);
}
// Check if ML UDF is registered in this session
registerPredictUdf(sessionHandle, queryRunner);
- LOG.info("Running evaluation query " + testQuery);
+ log.info("Running evaluation query " + testQuery);
queryRunner.setQueryName("model_test_" + modelID);
QueryHandle testQueryHandle = queryRunner.runQuery(testQuery);
@@ -483,7 +480,7 @@ public class LensMLImpl implements LensML {
// Save test report
persistTestReport(testReport);
- LOG.info("Saved test report " + testReport.getReportID());
+ log.info("Saved test report " + testReport.getReportID());
return testReport;
}
@@ -494,12 +491,12 @@ public class LensMLImpl implements LensML {
* @throws LensException the lens exception
*/
private void persistTestReport(MLTestReport testReport) throws LensException {
- LOG.info("saving test report " + testReport.getReportID());
+ log.info("saving test report " + testReport.getReportID());
try {
ModelLoader.saveTestReport(conf, testReport);
- LOG.info("Saved report " + testReport.getReportID());
+ log.info("Saved report " + testReport.getReportID());
} catch (IOException e) {
- LOG.error("Error saving report " + testReport.getReportID() + " reason: " + e.getMessage());
+ log.error("Error saving report " + testReport.getReportID() + " reason: " + e.getMessage(), e);
}
}
@@ -529,7 +526,7 @@ public class LensMLImpl implements LensML {
}
return reports;
} catch (IOException e) {
- LOG.error("Error reading report list for " + algorithm, e);
+ log.error("Error reading report list for " + algorithm, e);
return null;
}
}
@@ -566,9 +563,9 @@ public class LensMLImpl implements LensML {
public void deleteModel(String algorithm, String modelID) throws LensException {
try {
ModelLoader.deleteModel(conf, algorithm, modelID);
- LOG.info("DELETED model " + modelID + " algorithm=" + algorithm);
+ log.info("DELETED model " + modelID + " algorithm=" + algorithm);
} catch (IOException e) {
- LOG.error(
+ log.error(
"Error deleting model file. algorithm=" + algorithm + " model=" + modelID + " reason: " + e.getMessage(), e);
throw new LensException("Unable to delete model " + modelID + " for algorithm " + algorithm, e);
}
@@ -582,9 +579,9 @@ public class LensMLImpl implements LensML {
public void deleteTestReport(String algorithm, String reportID) throws LensException {
try {
ModelLoader.deleteTestReport(conf, algorithm, reportID);
- LOG.info("DELETED report=" + reportID + " algorithm=" + algorithm);
+ log.info("DELETED report=" + reportID + " algorithm=" + algorithm);
} catch (IOException e) {
- LOG.error("Error deleting report " + reportID + " algorithm=" + algorithm + " reason: " + e.getMessage(), e);
+ log.error("Error deleting report " + reportID + " algorithm=" + algorithm + " reason: " + e.getMessage(), e);
throw new LensException("Unable to delete report " + reportID + " for algorithm " + algorithm, e);
}
}
@@ -599,7 +596,7 @@ public class LensMLImpl implements LensML {
try {
algo = getAlgoForName(algorithm);
} catch (LensException e) {
- LOG.error("Error getting algo description : " + algorithm, e);
+ log.error("Error getting algo description : " + algorithm, e);
return null;
}
if (algo instanceof BaseSparkAlgo) {
@@ -693,15 +690,15 @@ public class LensMLImpl implements LensML {
return;
}
- LOG.info("Registering UDF for session " + sessionHandle.getPublicId().toString());
+ log.info("Registering UDF for session " + sessionHandle.getPublicId().toString());
String regUdfQuery = "CREATE TEMPORARY FUNCTION " + HiveMLUDF.UDF_NAME + " AS '" + HiveMLUDF.class
.getCanonicalName() + "'";
queryRunner.setQueryName("register_predict_udf_" + sessionHandle.getPublicId().toString());
QueryHandle udfQuery = queryRunner.runQuery(regUdfQuery);
- LOG.info("udf query handle is " + udfQuery);
+ log.info("udf query handle is " + udfQuery);
predictUdfStatus.put(sessionHandle, true);
- LOG.info("Predict UDF registered for session " + sessionHandle.getPublicId().toString());
+ log.info("Predict UDF registered for session " + sessionHandle.getPublicId().toString());
}
protected boolean isUdfRegisterd(LensSessionHandle sessionHandle) {
@@ -719,12 +716,12 @@ public class LensMLImpl implements LensML {
List<LensSessionHandle> sessions = new ArrayList<LensSessionHandle>(predictUdfStatus.keySet());
for (LensSessionHandle sessionHandle : sessions) {
if (!sessionService.isOpen(sessionHandle)) {
- LOG.info("Session closed, removing UDF status: " + sessionHandle);
+ log.info("Session closed, removing UDF status: " + sessionHandle);
predictUdfStatus.remove(sessionHandle);
}
}
} catch (Exception exc) {
- LOG.warn("Error clearing UDF statuses", exc);
+ log.warn("Error clearing UDF statuses", exc);
}
}
}