You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2015/02/05 07:01:49 UTC
[06/10] incubator-lens git commit: LENS-249 : Fix check style issues
in lens-server module (Rajat Khandelwal via amareshwari)
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/stats/store/log/LogStatisticsStore.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/LogStatisticsStore.java b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/LogStatisticsStore.java
index 67fd77b..baa728f 100644
--- a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/LogStatisticsStore.java
+++ b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/LogStatisticsStore.java
@@ -18,18 +18,21 @@
*/
package org.apache.lens.server.stats.store.log;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.hadoop.conf.Configuration;
import org.apache.lens.server.LensServices;
import org.apache.lens.server.api.events.LensEventService;
import org.apache.lens.server.api.metrics.MetricsService;
import org.apache.lens.server.stats.event.LoggableLensStatistics;
import org.apache.lens.server.stats.store.StatisticsStore;
+
+import org.apache.hadoop.conf.Configuration;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
/**
* The Class LogStatisticsStore.
*/
@@ -60,7 +63,7 @@ public class LogStatisticsStore extends StatisticsStore<LoggableLensStatistics>
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.stats.store.StatisticsStore#initialize(org.apache.hadoop.conf.Configuration)
*/
public void initialize(Configuration conf) {
@@ -74,7 +77,7 @@ public class LogStatisticsStore extends StatisticsStore<LoggableLensStatistics>
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.api.events.AsyncEventListener#process(org.apache.lens.server.api.events.LensEvent)
*/
@Override
@@ -84,7 +87,8 @@ public class LogStatisticsStore extends StatisticsStore<LoggableLensStatistics>
String representation = null;
try {
representation = mapper.writeValueAsString(event);
- } catch (JsonProcessingException ignored) {
+ } catch (JsonProcessingException e) {
+ LOG.error("json processing exception", e);
}
if (representation != null) {
rollupHandler.addToScanTask(eventClass.getName());
@@ -100,7 +104,7 @@ public class LogStatisticsStore extends StatisticsStore<LoggableLensStatistics>
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.stats.store.StatisticsStore#start(org.apache.lens.server.api.events.LensEventService)
*/
public void start(LensEventService service) {
@@ -117,7 +121,7 @@ public class LogStatisticsStore extends StatisticsStore<LoggableLensStatistics>
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.stats.store.StatisticsStore#stop(org.apache.lens.server.api.events.LensEventService)
*/
public void stop(LensEventService service) {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/stats/store/log/PartitionEvent.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/PartitionEvent.java b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/PartitionEvent.java
index 2f10113..f2eb98a 100644
--- a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/PartitionEvent.java
+++ b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/PartitionEvent.java
@@ -18,12 +18,12 @@
*/
package org.apache.lens.server.stats.store.log;
-import lombok.Getter;
-
import java.util.Map;
import org.apache.lens.server.api.events.LensEvent;
+import lombok.Getter;
+
/**
* Event class which encapsulates the partition information.
*/
@@ -42,12 +42,9 @@ public class PartitionEvent extends LensEvent {
/**
* Instantiates a new partition event.
*
- * @param eventName
- * the event name
- * @param partMap
- * the part map
- * @param className
- * the class name
+ * @param eventName the event name
+ * @param partMap the part map
+ * @param className the class name
*/
public PartitionEvent(String eventName, Map<String, String> partMap, String className) {
super(System.currentTimeMillis());
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogFileScannerTask.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogFileScannerTask.java b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogFileScannerTask.java
index 8430a34..b9806ae 100644
--- a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogFileScannerTask.java
+++ b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogFileScannerTask.java
@@ -18,22 +18,24 @@
*/
package org.apache.lens.server.stats.store.log;
-import lombok.Setter;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.lens.api.LensException;
import org.apache.lens.server.LensServices;
import org.apache.lens.server.api.events.LensEventService;
import org.apache.lens.server.api.metrics.MetricsService;
+
import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;
+
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
+import lombok.Setter;
/**
* Timer class for monitoring log file rollup.
@@ -58,7 +60,7 @@ public class StatisticsLogFileScannerTask extends TimerTask {
/*
* (non-Javadoc)
- *
+ *
* @see java.util.TimerTask#run()
*/
@Override
@@ -87,10 +89,8 @@ public class StatisticsLogFileScannerTask extends TimerTask {
/**
* Gets the part map.
*
- * @param fileName
- * the file name
- * @param latestLogFiles
- * the latest log files
+ * @param fileName the file name
+ * @param latestLogFiles the latest log files
* @return the part map
*/
private HashMap<String, String> getPartMap(String fileName, File[] latestLogFiles) {
@@ -104,8 +104,7 @@ public class StatisticsLogFileScannerTask extends TimerTask {
/**
* Gets the latest log file.
*
- * @param value
- * the value
+ * @param value the value
* @return the latest log file
*/
private File[] getLatestLogFile(String value) {
@@ -123,8 +122,7 @@ public class StatisticsLogFileScannerTask extends TimerTask {
/**
* Adds the log file.
*
- * @param event
- * the event
+ * @param event the event
*/
public void addLogFile(String event) {
if (scanSet.containsKey(event)) {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogLayout.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogLayout.java b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogLayout.java
index 3b1793b..67a163c 100644
--- a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogLayout.java
+++ b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogLayout.java
@@ -28,7 +28,7 @@ public class StatisticsLogLayout extends SimpleLayout {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.log4j.SimpleLayout#format(org.apache.log4j.spi.LoggingEvent)
*/
@Override
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogPartitionHandler.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogPartitionHandler.java b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogPartitionHandler.java
index 082f733..932e9aa 100644
--- a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogPartitionHandler.java
+++ b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogPartitionHandler.java
@@ -18,6 +18,18 @@
*/
package org.apache.lens.server.stats.store.log;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.lens.server.LensServices;
+import org.apache.lens.server.api.LensConfConstants;
+import org.apache.lens.server.api.events.AsyncEventListener;
+import org.apache.lens.server.api.metrics.MetricsService;
+import org.apache.lens.server.stats.event.LoggableLensStatistics;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -27,20 +39,10 @@ import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.metadata.Partition;
import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.hadoop.io.IOUtils;
-import org.apache.lens.server.LensServices;
-import org.apache.lens.server.api.LensConfConstants;
-import org.apache.lens.server.api.events.AsyncEventListener;
-import org.apache.lens.server.api.metrics.MetricsService;
-import org.apache.lens.server.stats.event.LoggableLensStatistics;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Class used to copy log files to HDFS and add partition to hive metastore.
*/
@@ -64,8 +66,7 @@ public class StatisticsLogPartitionHandler extends AsyncEventListener<PartitionE
/**
* Initialize.
*
- * @param conf
- * the conf
+ * @param conf the conf
*/
public void initialize(Configuration conf) {
String temp = conf.get(LensConfConstants.STATISTICS_WAREHOUSE_KEY, LensConfConstants.DEFAULT_STATISTICS_WAREHOUSE);
@@ -81,7 +82,7 @@ public class StatisticsLogPartitionHandler extends AsyncEventListener<PartitionE
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.api.events.AsyncEventListener#process(org.apache.lens.server.api.events.LensEvent)
*/
@Override
@@ -109,14 +110,10 @@ public class StatisticsLogPartitionHandler extends AsyncEventListener<PartitionE
/**
* Adds the partition.
*
- * @param eventName
- * the event name
- * @param key
- * the key
- * @param finalPath
- * the final path
- * @param className
- * the class name
+ * @param eventName the event name
+ * @param key the key
+ * @param finalPath the final path
+ * @param className the class name
* @return true, if successful
*/
private boolean addPartition(String eventName, String key, Path finalPath, String className) {
@@ -138,13 +135,10 @@ public class StatisticsLogPartitionHandler extends AsyncEventListener<PartitionE
/**
* Gets the table.
*
- * @param eventName
- * the event name
- * @param className
- * the class name
+ * @param eventName the event name
+ * @param className the class name
* @return the table
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
private Table getTable(String eventName, String className) throws Exception {
Table tmp = null;
@@ -162,13 +156,10 @@ public class StatisticsLogPartitionHandler extends AsyncEventListener<PartitionE
/**
* Creates the table.
*
- * @param eventName
- * the event name
- * @param className
- * the class name
+ * @param eventName the event name
+ * @param className the class name
* @return the table
- * @throws Exception
- * the exception
+ * @throws Exception the exception
*/
private Table createTable(String eventName, String className) throws Exception {
Table tmp;
@@ -197,12 +188,9 @@ public class StatisticsLogPartitionHandler extends AsyncEventListener<PartitionE
/**
* Copy to hdfs.
*
- * @param localPath
- * the local path
- * @param finalPath
- * the final path
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @param localPath the local path
+ * @param finalPath the final path
+ * @throws IOException Signals that an I/O exception has occurred.
*/
private void copyToHdfs(String localPath, Path finalPath) throws IOException {
Configuration conf = new Configuration();
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogRollupHandler.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogRollupHandler.java b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogRollupHandler.java
index cbab724..78e4518 100644
--- a/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogRollupHandler.java
+++ b/lens-server/src/main/java/org/apache/lens/server/stats/store/log/StatisticsLogRollupHandler.java
@@ -18,12 +18,14 @@
*/
package org.apache.lens.server.stats.store.log;
-import org.apache.hadoop.conf.Configuration;
+import java.util.Timer;
+
import org.apache.lens.server.api.LensConfConstants;
import org.apache.lens.server.api.events.LensEventService;
-import org.eclipse.jetty.util.ConcurrentHashSet;
-import java.util.Timer;
+import org.apache.hadoop.conf.Configuration;
+
+import org.eclipse.jetty.util.ConcurrentHashSet;
/**
* Class which handles the log4j rolled file.
@@ -45,8 +47,7 @@ public class StatisticsLogRollupHandler {
/**
* Initalize the handler.
*
- * @param conf
- * configuration to be used while initialization.
+ * @param conf configuration to be used while initialization.
*/
public void initialize(Configuration conf) {
task = new StatisticsLogFileScannerTask();
@@ -57,8 +58,7 @@ public class StatisticsLogRollupHandler {
/**
* Start.
*
- * @param service
- * the service
+ * @param service the service
*/
public void start(LensEventService service) {
task.setService(service);
@@ -75,8 +75,7 @@ public class StatisticsLogRollupHandler {
/**
* Adds the to scan task.
*
- * @param event
- * the event
+ * @param event the event
*/
public void addToScanTask(String event) {
if (!scanSet.contains(event)) {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java
index 3dd4abf..dbcca24 100644
--- a/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java
+++ b/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java
@@ -18,22 +18,25 @@
*/
package org.apache.lens.server.ui;
-import org.apache.lens.api.metastore.*;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.List;
+import java.util.UUID;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+
import org.apache.lens.api.LensException;
import org.apache.lens.api.LensSessionHandle;
+import org.apache.lens.api.metastore.*;
import org.apache.lens.server.LensServices;
import org.apache.lens.server.api.metastore.CubeMetastoreService;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import java.util.List;
-import java.util.UUID;
-
/**
* metastore UI resource api
* <p/>
@@ -77,7 +80,7 @@ public class MetastoreUIResource {
@Path("tables")
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public String getAllTables(@QueryParam("publicId") UUID publicId) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
JSONArray tableList = new JSONArray();
@@ -140,18 +143,18 @@ public class MetastoreUIResource {
@Path("tables/{name}")
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public String getDescription(@QueryParam("publicId") UUID publicId, @QueryParam("type") String type,
- @PathParam("name") String name) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ @PathParam("name") String name) {
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
JSONArray attribList = new JSONArray();
if (type.equals("cube")) {
XBaseCube cube;
try {
- cube = (XBaseCube)getSvc().getCube(sessionHandle, name);
+ cube = (XBaseCube) getSvc().getCube(sessionHandle, name);
} catch (LensException e) {
throw new WebApplicationException(e);
}
-
+
if (cube.getMeasures() != null) {
for (XMeasure measure : cube.getMeasures().getMeasure()) {
try {
@@ -191,7 +194,7 @@ public class MetastoreUIResource {
for (XExprColumn expr : table.getExpressions().getExpression()) {
try {
attribList.put(new JSONObject().put("name", expr.getName()).put("type", "expression")
- .put("expression", expr.getExpr()));
+ .put("expression", expr.getExpr()));
} catch (JSONException j) {
LOG.error(j);
}
@@ -213,7 +216,7 @@ public class MetastoreUIResource {
@Path("searchablefields")
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public String getFilterResults(@QueryParam("publicId") UUID publicId, @QueryParam("keyword") String keyword) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
JSONArray tableList = null;
JSONArray searchResultList = new JSONArray();
@@ -260,14 +263,14 @@ public class MetastoreUIResource {
if (cubeSearchResultList.length() > 0) {
try {
searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns",
- cubeSearchResultList));
+ cubeSearchResultList));
} catch (JSONException j) {
LOG.error(j);
}
} else if (name.contains(keyword)) {
try {
searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns",
- cubeSearchResultList));
+ cubeSearchResultList));
} catch (JSONException j) {
LOG.error(j);
}
@@ -301,14 +304,14 @@ public class MetastoreUIResource {
if (dimSearchResultList.length() > 0) {
try {
searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns",
- dimSearchResultList));
+ dimSearchResultList));
} catch (JSONException j) {
LOG.error(j);
}
} else if (name.contains(keyword)) {
try {
searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns",
- dimSearchResultList));
+ dimSearchResultList));
} catch (JSONException j) {
LOG.error(j);
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java
index cbf6551..a11a103 100644
--- a/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java
+++ b/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java
@@ -18,9 +18,14 @@
*/
package org.apache.lens.server.ui;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
import org.apache.lens.api.APIResult;
import org.apache.lens.api.LensConf;
import org.apache.lens.api.LensException;
@@ -28,14 +33,12 @@ import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.api.query.*;
import org.apache.lens.server.LensServices;
import org.apache.lens.server.api.query.QueryExecutionService;
-import org.glassfish.jersey.media.multipart.FormDataParam;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.glassfish.jersey.media.multipart.FormDataParam;
/**
* The Class QueryServiceUIResource.
@@ -50,11 +53,11 @@ public class QueryServiceUIResource {
private QueryExecutionService queryServer;
// assert: query is not empty
+
/**
* Check query.
*
- * @param query
- * the query
+ * @param query the query
*/
private void checkQuery(String query) {
if (StringUtils.isBlank(query)) {
@@ -63,11 +66,11 @@ public class QueryServiceUIResource {
}
// assert: sessionHandle is not null
+
/**
* Check session handle.
*
- * @param sessionHandle
- * the session handle
+ * @param sessionHandle the session handle
*/
private void checkSessionHandle(LensSessionHandle sessionHandle) {
if (sessionHandle == null) {
@@ -86,8 +89,7 @@ public class QueryServiceUIResource {
/**
* Gets the query handle.
*
- * @param queryHandle
- * the query handle
+ * @param queryHandle the query handle
* @return the query handle
*/
private QueryHandle getQueryHandle(String queryHandle) {
@@ -101,34 +103,28 @@ public class QueryServiceUIResource {
/**
* Get all the queries in the query server; can be filtered with state and user.
*
- * @param publicId
- * The public id of the session in which user is working
- * @param state
- * If any state is passed, all the queries in that state will be returned, otherwise all queries will be
- * returned. Possible states are {@value QueryStatus.Status#values()}
- * @param user
- * return queries matching the user. If set to "all", return queries of all users. By default, returns
- * queries of the current user.
- * @param queryName
- * human readable query name set by user (optional)
- * @param fromDate
- * the from date
- * @param toDate
- * the to date
+ * @param publicId The public id of the session in which user is working
+ * @param state If any state is passed, all the queries in that state will be returned, otherwise all queries will
+ * be returned. Possible states are {@value QueryStatus.Status#values()}
+ * @param user return queries matching the user. If set to "all", return queries of all users. By default,
+ * returns queries of the current user.
+ * @param queryName human readable query name set by user (optional)
+ * @param fromDate the from date
+ * @param toDate the to date
* @return List of {@link QueryHandle} objects
*/
@GET
@Path("queries")
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
public List<QueryHandle> getAllQueries(@QueryParam("publicId") UUID publicId,
- @DefaultValue("") @QueryParam("state") String state, @DefaultValue("") @QueryParam("user") String user,
- @DefaultValue("") @QueryParam("queryName") String queryName,
- @DefaultValue("-1") @QueryParam("fromDate") long fromDate, @DefaultValue("-1") @QueryParam("toDate") long toDate) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ @DefaultValue("") @QueryParam("state") String state, @DefaultValue("") @QueryParam("user") String user,
+ @DefaultValue("") @QueryParam("queryName") String queryName,
+ @DefaultValue("-1") @QueryParam("fromDate") long fromDate, @DefaultValue("-1") @QueryParam("toDate") long toDate) {
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
try {
return queryServer.getAllQueries(sessionHandle, state, user, queryName, fromDate, toDate == -1L ? Long.MAX_VALUE
- : toDate);
+ : toDate);
} catch (LensException e) {
throw new WebApplicationException(e);
}
@@ -137,22 +133,19 @@ public class QueryServiceUIResource {
/**
* Submit the query for explain or execute or execute with a timeout.
*
- * @param publicId
- * The public id of the session in which user is submitting the query. Any configuration set in the session
- * will be picked up.
- * @param query
- * The query to run
- * @param queryName
- * human readable query name set by user (optional)
+ * @param publicId The public id of the session in which user is submitting the query. Any configuration set in the
+ * session will be picked up.
+ * @param query The query to run
+ * @param queryName human readable query name set by user (optional)
* @return {@link QueryHandle}
*/
@POST
@Path("queries")
- @Consumes({ MediaType.MULTIPART_FORM_DATA })
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
+ @Consumes({MediaType.MULTIPART_FORM_DATA})
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
public QuerySubmitResult query(@FormDataParam("publicId") UUID publicId, @FormDataParam("query") String query,
- @DefaultValue("") @FormDataParam("queryName") String queryName) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ @DefaultValue("") @FormDataParam("queryName") String queryName) {
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
LensConf conf;
checkQuery(query);
@@ -167,17 +160,15 @@ public class QueryServiceUIResource {
/**
* Get lens query and its current status.
*
- * @param publicId
- * The public id of session handle
- * @param queryHandle
- * The query handle
+ * @param publicId The public id of session handle
+ * @param queryHandle The query handle
* @return {@link LensQuery}
*/
@GET
@Path("queries/{queryHandle}")
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
public LensQuery getStatus(@QueryParam("publicId") UUID publicId, @PathParam("queryHandle") String queryHandle) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
try {
return queryServer.getQuery(sessionHandle, getQueryHandle(queryHandle));
@@ -189,28 +180,24 @@ public class QueryServiceUIResource {
/**
* Fetch the result set.
*
- * @param publicId
- * The public id of user's session handle
- * @param queryHandle
- * The query handle
- * @param pageNumber
- * page number of the query result set to be read
- * @param fetchSize
- * fetch size
+ * @param publicId The public id of user's session handle
+ * @param queryHandle The query handle
+ * @param pageNumber page number of the query result set to be read
+ * @param fetchSize fetch size
* @return {@link ResultRow}
*/
@GET
@Path("queries/{queryHandle}/resultset")
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
public ResultRow getResultSet(@QueryParam("publicId") UUID publicId, @PathParam("queryHandle") String queryHandle,
- @QueryParam("pageNumber") int pageNumber, @QueryParam("fetchsize") int fetchSize) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ @QueryParam("pageNumber") int pageNumber, @QueryParam("fetchsize") int fetchSize) {
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
List<Object> rows = new ArrayList<Object>();
LOG.info("FetchResultSet for queryHandle:" + queryHandle);
try {
QueryResultSetMetadata resultSetMetadata = queryServer.getResultSetMetadata(sessionHandle,
- getQueryHandle(queryHandle));
+ getQueryHandle(queryHandle));
List<ResultColumn> metaColumns = resultSetMetadata.getColumns();
List<Object> metaResultColumns = new ArrayList<Object>();
for (ResultColumn column : metaColumns) {
@@ -218,7 +205,7 @@ public class QueryServiceUIResource {
}
rows.add(new ResultRow(metaResultColumns));
QueryResult result = queryServer.fetchResultSet(sessionHandle, getQueryHandle(queryHandle), (pageNumber - 1)
- * fetchSize, fetchSize);
+ * fetchSize, fetchSize);
if (result instanceof InMemoryQueryResult) {
InMemoryQueryResult inMemoryQueryResult = (InMemoryQueryResult) result;
List<ResultRow> tableRows = inMemoryQueryResult.getRows();
@@ -236,19 +223,17 @@ public class QueryServiceUIResource {
/**
* Cancel the query specified by the handle.
*
- * @param publicId
- * The user session handle
- * @param queryHandle
- * The query handle
+ * @param publicId The user session handle
+ * @param queryHandle The query handle
* @return APIResult with state {@value org.apache.lens.api.APIResult.Status#SUCCEEDED} in case of successful
- * cancellation. APIResult with state {@value org.apache.lens.api.APIResult.Status#FAILED} in case of
- * cancellation failure.
+ * cancellation. APIResult with state {@value org.apache.lens.api.APIResult.Status#FAILED} in case of cancellation
+ * failure.
*/
@DELETE
@Path("queries/{queryHandle}")
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
public APIResult cancelQuery(@QueryParam("sessionid") UUID publicId, @PathParam("queryHandle") String queryHandle) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
try {
boolean ret = queryServer.cancelQuery(sessionHandle, getQueryHandle(queryHandle));
@@ -265,17 +250,16 @@ public class QueryServiceUIResource {
/**
* Get the http endpoint for result set.
*
- * @param publicId
- * the public id
- * @param queryHandle
- * The query handle
+ * @param publicId the public id
+ * @param queryHandle The query handle
* @return Response with result as octet stream
*/
@GET
@Path("queries/{queryHandle}/httpresultset")
- @Produces({ MediaType.APPLICATION_OCTET_STREAM })
- public Response getHttpResultSet(@QueryParam("sessionid") UUID publicId, @PathParam("queryHandle") String queryHandle) {
- LensSessionHandle sessionHandle = SessionUIResource.openSessions.get(publicId);
+ @Produces({MediaType.APPLICATION_OCTET_STREAM})
+ public Response getHttpResultSet(@QueryParam("sessionid") UUID publicId,
+ @PathParam("queryHandle") String queryHandle) {
+ LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId);
checkSessionHandle(sessionHandle);
try {
return queryServer.getHttpResultSet(sessionHandle, getQueryHandle(queryHandle));
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
index 1e75879..c32edb4 100644
--- a/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
+++ b/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java
@@ -18,22 +18,25 @@
*/
package org.apache.lens.server.ui;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+
import org.apache.lens.api.APIResult;
+import org.apache.lens.api.APIResult.Status;
import org.apache.lens.api.LensConf;
import org.apache.lens.api.LensException;
import org.apache.lens.api.LensSessionHandle;
-import org.apache.lens.api.APIResult.Status;
import org.apache.lens.server.LensServices;
import org.apache.lens.server.api.session.SessionService;
-import org.glassfish.jersey.media.multipart.FormDataParam;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.glassfish.jersey.media.multipart.FormDataParam;
/**
* Session resource api
@@ -47,18 +50,28 @@ public class SessionUIResource {
public static final Log LOG = LogFactory.getLog(SessionUIResource.class);
/** The open sessions. */
- public static HashMap<UUID, LensSessionHandle> openSessions = new HashMap<UUID, LensSessionHandle>();
+ private static HashMap<UUID, LensSessionHandle> openSessions
+ = new HashMap<UUID, LensSessionHandle>();
/** The session service. */
private SessionService sessionService;
/**
+ * get open session from uuid
+ * @param id
+ * @return
+ */
+ public static LensSessionHandle getOpenSession(UUID id) {
+ return openSessions.get(id);
+ }
+
+ /**
* API to know if session service is up and running
*
* @return Simple text saying it up
*/
@GET
- @Produces({ MediaType.TEXT_PLAIN })
+ @Produces({MediaType.TEXT_PLAIN})
public String getMessage() {
return "session is up!";
}
@@ -66,8 +79,7 @@ public class SessionUIResource {
/**
* Instantiates a new session ui resource.
*
- * @throws LensException
- * the lens exception
+ * @throws LensException the lens exception
*/
public SessionUIResource() throws LensException {
sessionService = (SessionService) LensServices.get().getService("session");
@@ -76,8 +88,7 @@ public class SessionUIResource {
/**
* Check session handle.
*
- * @param sessionHandle
- * the session handle
+ * @param sessionHandle the session handle
*/
private void checkSessionHandle(LensSessionHandle sessionHandle) {
if (sessionHandle == null) {
@@ -88,19 +99,16 @@ public class SessionUIResource {
/**
* Create a new session with Lens server.
*
- * @param username
- * User name of the Lens server user
- * @param password
- * Password of the Lens server user
- * @param sessionconf
- * Key-value properties which will be used to configure this session
+ * @param username User name of the Lens server user
+ * @param password Password of the Lens server user
+ * @param sessionconf Key-value properties which will be used to configure this session
* @return A Session handle unique to this session
*/
@POST
- @Consumes({ MediaType.MULTIPART_FORM_DATA })
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
+ @Consumes({MediaType.MULTIPART_FORM_DATA})
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
public LensSessionHandle openSession(@FormDataParam("username") String username,
- @FormDataParam("password") String password, @FormDataParam("sessionconf") LensConf sessionconf) {
+ @FormDataParam("password") String password, @FormDataParam("sessionconf") LensConf sessionconf) {
try {
Map<String, String> conf;
if (sessionconf != null) {
@@ -119,15 +127,15 @@ public class SessionUIResource {
/**
* Close a Lens server session.
*
- * @param publicId
- * Session's public id of the session to be closed
+ * @param publicId Session's public id of the session to be closed
* @return APIResult object indicating if the operation was successful (check result.getStatus())
*/
- @DELETE @Path("{publicId}")
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
+ @DELETE
+ @Path("{publicId}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
public APIResult closeSession(@PathParam("publicId") UUID publicId) {
LOG.info("Closing session with id: " + publicId);
- LensSessionHandle sessionHandle = openSessions.get(publicId);
+ LensSessionHandle sessionHandle = getOpenSession(publicId);
checkSessionHandle(sessionHandle);
openSessions.remove(publicId);
try {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java
index 6afb81c..8563951 100644
--- a/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java
+++ b/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java
@@ -18,25 +18,28 @@
*/
package org.apache.lens.server.ui;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.io.Files;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.lens.server.LensServices;
-import org.apache.lens.server.api.LensConfConstants;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.concurrent.TimeUnit;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.lens.server.LensServices;
+import org.apache.lens.server.api.LensConfConstants;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.conf.HiveConf;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.io.Files;
+
/**
* The Class StaticFileResource.
*/
@@ -47,31 +50,28 @@ public class StaticFileResource {
public static final Log LOG = LogFactory.getLog(StaticFileResource.class);
// Cache for file content, bound by both size and time
- /** The Constant contentCache. */
- private static final LoadingCache<String, String> contentCache = CacheBuilder.newBuilder().maximumSize(100)
- .expireAfterAccess(10, TimeUnit.MINUTES).build(new CacheLoader<String, String>() {
- String baseDir = null;
+ /** The Constant CONTENT_CACHE. */
+ private static final LoadingCache<String, String> CONTENT_CACHE = CacheBuilder.newBuilder().maximumSize(100)
+ .expireAfterAccess(10, TimeUnit.MINUTES).build(new CacheLoader<String, String>() {
+ String baseDir = null;
- @Override
- public String load(String filePath) throws Exception {
- if (baseDir == null) {
- baseDir = LensServices.get().getHiveConf()
- .get(LensConfConstants.SERVER_UI_STATIC_DIR, LensConfConstants.DEFAULT_SERVER_UI_STATIC_DIR);
- }
- return loadFile(baseDir, filePath);
+ @Override
+ public String load(String filePath) throws Exception {
+ if (baseDir == null) {
+ baseDir = LensServices.get().getHiveConf()
+ .get(LensConfConstants.SERVER_UI_STATIC_DIR, LensConfConstants.DEFAULT_SERVER_UI_STATIC_DIR);
}
- });
+ return loadFile(baseDir, filePath);
+ }
+ });
/**
* Load file.
*
- * @param baseDir
- * the base dir
- * @param filePath
- * the file path
+ * @param baseDir the base dir
+ * @param filePath the file path
* @return the string
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @throws IOException Signals that an I/O exception has occurred.
*/
private static String loadFile(String baseDir, String filePath) throws IOException {
return Files.toString(new File(baseDir, filePath), Charset.forName("UTF-8"));
@@ -80,8 +80,7 @@ public class StaticFileResource {
/**
* Gets the static resource.
*
- * @param filePath
- * the file path
+ * @param filePath the file path
* @return the static resource
*/
@GET
@@ -90,12 +89,12 @@ public class StaticFileResource {
try {
HiveConf conf = LensServices.get().getHiveConf();
if (conf.getBoolean(LensConfConstants.SERVER_UI_ENABLE_CACHING,
- LensConfConstants.DEFAULT_SERVER_UI_ENABLE_CACHING)) {
- return Response.ok(contentCache.get(filePath), getMediaType(filePath)).build();
+ LensConfConstants.DEFAULT_SERVER_UI_ENABLE_CACHING)) {
+ return Response.ok(CONTENT_CACHE.get(filePath), getMediaType(filePath)).build();
} else {
// This is for dev mode
String baseDir = conf.get(LensConfConstants.SERVER_UI_STATIC_DIR,
- LensConfConstants.DEFAULT_SERVER_UI_STATIC_DIR);
+ LensConfConstants.DEFAULT_SERVER_UI_STATIC_DIR);
return Response.ok(loadFile(baseDir, filePath), getMediaType(filePath)).build();
}
} catch (Exception e) {
@@ -109,8 +108,7 @@ public class StaticFileResource {
/**
* Gets the media type.
*
- * @param filePath
- * the file path
+ * @param filePath the file path
* @return the media type
*/
private String getMediaType(String filePath) {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java b/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java
index be226e6..c22a1aa 100644
--- a/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java
+++ b/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java
@@ -18,14 +18,16 @@
*/
package org.apache.lens.server.ui;
-import org.apache.lens.server.AuthenticationFilter;
-import org.apache.lens.server.LensApplicationListener;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import java.util.HashSet;
+import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
-import java.util.HashSet;
-import java.util.Set;
+
+import org.apache.lens.server.AuthenticationFilter;
+import org.apache.lens.server.LensApplicationListener;
+
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
/**
* The Class UIApp.
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/CustomUserConfigLoader.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/CustomUserConfigLoader.java b/lens-server/src/main/java/org/apache/lens/server/user/CustomUserConfigLoader.java
index 4ac4d27..9a6a350 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/CustomUserConfigLoader.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/CustomUserConfigLoader.java
@@ -18,12 +18,13 @@
*/
package org.apache.lens.server.user;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.lens.server.api.LensConfConstants;
-
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
+import org.apache.lens.server.api.LensConfConstants;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+
/**
* The Class CustomUserConfigLoader.
*/
@@ -38,13 +39,12 @@ public class CustomUserConfigLoader extends UserConfigLoader {
/**
* Instantiates a new custom user config loader.
*
- * @param conf
- * the conf
+ * @param conf the conf
*/
public CustomUserConfigLoader(HiveConf conf) {
super(conf);
this.customHandlerClass = (Class<? extends UserConfigLoader>) hiveConf.getClass(
- LensConfConstants.USER_RESOLVER_CUSTOM_CLASS, UserConfigLoader.class);
+ LensConfConstants.USER_RESOLVER_CUSTOM_CLASS, UserConfigLoader.class);
try {
this.customProvider = customHandlerClass.getConstructor(HiveConf.class).newInstance(conf);
// in java6, these four extend directly from Exception. So have to handle separately. In java7,
@@ -62,7 +62,7 @@ public class CustomUserConfigLoader extends UserConfigLoader {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.user.UserConfigLoader#getUserConfig(java.lang.String)
*/
@Override
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/DatabaseUserConfigLoader.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/DatabaseUserConfigLoader.java b/lens-server/src/main/java/org/apache/lens/server/user/DatabaseUserConfigLoader.java
index 3d27241..d267948 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/DatabaseUserConfigLoader.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/DatabaseUserConfigLoader.java
@@ -18,14 +18,6 @@
*/
package org.apache.lens.server.user;
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.lens.server.api.LensConfConstants;
-import org.apache.lens.server.util.UtilityMethods;
-
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
@@ -33,6 +25,15 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import org.apache.lens.server.api.LensConfConstants;
+import org.apache.lens.server.util.UtilityMethods;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.hadoop.hive.conf.HiveConf;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
/**
* The Class DatabaseUserConfigLoader.
*/
@@ -53,18 +54,16 @@ public class DatabaseUserConfigLoader extends UserConfigLoader {
/**
* Instantiates a new database user config loader.
*
- * @param conf
- * the conf
- * @throws UserConfigLoaderException
- * the user config loader exception
+ * @param conf the conf
+ * @throws UserConfigLoaderException the user config loader exception
*/
public DatabaseUserConfigLoader(HiveConf conf) throws UserConfigLoaderException {
super(conf);
querySql = conf.get(LensConfConstants.USER_RESOLVER_DB_QUERY);
keys = conf.get(LensConfConstants.USER_RESOLVER_DB_KEYS).split("\\s*,\\s*", -1);
cache = CacheBuilder.newBuilder()
- .expireAfterWrite(conf.getInt(LensConfConstants.USER_RESOLVER_CACHE_EXPIRY, 2), TimeUnit.HOURS)
- .maximumSize(conf.getInt(LensConfConstants.USER_RESOLVER_CACHE_MAX_SIZE, 100)).build();
+ .expireAfterWrite(conf.getInt(LensConfConstants.USER_RESOLVER_CACHE_EXPIRY, 2), TimeUnit.HOURS)
+ .maximumSize(conf.getInt(LensConfConstants.USER_RESOLVER_CACHE_MAX_SIZE, 100)).build();
}
/*
@@ -82,7 +81,7 @@ public class DatabaseUserConfigLoader extends UserConfigLoader {
final String[] config = queryDatabase(querySql, false, loggedInUser);
if (config.length != keys.length) {
throw new UserConfigLoaderException("size of columns retrieved by db query(" + config.length + ") "
- + "is not equal to the number of keys required(" + keys.length + ").");
+ + "is not equal to the number of keys required(" + keys.length + ").");
}
return new HashMap<String, String>() {
{
@@ -102,7 +101,7 @@ public class DatabaseUserConfigLoader extends UserConfigLoader {
}
private BasicDataSource refreshDataSource() {
- if(ds == null || ds.isClosed()) {
+ if (ds == null || ds.isClosed()) {
ds = UtilityMethods.getDataSourceFromConf(hiveConf);
}
return ds;
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/FixedUserConfigLoader.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/FixedUserConfigLoader.java b/lens-server/src/main/java/org/apache/lens/server/user/FixedUserConfigLoader.java
index 6fa5fd0..b81b994 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/FixedUserConfigLoader.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/FixedUserConfigLoader.java
@@ -18,12 +18,13 @@
*/
package org.apache.lens.server.user;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.lens.server.api.LensConfConstants;
-
import java.util.HashMap;
import java.util.Map;
+import org.apache.lens.server.api.LensConfConstants;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+
/**
* The Class FixedUserConfigLoader.
*/
@@ -32,8 +33,7 @@ public class FixedUserConfigLoader extends UserConfigLoader {
/**
* Instantiates a new fixed user config loader.
*
- * @param conf
- * the conf
+ * @param conf the conf
*/
public FixedUserConfigLoader(HiveConf conf) {
super(conf);
@@ -41,7 +41,7 @@ public class FixedUserConfigLoader extends UserConfigLoader {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.user.UserConfigLoader#getUserConfig(java.lang.String)
*/
@Override
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/LDAPBackedDatabaseUserConfigLoader.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/LDAPBackedDatabaseUserConfigLoader.java b/lens-server/src/main/java/org/apache/lens/server/user/LDAPBackedDatabaseUserConfigLoader.java
index ba0da3e..108a012 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/LDAPBackedDatabaseUserConfigLoader.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/LDAPBackedDatabaseUserConfigLoader.java
@@ -18,21 +18,6 @@
*/
package org.apache.lens.server.user;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import org.apache.commons.dbutils.QueryRunner;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.lens.server.api.LensConfConstants;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
-
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.InitialLdapContext;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Hashtable;
@@ -41,6 +26,25 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.InitialLdapContext;
+
+import org.apache.lens.server.api.LensConfConstants;
+
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.hadoop.hive.conf.HiveConf;
+
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
/**
* The Class LDAPBackedDatabaseUserConfigLoader.
*/
@@ -64,8 +68,8 @@ public class LDAPBackedDatabaseUserConfigLoader extends DatabaseUserConfigLoader
/** The intermediate insert sql. */
private final String intermediateInsertSql;
- /** The Constant outputFormatter. */
- private final static DateTimeFormatter outputFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:SS")
+ /** The Constant DATE_TIME_FORMATTER. */
+ private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:SS")
.withZoneUTC();
/** The expiry hours. */
@@ -167,7 +171,7 @@ public class LDAPBackedDatabaseUserConfigLoader extends DatabaseUserConfigLoader
@Override
public String[] call() throws Exception {
String[] config = queryDatabase(intermediateQuerySql, true, loggedInUser,
- Timestamp.valueOf(DateTime.now().toString(outputFormatter)));
+ Timestamp.valueOf(DateTime.now().toString(DATE_TIME_FORMATTER)));
if (config == null) {
config = getAttributes(loggedInUser);
Object[] updateArray = new Object[config.length + 2];
@@ -176,7 +180,7 @@ public class LDAPBackedDatabaseUserConfigLoader extends DatabaseUserConfigLoader
}
updateArray[0] = loggedInUser;
updateArray[config.length + 1] = Timestamp.valueOf(DateTime.now().plusHours(expiryHours)
- .toString(outputFormatter));
+ .toString(DATE_TIME_FORMATTER));
QueryRunner runner = new QueryRunner(ds);
runner.update(intermediateDeleteSql, loggedInUser);
runner.update(intermediateInsertSql, updateArray);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/PropertyBasedUserConfigLoader.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/PropertyBasedUserConfigLoader.java b/lens-server/src/main/java/org/apache/lens/server/user/PropertyBasedUserConfigLoader.java
index 0129e11..46a0e37 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/PropertyBasedUserConfigLoader.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/PropertyBasedUserConfigLoader.java
@@ -18,9 +18,6 @@
*/
package org.apache.lens.server.user;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.lens.server.api.LensConfConstants;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -29,6 +26,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import org.apache.lens.server.api.LensConfConstants;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+
/**
* The Class PropertyBasedUserConfigLoader.
*/
@@ -40,10 +41,8 @@ public class PropertyBasedUserConfigLoader extends UserConfigLoader {
/**
* Instantiates a new property based user config loader.
*
- * @param conf
- * the conf
- * @throws UserConfigLoaderException
- * the user config loader exception
+ * @param conf the conf
+ * @throws UserConfigLoaderException the user config loader exception
*/
public PropertyBasedUserConfigLoader(HiveConf conf) throws UserConfigLoaderException {
super(conf);
@@ -52,7 +51,7 @@ public class PropertyBasedUserConfigLoader extends UserConfigLoader {
String filename = hiveConf.get(LensConfConstants.USER_RESOLVER_PROPERTYBASED_FILENAME, null);
if (filename == null) {
throw new UserConfigLoaderException("property file path not provided for property based resolver."
- + "Please set property " + LensConfConstants.USER_RESOLVER_PROPERTYBASED_FILENAME);
+ + "Please set property " + LensConfConstants.USER_RESOLVER_PROPERTYBASED_FILENAME);
}
try {
properties.load(new InputStreamReader(new FileInputStream(new File(filename))));
@@ -73,7 +72,7 @@ public class PropertyBasedUserConfigLoader extends UserConfigLoader {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.lens.server.user.UserConfigLoader#getUserConfig(java.lang.String)
*/
@Override
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoader.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoader.java b/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoader.java
index fceaaaf..21eea3b 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoader.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoader.java
@@ -18,10 +18,10 @@
*/
package org.apache.lens.server.user;
-import org.apache.hadoop.hive.conf.HiveConf;
-
import java.util.Map;
+import org.apache.hadoop.hive.conf.HiveConf;
+
/**
* The Class UserConfigLoader.
*/
@@ -33,8 +33,7 @@ public abstract class UserConfigLoader {
/**
* Instantiates a new user config loader.
*
- * @param conf
- * the conf
+ * @param conf the conf
*/
protected UserConfigLoader(HiveConf conf) {
this.hiveConf = conf;
@@ -43,11 +42,9 @@ public abstract class UserConfigLoader {
/**
* Gets the user config.
*
- * @param loggedInUser
- * the logged in user
+ * @param loggedInUser the logged in user
* @return the user config
- * @throws UserConfigLoaderException
- * the user config loader exception
+ * @throws UserConfigLoaderException the user config loader exception
*/
public abstract Map<String, String> getUserConfig(String loggedInUser) throws UserConfigLoaderException;
}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderException.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderException.java b/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderException.java
index 38de387..0899746 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderException.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderException.java
@@ -33,8 +33,7 @@ public class UserConfigLoaderException extends RuntimeException {
/**
* Instantiates a new user config loader exception.
*
- * @param s
- * the s
+ * @param s the s
*/
public UserConfigLoaderException(String s) {
super(s);
@@ -43,8 +42,7 @@ public class UserConfigLoaderException extends RuntimeException {
/**
* Instantiates a new user config loader exception.
*
- * @param e
- * the e
+ * @param e the e
*/
public UserConfigLoaderException(Throwable e) {
super(e);
@@ -53,10 +51,8 @@ public class UserConfigLoaderException extends RuntimeException {
/**
* Instantiates a new user config loader exception.
*
- * @param message
- * the message
- * @param cause
- * the cause
+ * @param message the message
+ * @param cause the cause
*/
public UserConfigLoaderException(String message, Throwable cause) {
super(message, cause);
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderFactory.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderFactory.java b/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderFactory.java
index 405bdea..383aaf5 100644
--- a/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderFactory.java
+++ b/lens-server/src/main/java/org/apache/lens/server/user/UserConfigLoaderFactory.java
@@ -18,16 +18,19 @@
*/
package org.apache.lens.server.user;
-import org.apache.hadoop.hive.conf.HiveConf;
+import java.util.Map;
+
import org.apache.lens.server.api.LensConfConstants;
-import java.util.Map;
+import org.apache.hadoop.hive.conf.HiveConf;
/**
* A factory for creating UserConfigLoader objects.
*/
-public class UserConfigLoaderFactory {
+public final class UserConfigLoaderFactory {
+ private UserConfigLoaderFactory() {
+ }
/** The conf. */
private static HiveConf conf;
@@ -37,8 +40,7 @@ public class UserConfigLoaderFactory {
/**
* Inits the.
*
- * @param c
- * the c
+ * @param c the c
*/
public static void init(HiveConf c) {
conf = c;
@@ -87,8 +89,7 @@ public class UserConfigLoaderFactory {
/**
* Gets the query user resolver.
*
- * @param resolverType
- * the resolver type
+ * @param resolverType the resolver type
* @return the query user resolver
*/
public static UserConfigLoader getQueryUserResolver(RESOLVER_TYPE resolverType) {
@@ -110,8 +111,7 @@ public class UserConfigLoaderFactory {
/**
* Gets the user config.
*
- * @param loggedInUser
- * the logged in user
+ * @param loggedInUser the logged in user
* @return the user config
*/
public static Map<String, String> getUserConfig(String loggedInUser) {
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/a18896b4/lens-server/src/main/java/org/apache/lens/server/util/UtilityMethods.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/util/UtilityMethods.java b/lens-server/src/main/java/org/apache/lens/server/util/UtilityMethods.java
index c282b3d..3f2e817 100644
--- a/lens-server/src/main/java/org/apache/lens/server/util/UtilityMethods.java
+++ b/lens-server/src/main/java/org/apache/lens/server/util/UtilityMethods.java
@@ -18,34 +18,33 @@
*/
package org.apache.lens.server.util;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import org.apache.lens.server.api.LensConfConstants;
+
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.hadoop.conf.Configuration;
-import org.apache.lens.server.api.LensConfConstants;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Map;
/**
* The Class UtilityMethods.
*/
-public class UtilityMethods {
+public final class UtilityMethods {
+ private UtilityMethods() {
+
+ }
/**
* Merge maps.
*
- * @param <K>
- * the key type
- * @param <V>
- * the value type
- * @param into
- * the into
- * @param from
- * the from
- * @param override
- * the override
+ * @param <K> the key type
+ * @param <V> the value type
+ * @param into the into
+ * @param from the from
+ * @param override the override
*/
public static <K, V> void mergeMaps(Map<K, V> into, Map<K, V> from, boolean override) {
for (K key : from.keySet()) {
@@ -58,8 +57,7 @@ public class UtilityMethods {
/**
* Removes the domain.
*
- * @param username
- * the username
+ * @param username the username
* @return the string
*/
public static String removeDomain(String username) {
@@ -72,8 +70,7 @@ public class UtilityMethods {
/**
* Any null.
*
- * @param args
- * the args
+ * @param args the args
* @return true, if successful
*/
public static boolean anyNull(Object... args) {
@@ -88,20 +85,15 @@ public class UtilityMethods {
/**
* Query database.
*
- * @param ds
- * the ds
- * @param querySql
- * the query sql
- * @param allowNull
- * the allow null
- * @param args
- * the args
+ * @param ds the ds
+ * @param querySql the query sql
+ * @param allowNull the allow null
+ * @param args the args
* @return the string[]
- * @throws SQLException
- * the SQL exception
+ * @throws SQLException the SQL exception
*/
public static String[] queryDatabase(BasicDataSource ds, String querySql, final boolean allowNull, Object... args)
- throws SQLException {
+ throws SQLException {
QueryRunner runner = new QueryRunner(ds);
return runner.query(querySql, new ResultSetHandler<String[]>() {
@Override
@@ -127,14 +119,13 @@ public class UtilityMethods {
/**
* Gets the data source from conf.
*
- * @param conf
- * the conf
+ * @param conf the conf
* @return the data source from conf
*/
public static BasicDataSource getDataSourceFromConf(Configuration conf) {
BasicDataSource tmp = new BasicDataSource();
tmp.setDriverClassName(conf.get(LensConfConstants.SERVER_DB_DRIVER_NAME,
- LensConfConstants.DEFAULT_SERVER_DB_DRIVER_NAME));
+ LensConfConstants.DEFAULT_SERVER_DB_DRIVER_NAME));
tmp.setUrl(conf.get(LensConfConstants.SERVER_DB_JDBC_URL, LensConfConstants.DEFAULT_SERVER_DB_JDBC_URL));
tmp.setUsername(conf.get(LensConfConstants.SERVER_DB_JDBC_USER, LensConfConstants.DEFAULT_SERVER_DB_USER));
tmp.setPassword(conf.get(LensConfConstants.SERVER_DB_JDBC_PASS, LensConfConstants.DEFAULT_SERVER_DB_PASS));
@@ -144,8 +135,7 @@ public class UtilityMethods {
/**
* Conf to string.
*
- * @param conf
- * the conf
+ * @param conf the conf
* @return the string
*/
public static String confToString(Configuration conf) {