You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pirk.apache.org by ea...@apache.org on 2016/07/23 15:29:14 UTC
[2/4] incubator-pirk git commit: PIRK-11 Switch to SLF4J with Log4j2
bindings, including other minor cleanup - closes apache/incubator-pirk#20
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/data/partitioner/DataPartitioner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/data/partitioner/DataPartitioner.java b/src/main/java/org/apache/pirk/schema/data/partitioner/DataPartitioner.java
index 1bbecca..cd1e632 100644
--- a/src/main/java/org/apache/pirk/schema/data/partitioner/DataPartitioner.java
+++ b/src/main/java/org/apache/pirk/schema/data/partitioner/DataPartitioner.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.data.partitioner;
import java.io.Serializable;
@@ -35,32 +35,32 @@ public interface DataPartitioner extends Serializable
* <p>
* If the Object does not have/need a specific type identifier, use null
*/
- public ArrayList<BigInteger> toPartitions(Object object, String type) throws Exception;
+ ArrayList<BigInteger> toPartitions(Object object, String type) throws Exception;
/**
* Method to reconstruct an Object given an ArrayList of its BigInteger partition elements and its type identifier
* <p>
* If the Object does not have/need a specific type identifier, use null
*/
- public Object fromPartitions(ArrayList<BigInteger> parts, int partsIndex, String type) throws Exception;
+ Object fromPartitions(ArrayList<BigInteger> parts, int partsIndex, String type) throws Exception;
/**
* Method to return the number of bits of an object with the given type
*/
- public int getBits(String type) throws Exception;
+ int getBits(String type) throws Exception;
/**
* Create partitions for an array of the same type of elements - used when a data value field is an array and we wish to encode these into the return value
*/
- public ArrayList<BigInteger> arrayToPartitions(List<?> elementList, String type) throws Exception;
+ ArrayList<BigInteger> arrayToPartitions(List<?> elementList, String type) throws Exception;
/**
* Method to get an empty set of partitions by data type - used for padding return array values
*/
- public ArrayList<BigInteger> getPaddedPartitions(String type) throws Exception;
+ ArrayList<BigInteger> getPaddedPartitions(String type) throws Exception;
/**
* Method to get the number of partitions of the data object given the type
*/
- public int getNumPartitions(String type) throws Exception;
+ int getNumPartitions(String type) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/data/partitioner/IPDataPartitioner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/data/partitioner/IPDataPartitioner.java b/src/main/java/org/apache/pirk/schema/data/partitioner/IPDataPartitioner.java
index 25e49a4..494aba0 100644
--- a/src/main/java/org/apache/pirk/schema/data/partitioner/IPDataPartitioner.java
+++ b/src/main/java/org/apache/pirk/schema/data/partitioner/IPDataPartitioner.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.data.partitioner;
import java.math.BigInteger;
@@ -36,7 +36,7 @@ public class IPDataPartitioner implements DataPartitioner
@Override
public ArrayList<BigInteger> toPartitions(Object object, String type) throws Exception
{
- ArrayList<BigInteger> parts = new ArrayList<BigInteger>();
+ ArrayList<BigInteger> parts = new ArrayList<>();
String[] octets = ((String) object).split("\\.");
for (String oct : octets)
@@ -50,7 +50,7 @@ public class IPDataPartitioner implements DataPartitioner
@Override
public Object fromPartitions(ArrayList<BigInteger> parts, int partsIndex, String type) throws Exception
{
- Object element = null;
+ Object element;
element = parts.get(partsIndex).toString() + "." + parts.get(partsIndex + 1).toString() + "." + parts.get(partsIndex + 2).toString() + "."
+ parts.get(partsIndex + 3).toString();
@@ -67,7 +67,7 @@ public class IPDataPartitioner implements DataPartitioner
@Override
public ArrayList<BigInteger> getPaddedPartitions(String type) throws Exception
{
- ArrayList<BigInteger> parts = new ArrayList<BigInteger>();
+ ArrayList<BigInteger> parts = new ArrayList<>();
for (int i = 0; i < 4; ++i)
{
@@ -82,7 +82,7 @@ public class IPDataPartitioner implements DataPartitioner
@Override
public ArrayList<BigInteger> arrayToPartitions(List<?> elementList, String type) throws Exception
{
- ArrayList<BigInteger> parts = new ArrayList<BigInteger>();
+ ArrayList<BigInteger> parts = new ArrayList<>();
int numArrayElementsToReturn = Integer.parseInt(SystemConfiguration.getProperty("pir.numReturnArrayElements", "1"));
for (int i = 0; i < numArrayElementsToReturn; ++i)
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/data/partitioner/ISO8601DatePartitioner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/data/partitioner/ISO8601DatePartitioner.java b/src/main/java/org/apache/pirk/schema/data/partitioner/ISO8601DatePartitioner.java
index 4bd29b6..715bf15 100644
--- a/src/main/java/org/apache/pirk/schema/data/partitioner/ISO8601DatePartitioner.java
+++ b/src/main/java/org/apache/pirk/schema/data/partitioner/ISO8601DatePartitioner.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.data.partitioner;
import java.math.BigInteger;
@@ -33,7 +33,7 @@ public class ISO8601DatePartitioner implements DataPartitioner
{
private static final long serialVersionUID = 1L;
- PrimitiveTypePartitioner ptp = null;
+ private PrimitiveTypePartitioner ptp = null;
public ISO8601DatePartitioner()
{
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java b/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java
index 1c3f42d..3688e81 100644
--- a/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java
+++ b/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java
@@ -18,16 +18,16 @@
*/
package org.apache.pirk.schema.data.partitioner;
-import org.apache.http.util.ByteArrayBuffer;
-import org.apache.log4j.Logger;
-import org.apache.pirk.utils.LogUtils;
-import org.apache.pirk.utils.SystemConfiguration;
-
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
+import org.apache.http.util.ByteArrayBuffer;
+import org.apache.pirk.utils.SystemConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Class for partitioning objects with primitive Java types
*
@@ -36,7 +36,7 @@ public class PrimitiveTypePartitioner implements DataPartitioner
{
private static final long serialVersionUID = 1L;
- private Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(PrimitiveTypePartitioner.class);
public static final String BYTE = "byte";
public static final String SHORT = "short";
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/query/LoadQuerySchemas.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/query/LoadQuerySchemas.java b/src/main/java/org/apache/pirk/schema/query/LoadQuerySchemas.java
index 213e983..fa00756 100644
--- a/src/main/java/org/apache/pirk/schema/query/LoadQuerySchemas.java
+++ b/src/main/java/org/apache/pirk/schema/query/LoadQuerySchemas.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.query;
import java.io.File;
@@ -29,12 +29,12 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.log4j.Logger;
import org.apache.pirk.schema.data.DataSchema;
import org.apache.pirk.schema.data.LoadDataSchemas;
import org.apache.pirk.schema.data.partitioner.DataPartitioner;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.SystemConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -66,15 +66,15 @@ import org.w3c.dom.NodeList;
*/
public class LoadQuerySchemas
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(LoadQuerySchemas.class);
- public static HashMap<String,QuerySchema> schemaMap;
+ private static HashMap<String,QuerySchema> schemaMap;
static
{
logger.info("Loading query schemas: ");
- schemaMap = new HashMap<String,QuerySchema>();
+ schemaMap = new HashMap<>();
try
{
initialize();
@@ -124,13 +124,13 @@ public class LoadQuerySchemas
private static QuerySchema loadQuerySchemaFile(String schemaFile, boolean hdfs, FileSystem fs) throws Exception
{
- QuerySchema querySchema = null;
+ QuerySchema querySchema;
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
// Read in and parse the schema file
- Document doc = null;
+ Document doc;
if (hdfs)
{
Path filePath = new Path(schemaFile);
@@ -176,7 +176,7 @@ public class LoadQuerySchemas
}
Element elements = (Element) elementsList.item(0);
- TreeSet<String> elementNames = new TreeSet<String>();
+ TreeSet<String> elementNames = new TreeSet<>();
int dataElementSize = 0;
NodeList nList = elements.getElementsByTagName("name");
for (int i = 0; i < nList.getLength(); i++)
@@ -193,7 +193,7 @@ public class LoadQuerySchemas
// Compute the number of bits for this element
logger.info("name = " + name);
logger.info("partitionerName = " + dataSchema.getPartitionerName(name));
- if (((DataPartitioner) dataSchema.getPartitionerForElement(name)) == null)
+ if ((dataSchema.getPartitionerForElement(name)) == null)
{
logger.info("partitioner is null");
}
@@ -218,7 +218,7 @@ public class LoadQuerySchemas
}
// Extract the filterNames, if they exist
- HashSet<String> filterNamesSet = new HashSet<String>();
+ HashSet<String> filterNamesSet = new HashSet<>();
if (doc.getElementsByTagName("filterNames").item(0) != null)
{
NodeList filterNamesList = doc.getElementsByTagName("filterNames");
@@ -256,7 +256,7 @@ public class LoadQuerySchemas
*/
private static String extractValue(Document doc, String valueName) throws Exception
{
- String value = null;
+ String value;
NodeList itemList = doc.getElementsByTagName(valueName);
if (itemList.getLength() > 1)
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/query/QuerySchema.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/query/QuerySchema.java b/src/main/java/org/apache/pirk/schema/query/QuerySchema.java
index b3ea515..7610b52 100644
--- a/src/main/java/org/apache/pirk/schema/query/QuerySchema.java
+++ b/src/main/java/org/apache/pirk/schema/query/QuerySchema.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.query;
import java.io.Serializable;
@@ -35,24 +35,24 @@ public class QuerySchema implements Serializable
{
private static final long serialVersionUID = 1L;
- public static final String NO_FILTER = "noFilter";
+ static final String NO_FILTER = "noFilter";
- String schemaName = null;
+ private String schemaName = null;
- String dataSchemaName = null; // name of the DataSchema for this query schema
+ private String dataSchemaName = null; // name of the DataSchema for this query schema
- TreeSet<String> elementNames = null; // names of elements in the data schema to
+ private TreeSet<String> elementNames = null; // names of elements in the data schema to
// include in the response, order matters for packing/unpacking
- String filter = null; // name of filter class to use in data filtering
+ private String filter = null; // name of filter class to use in data filtering
- Object filterObj = null; // instance of the filter
+ private Object filterObj = null; // instance of the filter
- HashSet<String> filterElementNames = null; // set of element names to apply filtering in pre-processing
+ private HashSet<String> filterElementNames = null; // set of element names to apply filtering in pre-processing
- String selectorName = null; // name of element in the dataSchema to be used as the selector
+ private String selectorName = null; // name of element in the dataSchema to be used as the selector
- int dataElementSize = 0; // total number of bits to be returned for each data element hit
+ private int dataElementSize = 0; // total number of bits to be returned for each data element hit
public QuerySchema(String schemaNameInput, String dataSchemaNameInput, TreeSet<String> elementNamesInput, String selectorNameInput, int dataElementSizeInput,
HashSet<String> filterElementNamesInput, String filterIn) throws Exception
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/query/filter/DataFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/query/filter/DataFilter.java b/src/main/java/org/apache/pirk/schema/query/filter/DataFilter.java
index 17f387d..35c64e0 100644
--- a/src/main/java/org/apache/pirk/schema/query/filter/DataFilter.java
+++ b/src/main/java/org/apache/pirk/schema/query/filter/DataFilter.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.query.filter;
import java.io.Serializable;
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/query/filter/FilterFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/query/filter/FilterFactory.java b/src/main/java/org/apache/pirk/schema/query/filter/FilterFactory.java
index 8c86235..946f803 100644
--- a/src/main/java/org/apache/pirk/schema/query/filter/FilterFactory.java
+++ b/src/main/java/org/apache/pirk/schema/query/filter/FilterFactory.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.query.filter;
import java.io.BufferedReader;
@@ -44,12 +44,12 @@ public class FilterFactory
FileSystem fs = FileSystem.get(new Configuration());
// Grab the stopList
- HashSet<String> stopList = new HashSet<String>();
+ HashSet<String> stopList = new HashSet<>();
String stopListFile = SystemConfiguration.getProperty("pir.stopListFile", "none");
if (!stopListFile.equals("none"))
{
- BufferedReader br = null;
+ BufferedReader br;
if (fs.exists(new Path(stopListFile)))
{
br = new BufferedReader(new InputStreamReader(fs.open(new Path(stopListFile))));
@@ -60,7 +60,7 @@ public class FilterFactory
br = new BufferedReader(fr);
}
- String qLine = null;
+ String qLine;
while ((qLine = br.readLine()) != null)
{
stopList.add(qLine);
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/query/filter/StopListFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/query/filter/StopListFilter.java b/src/main/java/org/apache/pirk/schema/query/filter/StopListFilter.java
index 1f458c1..6c58d2c 100644
--- a/src/main/java/org/apache/pirk/schema/query/filter/StopListFilter.java
+++ b/src/main/java/org/apache/pirk/schema/query/filter/StopListFilter.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.query.filter;
import java.util.Arrays;
@@ -24,11 +24,11 @@ import java.util.List;
import org.apache.hadoop.io.ArrayWritable;
import org.apache.hadoop.io.MapWritable;
-import org.apache.log4j.Logger;
import org.apache.pirk.schema.data.DataSchema;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.StopListUtils;
import org.elasticsearch.hadoop.mr.WritableArrayWritable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Filter class to filter data elements based upon a stoplist applied to specified field elements
@@ -37,10 +37,10 @@ public class StopListFilter implements DataFilter
{
private static final long serialVersionUID = 1L;
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(StopListFilter.class);
- HashSet<String> filterSet = null;
- HashSet<String> stopList = null;
+ private HashSet<String> filterSet = null;
+ private HashSet<String> stopList = null;
public StopListFilter(HashSet<String> filterSetIn, HashSet<String> stopListIn)
{
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/schema/response/QueryResponseJSON.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/schema/response/QueryResponseJSON.java b/src/main/java/org/apache/pirk/schema/response/QueryResponseJSON.java
index 5b3c108..5f7e79c 100644
--- a/src/main/java/org/apache/pirk/schema/response/QueryResponseJSON.java
+++ b/src/main/java/org/apache/pirk/schema/response/QueryResponseJSON.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.schema.response;
import java.io.Serializable;
@@ -25,15 +25,15 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
import org.apache.pirk.query.wideskies.QueryInfo;
import org.apache.pirk.schema.data.DataSchema;
import org.apache.pirk.schema.data.LoadDataSchemas;
import org.apache.pirk.schema.query.LoadQuerySchemas;
import org.apache.pirk.schema.query.QuerySchema;
-import org.apache.pirk.utils.LogUtils;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* JSON helper class for query results
@@ -44,13 +44,13 @@ public class QueryResponseJSON implements Serializable
{
private static final long serialVersionUID = 1L;
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(QueryResponseJSON.class);
- JSONObject jsonObj = null;
+ private JSONObject jsonObj = null;
- DataSchema dSchema = null;
+ private DataSchema dSchema = null;
- QueryInfo queryInfo = null;
+ private QueryInfo queryInfo = null;
public static final String EVENT_TYPE = "event_type"; // notification type the matched the record
public static final Text EVENT_TYPE_TEXT = new Text(EVENT_TYPE);
@@ -131,7 +131,7 @@ public class QueryResponseJSON implements Serializable
HashSet<String> schemaListRep = dSchema.getListRep();
for (String key : schemaListRep)
{
- jsonObj.put(key, new ArrayList<Object>());
+ jsonObj.put(key, new ArrayList<>());
}
}
@@ -152,10 +152,10 @@ public class QueryResponseJSON implements Serializable
{
if (!(val instanceof ArrayList))
{
- ArrayList<Object> list = null;
+ ArrayList<Object> list;
if (!jsonObj.containsKey(key))
{
- list = new ArrayList<Object>();
+ list = new ArrayList<>();
jsonObj.put(key, list);
}
list = (ArrayList<Object>) jsonObj.get(key);
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/test/distributed/DistributedTestCLI.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/test/distributed/DistributedTestCLI.java b/src/main/java/org/apache/pirk/test/distributed/DistributedTestCLI.java
index 977fa5e..1535e1f 100644
--- a/src/main/java/org/apache/pirk/test/distributed/DistributedTestCLI.java
+++ b/src/main/java/org/apache/pirk/test/distributed/DistributedTestCLI.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.test.distributed;
import org.apache.commons.cli.CommandLine;
@@ -24,18 +24,18 @@ import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-import org.apache.log4j.Logger;
-import org.apache.pirk.utils.LogUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A container for Apache's Command Line Interface that contains custom functionality for the MapReduce functional tests.
*/
public class DistributedTestCLI
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(DistributedTestCLI.class);
- CommandLine commandLine = null;
- Options cliOptions = null;
+ private CommandLine commandLine = null;
+ private Options cliOptions = null;
/**
* Create and parse allowable options
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/test/distributed/DistributedTestDriver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/test/distributed/DistributedTestDriver.java b/src/main/java/org/apache/pirk/test/distributed/DistributedTestDriver.java
index f567bab..d822e81 100755
--- a/src/main/java/org/apache/pirk/test/distributed/DistributedTestDriver.java
+++ b/src/main/java/org/apache/pirk/test/distributed/DistributedTestDriver.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,22 +15,22 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.test.distributed;
import java.util.ArrayList;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
-import org.apache.log4j.Logger;
import org.apache.pirk.schema.data.LoadDataSchemas;
import org.apache.pirk.schema.query.LoadQuerySchemas;
import org.apache.pirk.schema.query.filter.StopListFilter;
import org.apache.pirk.test.distributed.testsuite.DistTestSuite;
import org.apache.pirk.test.utils.Inputs;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.SystemConfiguration;
import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Driver class to run the suite of functional tests for MR and Spark PIR
@@ -38,7 +38,7 @@ import org.json.simple.JSONObject;
*/
public class DistributedTestDriver
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(DistributedTestDriver.class);
// Input
public static final String JSON_PIR_INPUT_FILE_PROPERTY = "test.pir.inputJSONFile";
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/test/distributed/testsuite/DistTestSuite.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/test/distributed/testsuite/DistTestSuite.java b/src/main/java/org/apache/pirk/test/distributed/testsuite/DistTestSuite.java
index dec00f9..37cb43c 100644
--- a/src/main/java/org/apache/pirk/test/distributed/testsuite/DistTestSuite.java
+++ b/src/main/java/org/apache/pirk/test/distributed/testsuite/DistTestSuite.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.test.distributed.testsuite;
import java.io.File;
@@ -24,7 +24,6 @@ import java.util.ArrayList;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.util.ToolRunner;
-import org.apache.log4j.Logger;
import org.apache.pirk.encryption.Paillier;
import org.apache.pirk.inputformat.hadoop.InputFormatConst;
import org.apache.pirk.inputformat.hadoop.json.JSONInputFormatBase;
@@ -41,10 +40,11 @@ import org.apache.pirk.test.distributed.DistributedTestDriver;
import org.apache.pirk.test.utils.BaseTests;
import org.apache.pirk.test.utils.Inputs;
import org.apache.pirk.test.utils.TestUtils;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.SystemConfiguration;
import org.apache.spark.launcher.SparkLauncher;
import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Distributed test class for PIR
@@ -52,7 +52,7 @@ import org.json.simple.JSONObject;
*/
public class DistTestSuite
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(DistTestSuite.class);
// This method also tests all non-query specific configuration options/properties
// for the MapReduce version of PIR
@@ -299,7 +299,7 @@ public class DistTestSuite
SystemConfiguration.setProperty("pir.numReduceTasks", "1");
SystemConfiguration.setProperty("pir.stopListFile", SystemConfiguration.getProperty(DistributedTestDriver.PIR_STOPLIST_FILE));
- ArrayList<QueryResponseJSON> results = null;
+ ArrayList<QueryResponseJSON> results;
// Create the temp result file
File fileFinalResults = File.createTempFile("finalResultsFile", ".txt");
@@ -361,7 +361,7 @@ public class DistTestSuite
// Build args
String inputFormat = SystemConfiguration.getProperty("pir.dataInputFormat");
logger.info("inputFormat = " + inputFormat);
- ArrayList<String> args = new ArrayList<String>();
+ ArrayList<String> args = new ArrayList<>();
args.add("-" + ResponderCLI.PLATFORM + "=spark");
args.add("-" + ResponderCLI.DATAINPUTFORMAT + "=" + inputFormat);
args.add("-" + ResponderCLI.QUERYINPUT + "=" + SystemConfiguration.getProperty("pir.queryInput"));
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/test/utils/BaseTests.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/test/utils/BaseTests.java b/src/main/java/org/apache/pirk/test/utils/BaseTests.java
index 621b64e..51497d6 100644
--- a/src/main/java/org/apache/pirk/test/utils/BaseTests.java
+++ b/src/main/java/org/apache/pirk/test/utils/BaseTests.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,41 +15,40 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.test.utils;
-import static org.junit.Assert.fail;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.hadoop.fs.FileSystem;
-import org.apache.log4j.Logger;
import org.apache.pirk.query.wideskies.QueryUtils;
import org.apache.pirk.schema.response.QueryResponseJSON;
import org.apache.pirk.test.distributed.testsuite.DistTestSuite;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.StringUtils;
import org.apache.pirk.utils.SystemConfiguration;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.fail;
/**
* Class to hold the base functional distributed tests
*/
public class BaseTests
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(BaseTests.class);
public static double queryNum = 1.0;
public static int dataPartitionBitSize = 8;
// Selectors for domain and IP queries, queryNum is the first entry for file generation
- public static ArrayList<String> selectorsDomain = new ArrayList<String>(Arrays.asList("s.t.u.net", "d.e.com", "r.r.r.r", "a.b.c.com", "something.else",
+ private static ArrayList<String> selectorsDomain = new ArrayList<>(Arrays.asList("s.t.u.net", "d.e.com", "r.r.r.r", "a.b.c.com", "something.else",
"x.y.net"));
- public static ArrayList<String> selectorsIP = new ArrayList<String>(Arrays.asList("55.55.55.55", "5.6.7.8", "10.20.30.40", "13.14.15.16", "21.22.23.24"));
+ private static ArrayList<String> selectorsIP = new ArrayList<>(Arrays.asList("55.55.55.55", "5.6.7.8", "10.20.30.40", "13.14.15.16", "21.22.23.24"));
// Encryption variables -- Paillier mechanisms are tested in the Paillier test code, so these are fixed...
public static int hashBitSize = 12;
@@ -75,7 +74,7 @@ public class BaseTests
logger.info("Running testDNSHostnameQuery(): ");
int numExpectedResults = 6;
- ArrayList<QueryResponseJSON> results = null;
+ ArrayList<QueryResponseJSON> results;
if (isDistributed)
{
results = DistTestSuite.performQuery(Inputs.DNS_HOSTNAME_QUERY, selectorsDomain, fs, isSpark, numThreads);
@@ -100,12 +99,12 @@ public class BaseTests
}
// Check that each qname appears once in the result set
- HashSet<String> correctQnames = new HashSet<String>();
+ HashSet<String> correctQnames = new HashSet<>();
correctQnames.add("a.b.c.com");
correctQnames.add("d.e.com");
correctQnames.add("something.else");
- HashSet<String> resultQnames = new HashSet<String>();
+ HashSet<String> resultQnames = new HashSet<>();
for (QueryResponseJSON qrJSON : results)
{
resultQnames.add((String) qrJSON.getValue(Inputs.QNAME));
@@ -138,7 +137,7 @@ public class BaseTests
removeTailElements = 3;
}
- ArrayList<QueryResponseJSON> correctResults = new ArrayList<QueryResponseJSON>();
+ ArrayList<QueryResponseJSON> correctResults = new ArrayList<>();
int i = 0;
while (i < (dataElements.size() - removeTailElements))
{
@@ -197,7 +196,7 @@ public class BaseTests
{
logger.info("Running testDNSIPQuery(): ");
- ArrayList<QueryResponseJSON> results = null;
+ ArrayList<QueryResponseJSON> results;
if (isDistributed)
{
results = DistTestSuite.performQuery(Inputs.DNS_IP_QUERY, selectorsIP, fs, isSpark, numThreads);
@@ -218,7 +217,7 @@ public class BaseTests
}
printResultList(results);
- ArrayList<QueryResponseJSON> correctResults = new ArrayList<QueryResponseJSON>();
+ ArrayList<QueryResponseJSON> correctResults = new ArrayList<>();
int i = 0;
while (i < (dataElements.size() - 3)) // last three data elements not hit - one on stoplist, two don't match selectors
{
@@ -270,7 +269,7 @@ public class BaseTests
{
logger.info("Running testDNSNXDOMAINQuery(): ");
- ArrayList<QueryResponseJSON> results = null;
+ ArrayList<QueryResponseJSON> results;
if (isDistributed)
{
results = DistTestSuite.performQuery(Inputs.DNS_NXDOMAIN_QUERY, selectorsDomain, fs, isSpark, numThreads);
@@ -286,7 +285,7 @@ public class BaseTests
fail("results.size() = " + results.size() + " -- must equal 1");
}
- ArrayList<QueryResponseJSON> correctResults = new ArrayList<QueryResponseJSON>();
+ ArrayList<QueryResponseJSON> correctResults = new ArrayList<>();
int i = 0;
while (i < dataElements.size())
{
@@ -332,7 +331,7 @@ public class BaseTests
{
logger.info("Running testSRCIPQuery(): ");
- ArrayList<QueryResponseJSON> results = null;
+ ArrayList<QueryResponseJSON> results;
int removeTailElements = 0;
int numExpectedResults = 1;
if (isDistributed)
@@ -352,7 +351,7 @@ public class BaseTests
fail("results.size() = " + results.size() + " -- must equal " + numExpectedResults);
}
- ArrayList<QueryResponseJSON> correctResults = new ArrayList<QueryResponseJSON>();
+ ArrayList<QueryResponseJSON> correctResults = new ArrayList<>();
int i = 0;
while (i < (dataElements.size() - removeTailElements))
{
@@ -404,7 +403,7 @@ public class BaseTests
{
logger.info("Running testSRCIPQueryNoFilter(): ");
- ArrayList<QueryResponseJSON> results = null;
+ ArrayList<QueryResponseJSON> results;
int numExpectedResults = 3;
if (isDistributed)
{
@@ -421,7 +420,7 @@ public class BaseTests
fail("results.size() = " + results.size() + " -- must equal " + numExpectedResults);
}
- ArrayList<QueryResponseJSON> correctResults = new ArrayList<QueryResponseJSON>();
+ ArrayList<QueryResponseJSON> correctResults = new ArrayList<>();
int i = 0;
while (i < dataElements.size())
{
@@ -471,9 +470,9 @@ public class BaseTests
// Method to convert a ArrayList<String> into the correct (padded) returned ArrayList
private static ArrayList<String> parseArray(JSONObject dataMap, String fieldName, boolean isIP)
{
- ArrayList<String> retArray = new ArrayList<String>();
+ ArrayList<String> retArray = new ArrayList<>();
- ArrayList<String> values = null;
+ ArrayList<String> values;
if (dataMap.get(fieldName) instanceof ArrayList)
{
values = (ArrayList<String>) dataMap.get(fieldName);
@@ -506,7 +505,7 @@ public class BaseTests
// Method to convert a ArrayList<Short> into the correct (padded) returned ArrayList
private static ArrayList<Short> parseShortArray(JSONObject dataMap, String fieldName)
{
- ArrayList<Short> retArray = new ArrayList<Short>();
+ ArrayList<Short> retArray = new ArrayList<>();
ArrayList<Short> values = (ArrayList<Short>) dataMap.get(fieldName);
@@ -529,7 +528,7 @@ public class BaseTests
// Method to convert the String field value to the correct returned substring
private static String parseString(JSONObject dataMap, String fieldName)
{
- String ret = null;
+ String ret;
String element = (String) dataMap.get(fieldName);
int numParts = Integer.parseInt(SystemConfiguration.getProperty("pir.stringBits")) / dataPartitionBitSize;
@@ -604,7 +603,7 @@ public class BaseTests
// Method to pull the elements of a list (either an ArrayList or JSONArray) into a HashSet
private static HashSet<String> getSetFromList(Object list)
{
- HashSet<String> set = new HashSet<String>();
+ HashSet<String> set = new HashSet<>();
if (list instanceof ArrayList)
{
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/test/utils/Inputs.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/test/utils/Inputs.java b/src/main/java/org/apache/pirk/test/utils/Inputs.java
index 1b362ef..5070672 100644
--- a/src/main/java/org/apache/pirk/test/utils/Inputs.java
+++ b/src/main/java/org/apache/pirk/test/utils/Inputs.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.test.utils;
import java.io.File;
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
@@ -34,7 +35,6 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.log4j.Logger;
import org.apache.pirk.schema.data.LoadDataSchemas;
import org.apache.pirk.schema.data.partitioner.IPDataPartitioner;
import org.apache.pirk.schema.data.partitioner.ISO8601DatePartitioner;
@@ -42,9 +42,10 @@ import org.apache.pirk.schema.data.partitioner.PrimitiveTypePartitioner;
import org.apache.pirk.schema.query.LoadQuerySchemas;
import org.apache.pirk.test.distributed.DistributedTestDriver;
import org.apache.pirk.utils.HDFS;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.SystemConfiguration;
import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -54,7 +55,7 @@ import org.w3c.dom.Element;
*/
public class Inputs
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(Inputs.class);
// Test data schema fields
public static final String DATE = "date";
@@ -126,16 +127,16 @@ public class Inputs
@SuppressWarnings("unchecked")
public static ArrayList<JSONObject> createJSONDataElements()
{
- ArrayList<JSONObject> dataElementsJSON = new ArrayList<JSONObject>();
+ ArrayList<JSONObject> dataElementsJSON = new ArrayList<>();
JSONObject jsonObj1 = new JSONObject();
jsonObj1.put(DATE, "2016-02-20T23:29:05.000Z");
jsonObj1.put(QNAME, "a.b.c.com"); // hits on domain selector
jsonObj1.put(SRCIP, "55.55.55.55"); // hits on IP selector
jsonObj1.put(DSTIP, "1.2.3.6");
- jsonObj1.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj1.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj1.put(RCODE, 0);
- jsonObj1.put(IPS, new ArrayList<String>(Arrays.asList("10.20.30.40", "10.20.30.60")));
+ jsonObj1.put(IPS, new ArrayList<>(Arrays.asList("10.20.30.40", "10.20.30.60")));
dataElementsJSON.add(jsonObj1);
@@ -144,9 +145,9 @@ public class Inputs
jsonObj2.put(QNAME, "d.e.com");
jsonObj2.put(SRCIP, "127.128.129.130");
jsonObj2.put(DSTIP, "1.2.3.4");
- jsonObj2.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj2.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj2.put(RCODE, 0);
- jsonObj2.put(IPS, new ArrayList<String>(Arrays.asList("5.6.7.8")));
+ jsonObj2.put(IPS, new ArrayList<>(Collections.singletonList("5.6.7.8")));
dataElementsJSON.add(jsonObj2);
@@ -155,9 +156,9 @@ public class Inputs
jsonObj3.put(QNAME, "d.e.com");
jsonObj3.put(SRCIP, "131.132.133.134");
jsonObj3.put(DSTIP, "9.10.11.12");
- jsonObj3.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj3.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj3.put(RCODE, 0);
- jsonObj3.put(IPS, new ArrayList<String>(Arrays.asList("13.14.15.16")));
+ jsonObj3.put(IPS, new ArrayList<>(Collections.singletonList("13.14.15.16")));
dataElementsJSON.add(jsonObj3);
@@ -166,9 +167,9 @@ public class Inputs
jsonObj4.put(QNAME, "d.e.com");
jsonObj4.put(SRCIP, "135.136.137.138");
jsonObj4.put(DSTIP, "17.18.19.20");
- jsonObj4.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj4.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj4.put(RCODE, 3);
- jsonObj4.put(IPS, new ArrayList<String>(Arrays.asList("21.22.23.24")));
+ jsonObj4.put(IPS, new ArrayList<>(Collections.singletonList("21.22.23.24")));
dataElementsJSON.add(jsonObj4);
@@ -177,9 +178,9 @@ public class Inputs
jsonObj5.put(QNAME, "d.e.com");
jsonObj5.put(SRCIP, "139.140.141.142");
jsonObj5.put(DSTIP, "25.26.27.28");
- jsonObj5.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj5.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj5.put(RCODE, 0);
- jsonObj5.put(IPS, new ArrayList<String>(Arrays.asList("5.6.7.8")));
+ jsonObj5.put(IPS, new ArrayList<>(Collections.singletonList("5.6.7.8")));
dataElementsJSON.add(jsonObj5);
@@ -188,9 +189,9 @@ public class Inputs
jsonObj6.put(QNAME, "d.e.com");
jsonObj6.put(SRCIP, "143.144.145.146");
jsonObj6.put(DSTIP, "33.34.35.36");
- jsonObj6.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj6.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj6.put(RCODE, 0);
- jsonObj6.put(IPS, new ArrayList<String>(Arrays.asList("5.6.7.8")));
+ jsonObj6.put(IPS, new ArrayList<>(Collections.singletonList("5.6.7.8")));
dataElementsJSON.add(jsonObj6);
@@ -199,9 +200,9 @@ public class Inputs
jsonObj7.put(QNAME, "something.else");
jsonObj7.put(SRCIP, "1.1.1.1");
jsonObj7.put(DSTIP, "2.2.2.2");
- jsonObj7.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj7.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj7.put(RCODE, 0);
- jsonObj7.put(IPS, new ArrayList<String>(Arrays.asList("3.3.3.3")));
+ jsonObj7.put(IPS, new ArrayList<>(Collections.singletonList("3.3.3.3")));
dataElementsJSON.add(jsonObj7);
@@ -212,9 +213,9 @@ public class Inputs
jsonObj8.put(QNAME, "something.else2");
jsonObj8.put(SRCIP, "5.6.7.8");
jsonObj8.put(DSTIP, "2.2.2.22");
- jsonObj8.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj8.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj8.put(RCODE, 0);
- jsonObj8.put(IPS, new ArrayList<String>(Arrays.asList("3.3.3.132")));
+ jsonObj8.put(IPS, new ArrayList<>(Collections.singletonList("3.3.3.132")));
dataElementsJSON.add(jsonObj8);
@@ -224,9 +225,9 @@ public class Inputs
jsonObj9.put(QNAME, "something.else.on.stoplist");
jsonObj9.put(SRCIP, "55.55.55.55");
jsonObj9.put(DSTIP, "2.2.2.232");
- jsonObj9.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj9.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj9.put(RCODE, 0);
- jsonObj9.put(IPS, new ArrayList<String>(Arrays.asList("3.3.3.132")));
+ jsonObj9.put(IPS, new ArrayList<>(Collections.singletonList("3.3.3.132")));
dataElementsJSON.add(jsonObj9);
@@ -239,16 +240,16 @@ public class Inputs
@SuppressWarnings("unchecked")
public static ArrayList<JSONObject> getRcode3JSONDataElements()
{
- ArrayList<JSONObject> dataElementsJSON = new ArrayList<JSONObject>();
+ ArrayList<JSONObject> dataElementsJSON = new ArrayList<>();
JSONObject jsonObj4 = new JSONObject();
jsonObj4.put(DATE, "2016-02-20T23:29:08.000Z");
jsonObj4.put(QNAME, "d.e.com");
jsonObj4.put(SRCIP, "135.136.137.138");
jsonObj4.put(DSTIP, "17.18.19.20");
- jsonObj4.put(QTYPE, new ArrayList<Short>(Arrays.asList((short) 1)));
+ jsonObj4.put(QTYPE, new ArrayList<>(Collections.singletonList((short) 1)));
jsonObj4.put(RCODE, 3);
- jsonObj4.put(IPS, new ArrayList<String>(Arrays.asList("21.22.23.24")));
+ jsonObj4.put(IPS, new ArrayList<>(Collections.singletonList("21.22.23.24")));
dataElementsJSON.add(jsonObj4);
@@ -393,9 +394,9 @@ public class Inputs
{
logger.info("PIR stopList file being created");
- String tmpFileName = null;
+ String tmpFileName;
- ArrayList<String> elements = new ArrayList<String>();
+ ArrayList<String> elements = new ArrayList<>();
elements.add("something.else.on.stoplist");
elements.add("3.3.3.132");
@@ -441,7 +442,7 @@ public class Inputs
// Create and load the query schemas
// DNS_HOSTNAME_QUERY
List<String> dnsHostnameQueryElements = Arrays.asList(DATE, SRCIP, DSTIP, QTYPE, RCODE, IPS);
- List<String> dnsHostnameQueryFilterElements = Arrays.asList(QNAME);
+ List<String> dnsHostnameQueryFilterElements = Collections.singletonList(QNAME);
TestUtils.createQuerySchema(DNS_HOSTNAME_QUERY_FILE, DNS_HOSTNAME_QUERY, TEST_DATA_SCHEMA_NAME, QNAME, dnsHostnameQueryElements,
dnsHostnameQueryFilterElements, filter);
@@ -453,7 +454,7 @@ public class Inputs
// DNS_IP_QUERY
List<String> dnsIPQueryElements = Arrays.asList(SRCIP, DSTIP, IPS);
- List<String> dnsIPQueryFilterElements = Arrays.asList(QNAME);
+ List<String> dnsIPQueryFilterElements = Collections.singletonList(QNAME);
TestUtils.createQuerySchema(DNS_IP_QUERY_FILE, DNS_IP_QUERY, TEST_DATA_SCHEMA_NAME, IPS, dnsIPQueryElements, dnsIPQueryFilterElements, filter);
if (hdfs)
@@ -464,7 +465,7 @@ public class Inputs
// DNS_NXDOMAIN_QUERY
List<String> dnsNXQueryElements = Arrays.asList(QNAME, SRCIP, DSTIP);
- List<String> dnsNXQueryFilterElements = Arrays.asList(QNAME);
+ List<String> dnsNXQueryFilterElements = Collections.singletonList(QNAME);
TestUtils
.createQuerySchema(DNS_NXDOMAIN_QUERY_FILE, DNS_NXDOMAIN_QUERY, TEST_DATA_SCHEMA_NAME, QNAME, dnsNXQueryElements, dnsNXQueryFilterElements, filter);
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/test/utils/StandaloneQuery.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/test/utils/StandaloneQuery.java b/src/main/java/org/apache/pirk/test/utils/StandaloneQuery.java
index 027e042..aeda7dc 100644
--- a/src/main/java/org/apache/pirk/test/utils/StandaloneQuery.java
+++ b/src/main/java/org/apache/pirk/test/utils/StandaloneQuery.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,17 +15,14 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.test.utils;
-import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import org.apache.log4j.Logger;
import org.apache.pirk.encryption.Paillier;
import org.apache.pirk.querier.wideskies.Querier;
import org.apache.pirk.querier.wideskies.QuerierConst;
@@ -37,25 +34,23 @@ import org.apache.pirk.query.wideskies.QueryUtils;
import org.apache.pirk.responder.wideskies.standalone.Responder;
import org.apache.pirk.response.wideskies.Response;
import org.apache.pirk.schema.response.QueryResponseJSON;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.PIRException;
import org.apache.pirk.utils.SystemConfiguration;
import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.fail;
public class StandaloneQuery
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(StandaloneQuery.class);
static String queryFileDomain = "qfDomain";
static String queryFileIP = "qfIP";
- static String querySideOuputFilePrefix = "querySideOut"; // the file pre-fix for the query side output files
- static String finalResultsFile = "finalResultFile"; // file to hold the final results
String testDataSchemaName = "testDataSchema";
String testQuerySchemaName = "testQuerySchema";
- static String responseFile = "encryptedResponse"; // the PIR response file from the responder
-
// Base method to perform the query
public static ArrayList<QueryResponseJSON> performStandaloneQuery(ArrayList<JSONObject> dataElements, String queryType, ArrayList<String> selectors,
int numThreads, boolean testFalsePositive) throws IOException, InterruptedException, PIRException
@@ -65,9 +60,12 @@ public class StandaloneQuery
ArrayList<QueryResponseJSON> results = null;
// Create the necessary files
+ String querySideOuputFilePrefix = "querySideOut";
File fileQuerier = File.createTempFile(querySideOuputFilePrefix + "-" + QuerierConst.QUERIER_FILETAG, ".txt");
File fileQuery = File.createTempFile(querySideOuputFilePrefix + "-" + QuerierConst.QUERY_FILETAG, ".txt");
+ String responseFile = "encryptedResponse";
File fileResponse = File.createTempFile(responseFile, ".txt");
+ String finalResultsFile = "finalResultFile";
File fileFinalResults = File.createTempFile(finalResultsFile, ".txt");
logger.info("fileQuerier = " + fileQuerier.getAbsolutePath() + " fileQuery = " + fileQuery.getAbsolutePath() + " responseFile = "
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/test/utils/TestUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/test/utils/TestUtils.java b/src/main/java/org/apache/pirk/test/utils/TestUtils.java
index 11348cb..57af5c4 100644
--- a/src/main/java/org/apache/pirk/test/utils/TestUtils.java
+++ b/src/main/java/org/apache/pirk/test/utils/TestUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.test.utils;
import java.io.BufferedReader;
@@ -38,10 +38,10 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.log4j.Logger;
import org.apache.pirk.schema.response.QueryResponseJSON;
-import org.apache.pirk.utils.LogUtils;
import org.apache.pirk.utils.SystemConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -51,7 +51,7 @@ import org.w3c.dom.Element;
*/
public class TestUtils
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(TestUtils.class);
/**
* Method to delete an ES index
@@ -81,7 +81,7 @@ public class TestUtils
// Read the output from the command
logger.info("Standard output of the command:\n");
- String s = null;
+ String s;
while ((s = stdInput.readLine()) != null)
{
logger.info(s);
@@ -142,7 +142,7 @@ public class TestUtils
logger.info("createQuerySchema: querySchemaName = " + querySchemaName);
// Create a temporary file for the test schema, set in the properties
- String fileName = null;
+ String fileName;
File file = null;
OutputStreamWriter osw = null;
if (hdfs)
@@ -237,7 +237,7 @@ public class TestUtils
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
- StreamResult result = null;
+ StreamResult result;
if (hdfs)
{
result = new StreamResult(osw);
@@ -269,7 +269,7 @@ public class TestUtils
*/
public static ArrayList<QueryResponseJSON> readResultsFile(File file)
{
- ArrayList<QueryResponseJSON> results = new ArrayList<QueryResponseJSON>();
+ ArrayList<QueryResponseJSON> results = new ArrayList<>();
try
{
FileReader fr = new FileReader(file);
@@ -295,7 +295,7 @@ public class TestUtils
*/
public static String writeToTmpFile(ArrayList<String> list, String fileName, String suffix) throws IOException
{
- String filename = null;
+ String filename;
File file = File.createTempFile(fileName, suffix);
file.deleteOnExit();
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/CSVOutputUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/CSVOutputUtils.java b/src/main/java/org/apache/pirk/utils/CSVOutputUtils.java
index ebb1f21..311fe87 100644
--- a/src/main/java/org/apache/pirk/utils/CSVOutputUtils.java
+++ b/src/main/java/org/apache/pirk/utils/CSVOutputUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,11 +15,12 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Utils class for CSV value output
@@ -31,7 +32,7 @@ public class CSVOutputUtils
{
public static String EMPTYFIELD = "";
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(CSVOutputUtils.class);
public static Text setCSVOutput(String domain, String ip, String timestamp)
{
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/EpochDateParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/EpochDateParser.java b/src/main/java/org/apache/pirk/utils/EpochDateParser.java
index 388726f..870128c 100644
--- a/src/main/java/org/apache/pirk/utils/EpochDateParser.java
+++ b/src/main/java/org/apache/pirk/utils/EpochDateParser.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,10 +15,11 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to parse dates in Epoch date format
@@ -26,7 +27,7 @@ import org.apache.log4j.Logger;
public class EpochDateParser
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(EpochDateParser.class);
public static boolean isEpochDateFormat(String date)
{
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/FileConst.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/FileConst.java b/src/main/java/org/apache/pirk/utils/FileConst.java
index 83e43d8..382b97d 100644
--- a/src/main/java/org/apache/pirk/utils/FileConst.java
+++ b/src/main/java/org/apache/pirk/utils/FileConst.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
/**
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/FileIOUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/FileIOUtils.java b/src/main/java/org/apache/pirk/utils/FileIOUtils.java
index 52bde2e..17b97ec 100644
--- a/src/main/java/org/apache/pirk/utils/FileIOUtils.java
+++ b/src/main/java/org/apache/pirk/utils/FileIOUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import java.io.BufferedReader;
@@ -29,14 +29,15 @@ import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.HashSet;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class holding basic fileIO utils
*/
public class FileIOUtils
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(FileIOUtils.class);
public interface Callable<V>
{
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/HDFS.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/HDFS.java b/src/main/java/org/apache/pirk/utils/HDFS.java
index 8f3992e..32e0c05 100644
--- a/src/main/java/org/apache/pirk/utils/HDFS.java
+++ b/src/main/java/org/apache/pirk/utils/HDFS.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import java.io.BufferedReader;
@@ -33,15 +33,16 @@ import java.util.Map;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.log4j.Logger;
import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class for basic HDFS fileIO utils
*/
public class HDFS
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(HDFS.class);
public static void writeFile(Collection<String> elements, FileSystem fs, String path, boolean deleteOnExit)
{
@@ -190,7 +191,7 @@ public class HDFS
public static HashSet<String> readFileHashSet(FileSystem fs, Path path)
{
- HashSet<String> rv = new HashSet<String>();
+ HashSet<String> rv = new HashSet<>();
try
{
InputStreamReader isr = new InputStreamReader(fs.open(path));
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/ISO8601DateParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/ISO8601DateParser.java b/src/main/java/org/apache/pirk/utils/ISO8601DateParser.java
index 0826322..675fb21 100755
--- a/src/main/java/org/apache/pirk/utils/ISO8601DateParser.java
+++ b/src/main/java/org/apache/pirk/utils/ISO8601DateParser.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import java.text.ParseException;
@@ -23,7 +23,8 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to parse a date in ISO86091 format
@@ -31,7 +32,7 @@ import org.apache.log4j.Logger;
*/
public class ISO8601DateParser
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(ISO8601DateParser.class);
static
{
@@ -51,7 +52,7 @@ public class ISO8601DateParser
try
{
return format.parse(date).getTime() + "";
- } catch (Exception e)
+ } catch (Exception ignore)
{}
return null;
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/KeyedHash.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/KeyedHash.java b/src/main/java/org/apache/pirk/utils/KeyedHash.java
index 481108e..579b196 100644
--- a/src/main/java/org/apache/pirk/utils/KeyedHash.java
+++ b/src/main/java/org/apache/pirk/utils/KeyedHash.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,13 +15,14 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class for the PIR keyed hash
@@ -31,7 +32,7 @@ import org.apache.log4j.Logger;
*/
public class KeyedHash
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(KeyedHash.class);
/**
* Hash method that uses the java String hashCode()
@@ -58,9 +59,9 @@ public class KeyedHash
*/
public static int hash(String key, int bitSize, String input, String hashType)
{
- int bitLimitedHash = 0;
+ int bitLimitedHash;
- MessageDigest md = null;
+ MessageDigest md;
try
{
md = MessageDigest.getInstance(hashType);
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/LogUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/LogUtils.java b/src/main/java/org/apache/pirk/utils/LogUtils.java
deleted file mode 100755
index d10d43b..0000000
--- a/src/main/java/org/apache/pirk/utils/LogUtils.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *******************************************************************************/
-package org.apache.pirk.utils;
-
-import java.io.InputStream;
-import java.util.Properties;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-
-/**
- * Class for basic logging utils
- */
-public class LogUtils
-{
- public static Logger logger;
-
- static
- {
- initialize();
- }
-
- public static void initialize()
- {
- Properties props = new Properties();
- try
- {
- String log4jFilename = SystemConfiguration.getProperty("log4jPropertiesFile");
- if (log4jFilename == null)
- {
- System.err.println("log4jPropertiesFile property not found during LogUtils initialization.");
- }
- else
- {
- InputStream stream = SystemConfiguration.class.getClassLoader().getResourceAsStream(log4jFilename);
- if (stream != null)
- {
- System.out.println("Loading log4j properties file: '" + log4jFilename + "'");
- props.load(stream);
- PropertyConfigurator.configure(props);
- stream.close();
- }
- else
- {
- System.err.println("log4j properties file not found: '" + log4jFilename + "'");
- }
- }
- } catch (Exception e)
- {
- System.err.println("Exception occured configuring the log4j system: " + e.toString());
- e.printStackTrace();
- }
- }
-
- /**
- * Should be called at the from from each class using log4j. Example: static private Logger logger = LogUtils.getLoggerForThisClass();
- *
- * @return
- */
- public static Logger getLoggerForThisClass()
- {
- // We use the third stack element; second is this method, first is
- // .getStackTrace()
- StackTraceElement myCaller = Thread.currentThread().getStackTrace()[2];
- return Logger.getLogger(myCaller.getClassName());
- }
-
- /**
- * Returns the name of the class calling this method.
- *
- */
- public static String getNameForThisClass()
- {
- // We use the third stack element; second is this method, first is
- // .getStackTrace()
- StackTraceElement myCaller = Thread.currentThread().getStackTrace()[2];
- return myCaller.getClassName();
- }
-
- public static String entering()
- {
- StackTraceElement myCaller = Thread.currentThread().getStackTrace()[2];
- String methodName = myCaller.getMethodName();
- return entering(methodName);
- }
-
- public static String exiting()
- {
- StackTraceElement myCaller = Thread.currentThread().getStackTrace()[2];
- String methodName = myCaller.getMethodName();
- return exiting(methodName);
- }
-
- public static String entering(String methodName)
- {
- return String.format("Entering %s", methodName);
- }
-
- public static String exiting(String methodName)
- {
- return String.format("Exiting %s", methodName);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/PIRException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/PIRException.java b/src/main/java/org/apache/pirk/utils/PIRException.java
index 9010c0f..7ec9c8b 100644
--- a/src/main/java/org/apache/pirk/utils/PIRException.java
+++ b/src/main/java/org/apache/pirk/utils/PIRException.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
/**
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/QueryParserUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/QueryParserUtils.java b/src/main/java/org/apache/pirk/utils/QueryParserUtils.java
index 5bc9794..afef6c9 100644
--- a/src/main/java/org/apache/pirk/utils/QueryParserUtils.java
+++ b/src/main/java/org/apache/pirk/utils/QueryParserUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,21 +15,23 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import java.text.ParseException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.hadoop.io.MapWritable;
import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
import org.apache.pirk.inputformat.hadoop.TextArrayWritable;
import org.apache.pirk.schema.data.DataSchema;
import org.apache.pirk.schema.data.partitioner.IPDataPartitioner;
import org.elasticsearch.hadoop.mr.WritableArrayWritable;
+import org.slf4j.LoggerFactory;
/**
* Class used for URI query parsing
@@ -41,7 +43,7 @@ import org.elasticsearch.hadoop.mr.WritableArrayWritable;
*/
public class QueryParserUtils
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(QueryParserUtils.class);
/**
* Given a URI query string, checks to see if the given document satisfies the query
@@ -73,7 +75,7 @@ public class QueryParserUtils
String[] queryTokens = uriQuery.split("\\+(?=AND)|\\+(?=OR)|\\+(?=[a-z])"); // booleans of the form +AND+, +OR+, don't split on +T0+
int index = 0;
- String item = null;
+ String item;
while (index < queryTokens.length)
{
boolean ignoreCase = false;
@@ -227,7 +229,7 @@ public class QueryParserUtils
{
if (queryTokens[index].equals("AND")) // Do nothing and keep going
{
- if (satisfiesQuery == false)
+ if (!satisfiesQuery)
{
break;
}
@@ -247,7 +249,7 @@ public class QueryParserUtils
satisfiesQuery = true; // reset so that we pick up matches for the next term
}
}
- else if (satisfiesQuery == false)
+ else if (!satisfiesQuery)
{
logger.debug("Does not satisfy the query and no boolean ops next...");
break;
@@ -274,7 +276,7 @@ public class QueryParserUtils
String[] queryTokens = uriQuery.split("\\+(?=AND)|\\+(?=OR)|\\+(?=[a-z])"); // booleans of the form +AND+, +OR+, don't split on +T0+
int index = 0;
- String item = null;
+ String item;
while (index < queryTokens.length)
{
item = queryTokens[index];
@@ -374,12 +376,12 @@ public class QueryParserUtils
logger.debug("itemTokens[1] = " + itemTokens[1] + " contains wildcard");
if (!Pattern.matches(wildcardToRegex(itemTokens[1]), (String) value))
{
- logger.debug("stringValue = " + (String) value + " did not satisfy itemTokens[1] = " + itemTokens[1]);
+ logger.debug("stringValue = " + value + " did not satisfy itemTokens[1] = " + itemTokens[1]);
satisfiesQuery = false;
}
- logger.debug("stringValue = " + (String) value + " did satisfy itemTokens[1] = " + itemTokens[1]);
+ logger.debug("stringValue = " + value + " did satisfy itemTokens[1] = " + itemTokens[1]);
}
- else if (!((String) value).equals(itemTokens[1])) // Single value match
+ else if (!(value).equals(itemTokens[1])) // Single value match
{
logger.debug("We do not have a single value match: stringValue " + (String) value + " != itemTokens[1] = " + itemTokens[1]);
satisfiesQuery = false;
@@ -427,7 +429,7 @@ public class QueryParserUtils
{
if (queryTokens[index].equals("AND")) // Do nothing and keep going
{
- if (satisfiesQuery == false)
+ if (!satisfiesQuery)
{
break;
}
@@ -447,7 +449,7 @@ public class QueryParserUtils
satisfiesQuery = true; // reset so that we pick up matches for the next term
}
}
- else if (satisfiesQuery == false)
+ else if (!satisfiesQuery)
{
logger.debug("Does not satisfy the query and no boolean ops next...");
break;
@@ -474,7 +476,7 @@ public class QueryParserUtils
String[] queryTokens = uriQuery.split("\\+(?=AND)|\\+(?=OR)|\\+(?=[a-z])"); // booleans of the form +AND+, +OR+, don't split on +T0+
int index = 0;
- String item = null;
+ String item;
while (index < queryTokens.length)
{
boolean ignoreCase = false;
@@ -628,7 +630,7 @@ public class QueryParserUtils
{
if (queryTokens[index].equals("AND")) // Do nothing and keep going
{
- if (satisfiesQuery == false)
+ if (!satisfiesQuery)
{
break;
}
@@ -648,7 +650,7 @@ public class QueryParserUtils
satisfiesQuery = true; // reset so that we pick up matches for the next term
}
}
- else if (satisfiesQuery == false)
+ else if (!satisfiesQuery)
{
logger.debug("Does not satisfy the query and no boolean ops next...");
break;
@@ -690,7 +692,7 @@ public class QueryParserUtils
String[] ranges = query.split("\\+TO\\+");
logger.info("ranges[0] = " + ranges[0] + " ranges[1] = " + ranges[1]);
- if ((inclusive == false) && (value.equals(ranges[0]) || value.equals(ranges[1])))
+ if ((!inclusive) && (value.equals(ranges[0]) || value.equals(ranges[1])))
{
logger.debug("inclusive = false and either value.equals(ranges[0]) or value.equals(ranges[1])");
matches = false;
@@ -769,10 +771,10 @@ public class QueryParserUtils
toMilli = Integer.parseInt(toDateArr[1]);
} catch (Exception e)
{
- logger.info(e.getStackTrace().toString());
+ logger.info(Arrays.toString(e.getStackTrace()));
}
- if ((inclusive == false) && (fromDate == valueDate || toDate == valueDate))
+ if ((!inclusive) && (fromDate == valueDate || toDate == valueDate))
{
logger.debug("(inclusive == false) && (fromDate == valueDate || toDate == valueDate))");
matches = false;
@@ -800,7 +802,7 @@ public class QueryParserUtils
{
e.printStackTrace();
}
- if ((inclusive == false) && (lower == valueDate || upper == valueDate))
+ if ((!inclusive) && (lower == valueDate || upper == valueDate))
{
logger.debug("(inclusive == false) && (lower == valueDate || upper == valueDate))");
matches = false;
@@ -830,7 +832,7 @@ public class QueryParserUtils
int valueInt = Integer.parseInt(value);
logger.debug("valueInt = " + valueInt + " lower = " + lower + " upper = " + upper);
- if ((inclusive == false) && (lower == valueInt || upper == valueInt))
+ if ((!inclusive) && (lower == valueInt || upper == valueInt))
{
logger.debug("(inclusive == false) && (lower == valueInt || upper == valueInt))");
matches = false;
@@ -855,7 +857,7 @@ public class QueryParserUtils
*/
public static String wildcardToRegex(String wildcard)
{
- StringBuffer s = new StringBuffer(wildcard.length());
+ StringBuilder s = new StringBuilder(wildcard.length());
for (int i = 0, is = wildcard.length(); i < is; i++)
{
char c = wildcard.charAt(i);
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/StopListUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/StopListUtils.java b/src/main/java/org/apache/pirk/utils/StopListUtils.java
index 2019fe1..285179e 100644
--- a/src/main/java/org/apache/pirk/utils/StopListUtils.java
+++ b/src/main/java/org/apache/pirk/utils/StopListUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import java.util.HashSet;
http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/ef8d1c1a/src/main/java/org/apache/pirk/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/pirk/utils/StringUtils.java b/src/main/java/org/apache/pirk/utils/StringUtils.java
index 9ac0279..be8ea09 100755
--- a/src/main/java/org/apache/pirk/utils/StringUtils.java
+++ b/src/main/java/org/apache/pirk/utils/StringUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.pirk.utils;
import java.util.ArrayList;
@@ -27,12 +27,13 @@ import org.apache.hadoop.io.ArrayWritable;
import org.apache.hadoop.io.MapWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
import org.apache.pirk.schema.data.DataSchema;
import org.elasticsearch.hadoop.mr.WritableArrayWritable;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
+import org.slf4j.LoggerFactory;
/**
* Pirk-specific string utilities
@@ -40,7 +41,7 @@ import org.json.simple.parser.ParseException;
*/
public class StringUtils
{
- private static Logger logger = LogUtils.getLoggerForThisClass();
+ private static final Logger logger = LoggerFactory.getLogger(StringUtils.class);
/**
* Method to convert a MapWritable into a JSON string
@@ -176,7 +177,7 @@ public class StringUtils
*/
public static Map<String,Object> jsonStringToMap(String jsonString, DataSchema dataSchema)
{
- Map<String,Object> value = new HashMap<String,Object>();
+ Map<String,Object> value = new HashMap<>();
JSONParser jsonParser = new JSONParser();
try
@@ -255,7 +256,7 @@ public class StringUtils
modString = modString.replaceAll("\"", "");
String[] elements = modString.split("\\s*,\\s*");
- return new ArrayList<String>(Arrays.asList(elements));
+ return new ArrayList<>(Arrays.asList(elements));
}
/**
@@ -266,8 +267,6 @@ public class StringUtils
String modString = jsonString.replaceFirst("\\[", "");
modString = modString.replaceFirst("\\]", "");
modString = modString.replaceAll("\"", "");
- String[] elements = modString.split("\\s*,\\s*");
-
- return elements;
+ return modString.split("\\s*,\\s*");
}
}