You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2015/01/09 03:44:35 UTC
[31/66] [abbrv] accumulo git commit: ACCUMULO-3451 Format master
branch (1.7.0-SNAPSHOT)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/ColumnFQ.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ColumnFQ.java b/core/src/main/java/org/apache/accumulo/core/util/ColumnFQ.java
index 8826bb1..11d97e5 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ColumnFQ.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ColumnFQ.java
@@ -27,48 +27,48 @@ import org.apache.hadoop.io.Text;
public class ColumnFQ implements Comparable<ColumnFQ> {
private Text colf;
private Text colq;
-
+
public ColumnFQ(Text colf, Text colq) {
if (colf == null || colq == null) {
throw new IllegalArgumentException();
}
-
+
this.colf = colf;
this.colq = colq;
}
-
+
public ColumnFQ(Key k) {
this(k.getColumnFamily(), k.getColumnQualifier());
}
-
+
public ColumnFQ(ColumnUpdate cu) {
this(new Text(cu.getColumnFamily()), new Text(cu.getColumnQualifier()));
}
-
+
public Text getColumnQualifier() {
return colq;
}
-
+
public Text getColumnFamily() {
return colf;
}
-
+
public Column toColumn() {
return new Column(TextUtil.getBytes(colf), TextUtil.getBytes(colq), null);
}
-
+
public void fetch(ScannerBase sb) {
sb.fetchColumn(colf, colq);
}
-
+
public void put(Mutation m, Value v) {
m.put(colf, colq, v);
}
-
+
public void putDelete(Mutation m) {
m.putDelete(colf, colq);
}
-
+
@Override
public boolean equals(Object o) {
if (!(o instanceof ColumnFQ))
@@ -78,33 +78,33 @@ public class ColumnFQ implements Comparable<ColumnFQ> {
ColumnFQ ocfq = (ColumnFQ) o;
return ocfq.colf.equals(colf) && ocfq.colq.equals(colq);
}
-
+
@Override
public int hashCode() {
return colf.hashCode() + colq.hashCode();
}
-
+
public boolean hasColumns(Key key) {
return key.compareColumnFamily(colf) == 0 && key.compareColumnQualifier(colq) == 0;
}
-
+
public boolean equals(Text colf, Text colq) {
return this.colf.equals(colf) && this.colq.equals(colq);
}
-
+
@Override
public int compareTo(ColumnFQ o) {
int cmp = colf.compareTo(o.colf);
-
+
if (cmp == 0)
cmp = colq.compareTo(o.colq);
-
+
return cmp;
}
-
+
@Override
public String toString() {
return colf + ":" + colq;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/ComparablePair.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ComparablePair.java b/core/src/main/java/org/apache/accumulo/core/util/ComparablePair.java
index 2fc38b6..6663032 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ComparablePair.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ComparablePair.java
@@ -17,22 +17,22 @@
package org.apache.accumulo.core.util;
/**
- *
+ *
*/
public class ComparablePair<A extends Comparable<A>,B extends Comparable<B>> extends Pair<A,B> implements Comparable<ComparablePair<A,B>> {
-
+
public ComparablePair(A f, B s) {
super(f, s);
}
-
+
@Override
public int compareTo(ComparablePair<A,B> abPair) {
int cmp = first.compareTo(abPair.first);
if (cmp == 0) {
cmp = second.compareTo(abPair.second);
}
-
+
return cmp;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java b/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
index cfac8fe..79b241c 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
+
import jline.console.ConsoleReader;
import org.apache.accumulo.core.cli.ClientOpts.Password;
@@ -32,53 +33,52 @@ import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Authe
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.TokenProperty;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.util.Base64;
import com.beust.jcommander.Parameter;
public class CreateToken {
-
+
private static ConsoleReader reader = null;
-
+
private static ConsoleReader getConsoleReader() throws IOException {
if (reader == null)
reader = new ConsoleReader();
return reader;
}
-
+
static class Opts extends Help {
@Parameter(names = {"-u", "--user"}, description = "Connection user")
public String principal = null;
-
+
@Parameter(names = "-p", converter = PasswordConverter.class, description = "Connection password")
public Password password = null;
-
+
@Parameter(names = "--password", converter = PasswordConverter.class, description = "Enter the connection password", password = true)
public Password securePassword = null;
-
+
@Parameter(names = {"-tc", "--tokenClass"}, description = "The class of the authentication token")
public String tokenClassName = PasswordToken.class.getName();
-
+
@Parameter(names = {"-f", "--file"}, description = "The filename to save the auth token to. Multiple tokens can be stored in the same file,"
+ " but only the first for each user will be recognized.")
public String tokenFile = null;
}
-
+
public static void main(String[] args) {
Opts opts = new Opts();
opts.parseArgs(CreateToken.class.getName(), args);
-
+
Password pass = opts.password;
if (pass == null && opts.securePassword != null) {
pass = opts.securePassword;
}
-
+
try {
String principal = opts.principal;
if (principal == null) {
principal = getConsoleReader().readLine("Username (aka principal): ");
}
-
+
AuthenticationToken token = Class.forName(opts.tokenClassName).asSubclass(AuthenticationToken.class).newInstance();
Properties props = new Properties();
for (TokenProperty tp : token.getProperties()) {
@@ -96,7 +96,7 @@ public class CreateToken {
token.init(props);
}
String tokenBase64 = Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(token));
-
+
String tokenFile = opts.tokenFile;
if (tokenFile == null) {
tokenFile = getConsoleReader().readLine("File to save auth token to: ");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/Daemon.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Daemon.java b/core/src/main/java/org/apache/accumulo/core/util/Daemon.java
index 7ce46eb..a2c9e79 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Daemon.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Daemon.java
@@ -17,44 +17,44 @@
package org.apache.accumulo.core.util;
public class Daemon extends Thread {
-
+
public Daemon() {
setDaemon(true);
}
-
+
public Daemon(Runnable target) {
super(target);
setDaemon(true);
}
-
+
public Daemon(String name) {
super(name);
setDaemon(true);
}
-
+
public Daemon(ThreadGroup group, Runnable target) {
super(group, target);
setDaemon(true);
}
-
+
public Daemon(ThreadGroup group, String name) {
super(group, name);
setDaemon(true);
}
-
+
public Daemon(Runnable target, String name) {
super(target, name);
setDaemon(true);
}
-
+
public Daemon(ThreadGroup group, Runnable target, String name) {
super(group, target, name);
setDaemon(true);
}
-
+
public Daemon(ThreadGroup group, Runnable target, String name, long stackSize) {
super(group, target, name, stackSize);
setDaemon(true);
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/Duration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Duration.java b/core/src/main/java/org/apache/accumulo/core/util/Duration.java
index 91ae089..b1b8572 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Duration.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Duration.java
@@ -17,15 +17,15 @@
package org.apache.accumulo.core.util;
public class Duration {
-
+
public static String format(long time) {
return format(time, " ");
}
-
+
public static String format(long time, String space) {
return format(time, space, "—");
}
-
+
public static String format(long time, String space, String zero) {
long ms, sec, min, hr, day, yr;
ms = sec = min = hr = day = yr = -1;
@@ -53,7 +53,7 @@ public class Duration {
return String.format("%dd" + space + "%dh", day, hr);
yr = time;
return String.format("%dy" + space + "%dd", yr, day);
-
+
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Encoding.java b/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
index 259f783..524f377 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
@@ -18,27 +18,26 @@ package org.apache.accumulo.core.util;
import static java.nio.charset.StandardCharsets.UTF_8;
-import org.apache.accumulo.core.util.Base64;
import org.apache.hadoop.io.Text;
public class Encoding {
-
+
public static String encodeAsBase64FileName(Text data) {
String encodedRow = Base64.encodeBase64URLSafeString(TextUtil.getBytes(data));
-
+
int index = encodedRow.length() - 1;
while (index >= 0 && encodedRow.charAt(index) == '=')
index--;
-
+
encodedRow = encodedRow.substring(0, index + 1);
return encodedRow;
}
-
+
public static byte[] decodeBase64FileName(String node) {
while (node.length() % 4 != 0)
node += "=";
/* decode transparently handles URLSafe encodings */
return Base64.decodeBase64(node.getBytes(UTF_8));
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java b/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
index e103ac6..8d76f27 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
@@ -26,28 +26,28 @@ public class FastFormat {
throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, UTF_8));
return ret;
}
-
+
public static int toZeroPaddedString(byte output[], int outputOffset, long num, int width, int radix, byte[] prefix) {
if (num < 0)
throw new IllegalArgumentException();
-
+
String s = Long.toString(num, radix);
-
+
int index = outputOffset;
-
+
for (int i = 0; i < prefix.length; i++) {
output[index++] = prefix[i];
}
-
+
int end = width - s.length() + index;
-
+
while (index < end)
output[index++] = '0';
-
+
for (int i = 0; i < s.length(); i++) {
output[index++] = (byte) s.charAt(i);
}
-
+
return index - outputOffset;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java b/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
index 9696025..d590ecd 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/LocalityGroupUtil.java
@@ -43,11 +43,11 @@ import org.apache.hadoop.io.Text;
import com.google.common.base.Joiner;
public class LocalityGroupUtil {
-
+
// private static final Logger log = Logger.getLogger(ColumnFamilySet.class);
-
+
public static final Set<ByteSequence> EMPTY_CF_SET = Collections.emptySet();
-
+
public static Set<ByteSequence> families(Collection<Column> columns) {
Set<ByteSequence> result = new HashSet<ByteSequence>(columns.size());
for (Column col : columns) {
@@ -55,14 +55,14 @@ public class LocalityGroupUtil {
}
return result;
}
-
+
@SuppressWarnings("serial")
static public class LocalityGroupConfigurationError extends AccumuloException {
LocalityGroupConfigurationError(String why) {
super(why);
}
}
-
+
public static Map<String,Set<ByteSequence>> getLocalityGroups(AccumuloConfiguration acuconf) throws LocalityGroupConfigurationError {
Map<String,Set<ByteSequence>> result = new HashMap<String,Set<ByteSequence>>();
String[] groups = acuconf.get(Property.TABLE_LOCALITY_GROUPS).split(",");
@@ -87,7 +87,7 @@ public class LocalityGroupUtil {
colFamsSet.retainAll(all);
throw new LocalityGroupConfigurationError("Column families " + colFamsSet + " in group " + group + " is already used by another locality group");
}
-
+
all.addAll(colFamsSet);
result.put(group, colFamsSet);
}
@@ -97,35 +97,35 @@ public class LocalityGroupUtil {
// result.put("", all);
return result;
}
-
+
public static Set<ByteSequence> decodeColumnFamilies(String colFams) throws LocalityGroupConfigurationError {
HashSet<ByteSequence> colFamsSet = new HashSet<ByteSequence>();
-
+
for (String family : colFams.split(",")) {
ByteSequence cfbs = decodeColumnFamily(family);
colFamsSet.add(cfbs);
}
-
+
return colFamsSet;
}
-
+
public static ByteSequence decodeColumnFamily(String colFam) throws LocalityGroupConfigurationError {
byte output[] = new byte[colFam.length()];
int pos = 0;
-
+
for (int i = 0; i < colFam.length(); i++) {
char c = colFam.charAt(i);
-
+
if (c == '\\') {
// next char must be 'x' or '\'
i++;
-
+
if (i >= colFam.length()) {
throw new LocalityGroupConfigurationError("Expected 'x' or '\' after '\' in " + colFam);
}
-
+
char nc = colFam.charAt(i);
-
+
switch (nc) {
case '\\':
output[pos++] = '\\';
@@ -142,36 +142,36 @@ public class LocalityGroupUtil {
} else {
output[pos++] = (byte) (0xff & c);
}
-
+
}
-
+
return new ArrayByteSequence(output, 0, pos);
-
+
}
-
+
public static String encodeColumnFamilies(Set<Text> colFams) {
SortedSet<String> ecfs = new TreeSet<String>();
-
+
StringBuilder sb = new StringBuilder();
-
+
for (Text text : colFams) {
String ecf = encodeColumnFamily(sb, text.getBytes(), text.getLength());
ecfs.add(ecf);
}
-
+
return Joiner.on(",").join(ecfs);
}
-
+
public static String encodeColumnFamily(ByteSequence bs) {
if (bs.offset() != 0) {
throw new IllegalArgumentException("The offset cannot be non-zero.");
}
return encodeColumnFamily(new StringBuilder(), bs.getBackingArray(), bs.length());
}
-
+
private static String encodeColumnFamily(StringBuilder sb, byte[] ba, int len) {
sb.setLength(0);
-
+
for (int i = 0; i < len; i++) {
int c = 0xff & ba[i];
if (c == '\\')
@@ -181,45 +181,45 @@ public class LocalityGroupUtil {
else
sb.append("\\x").append(String.format("%02X", c));
}
-
+
String ecf = sb.toString();
return ecf;
}
-
+
private static class PartitionedMutation extends Mutation {
private byte[] row;
private List<ColumnUpdate> updates;
-
+
PartitionedMutation(byte[] row, List<ColumnUpdate> updates) {
this.row = row;
this.updates = updates;
}
-
+
@Override
public byte[] getRow() {
return row;
}
-
+
@Override
public List<ColumnUpdate> getUpdates() {
return updates;
}
-
+
@Override
public TMutation toThrift() {
throw new UnsupportedOperationException();
}
-
+
@Override
public int hashCode() {
throw new UnsupportedOperationException();
}
-
+
@Override
public boolean equals(Object o) {
throw new UnsupportedOperationException();
}
-
+
@Override
public boolean equals(Mutation m) {
throw new UnsupportedOperationException();
@@ -227,28 +227,28 @@ public class LocalityGroupUtil {
}
public static class Partitioner {
-
+
private Map<ByteSequence,Integer> colfamToLgidMap;
private Map<ByteSequence,MutableLong>[] groups;
-
+
public Partitioner(Map<ByteSequence,MutableLong> groups[]) {
this.groups = groups;
this.colfamToLgidMap = new HashMap<ByteSequence,Integer>();
-
+
for (int i = 0; i < groups.length; i++) {
for (ByteSequence cf : groups[i].keySet()) {
colfamToLgidMap.put(cf, i);
}
}
}
-
+
public void partition(List<Mutation> mutations, List<Mutation> partitionedMutations[]) {
MutableByteSequence mbs = new MutableByteSequence(new byte[0], 0, 0);
-
+
@SuppressWarnings("unchecked")
List<ColumnUpdate> parts[] = new List[groups.length + 1];
-
+
for (Mutation mutation : mutations) {
if (mutation.getUpdates().size() == 1) {
int lgid = getLgid(mbs, mutation.getUpdates().get(0));
@@ -257,7 +257,7 @@ public class LocalityGroupUtil {
for (int i = 0; i < parts.length; i++) {
parts[i] = null;
}
-
+
int lgcount = 0;
for (ColumnUpdate cu : mutation.getUpdates()) {
@@ -267,10 +267,10 @@ public class LocalityGroupUtil {
parts[lgid] = new ArrayList<ColumnUpdate>();
lgcount++;
}
-
+
parts[lgid].add(cu);
}
-
+
if (lgcount == 1) {
for (int i = 0; i < parts.length; i++)
if (parts[i] != null) {
@@ -285,7 +285,7 @@ public class LocalityGroupUtil {
}
}
}
-
+
private Integer getLgid(MutableByteSequence mbs, ColumnUpdate cu) {
mbs.setArray(cu.getColumnFamily(), 0, cu.getColumnFamily().length);
Integer lgid = colfamToLgidMap.get(mbs);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/LoggingRunnable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/LoggingRunnable.java b/core/src/main/java/org/apache/accumulo/core/util/LoggingRunnable.java
index 5d486b9..081a433 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/LoggingRunnable.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/LoggingRunnable.java
@@ -23,7 +23,7 @@ import org.slf4j.Logger;
public class LoggingRunnable implements Runnable {
private Runnable runnable;
private Logger log;
-
+
public LoggingRunnable(Logger log, Runnable r) {
this.runnable = r;
this.log = log;
@@ -40,7 +40,7 @@ public class LoggingRunnable implements Runnable {
// maybe the logging system is screwed up OR there is a bug in the exception, like t.getMessage() throws a NPE
System.err.println("ERROR " + new Date() + " Failed to log message about thread death " + t2.getMessage());
t2.printStackTrace();
-
+
// try to print original exception
System.err.println("ERROR " + new Date() + " Exception that failed to log : " + t.getMessage());
t.printStackTrace();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/MapCounter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/MapCounter.java b/core/src/main/java/org/apache/accumulo/core/util/MapCounter.java
index 30f9f1d..f6f3ff7 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/MapCounter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/MapCounter.java
@@ -22,64 +22,64 @@ import java.util.HashMap;
import java.util.Set;
public class MapCounter<KT> {
-
+
static class MutableLong {
long l = 0l;
}
-
+
private HashMap<KT,MutableLong> map;
-
+
public MapCounter() {
map = new HashMap<KT,MutableLong>();
}
-
+
public long increment(KT key, long l) {
MutableLong ml = map.get(key);
if (ml == null) {
ml = new MutableLong();
map.put(key, ml);
}
-
+
ml.l += l;
-
+
if (ml.l == 0) {
map.remove(key);
}
-
+
return ml.l;
}
-
+
public long decrement(KT key, long l) {
return increment(key, -1 * l);
}
-
+
public boolean contains(KT key) {
return map.containsKey(key);
}
-
+
public long get(KT key) {
MutableLong ml = map.get(key);
if (ml == null) {
return 0;
}
-
+
return ml.l;
}
-
+
public Set<KT> keySet() {
return map.keySet();
}
-
+
public Collection<Long> values() {
Collection<MutableLong> vals = map.values();
ArrayList<Long> ret = new ArrayList<Long>(vals.size());
for (MutableLong ml : vals) {
ret.add(ml.l);
}
-
+
return ret;
}
-
+
public int size() {
return map.size();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java b/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
index 4a0f9ef..4497981 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
@@ -28,6 +28,6 @@ public class MonitorUtil {
public static String getLocation(Instance instance) throws KeeperException, InterruptedException {
ZooReader zr = new ZooReader(instance.getZooKeepers(), 5000);
byte[] loc = zr.getData(ZooUtil.getRoot(instance) + Constants.ZMONITOR_HTTP_ADDR, null);
- return loc==null ? null : new String(loc, UTF_8);
+ return loc == null ? null : new String(loc, UTF_8);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/MutableByteSequence.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/MutableByteSequence.java b/core/src/main/java/org/apache/accumulo/core/util/MutableByteSequence.java
index 6db7170..f9a0183 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/MutableByteSequence.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/MutableByteSequence.java
@@ -19,28 +19,27 @@ package org.apache.accumulo.core.util;
import org.apache.accumulo.core.data.ArrayByteSequence;
import org.apache.accumulo.core.data.ByteSequence;
-
public class MutableByteSequence extends ArrayByteSequence {
private static final long serialVersionUID = 1L;
public MutableByteSequence(byte[] data, int offset, int length) {
super(data, offset, length);
}
-
+
public MutableByteSequence(ByteSequence bs) {
super(new byte[Math.max(64, bs.length())]);
System.arraycopy(bs.getBackingArray(), bs.offset(), data, 0, bs.length());
this.length = bs.length();
this.offset = 0;
}
-
+
public void setArray(byte[] data, int offset, int len) {
this.data = data;
this.offset = offset;
this.length = len;
}
-
+
public void setLength(int len) {
this.length = len;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/NamingThreadFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/NamingThreadFactory.java b/core/src/main/java/org/apache/accumulo/core/util/NamingThreadFactory.java
index c37d0af..ebe9002 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/NamingThreadFactory.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/NamingThreadFactory.java
@@ -28,13 +28,13 @@ public class NamingThreadFactory implements ThreadFactory {
private AtomicInteger threadNum = new AtomicInteger(1);
private String name;
-
+
public NamingThreadFactory(String name) {
this.name = name;
}
-
+
public Thread newThread(Runnable r) {
return new Daemon(new LoggingRunnable(log, new TraceRunnable(r)), name + " " + threadNum.getAndIncrement());
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/NumUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/NumUtil.java b/core/src/main/java/org/apache/accumulo/core/util/NumUtil.java
index ebc8c4f..ef94f0c 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/NumUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/NumUtil.java
@@ -21,7 +21,7 @@ import java.text.DecimalFormat;
public class NumUtil {
private static final String QUANTITY_SUFFIX[] = {"", "K", "M", "B", "T", "e15", "e18", "e21"};
- private static final String SIZE_SUFFIX[] = {"", "K", "M", "G", "T", "P", "E", "Z"};
+ private static final String SIZE_SUFFIX[] = {"", "K", "M", "G", "T", "P", "E", "Z"};
private static DecimalFormat df = new DecimalFormat("#,###,##0");
private static DecimalFormat df_mantissa = new DecimalFormat("#,###,##0.00");
@@ -39,14 +39,16 @@ public class NumUtil {
}
private static String bigNumber(long big, String[] SUFFIXES, long base) {
- if (big < base) return df.format(big) + SUFFIXES[0];
+ if (big < base)
+ return df.format(big) + SUFFIXES[0];
int exp = (int) (Math.log(big) / Math.log(base));
double val = big / Math.pow(base, exp);
- return df_mantissa.format(val) + SUFFIXES[exp];
+ return df_mantissa.format(val) + SUFFIXES[exp];
}
private static String bigNumber(double big, String[] SUFFIXES, long base) {
- if (big < base) return df_mantissa.format(big) + SUFFIXES[0];
+ if (big < base)
+ return df_mantissa.format(big) + SUFFIXES[0];
int exp = (int) (Math.log(big) / Math.log(base));
double val = big / Math.pow(base, exp);
return df_mantissa.format(val) + SUFFIXES[exp];
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java b/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java
index 205b043..564a824 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java
@@ -27,12 +27,12 @@ public class OpTimer {
private long t1;
private long opid;
private static AtomicLong nextOpid = new AtomicLong();
-
+
public OpTimer(Logger log, Level level) {
this.log = log;
this.level = level;
}
-
+
public OpTimer start(String msg) {
opid = nextOpid.getAndIncrement();
if (log.isEnabledFor(level))
@@ -40,7 +40,7 @@ public class OpTimer {
t1 = System.currentTimeMillis();
return this;
}
-
+
public void stop(String msg) {
if (log.isEnabledFor(level)) {
long t2 = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/PeekingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/PeekingIterator.java b/core/src/main/java/org/apache/accumulo/core/util/PeekingIterator.java
index 04c2b86..6d25a0b 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/PeekingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/PeekingIterator.java
@@ -19,11 +19,11 @@ package org.apache.accumulo.core.util;
import java.util.Iterator;
public class PeekingIterator<E> implements Iterator<E> {
-
+
boolean isInitialized;
Iterator<E> source;
E top;
-
+
public PeekingIterator(Iterator<E> source) {
this.source = source;
if (source.hasNext())
@@ -32,14 +32,14 @@ public class PeekingIterator<E> implements Iterator<E> {
top = null;
isInitialized = true;
}
-
+
/**
* Creates an uninitialized instance. This should be used in conjunction with {@link #initialize(Iterator)}.
*/
public PeekingIterator() {
isInitialized = false;
}
-
+
/**
* Initializes this iterator, to be used with {@link #PeekingIterator()}.
*/
@@ -52,13 +52,13 @@ public class PeekingIterator<E> implements Iterator<E> {
isInitialized = true;
return this;
}
-
+
public E peek() {
if (!isInitialized)
throw new IllegalStateException("Iterator has not yet been initialized");
return top;
}
-
+
@Override
public E next() {
if (!isInitialized)
@@ -70,12 +70,12 @@ public class PeekingIterator<E> implements Iterator<E> {
top = null;
return lastPeeked;
}
-
+
@Override
public void remove() {
throw new UnsupportedOperationException();
}
-
+
@Override
public boolean hasNext() {
if (!isInitialized)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java b/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
index 88c4ebf..a07ef76 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ServerServices.java
@@ -24,35 +24,35 @@ public class ServerServices implements Comparable<ServerServices> {
public static enum Service {
TSERV_CLIENT, GC_CLIENT;
}
-
+
public static final String SERVICE_SEPARATOR = ";";
public static final String SEPARATOR_CHAR = "=";
-
+
private EnumMap<Service,String> services;
private String stringForm = null;
-
+
public ServerServices(String services) {
this.services = new EnumMap<Service,String>(Service.class);
-
+
String[] addresses = services.split(SERVICE_SEPARATOR);
for (String address : addresses) {
String[] sa = address.split(SEPARATOR_CHAR, 2);
this.services.put(Service.valueOf(sa[0]), sa[1]);
}
}
-
+
public ServerServices(String address, Service service) {
this(service.name() + SEPARATOR_CHAR + address);
}
-
+
public String getAddressString(Service service) {
return services.get(service);
}
-
+
public HostAndPort getAddress(Service service) {
return AddressUtil.parseAddress(getAddressString(service), false);
}
-
+
// DON'T CHANGE THIS; WE'RE USING IT FOR SERIALIZATION!!!
@Override
public String toString() {
@@ -69,19 +69,19 @@ public class ServerServices implements Comparable<ServerServices> {
}
return stringForm;
}
-
+
@Override
public int hashCode() {
return toString().hashCode();
}
-
+
@Override
public boolean equals(Object o) {
if (o instanceof ServerServices)
return toString().equals(((ServerServices) o).toString());
return false;
}
-
+
@Override
public int compareTo(ServerServices other) {
return toString().compareTo(other.toString());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/SimpleThreadPool.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/SimpleThreadPool.java b/core/src/main/java/org/apache/accumulo/core/util/SimpleThreadPool.java
index cbac519..a406233 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/SimpleThreadPool.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/SimpleThreadPool.java
@@ -20,15 +20,14 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-
/**
* Create a simple thread pool using common parameters.
*/
public class SimpleThreadPool extends ThreadPoolExecutor {
-
+
public SimpleThreadPool(int max, final String name) {
super(max, max, 4l, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamingThreadFactory(name));
allowCoreThreadTimeOut(true);
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/StopWatch.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/StopWatch.java b/core/src/main/java/org/apache/accumulo/core/util/StopWatch.java
index 4f30d4a..ddb612f 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/StopWatch.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/StopWatch.java
@@ -21,62 +21,62 @@ import java.util.EnumMap;
public class StopWatch<K extends Enum<K>> {
EnumMap<K,Long> startTime;
EnumMap<K,Long> totalTime;
-
+
public StopWatch(Class<K> k) {
startTime = new EnumMap<K,Long>(k);
totalTime = new EnumMap<K,Long>(k);
}
-
+
public synchronized void start(K timer) {
if (startTime.containsKey(timer)) {
throw new IllegalStateException(timer + " already started");
}
startTime.put(timer, System.currentTimeMillis());
}
-
+
public synchronized void stopIfActive(K timer) {
if (startTime.containsKey(timer))
stop(timer);
}
-
+
public synchronized void stop(K timer) {
-
+
Long st = startTime.get(timer);
-
+
if (st == null) {
throw new IllegalStateException(timer + " not started");
}
-
+
Long existingTime = totalTime.get(timer);
if (existingTime == null)
existingTime = 0L;
-
+
totalTime.put(timer, existingTime + (System.currentTimeMillis() - st));
startTime.remove(timer);
}
-
+
public synchronized void reset(K timer) {
totalTime.remove(timer);
}
-
+
public synchronized long get(K timer) {
Long existingTime = totalTime.get(timer);
if (existingTime == null)
existingTime = 0L;
return existingTime;
}
-
+
public synchronized double getSecs(K timer) {
Long existingTime = totalTime.get(timer);
if (existingTime == null)
existingTime = 0L;
return existingTime / 1000.0;
}
-
+
public synchronized void print() {
for (K timer : totalTime.keySet()) {
System.out.printf("%20s : %,6.4f secs%n", timer.toString(), get(timer) / 1000.0);
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java b/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
index 66ad8f5..d2cd6cc 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.util;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.nio.ByteBuffer;
+
import org.apache.accumulo.core.Constants;
import org.apache.hadoop.io.Text;
@@ -31,14 +32,14 @@ public final class TextUtil {
}
return bytes;
}
-
+
public static ByteBuffer getByteBuffer(Text text) {
if (text == null)
return null;
byte[] bytes = text.getBytes();
return ByteBuffer.wrap(bytes, 0, text.getLength());
}
-
+
public static Text truncate(Text text, int maxLen) {
if (text.getLength() > maxLen) {
Text newText = new Text();
@@ -47,10 +48,10 @@ public final class TextUtil {
newText.append(suffix.getBytes(UTF_8), 0, suffix.length());
return newText;
}
-
+
return text;
}
-
+
public static Text truncate(Text row) {
return truncate(row, Constants.MAX_DATA_TO_PRINT);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/UnsynchronizedBuffer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/UnsynchronizedBuffer.java b/core/src/main/java/org/apache/accumulo/core/util/UnsynchronizedBuffer.java
index 36aa473..e07ee10 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/UnsynchronizedBuffer.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/UnsynchronizedBuffer.java
@@ -21,8 +21,7 @@ import java.nio.ByteBuffer;
import org.apache.hadoop.io.WritableUtils;
/**
- * A utility class for reading and writing bytes to byte buffers without
- * synchronization.
+ * A utility class for reading and writing bytes to byte buffers without synchronization.
*/
public class UnsynchronizedBuffer {
// created this little class instead of using ByteArrayOutput stream and DataOutputStream
@@ -31,26 +30,27 @@ public class UnsynchronizedBuffer {
* A byte buffer writer.
*/
public static class Writer {
-
+
int offset = 0;
byte data[];
-
+
/**
* Creates a new writer.
*/
public Writer() {
data = new byte[64];
}
-
+
/**
* Creates a new writer.
*
- * @param initialCapacity initial byte capacity
+ * @param initialCapacity
+ * initial byte capacity
*/
public Writer(int initialCapacity) {
data = new byte[initialCapacity];
}
-
+
private void reserve(int l) {
if (offset + l > data.length) {
int newSize = UnsynchronizedBuffer.nextArraySize(offset + l);
@@ -59,27 +59,32 @@ public class UnsynchronizedBuffer {
System.arraycopy(data, 0, newData, 0, offset);
data = newData;
}
-
+
}
-
+
/**
* Adds bytes to this writer's buffer.
*
- * @param bytes byte array
- * @param off offset into array to start copying bytes
- * @param length number of bytes to add
- * @throws IndexOutOfBoundsException if off or length are invalid
+ * @param bytes
+ * byte array
+ * @param off
+ * offset into array to start copying bytes
+ * @param length
+ * number of bytes to add
+ * @throws IndexOutOfBoundsException
+ * if off or length are invalid
*/
public void add(byte[] bytes, int off, int length) {
reserve(length);
System.arraycopy(bytes, off, data, offset, length);
offset += length;
}
-
+
/**
* Adds a Boolean value to this writer's buffer.
*
- * @param b Boolean value
+ * @param b
+ * Boolean value
*/
public void add(boolean b) {
reserve(1);
@@ -88,7 +93,7 @@ public class UnsynchronizedBuffer {
else
data[offset++] = 0;
}
-
+
/**
* Gets (a copy of) the contents of this writer's buffer.
*
@@ -99,7 +104,7 @@ public class UnsynchronizedBuffer {
System.arraycopy(data, 0, ret, 0, offset);
return ret;
}
-
+
/**
* Gets a <code>ByteBuffer</code> wrapped around this writer's buffer.
*
@@ -110,24 +115,23 @@ public class UnsynchronizedBuffer {
}
/**
- * Adds an integer value to this writer's buffer. The integer is encoded as
- * a variable-length list of bytes. See {@link #writeVLong(long)} for a
- * description of the encoding.
+ * Adds an integer value to this writer's buffer. The integer is encoded as a variable-length list of bytes. See {@link #writeVLong(long)} for a description
+ * of the encoding.
*
- * @param i integer value
+ * @param i
+ * integer value
*/
public void writeVInt(int i) {
writeVLong(i);
}
/**
- * Adds a long value to this writer's buffer. The long is encoded as
- * a variable-length list of bytes. For a description of the encoding
- * scheme, see <code>WritableUtils.writeVLong()</code> in the Hadoop
- * API.
- * [<a href="http://hadoop.apache.org/docs/stable/api/org/apache/hadoop/io/WritableUtils.html#writeVLong%28java.io.DataOutput,%20long%29">link</a>]
+ * Adds a long value to this writer's buffer. The long is encoded as a variable-length list of bytes. For a description of the encoding scheme, see
+ * <code>WritableUtils.writeVLong()</code> in the Hadoop API. [<a
+ * href="http://hadoop.apache.org/docs/stable/api/org/apache/hadoop/io/WritableUtils.html#writeVLong%28java.io.DataOutput,%20long%29">link</a>]
*
- * @param i long value
+ * @param i
+ * long value
*/
public void writeVLong(long i) {
reserve(9);
@@ -135,23 +139,23 @@ public class UnsynchronizedBuffer {
data[offset++] = (byte) i;
return;
}
-
+
int len = -112;
if (i < 0) {
i ^= -1L; // take one's complement'
len = -120;
}
-
+
long tmp = i;
while (tmp != 0) {
tmp = tmp >> 8;
len--;
}
-
+
data[offset++] = (byte) len;
-
+
len = (len < -120) ? -(len + 120) : -(len + 112);
-
+
for (int idx = len; idx != 0; idx--) {
int shiftbits = (idx - 1) * 8;
long mask = 0xFFL << shiftbits;
@@ -159,27 +163,29 @@ public class UnsynchronizedBuffer {
}
}
}
-
+
/**
* A byte buffer reader.
*/
public static class Reader {
int offset;
byte data[];
-
+
/**
* Creates a new reader.
*
- * @param b bytes to read
+ * @param b
+ * bytes to read
*/
public Reader(byte b[]) {
this.data = b;
}
-
+
/**
* Creates a new reader.
*
- * @param buffer byte buffer containing bytes to read
+ * @param buffer
+ * byte buffer containing bytes to read
*/
public Reader(ByteBuffer buffer) {
if (buffer.hasArray()) {
@@ -199,7 +205,7 @@ public class UnsynchronizedBuffer {
public int readInt() {
return (data[offset++] << 24) + ((data[offset++] & 255) << 16) + ((data[offset++] & 255) << 8) + ((data[offset++] & 255) << 0);
}
-
+
/**
* Reads a long value from this reader's buffer.
*
@@ -209,17 +215,18 @@ public class UnsynchronizedBuffer {
return (((long) data[offset++] << 56) + ((long) (data[offset++] & 255) << 48) + ((long) (data[offset++] & 255) << 40)
+ ((long) (data[offset++] & 255) << 32) + ((long) (data[offset++] & 255) << 24) + ((data[offset++] & 255) << 16) + ((data[offset++] & 255) << 8) + ((data[offset++] & 255) << 0));
}
-
+
/**
* Reads bytes from this reader's buffer, filling the given byte array.
*
- * @param b byte array to fill
+ * @param b
+ * byte array to fill
*/
public void readBytes(byte b[]) {
System.arraycopy(data, offset, b, 0, b.length);
offset += b.length;
}
-
+
/**
* Reads a Boolean value from this reader's buffer.
*
@@ -228,10 +235,9 @@ public class UnsynchronizedBuffer {
public boolean readBoolean() {
return (data[offset++] == 1);
}
-
+
/**
- * Reads an integer value from this reader's buffer, assuming the integer
- * was encoded as a variable-length list of bytes.
+ * Reads an integer value from this reader's buffer, assuming the integer was encoded as a variable-length list of bytes.
*
* @return integer value
*/
@@ -240,8 +246,7 @@ public class UnsynchronizedBuffer {
}
/**
- * Reads a long value from this reader's buffer, assuming the long
- * was encoded as a variable-length list of bytes.
+ * Reads a long value from this reader's buffer, assuming the long was encoded as a variable-length list of bytes.
*
* @return long value
*/
@@ -264,21 +269,23 @@ public class UnsynchronizedBuffer {
/**
* Determines what next array size should be by rounding up to next power of two.
*
- * @param i current array size
+ * @param i
+ * current array size
* @return next array size
- * @throws IllegalArgumentException if i is negative
+ * @throws IllegalArgumentException
+ * if i is negative
*/
public static int nextArraySize(int i) {
if (i < 0)
throw new IllegalArgumentException();
-
+
if (i > (1 << 30))
return Integer.MAX_VALUE; // this is the next power of 2 minus one... a special case
-
+
if (i == 0) {
return 1;
}
-
+
// round up to next power of two
int ret = i;
ret--;
@@ -288,7 +295,7 @@ public class UnsynchronizedBuffer {
ret |= ret >> 8;
ret |= ret >> 16;
ret++;
-
+
return ret;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/UtilWaitThread.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/UtilWaitThread.java b/core/src/main/java/org/apache/accumulo/core/util/UtilWaitThread.java
index 36a4279..b559997 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/UtilWaitThread.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/UtilWaitThread.java
@@ -20,7 +20,7 @@ import org.apache.log4j.Logger;
public class UtilWaitThread {
private static final Logger log = Logger.getLogger(UtilWaitThread.class);
-
+
public static void sleep(long millis) {
try {
Thread.sleep(millis);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/Validator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Validator.java b/core/src/main/java/org/apache/accumulo/core/util/Validator.java
index efb70c0..a5ae156 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Validator.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Validator.java
@@ -17,14 +17,14 @@
package org.apache.accumulo.core.util;
/**
- * A class that validates arguments of a particular type. Implementations must
- * implement {@link #isValid(Object)} and should override {@link #invalidMessage(Object)}.
+ * A class that validates arguments of a particular type. Implementations must implement {@link #isValid(Object)} and should override
+ * {@link #invalidMessage(Object)}.
*/
public abstract class Validator<T> {
/**
* Validates an argument.
- *
+ *
* @param argument
* argument to validate
* @return the argument, if validation passes
@@ -39,7 +39,7 @@ public abstract class Validator<T> {
/**
* Checks an argument for validity.
- *
+ *
* @param argument
* argument to validate
* @return true if valid, false if invalid
@@ -48,7 +48,7 @@ public abstract class Validator<T> {
/**
* Formulates an exception message for invalid values.
- *
+ *
* @param argument
* argument that failed validation
* @return exception message
@@ -60,7 +60,7 @@ public abstract class Validator<T> {
/**
* Creates a new validator that is the conjunction of this one and the given one. An argument passed to the returned validator is valid only if it passes both
* validators.
- *
+ *
* @param other
* other validator
* @return combined validator
@@ -87,7 +87,7 @@ public abstract class Validator<T> {
/**
* Creates a new validator that is the disjunction of this one and the given one. An argument passed to the returned validator is valid only if it passes at
* least one of the validators.
- *
+ *
* @param other
* other validator
* @return combined validator
@@ -113,7 +113,7 @@ public abstract class Validator<T> {
/**
* Creates a new validator that is the negation of this one. An argument passed to the returned validator is valid only if it fails this one.
- *
+ *
* @return negated validator
*/
public final Validator<T> not() {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/Version.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Version.java b/core/src/main/java/org/apache/accumulo/core/util/Version.java
index 7347227..ee645ff 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Version.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Version.java
@@ -25,17 +25,17 @@ public class Version {
int minor = 0;
int release = 0;
String etcetera = null;
-
+
public Version(String everything) {
parse(everything);
}
-
+
private void parse(String everything) {
Pattern pattern = Pattern.compile("(([^-]*)-)?(\\d+)(\\.(\\d+)(\\.(\\d+))?)?(-(.*))?");
Matcher parser = pattern.matcher(everything);
if (!parser.matches())
throw new IllegalArgumentException("Unable to parse: " + everything + " as a version");
-
+
if (parser.group(1) != null)
package_ = parser.group(2);
major = Integer.valueOf(parser.group(3));
@@ -46,29 +46,29 @@ public class Version {
release = Integer.valueOf(parser.group(7));
if (parser.group(9) != null)
etcetera = parser.group(9);
-
+
}
-
+
public String getPackage() {
return package_;
}
-
+
public int getMajorVersion() {
return major;
}
-
+
public int getMinorVersion() {
return minor;
}
-
+
public int getReleaseVersion() {
return release;
}
-
+
public String getEtcetera() {
return etcetera;
}
-
+
@Override
public String toString() {
StringBuilder result = new StringBuilder();
@@ -87,5 +87,5 @@ public class Version {
}
return result.toString();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java b/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java
index b31df18..ec20da5 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java
@@ -25,17 +25,17 @@ import org.apache.hadoop.io.Text;
public class BinaryFormatter extends DefaultFormatter {
private static int showLength;
-
+
public String next() {
checkState(true);
return formatEntry(getScannerIterator().next(), isDoTimestamps());
}
-
+
// this should be replaced with something like Record.toString();
// it would be great if we were able to combine code with DefaultFormatter.formatEntry, but that currently does not respect the showLength option.
public static String formatEntry(Entry<Key,Value> entry, boolean showTimestamps) {
StringBuilder sb = new StringBuilder();
-
+
Key key = entry.getKey();
// append row
@@ -49,11 +49,11 @@ public class BinaryFormatter extends DefaultFormatter {
// append visibility expression
sb.append(new ColumnVisibility(key.getColumnVisibility()));
-
+
// append timestamp
if (showTimestamps)
sb.append(" ").append(entry.getKey().getTimestamp());
-
+
// append value
Value value = entry.getValue();
if (value != null && value.getSize() > 0) {
@@ -62,20 +62,20 @@ public class BinaryFormatter extends DefaultFormatter {
}
return sb.toString();
}
-
+
public static StringBuilder appendText(StringBuilder sb, Text t) {
return appendBytes(sb, t.getBytes(), 0, t.getLength());
}
-
+
static StringBuilder appendValue(StringBuilder sb, Value value) {
return appendBytes(sb, value.get(), 0, value.get().length);
}
-
+
static StringBuilder appendBytes(StringBuilder sb, byte ba[], int offset, int len) {
int length = Math.min(len, showLength);
return DefaultFormatter.appendBytes(sb, ba, offset, length);
}
-
+
public static void getlength(int length) {
showLength = length;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java b/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
index 037ddb0..5bcd4a3 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/DateStringFormatter.java
@@ -36,26 +36,29 @@ public class DateStringFormatter implements Formatter {
return new SimpleDateFormat(DATE_FORMAT);
}
};
-
+
@Override
public void initialize(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) {
this.printTimestamps = printTimestamps;
defaultFormatter.initialize(scanner, printTimestamps);
}
+
@Override
public boolean hasNext() {
return defaultFormatter.hasNext();
}
+
@Override
public String next() {
DateFormat timestampformat = null;
-
- if(printTimestamps) {
+
+ if (printTimestamps) {
timestampformat = formatter.get();
}
-
+
return defaultFormatter.next(timestampformat);
}
+
@Override
public void remove() {
defaultFormatter.remove();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java b/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java
index 931b59f..f104610 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/DefaultFormatter.java
@@ -36,7 +36,7 @@ public class DefaultFormatter implements Formatter {
protected DateFormat initialValue() {
return new DefaultDateFormat();
}
-
+
class DefaultDateFormat extends DateFormat {
private static final long serialVersionUID = 1L;
@@ -50,42 +50,42 @@ public class DefaultFormatter implements Formatter {
public Date parse(String source, ParsePosition pos) {
return new Date(Long.parseLong(source));
}
-
+
}
};
-
+
@Override
public void initialize(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) {
checkState(false);
si = scanner.iterator();
doTimestamps = printTimestamps;
}
-
+
public boolean hasNext() {
checkState(true);
return si.hasNext();
}
-
+
public String next() {
DateFormat timestampFormat = null;
-
- if(doTimestamps) {
+
+ if (doTimestamps) {
timestampFormat = formatter.get();
}
-
+
return next(timestampFormat);
}
-
+
protected String next(DateFormat timestampFormat) {
checkState(true);
return formatEntry(si.next(), timestampFormat);
}
-
+
public void remove() {
checkState(true);
si.remove();
}
-
+
protected void checkState(boolean expectInitialized) {
if (expectInitialized && si == null)
throw new IllegalStateException("Not initialized");
@@ -96,22 +96,22 @@ public class DefaultFormatter implements Formatter {
// this should be replaced with something like Record.toString();
public static String formatEntry(Entry<Key,Value> entry, boolean showTimestamps) {
DateFormat timestampFormat = null;
-
- if(showTimestamps) {
+
+ if (showTimestamps) {
timestampFormat = formatter.get();
}
-
+
return formatEntry(entry, timestampFormat);
}
-
+
/* so a new date object doesn't get created for every record in the scan result */
private static ThreadLocal<Date> tmpDate = new ThreadLocal<Date>() {
@Override
- protected Date initialValue() {
+ protected Date initialValue() {
return new Date();
}
};
-
+
public static String formatEntry(Entry<Key,Value> entry, DateFormat timestampFormat) {
StringBuilder sb = new StringBuilder();
Key key = entry.getKey();
@@ -119,16 +119,16 @@ public class DefaultFormatter implements Formatter {
// append row
appendText(sb, key.getRow(buffer)).append(" ");
-
+
// append column family
appendText(sb, key.getColumnFamily(buffer)).append(":");
-
+
// append column qualifier
appendText(sb, key.getColumnQualifier(buffer)).append(" ");
-
+
// append visibility expression
sb.append(new ColumnVisibility(key.getColumnVisibility(buffer)));
-
+
// append timestamp
if (timestampFormat != null) {
tmpDate.get().setTime(entry.getKey().getTimestamp());
@@ -142,18 +142,18 @@ public class DefaultFormatter implements Formatter {
sb.append("\t");
appendValue(sb, value);
}
-
+
return sb.toString();
}
static StringBuilder appendText(StringBuilder sb, Text t) {
return appendBytes(sb, t.getBytes(), 0, t.getLength());
}
-
+
static StringBuilder appendValue(StringBuilder sb, Value value) {
return appendBytes(sb, value.get(), 0, value.get().length);
}
-
+
static StringBuilder appendBytes(StringBuilder sb, byte ba[], int offset, int len) {
for (int i = 0; i < len; i++) {
int c = 0xff & ba[offset + i];
@@ -166,7 +166,7 @@ public class DefaultFormatter implements Formatter {
}
return sb;
}
-
+
public Iterator<Entry<Key,Value>> getScannerIterator() {
return si;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/format/FormatterFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/FormatterFactory.java b/core/src/main/java/org/apache/accumulo/core/util/format/FormatterFactory.java
index 27299ee..e8a9e7d 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/FormatterFactory.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/FormatterFactory.java
@@ -24,7 +24,7 @@ import org.apache.log4j.Logger;
public class FormatterFactory {
private static final Logger log = Logger.getLogger(FormatterFactory.class);
-
+
public static Formatter getFormatter(Class<? extends Formatter> formatterClass, Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) {
Formatter formatter = null;
try {
@@ -36,7 +36,7 @@ public class FormatterFactory {
formatter.initialize(scanner, printTimestamps);
return formatter;
}
-
+
public static Formatter getDefaultFormatter(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) {
return getFormatter(DefaultFormatter.class, scanner, printTimestamps);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/format/HexFormatter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/HexFormatter.java b/core/src/main/java/org/apache/accumulo/core/util/format/HexFormatter.java
index b636278..65e52d3 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/HexFormatter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/HexFormatter.java
@@ -28,11 +28,11 @@ import org.apache.hadoop.io.Text;
* A simple formatter that print the row, column family, column qualifier, and value as hex
*/
public class HexFormatter implements Formatter, ScanInterpreter {
-
+
private char chars[] = new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private Iterator<Entry<Key,Value>> iter;
private boolean printTimestamps;
-
+
private void toHex(StringBuilder sb, byte[] bin) {
for (int i = 0; i < bin.length; i++) {
@@ -42,22 +42,22 @@ public class HexFormatter implements Formatter, ScanInterpreter {
sb.append(chars[0x0f & bin[i]]);
}
}
-
+
private int fromChar(char b) {
if (b >= '0' && b <= '9') {
return (b - '0');
} else if (b >= 'a' && b <= 'f') {
return (b - 'a' + 10);
}
-
+
throw new IllegalArgumentException("Bad char " + b);
}
-
+
private byte[] toBinary(String hex) {
hex = hex.replace("-", "");
byte[] bin = new byte[(hex.length() / 2) + (hex.length() % 2)];
-
+
int j = 0;
for (int i = 0; i < bin.length; i++) {
bin[i] = (byte) (fromChar(hex.charAt(j++)) << 4);
@@ -65,22 +65,21 @@ public class HexFormatter implements Formatter, ScanInterpreter {
break;
bin[i] |= (byte) fromChar(hex.charAt(j++));
}
-
+
return bin;
}
-
@Override
public boolean hasNext() {
return iter.hasNext();
}
-
+
@Override
public String next() {
Entry<Key,Value> entry = iter.next();
-
+
StringBuilder sb = new StringBuilder();
-
+
toHex(sb, entry.getKey().getRowData().toArray());
sb.append(" ");
toHex(sb, entry.getKey().getColumnFamilyData().toArray());
@@ -94,26 +93,26 @@ public class HexFormatter implements Formatter, ScanInterpreter {
sb.append(" ");
}
toHex(sb, entry.getValue().get());
-
+
return sb.toString();
}
-
+
@Override
public void remove() {
iter.remove();
}
-
+
@Override
public void initialize(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) {
this.iter = scanner.iterator();
this.printTimestamps = printTimestamps;
}
-
+
@Override
public Text interpretRow(Text row) {
return new Text(toBinary(row.toString()));
}
-
+
@Override
public Text interpretBeginRow(Text row) {
return interpretRow(row);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatter.java b/core/src/main/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatter.java
index f81209f..877f164 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatter.java
@@ -27,15 +27,15 @@ import org.apache.accumulo.core.data.Value;
/**
* Formats the rows in a METADATA table scan to show distribution of shards over servers per day. This can be used to determine the effectiveness of the
* ShardedTableLoadBalancer
- *
+ *
* Use this formatter with the following scan command in the shell:
- *
+ *
* scan -b tableId -c ~tab:loc
*/
public class ShardedTableDistributionFormatter extends AggregatingFormatter {
-
+
private Map<String,HashSet<String>> countsByDay = new HashMap<String,HashSet<String>>();
-
+
@Override
protected void aggregateStats(Entry<Key,Value> entry) {
if (entry.getKey().getColumnFamily().toString().equals("~tab") && entry.getKey().getColumnQualifier().toString().equals("loc")) {
@@ -55,7 +55,7 @@ public class ShardedTableDistributionFormatter extends AggregatingFormatter {
countsByDay.get(day).add(server);
}
}
-
+
@Override
protected String getStats() {
StringBuilder buf = new StringBuilder();
@@ -65,5 +65,5 @@ public class ShardedTableDistributionFormatter extends AggregatingFormatter {
buf.append(day + "\t\t" + countsByDay.get(day).size() + "\n");
return buf.toString();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/format/StatisticsDisplayFormatter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/format/StatisticsDisplayFormatter.java b/core/src/main/java/org/apache/accumulo/core/util/format/StatisticsDisplayFormatter.java
index 98d4d28..b3ee3ee 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/format/StatisticsDisplayFormatter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/format/StatisticsDisplayFormatter.java
@@ -32,27 +32,27 @@ public class StatisticsDisplayFormatter extends AggregatingFormatter {
private Map<String,Long> columnFamilies = new HashMap<String,Long>();
private Map<String,Long> columnQualifiers = new HashMap<String,Long>();
private long total = 0;
-
+
@Override
protected void aggregateStats(Entry<Key,Value> entry) {
String key;
Long count;
-
+
key = entry.getKey().getColumnVisibility().toString();
count = classifications.get(key);
classifications.put(key, count != null ? count + 1 : 0L);
-
+
key = entry.getKey().getColumnFamily().toString();
count = columnFamilies.get(key);
columnFamilies.put(key, count != null ? count + 1 : 0L);
-
+
key = entry.getKey().getColumnQualifier().toString();
count = columnQualifiers.get(key);
columnQualifiers.put(key, count != null ? count + 1 : 0L);
-
+
++total;
}
-
+
@Override
protected String getStats() {
StringBuilder buf = new StringBuilder();
@@ -68,13 +68,13 @@ public class StatisticsDisplayFormatter extends AggregatingFormatter {
buf.append("------------------\n");
for (String key : columnQualifiers.keySet())
buf.append("\t").append(key).append(": ").append(columnQualifiers.get(key)).append("\n");
-
+
buf.append(total).append(" entries matched.");
total = 0;
classifications = new HashMap<String,Long>();
columnFamilies = new HashMap<String,Long>();
columnQualifiers = new HashMap<String,Long>();
-
+
return buf.toString();
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/interpret/DefaultScanInterpreter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/interpret/DefaultScanInterpreter.java b/core/src/main/java/org/apache/accumulo/core/util/interpret/DefaultScanInterpreter.java
index b1d7d36..761756f 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/interpret/DefaultScanInterpreter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/interpret/DefaultScanInterpreter.java
@@ -19,33 +19,33 @@ package org.apache.accumulo.core.util.interpret;
import org.apache.hadoop.io.Text;
/**
- *
+ *
*/
public class DefaultScanInterpreter implements ScanInterpreter {
-
+
@Override
public Text interpretRow(Text row) {
return row;
}
-
+
@Override
public Text interpretBeginRow(Text row) {
return row;
}
-
+
@Override
public Text interpretEndRow(Text row) {
return row;
}
-
+
@Override
public Text interpretColumnFamily(Text cf) {
return cf;
}
-
+
@Override
public Text interpretColumnQualifier(Text cq) {
return cq;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/interpret/HexScanInterpreter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/interpret/HexScanInterpreter.java b/core/src/main/java/org/apache/accumulo/core/util/interpret/HexScanInterpreter.java
index 78c0ce2..964e8c6 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/interpret/HexScanInterpreter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/interpret/HexScanInterpreter.java
@@ -23,5 +23,5 @@ import org.apache.accumulo.core.util.format.HexFormatter;
* dashes (because {@link HexFormatter} outputs dashes) which are ignored.
*/
public class HexScanInterpreter extends HexFormatter implements ScanInterpreter {
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/util/interpret/ScanInterpreter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/interpret/ScanInterpreter.java b/core/src/main/java/org/apache/accumulo/core/util/interpret/ScanInterpreter.java
index 315767e..7dfcf22 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/interpret/ScanInterpreter.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/interpret/ScanInterpreter.java
@@ -22,14 +22,14 @@ import org.apache.hadoop.io.Text;
* A simple interface for creating shell plugins that translate the range and column arguments for the shell's scan command.
*/
public interface ScanInterpreter {
-
+
Text interpretRow(Text row);
Text interpretBeginRow(Text row);
-
+
Text interpretEndRow(Text row);
-
+
Text interpretColumnFamily(Text cf);
-
+
Text interpretColumnQualifier(Text cq);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/volume/Volume.java b/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
index 58b0ada..5a3ea53 100644
--- a/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
+++ b/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
@@ -20,8 +20,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/**
- * Encapsulates a {@link FileSystem} and a base {@link Path} within that filesystem. This
- * also avoid the necessity to pass around a Configuration.
+ * Encapsulates a {@link FileSystem} and a base {@link Path} within that filesystem. This also avoid the necessity to pass around a Configuration.
*/
public interface Volume {
@@ -37,21 +36,24 @@ public interface Volume {
/**
* Convert the given Path into a Path that is relative to the base path for this Volume
- * @param p The suffix to use
+ *
+ * @param p
+ * The suffix to use
* @return A Path for this Volume with the provided suffix
*/
public Path prefixChild(Path p);
/**
* Convert the given child path into a Path that is relative to the base path for this Volume
- * @param p The suffix to use
+ *
+ * @param p
+ * The suffix to use
* @return A Path for this Volume with the provided suffix
*/
public Path prefixChild(String p);
/**
- * Determine if the Path is valid on this Volume. A Path is valid if it is contained
- * in the Volume's FileSystem and is rooted beneath the basePath
+ * Determine if the Path is valid on this Volume. A Path is valid if it is contained in the Volume's FileSystem and is rooted beneath the basePath
*/
public boolean isValidPath(Path p);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/volume/VolumeConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/volume/VolumeConfiguration.java b/core/src/main/java/org/apache/accumulo/core/volume/VolumeConfiguration.java
index 8d56d9e..99032ad 100644
--- a/core/src/main/java/org/apache/accumulo/core/volume/VolumeConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/volume/VolumeConfiguration.java
@@ -84,12 +84,12 @@ public class VolumeConfiguration {
/**
* Compute the URIs to be used by Accumulo
- *
+ *
*/
public static String[] getVolumeUris(AccumuloConfiguration conf) {
return getVolumeUris(conf, CachedConfiguration.getInstance());
}
-
+
public static String[] getVolumeUris(AccumuloConfiguration conf, Configuration hadoopConfig) {
String ns = conf.get(Property.INSTANCE_VOLUMES);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java b/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
index 9a324a0..9b9a80e 100644
--- a/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
@@ -27,8 +27,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.log4j.Logger;
/**
- * Basic Volume implementation that contains a FileSystem and a base path
- * that should be used within that filesystem.
+ * Basic Volume implementation that contains a FileSystem and a base path that should be used within that filesystem.
*/
public class VolumeImpl implements Volume {
private static final Logger log = Logger.getLogger(VolumeImpl.class);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java b/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java
index 7b29986..5cb5c32 100644
--- a/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java
+++ b/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java
@@ -1,4 +1,5 @@
package org.apache.accumulo.core.cli;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,12 +18,13 @@ package org.apache.accumulo.core.cli;
*/
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
public class TestHelp {
protected class HelpStub extends Help {
@Override
- public void parseArgs(String programName, String[] args, Object ... others) {
+ public void parseArgs(String programName, String[] args, Object... others) {
super.parseArgs(programName, args, others);
}
@@ -31,7 +33,7 @@ public class TestHelp {
throw new RuntimeException(Integer.toString(status));
}
}
-
+
@Test
public void testInvalidArgs() {
String[] args = {"foo"};
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
index a386c04..9a32c26 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
@@ -30,10 +30,10 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
/**
- *
+ *
*/
public class BatchWriterConfigTest {
-
+
@Test
public void testReasonableDefaults() {
long expectedMaxMemory = 50 * 1024 * 1024l;
@@ -41,7 +41,7 @@ public class BatchWriterConfigTest {
long expectedTimeout = Long.MAX_VALUE;
int expectedMaxWriteThreads = 3;
Durability expectedDurability = Durability.DEFAULT;
-
+
BatchWriterConfig defaults = new BatchWriterConfig();
assertEquals(expectedMaxMemory, defaults.getMaxMemory());
assertEquals(expectedMaxLatency, defaults.getMaxLatency(TimeUnit.MILLISECONDS));
@@ -49,7 +49,7 @@ public class BatchWriterConfigTest {
assertEquals(expectedMaxWriteThreads, defaults.getMaxWriteThreads());
assertEquals(expectedDurability, defaults.getDurability());
}
-
+
@Test
public void testOverridingDefaults() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
@@ -58,77 +58,77 @@ public class BatchWriterConfigTest {
bwConfig.setTimeout(33, TimeUnit.DAYS);
bwConfig.setMaxWriteThreads(42);
bwConfig.setDurability(Durability.NONE);
-
+
assertEquals(1123581321l, bwConfig.getMaxMemory());
assertEquals(22 * 60 * 60 * 1000l, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
assertEquals(33 * 24 * 60 * 60 * 1000l, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
assertEquals(42, bwConfig.getMaxWriteThreads());
assertEquals(Durability.NONE, bwConfig.getDurability());
}
-
+
@Test
public void testZeroValues() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxLatency(0, TimeUnit.MILLISECONDS);
bwConfig.setTimeout(0, TimeUnit.MILLISECONDS);
bwConfig.setMaxMemory(0);
-
+
assertEquals(Long.MAX_VALUE, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
assertEquals(Long.MAX_VALUE, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
assertEquals(0, bwConfig.getMaxMemory());
}
-
+
@Test(expected = IllegalArgumentException.class)
public void testNegativeMaxMemory() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxMemory(-1);
}
-
+
@Test(expected = IllegalArgumentException.class)
public void testNegativeMaxLatency() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxLatency(-1, TimeUnit.DAYS);
}
-
+
@Test
public void testTinyTimeConversions() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxLatency(999, TimeUnit.MICROSECONDS);
bwConfig.setTimeout(999, TimeUnit.MICROSECONDS);
-
+
assertEquals(1000, bwConfig.getMaxLatency(TimeUnit.MICROSECONDS));
assertEquals(1000, bwConfig.getTimeout(TimeUnit.MICROSECONDS));
assertEquals(1, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
assertEquals(1, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
-
+
bwConfig.setMaxLatency(10, TimeUnit.NANOSECONDS);
bwConfig.setTimeout(10, TimeUnit.NANOSECONDS);
-
+
assertEquals(1000000, bwConfig.getMaxLatency(TimeUnit.NANOSECONDS));
assertEquals(1000000, bwConfig.getTimeout(TimeUnit.NANOSECONDS));
assertEquals(1, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
assertEquals(1, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
-
+
}
-
+
@Test(expected = IllegalArgumentException.class)
public void testNegativeTimeout() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setTimeout(-1, TimeUnit.DAYS);
}
-
+
@Test(expected = IllegalArgumentException.class)
public void testZeroMaxWriteThreads() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxWriteThreads(0);
}
-
+
@Test(expected = IllegalArgumentException.class)
public void testNegativeMaxWriteThreads() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxWriteThreads(-1);
}
-
+
@Test
public void testSerialize() throws IOException {
// make sure we aren't testing defaults
@@ -138,7 +138,7 @@ public class BatchWriterConfigTest {
assertNotEquals(42, bwDefaults.getMaxWriteThreads());
assertNotEquals(1123581321l, bwDefaults.getMaxMemory());
assertNotEquals(Durability.FLUSH, bwDefaults.getDurability());
-
+
// test setting all fields
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxLatency(7654321l, TimeUnit.MILLISECONDS);
@@ -148,14 +148,14 @@ public class BatchWriterConfigTest {
bwConfig.setDurability(Durability.FLUSH);
byte[] bytes = createBytes(bwConfig);
checkBytes(bwConfig, bytes);
-
+
// test human-readable serialization
bwConfig = new BatchWriterConfig();
bwConfig.setMaxWriteThreads(42);
bytes = createBytes(bwConfig);
assertEquals(" i#maxWriteThreads=42", new String(bytes, UTF_8));
checkBytes(bwConfig, bytes);
-
+
// test human-readable with 2 fields
bwConfig = new BatchWriterConfig();
bwConfig.setMaxWriteThreads(24);
@@ -163,7 +163,7 @@ public class BatchWriterConfigTest {
bytes = createBytes(bwConfig);
assertEquals(" v#maxWriteThreads=24,timeout=3000", new String(bytes, UTF_8));
checkBytes(bwConfig, bytes);
-
+
// test human-readable durability
bwConfig = new BatchWriterConfig();
bwConfig.setDurability(Durability.LOG);
@@ -195,27 +195,27 @@ public class BatchWriterConfigTest {
cfg1.setTimeout(10, TimeUnit.SECONDS);
cfg2.setTimeout(10000, TimeUnit.MILLISECONDS);
-
+
assertEquals(cfg1, cfg2);
assertEquals(cfg1.hashCode(), cfg2.hashCode());
}
-
+
private byte[] createBytes(BatchWriterConfig bwConfig) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bwConfig.write(new DataOutputStream(baos));
return baos.toByteArray();
}
-
+
private void checkBytes(BatchWriterConfig bwConfig, byte[] bytes) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
BatchWriterConfig createdConfig = new BatchWriterConfig();
createdConfig.readFields(new DataInputStream(bais));
-
+
assertEquals(bwConfig.getMaxMemory(), createdConfig.getMaxMemory());
assertEquals(bwConfig.getMaxLatency(TimeUnit.MILLISECONDS), createdConfig.getMaxLatency(TimeUnit.MILLISECONDS));
assertEquals(bwConfig.getTimeout(TimeUnit.MILLISECONDS), createdConfig.getTimeout(TimeUnit.MILLISECONDS));
assertEquals(bwConfig.getMaxWriteThreads(), createdConfig.getMaxWriteThreads());
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/core/src/test/java/org/apache/accumulo/core/client/ClientSideIteratorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/ClientSideIteratorTest.java b/core/src/test/java/org/apache/accumulo/core/client/ClientSideIteratorTest.java
index 74fab9c..60f668b 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/ClientSideIteratorTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/ClientSideIteratorTest.java
@@ -53,7 +53,7 @@ public class ClientSideIteratorTest {
resultSet3.add(new Key("part1", "", "doc2"));
resultSet3.add(new Key("part2", "", "DOC2"));
}
-
+
public void checkResults(final Iterable<Entry<Key,Value>> scanner, final List<Key> results, final PartialKey pk) {
int i = 0;
for (Entry<Key,Value> entry : scanner) {
@@ -61,7 +61,7 @@ public class ClientSideIteratorTest {
}
assertEquals(i, results.size());
}
-
+
@Test
public void testIntersect() throws Exception {
Instance instance = new MockInstance("local");
@@ -83,15 +83,15 @@ public class ClientSideIteratorTest {
m.put("foo", "DOC3", "value");
bw.addMutation(m);
bw.flush();
-
+
final ClientSideIteratorScanner csis = new ClientSideIteratorScanner(conn.createScanner("intersect", new Authorizations()));
final IteratorSetting si = new IteratorSetting(10, "intersect", IntersectingIterator.class);
IntersectingIterator.setColumnFamilies(si, new Text[] {new Text("bar"), new Text("foo")});
csis.addScanIterator(si);
-
+
checkResults(csis, resultSet3, PartialKey.ROW_COLFAM_COLQUAL);
}
-
+
@Test
public void testVersioning() throws Exception {
final Instance instance = new MockInstance("local");
@@ -111,17 +111,17 @@ public class ClientSideIteratorTest {
m.put("colf", "colq", 4l, "value");
bw.addMutation(m);
bw.flush();
-
+
final Scanner scanner = conn.createScanner("table", new Authorizations());
-
+
final ClientSideIteratorScanner csis = new ClientSideIteratorScanner(scanner);
final IteratorSetting si = new IteratorSetting(10, "localvers", VersioningIterator.class);
si.addOption("maxVersions", "2");
csis.addScanIterator(si);
-
+
checkResults(csis, resultSet1, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
checkResults(scanner, resultSet2, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
-
+
csis.fetchColumnFamily(new Text("colf"));
checkResults(csis, resultSet1, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
csis.clearColumns();