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 2013/11/08 23:26:40 UTC
[2/2] git commit: ACCUMULO-1872 Remove compiler warnings
ACCUMULO-1872 Remove compiler warnings
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/7f403df2
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7f403df2
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7f403df2
Branch: refs/heads/1.5.1-SNAPSHOT
Commit: 7f403df24a29c57cc5d4758b4aa552c237b68fff
Parents: 422aaaa
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri Nov 8 17:17:50 2013 -0500
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri Nov 8 17:17:50 2013 -0500
----------------------------------------------------------------------
.../core/client/AccumuloSecurityException.java | 20 +-
.../accumulo/core/client/IteratorSetting.java | 61 ++--
.../core/client/MutationsRejectedException.java | 15 +-
.../core/client/admin/TableOperationsImpl.java | 313 ++++++++++---------
.../mapreduce/lib/util/ConfiguratorBase.java | 38 +--
.../core/client/mock/MockTableOperations.java | 80 ++---
.../core/client/security/tokens/NullToken.java | 23 +-
.../accumulo/core/security/Authorizations.java | 82 +++--
.../client/admin/TableOperationsHelperTest.java | 90 +++---
.../examples/simple/client/TracingExample.java | 201 ++++++------
.../minicluster/MiniAccumuloConfig.java | 28 +-
.../accumulo/server/client/HdfsZooInstance.java | 71 +++--
.../server/security/SecurityOperation.java | 199 ++++++------
.../server/tabletserver/log/DfsLogger.java | 138 ++++----
.../accumulo/server/trace/TraceFileSystem.java | 147 ++++-----
.../accumulo/test/randomwalk/FrameworkTest.java | 19 +-
16 files changed, 763 insertions(+), 762 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/client/AccumuloSecurityException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/AccumuloSecurityException.java b/core/src/main/java/org/apache/accumulo/core/client/AccumuloSecurityException.java
index 4c429e4..890db36 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/AccumuloSecurityException.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/AccumuloSecurityException.java
@@ -25,7 +25,7 @@ import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
*/
public class AccumuloSecurityException extends Exception {
private static final long serialVersionUID = 1L;
-
+
private static String getDefaultErrorMessage(final SecurityErrorCode errorcode) {
switch (errorcode) {
case BAD_CREDENTIALS:
@@ -61,17 +61,17 @@ public class AccumuloSecurityException extends Exception {
return "Unknown security exception";
}
}
-
+
private String user;
private SecurityErrorCode errorCode;
-
+
/**
* @return this exception as a thrift exception
*/
public ThriftSecurityException asThriftException() {
return new ThriftSecurityException(user, errorCode);
}
-
+
/**
* @param user
* the relevant user for the security violation
@@ -85,7 +85,7 @@ public class AccumuloSecurityException extends Exception {
this.user = user;
this.errorCode = errorcode == null ? SecurityErrorCode.DEFAULT_SECURITY_ERROR : errorcode;
}
-
+
/**
* @param user
* the relevant user for the security violation
@@ -97,18 +97,18 @@ public class AccumuloSecurityException extends Exception {
this.user = user;
this.errorCode = errorcode == null ? SecurityErrorCode.DEFAULT_SECURITY_ERROR : errorcode;
}
-
+
/**
* @return the relevant user for the security violation
*/
public String getUser() {
return user;
}
-
+
public void setUser(String s) {
this.user = s;
}
-
+
/**
* @return the specific reason for this exception
* @since 1.5.0
@@ -123,10 +123,12 @@ public class AccumuloSecurityException extends Exception {
*
* @deprecated since 1.5.0; Use {@link #getSecurityErrorCode()} instead.
*/
+ @Deprecated
public org.apache.accumulo.core.security.thrift.SecurityErrorCode getErrorCode() {
return org.apache.accumulo.core.security.thrift.SecurityErrorCode.valueOf(errorCode.name());
}
-
+
+ @Override
public String getMessage() {
return "Error " + errorCode + " for user " + user + " - " + super.getMessage();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java b/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
index 70a7e45..85e996a 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
@@ -52,7 +52,7 @@ public class IteratorSetting implements Writable {
private String name;
private String iteratorClass;
private Map<String,String> properties;
-
+
/**
* Get layer at which this iterator applies. See {@link #setPriority(int)} for how the priority is used.
*
@@ -61,7 +61,7 @@ public class IteratorSetting implements Writable {
public int getPriority() {
return priority;
}
-
+
/**
* Set layer at which this iterator applies.
*
@@ -73,7 +73,7 @@ public class IteratorSetting implements Writable {
ArgumentChecker.strictlyPositive(priority);
this.priority = priority;
}
-
+
/**
* Get the iterator's name.
*
@@ -82,7 +82,7 @@ public class IteratorSetting implements Writable {
public String getName() {
return name;
}
-
+
/**
* Set the iterator's name. Must be a simple alphanumeric identifier.
*
@@ -92,7 +92,7 @@ public class IteratorSetting implements Writable {
ArgumentChecker.notNull(name);
this.name = name;
}
-
+
/**
* Get the name of the class that implements the iterator.
*
@@ -101,7 +101,7 @@ public class IteratorSetting implements Writable {
public String getIteratorClass() {
return iteratorClass;
}
-
+
/**
* Set the name of the class that implements the iterator. The class does not have to be present on the client, but it must be available to all tablet
* servers.
@@ -112,7 +112,7 @@ public class IteratorSetting implements Writable {
ArgumentChecker.notNull(iteratorClass);
this.iteratorClass = iteratorClass;
}
-
+
/**
* Constructs an iterator setting configured for the scan scope with no parameters. (Parameters can be added later.)
*
@@ -126,7 +126,7 @@ public class IteratorSetting implements Writable {
public IteratorSetting(int priority, String name, String iteratorClass) {
this(priority, name, iteratorClass, new HashMap<String,String>());
}
-
+
/**
* Constructs an iterator setting configured for the specified scopes with the specified parameters.
*
@@ -146,7 +146,7 @@ public class IteratorSetting implements Writable {
this.properties = new HashMap<String,String>();
addOptions(properties);
}
-
+
/**
* Constructs an iterator setting using the given class's SimpleName for the iterator name. The iterator setting will be configured for the scan scope with no
* parameters.
@@ -159,7 +159,7 @@ public class IteratorSetting implements Writable {
public IteratorSetting(int priority, Class<? extends SortedKeyValueIterator<Key,Value>> iteratorClass) {
this(priority, iteratorClass.getSimpleName(), iteratorClass.getName());
}
-
+
/**
*
* Constructs an iterator setting using the given class's SimpleName for the iterator name and configured for the specified scopes with the specified
@@ -175,7 +175,7 @@ public class IteratorSetting implements Writable {
public IteratorSetting(int priority, Class<? extends SortedKeyValueIterator<Key,Value>> iteratorClass, Map<String,String> properties) {
this(priority, iteratorClass.getSimpleName(), iteratorClass.getName(), properties);
}
-
+
/**
* Constructs an iterator setting configured for the scan scope with no parameters.
*
@@ -189,7 +189,7 @@ public class IteratorSetting implements Writable {
public IteratorSetting(int priority, String name, Class<? extends SortedKeyValueIterator<Key,Value>> iteratorClass) {
this(priority, name, iteratorClass.getName());
}
-
+
/**
* @since 1.5.0
*/
@@ -210,7 +210,7 @@ public class IteratorSetting implements Writable {
ArgumentChecker.notNull(option, value);
properties.put(option, value);
}
-
+
/**
* Remove an option from the iterator.
*
@@ -222,7 +222,7 @@ public class IteratorSetting implements Writable {
ArgumentChecker.notNull(option);
return properties.remove(option);
}
-
+
/**
* Add many options to the iterator.
*
@@ -235,7 +235,7 @@ public class IteratorSetting implements Writable {
addOption(keyValue.getKey(), keyValue.getValue());
}
}
-
+
/**
* Add many options to the iterator.
*
@@ -246,7 +246,7 @@ public class IteratorSetting implements Writable {
ArgumentChecker.notNull(properties);
addOptions(properties.entrySet());
}
-
+
/**
* Get the configuration parameters for this iterator.
*
@@ -255,14 +255,14 @@ public class IteratorSetting implements Writable {
public Map<String,String> getOptions() {
return Collections.unmodifiableMap(properties);
}
-
+
/**
* Remove all options from the iterator.
*/
public void clearOptions() {
properties.clear();
}
-
+
/**
* @see java.lang.Object#hashCode()
*/
@@ -276,10 +276,7 @@ public class IteratorSetting implements Writable {
result = prime * result + ((properties == null) ? 0 : properties.hashCode());
return result;
}
-
- /**
- * @see java.lang.Object#equals()
- */
+
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -325,38 +322,38 @@ public class IteratorSetting implements Writable {
sb.append(properties);
return sb.toString();
}
-
+
/**
* A convenience class for passing column family and column qualifiers to iterator configuration methods.
*/
public static class Column extends Pair<Text,Text> {
-
+
public Column(Text columnFamily, Text columnQualifier) {
super(columnFamily, columnQualifier);
}
-
+
public Column(Text columnFamily) {
super(columnFamily, null);
}
-
+
public Column(String columnFamily, String columnQualifier) {
super(new Text(columnFamily), new Text(columnQualifier));
}
-
+
public Column(String columnFamily) {
super(new Text(columnFamily), null);
}
-
+
public Text getColumnFamily() {
return getFirst();
}
-
+
public Text getColumnQualifier() {
return getSecond();
}
-
+
}
-
+
/**
* @since 1.5.0
*/
@@ -372,7 +369,7 @@ public class IteratorSetting implements Writable {
size--;
}
}
-
+
/**
* @since 1.5.0
*/
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java b/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
index 25fc43c..03b914c 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java
@@ -33,12 +33,12 @@ import org.apache.accumulo.core.data.KeyExtent;
*/
public class MutationsRejectedException extends AccumuloException {
private static final long serialVersionUID = 1L;
-
+
private List<ConstraintViolationSummary> cvsl;
private Map<KeyExtent,Set<SecurityErrorCode>> af;
private Collection<String> es;
private int unknownErrors;
-
+
/**
* @param cvsList
* list of constraint violations
@@ -58,22 +58,23 @@ public class MutationsRejectedException extends AccumuloException {
this.es = serverSideErrors;
this.unknownErrors = unknownErrors;
}
-
+
/**
* @return the internal list of constraint violations
*/
public List<ConstraintViolationSummary> getConstraintViolationSummaries() {
return cvsl;
}
-
+
/**
* @return the internal list of authorization failures
* @deprecated since 1.5, see {@link #getAuthorizationFailuresMap()}
*/
+ @Deprecated
public List<KeyExtent> getAuthorizationFailures() {
return new ArrayList<KeyExtent>(af.keySet());
}
-
+
/**
* @return the internal mapping of keyextent mappings to SecurityErrorCode
* @since 1.5.0
@@ -81,7 +82,7 @@ public class MutationsRejectedException extends AccumuloException {
public Map<KeyExtent,Set<SecurityErrorCode>> getAuthorizationFailuresMap() {
return af;
}
-
+
/**
*
* @return A list of servers that had internal errors when mutations were written
@@ -90,7 +91,7 @@ public class MutationsRejectedException extends AccumuloException {
public Collection<String> getErrorServers() {
return es;
}
-
+
/**
*
* @return a count of unknown exceptions that occurred during processing
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
index 3aca348..cdb813a 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
@@ -112,11 +112,11 @@ import org.apache.thrift.transport.TTransportException;
public class TableOperationsImpl extends TableOperationsHelper {
private Instance instance;
private TCredentials credentials;
-
+
public static final String CLONE_EXCLUDE_PREFIX = "!";
private static final Logger log = Logger.getLogger(TableOperations.class);
-
+
/**
* @param instance
* the connection information for this instance
@@ -128,7 +128,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
this.instance = instance;
this.credentials = credentials;
}
-
+
/**
* Retrieve a list of tables in Accumulo.
*
@@ -141,7 +141,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
opTimer.stop("Fetched " + tableNames.size() + " table names in %DURATION%");
return tableNames;
}
-
+
/**
* A method to check if a table exists in Accumulo.
*
@@ -154,13 +154,13 @@ public class TableOperationsImpl extends TableOperationsHelper {
ArgumentChecker.notNull(tableName);
if (tableName.equals(Constants.METADATA_TABLE_NAME))
return true;
-
+
OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Checking if table " + tableName + "exists...");
boolean exists = Tables.getNameToIdMap(instance).containsKey(tableName);
opTimer.stop("Checked existance of " + exists + " in %DURATION%");
return exists;
}
-
+
/**
* Create a table with no special configuration
*
@@ -177,7 +177,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException {
create(tableName, true, TimeType.MILLIS);
}
-
+
/**
* @param tableName
* the name of the table
@@ -188,7 +188,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void create(String tableName, boolean limitVersion) throws AccumuloException, AccumuloSecurityException, TableExistsException {
create(tableName, limitVersion, TimeType.MILLIS);
}
-
+
/**
* @param tableName
* the name of the table
@@ -200,11 +200,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
@Override
public void create(String tableName, boolean limitVersion, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException {
ArgumentChecker.notNull(tableName, timeType);
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(timeType.name().getBytes()));
-
+
Map<String,String> opts = IteratorUtil.generateInitialTableProperties(limitVersion);
-
+
try {
doTableOperation(TableOperation.CREATE, args, opts);
} catch (TableNotFoundException e1) {
@@ -212,7 +212,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new RuntimeException(e1);
}
}
-
+
private long beginTableOperation() throws ThriftSecurityException, TException {
while (true) {
MasterClientService.Iface client = null;
@@ -227,7 +227,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
}
}
-
+
private void executeTableOperation(long opid, TableOperation op, List<ByteBuffer> args, Map<String,String> opts, boolean autoCleanUp)
throws ThriftSecurityException, TException, ThriftTableOperationException {
while (true) {
@@ -244,7 +244,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
}
}
-
+
private String waitForTableOperation(long opid) throws ThriftSecurityException, TException, ThriftTableOperationException {
while (true) {
MasterClientService.Iface client = null;
@@ -259,7 +259,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
}
}
-
+
private void finishTableOperation(long opid) throws ThriftSecurityException, TException {
while (true) {
MasterClientService.Iface client = null;
@@ -275,16 +275,16 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
}
}
-
+
private String doTableOperation(TableOperation op, List<ByteBuffer> args, Map<String,String> opts) throws AccumuloSecurityException, TableExistsException,
TableNotFoundException, AccumuloException {
return doTableOperation(op, args, opts, true);
}
-
+
private String doTableOperation(TableOperation op, List<ByteBuffer> args, Map<String,String> opts, boolean wait) throws AccumuloSecurityException,
TableExistsException, TableNotFoundException, AccumuloException {
Long opid = null;
-
+
try {
opid = beginTableOperation();
executeTableOperation(opid, op, args, opts, !wait);
@@ -321,14 +321,14 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
}
}
-
+
private static class SplitEnv {
private String tableName;
private String tableId;
private ExecutorService executor;
private CountDownLatch latch;
private AtomicReference<Exception> exception;
-
+
SplitEnv(String tableName, String tableId, ExecutorService executor, CountDownLatch latch, AtomicReference<Exception> exception) {
this.tableName = tableName;
this.tableId = tableId;
@@ -337,47 +337,47 @@ public class TableOperationsImpl extends TableOperationsHelper {
this.exception = exception;
}
}
-
+
private class SplitTask implements Runnable {
-
+
private List<Text> splits;
private SplitEnv env;
-
+
SplitTask(SplitEnv env, List<Text> splits) {
this.env = env;
this.splits = splits;
}
-
+
@Override
public void run() {
try {
if (env.exception.get() != null)
return;
-
+
if (splits.size() <= 2) {
addSplits(env.tableName, new TreeSet<Text>(splits), env.tableId);
for (int i = 0; i < splits.size(); i++)
env.latch.countDown();
return;
}
-
+
int mid = splits.size() / 2;
-
+
// split the middle split point to ensure that child task split different tablets and can therefore
// run in parallel
addSplits(env.tableName, new TreeSet<Text>(splits.subList(mid, mid + 1)), env.tableId);
env.latch.countDown();
-
+
env.executor.submit(new SplitTask(env, splits.subList(0, mid)));
env.executor.submit(new SplitTask(env, splits.subList(mid + 1, splits.size())));
-
+
} catch (Exception e) {
env.exception.compareAndSet(null, e);
}
}
-
+
}
-
+
/**
* @param tableName
* the name of the table
@@ -393,19 +393,19 @@ public class TableOperationsImpl extends TableOperationsHelper {
@Override
public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
String tableId = Tables.getTableId(instance, tableName);
-
+
List<Text> splits = new ArrayList<Text>(partitionKeys);
// should be sorted because we copied from a sorted set, but that makes assumptions about
// how the copy was done so resort to be sure.
Collections.sort(splits);
-
+
CountDownLatch latch = new CountDownLatch(splits.size());
AtomicReference<Exception> exception = new AtomicReference<Exception>(null);
-
+
ExecutorService executor = Executors.newFixedThreadPool(16, new NamingThreadFactory("addSplits"));
try {
executor.submit(new SplitTask(new SplitEnv(tableName, tableId, executor, latch, exception), splits));
-
+
while (!latch.await(100, TimeUnit.MILLISECONDS)) {
if (exception.get() != null) {
executor.shutdownNow();
@@ -428,24 +428,24 @@ public class TableOperationsImpl extends TableOperationsHelper {
executor.shutdown();
}
}
-
+
private void addSplits(String tableName, SortedSet<Text> partitionKeys, String tableId) throws AccumuloException, AccumuloSecurityException,
TableNotFoundException, AccumuloServerException {
TabletLocator tabLocator = TabletLocator.getInstance(instance, new Text(tableId));
-
+
for (Text split : partitionKeys) {
boolean successful = false;
int attempt = 0;
-
+
while (!successful) {
-
+
if (attempt > 0)
UtilWaitThread.sleep(100);
-
+
attempt++;
-
+
TabletLocation tl = tabLocator.locateTablet(split, false, false, credentials);
-
+
if (tl == null) {
if (!Tables.exists(instance, tableId))
throw new TableNotFoundException(tableId, tableName, null);
@@ -453,25 +453,25 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new TableOfflineException(instance, tableId);
continue;
}
-
+
try {
TabletClientService.Client client = ThriftUtil.getTServerClient(tl.tablet_location, instance.getConfiguration());
try {
OpTimer opTimer = null;
if (log.isTraceEnabled())
opTimer = new OpTimer(log, Level.TRACE).start("Splitting tablet " + tl.tablet_extent + " on " + tl.tablet_location + " at " + split);
-
+
client.splitTablet(Tracer.traceInfo(), credentials, tl.tablet_extent.toThrift(), TextUtil.getByteBuffer(split));
-
+
// just split it, might as well invalidate it in the cache
tabLocator.invalidateCache(tl.tablet_extent);
-
+
if (opTimer != null)
opTimer.stop("Split tablet in %DURATION%");
} finally {
ThriftUtil.returnClient(client);
}
-
+
} catch (TApplicationException tae) {
throw new AccumuloServerException(tl.tablet_location, tae);
} catch (TTransportException e) {
@@ -489,15 +489,15 @@ public class TableOperationsImpl extends TableOperationsHelper {
tabLocator.invalidateCache(tl.tablet_location);
continue;
}
-
+
successful = true;
}
}
}
-
+
@Override
public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
-
+
ArgumentChecker.notNull(tableName);
ByteBuffer EMPTY = ByteBuffer.allocate(0);
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
@@ -510,10 +510,10 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new RuntimeException(e);
}
}
-
+
@Override
public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
-
+
ArgumentChecker.notNull(tableName);
ByteBuffer EMPTY = ByteBuffer.allocate(0);
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
@@ -526,7 +526,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new RuntimeException(e);
}
}
-
+
/**
* @param tableName
* the name of the table
@@ -534,11 +534,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
*/
@Override
public Collection<Text> listSplits(String tableName) throws TableNotFoundException, AccumuloSecurityException {
-
+
ArgumentChecker.notNull(tableName);
-
+
String tableId = Tables.getTableId(instance, tableName);
-
+
SortedSet<KeyExtent> tablets = new TreeSet<KeyExtent>();
Map<KeyExtent,String> locations = new TreeMap<KeyExtent,String>();
@@ -564,16 +564,17 @@ public class TableOperationsImpl extends TableOperationsHelper {
UtilWaitThread.sleep(3000);
}
}
-
+
ArrayList<Text> endRows = new ArrayList<Text>(tablets.size());
-
+
for (KeyExtent ke : tablets)
if (ke.getEndRow() != null)
endRows.add(ke.getEndRow());
-
+
return endRows;
}
-
+
+ @Deprecated
@Override
public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
try {
@@ -594,15 +595,15 @@ public class TableOperationsImpl extends TableOperationsHelper {
@Override
public Collection<Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException, AccumuloSecurityException {
Collection<Text> endRows = listSplits(tableName);
-
+
if (endRows.size() <= maxSplits)
return endRows;
-
+
double r = (maxSplits + 1) / (double) (endRows.size());
double pos = 0;
-
+
ArrayList<Text> subset = new ArrayList<Text>(maxSplits);
-
+
int j = 0;
for (int i = 0; i < endRows.size() && j < maxSplits; i++) {
pos += r;
@@ -612,10 +613,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
pos -= 1;
}
}
-
+
return subset;
}
-
+
+ @Deprecated
@Override
public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
try {
@@ -640,39 +642,39 @@ public class TableOperationsImpl extends TableOperationsHelper {
@Override
public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
ArgumentChecker.notNull(tableName);
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()));
Map<String,String> opts = new HashMap<String,String>();
-
+
try {
doTableOperation(TableOperation.DELETE, args, opts);
} catch (TableExistsException e) {
// should not happen
throw new RuntimeException(e);
}
-
+
}
-
+
@Override
public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException {
-
+
ArgumentChecker.notNull(srcTableName, newTableName);
-
+
String srcTableId = Tables.getTableId(instance, srcTableName);
-
+
if (flush)
_flush(srcTableId, null, null, true);
-
+
if (propertiesToExclude == null)
propertiesToExclude = Collections.emptySet();
-
+
if (propertiesToSet == null)
propertiesToSet = Collections.emptyMap();
-
+
if (!Collections.disjoint(propertiesToExclude, propertiesToSet.keySet()))
throw new IllegalArgumentException("propertiesToSet and propertiesToExclude not disjoint");
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(srcTableId.getBytes()), ByteBuffer.wrap(newTableName.getBytes()));
Map<String,String> opts = new HashMap<String,String>();
for (Entry<String,String> entry : propertiesToSet.entrySet()) {
@@ -680,14 +682,14 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new IllegalArgumentException("Property can not start with " + CLONE_EXCLUDE_PREFIX);
opts.put(entry.getKey(), entry.getValue());
}
-
+
for (String prop : propertiesToExclude) {
opts.put(CLONE_EXCLUDE_PREFIX + prop, "");
}
-
+
doTableOperation(TableOperation.CLONE, args, opts);
}
-
+
/**
* Rename a table
*
@@ -707,12 +709,12 @@ public class TableOperationsImpl extends TableOperationsHelper {
@Override
public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
TableExistsException {
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(oldTableName.getBytes()), ByteBuffer.wrap(newTableName.getBytes()));
Map<String,String> opts = new HashMap<String,String>();
doTableOperation(TableOperation.RENAME, args, opts);
}
-
+
/**
* @deprecated since 1.4 {@link #flush(String, Text, Text, boolean)}
*/
@@ -725,7 +727,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new AccumuloException(e.getMessage(), e);
}
}
-
+
/**
* Flush a table
*
@@ -740,31 +742,31 @@ public class TableOperationsImpl extends TableOperationsHelper {
@Override
public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
ArgumentChecker.notNull(tableName);
-
+
String tableId = Tables.getTableId(instance, tableName);
_flush(tableId, start, end, wait);
}
-
+
@Override
public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException,
AccumuloException {
compact(tableName, start, end, new ArrayList<IteratorSetting>(), flush, wait);
}
-
+
@Override
public void compact(String tableName, Text start, Text end, List<IteratorSetting> iterators, boolean flush, boolean wait) throws AccumuloSecurityException,
TableNotFoundException, AccumuloException {
ArgumentChecker.notNull(tableName);
ByteBuffer EMPTY = ByteBuffer.allocate(0);
-
+
String tableId = Tables.getTableId(instance, tableName);
-
+
if (flush)
_flush(tableId, start, end, true);
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes()), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
: TextUtil.getByteBuffer(end), ByteBuffer.wrap(IteratorUtil.encodeIteratorSettings(iterators)));
-
+
Map<String,String> opts = new HashMap<String,String>();
try {
doTableOperation(TableOperation.COMPACT, args, opts, wait);
@@ -773,13 +775,13 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new RuntimeException(e);
}
}
-
+
@Override
public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
String tableId = Tables.getTableId(instance, tableName);
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes()));
-
+
Map<String,String> opts = new HashMap<String,String>();
try {
doTableOperation(TableOperation.COMPACT_CANCEL, args, opts, true);
@@ -787,17 +789,17 @@ public class TableOperationsImpl extends TableOperationsHelper {
// should not happen
throw new RuntimeException(e);
}
-
+
}
-
+
private void _flush(String tableId, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
-
+
try {
long flushID;
-
+
// used to pass the table name. but the tableid associated with a table name could change between calls.
// so pass the tableid to both calls
-
+
while (true) {
MasterClientService.Iface client = null;
try {
@@ -811,7 +813,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
MasterClient.close(client);
}
}
-
+
while (true) {
MasterClientService.Iface client = null;
try {
@@ -844,7 +846,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new AccumuloException(e);
}
}
-
+
/**
* Sets a property on a table
*
@@ -869,7 +871,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
});
}
-
+
/**
* Removes a property from a table
*
@@ -892,7 +894,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
});
}
-
+
/**
* Gets properties of a table
*
@@ -925,9 +927,9 @@ public class TableOperationsImpl extends TableOperationsHelper {
} catch (Exception e) {
throw new AccumuloException(e);
}
-
+
}
-
+
/**
* Sets a tables locality groups. A tables locality groups can be changed at any time.
*
@@ -947,22 +949,22 @@ public class TableOperationsImpl extends TableOperationsHelper {
// ensure locality groups do not overlap
HashSet<Text> all = new HashSet<Text>();
for (Entry<String,Set<Text>> entry : groups.entrySet()) {
-
+
if (!Collections.disjoint(all, entry.getValue())) {
throw new IllegalArgumentException("Group " + entry.getKey() + " overlaps with another group");
}
-
+
all.addAll(entry.getValue());
}
-
+
for (Entry<String,Set<Text>> entry : groups.entrySet()) {
Set<Text> colFams = entry.getValue();
String value = LocalityGroupUtil.encodeColumnFamilies(colFams);
setProperty(tableName, Property.TABLE_LOCALITY_GROUP_PREFIX + entry.getKey(), value);
}
-
+
setProperty(tableName, Property.TABLE_LOCALITY_GROUPS.getKey(), StringUtil.join(groups.keySet(), ","));
-
+
// remove anything extraneous
String prefix = Property.TABLE_LOCALITY_GROUP_PREFIX.getKey();
for (Entry<String,String> entry : getProperties(tableName)) {
@@ -972,14 +974,14 @@ public class TableOperationsImpl extends TableOperationsHelper {
// one:
String[] parts = property.split("\\.");
String group = parts[parts.length - 1];
-
+
if (!groups.containsKey(group)) {
removeProperty(tableName, property);
}
}
}
}
-
+
/**
*
* Gets the locality groups currently set for a table.
@@ -996,22 +998,22 @@ public class TableOperationsImpl extends TableOperationsHelper {
public Map<String,Set<Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException {
AccumuloConfiguration conf = new ConfigurationCopy(this.getProperties(tableName));
Map<String,Set<ByteSequence>> groups = LocalityGroupUtil.getLocalityGroups(conf);
-
+
Map<String,Set<Text>> groups2 = new HashMap<String,Set<Text>>();
for (Entry<String,Set<ByteSequence>> entry : groups.entrySet()) {
-
+
HashSet<Text> colFams = new HashSet<Text>();
-
+
for (ByteSequence bs : entry.getValue()) {
colFams.add(new Text(bs.toArray()));
}
-
+
groups2.put(entry.getKey(), colFams);
}
-
+
return groups2;
}
-
+
/**
* @param tableName
* the name of the table
@@ -1035,7 +1037,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new IllegalArgumentException("maximum splits must be >= 1");
if (maxSplits == 1)
return Collections.singleton(range);
-
+
Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<String,Map<KeyExtent,List<Range>>>();
String tableId = Tables.getTableId(instance, tableName);
TabletLocator tl = TabletLocator.getInstance(instance, new Text(tableId));
@@ -1046,24 +1048,24 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new TableDeletedException(tableId);
if (Tables.getTableState(instance, tableId) == TableState.OFFLINE)
throw new TableOfflineException(instance, tableId);
-
+
log.warn("Unable to locate bins for specified range. Retrying.");
// sleep randomly between 100 and 200ms
UtilWaitThread.sleep(100 + (int) (Math.random() * 100));
binnedRanges.clear();
tl.invalidateCache();
}
-
+
// group key extents to get <= maxSplits
LinkedList<KeyExtent> unmergedExtents = new LinkedList<KeyExtent>();
List<KeyExtent> mergedExtents = new ArrayList<KeyExtent>();
-
+
for (Map<KeyExtent,List<Range>> map : binnedRanges.values())
unmergedExtents.addAll(map.keySet());
-
+
// the sort method is efficient for linked list
Collections.sort(unmergedExtents);
-
+
while (unmergedExtents.size() + mergedExtents.size() > maxSplits) {
if (unmergedExtents.size() >= 2) {
KeyExtent first = unmergedExtents.removeFirst();
@@ -1076,18 +1078,18 @@ public class TableOperationsImpl extends TableOperationsHelper {
unmergedExtents.addAll(mergedExtents);
mergedExtents.clear();
}
-
+
}
-
+
mergedExtents.addAll(unmergedExtents);
-
+
Set<Range> ranges = new HashSet<Range>();
for (KeyExtent k : mergedExtents)
ranges.add(k.toDataRange().clip(range));
-
+
return ranges;
}
-
+
@Override
public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws IOException, AccumuloSecurityException,
TableNotFoundException, AccumuloException {
@@ -1109,7 +1111,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(dirPath.toString().getBytes()),
ByteBuffer.wrap(failPath.toString().getBytes()), ByteBuffer.wrap((setTime + "").getBytes()));
Map<String,String> opts = new HashMap<String,String>();
-
+
try {
doTableOperation(TableOperation.BULK_IMPORT, args, opts);
} catch (TableExistsException e) {
@@ -1119,7 +1121,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
// return new BulkImportHelper(instance, credentials, tableName).importDirectory(new Path(dir), new Path(failureDir), numThreads, numAssignThreads,
// disableGC);
}
-
+
/**
*
* @param tableName
@@ -1132,11 +1134,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
*/
@Override
public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
-
+
ArgumentChecker.notNull(tableName);
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()));
Map<String,String> opts = new HashMap<String,String>();
-
+
try {
doTableOperation(TableOperation.OFFLINE, args, opts);
} catch (TableExistsException e) {
@@ -1144,7 +1146,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new RuntimeException(e);
}
}
-
+
/**
*
* @param tableName
@@ -1160,7 +1162,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
ArgumentChecker.notNull(tableName);
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()));
Map<String,String> opts = new HashMap<String,String>();
-
+
try {
doTableOperation(TableOperation.ONLINE, args, opts);
} catch (TableExistsException e) {
@@ -1168,7 +1170,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new RuntimeException(e);
}
}
-
+
/**
* Clears the tablet locator cache for a specified table
*
@@ -1183,7 +1185,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
TabletLocator tabLocator = TabletLocator.getInstance(instance, new Text(Tables.getTableId(instance, tableName)));
tabLocator.invalidateCache();
}
-
+
/**
* Get a mapping of table name to internal table id.
*
@@ -1193,7 +1195,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public Map<String,String> tableIdMap() {
return Tables.getNameToIdMap(instance);
}
-
+
@Override
public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive)
throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
@@ -1201,10 +1203,10 @@ public class TableOperationsImpl extends TableOperationsHelper {
Scanner scanner = instance.getConnector(credentials.getPrincipal(), CredentialHelper.extractToken(credentials)).createScanner(tableName, auths);
return FindMax.findMax(scanner, startRow, startInclusive, endRow, endInclusive);
}
-
+
public static Map<String,String> getExportedProps(FileSystem fs, Path path) throws IOException {
HashMap<String,String> props = new HashMap<String,String>();
-
+
ZipInputStream zis = new ZipInputStream(fs.open(path));
try {
ZipEntry zipEntry;
@@ -1216,7 +1218,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
String sa[] = line.split("=", 2);
props.put(sa[0], sa[1]);
}
-
+
break;
}
}
@@ -1225,48 +1227,48 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
return props;
}
-
+
@Override
public void importTable(String tableName, String importDir) throws TableExistsException, AccumuloException, AccumuloSecurityException {
ArgumentChecker.notNull(tableName, importDir);
-
+
try {
FileSystem fs = FileUtil.getFileSystem(CachedConfiguration.getInstance(), instance.getConfiguration());
;
Map<String,String> props = getExportedProps(fs, new Path(importDir, Constants.EXPORT_FILE));
-
+
for (String propKey : props.keySet()) {
if (Property.isClassProperty(propKey) && !props.get(propKey).contains(Constants.CORE_PACKAGE_NAME)) {
Logger.getLogger(this.getClass()).info(
"Imported table sets '" + propKey + "' to '" + props.get(propKey) + "'. Ensure this class is on Accumulo classpath.");
}
}
-
+
} catch (IOException ioe) {
Logger.getLogger(this.getClass()).warn("Failed to check if imported table references external java classes : " + ioe.getMessage());
}
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(importDir.getBytes()));
-
+
Map<String,String> opts = Collections.emptyMap();
-
+
try {
doTableOperation(TableOperation.IMPORT, args, opts);
} catch (TableNotFoundException e1) {
// should not happen
throw new RuntimeException(e1);
}
-
+
}
-
+
@Override
public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
ArgumentChecker.notNull(tableName, exportDir);
-
+
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(exportDir.getBytes()));
-
+
Map<String,String> opts = Collections.emptyMap();
-
+
try {
doTableOperation(TableOperation.EXPORT, args, opts);
} catch (TableExistsException e1) {
@@ -1274,12 +1276,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new RuntimeException(e1);
}
}
-
+
@Override
public boolean testClassLoad(final String tableName, final String className, final String asTypeName) throws TableNotFoundException, AccumuloException,
AccumuloSecurityException {
ArgumentChecker.notNull(tableName, className, asTypeName);
-
try {
return ServerClient.executeRaw(instance, new ClientExecReturn<Boolean,ClientService.Client>() {
@@ -1304,14 +1305,14 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new AccumuloException(e);
}
}
-
+
@Override
public void attachIterator(String tableName, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
TableNotFoundException {
testClassLoad(tableName, setting.getIteratorClass(), SortedKeyValueIterator.class.getName());
super.attachIterator(tableName, setting, scopes);
}
-
+
@Override
public int addConstraint(String tableName, String constraintClassName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
testClassLoad(tableName, constraintClassName, Constraint.class.getName());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
index dceabec..ab99f56 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
@@ -35,16 +35,16 @@ import org.apache.log4j.Logger;
* @since 1.5.0
*/
public class ConfiguratorBase {
-
+
/**
- * Configuration keys for {@link Instance#getConnector(String, byte[])}.
+ * Configuration keys for {@link Instance#getConnector(String, AuthenticationToken)}.
*
* @since 1.5.0
*/
public static enum ConnectorInfo {
IS_CONFIGURED, PRINCIPAL, TOKEN, TOKEN_CLASS
}
-
+
/**
* Configuration keys for {@link Instance}, {@link ZooKeeperInstance}, and {@link MockInstance}.
*
@@ -53,7 +53,7 @@ public class ConfiguratorBase {
protected static enum InstanceOpts {
TYPE, NAME, ZOO_KEEPERS;
}
-
+
/**
* Configuration keys for general configuration options.
*
@@ -62,7 +62,7 @@ public class ConfiguratorBase {
protected static enum GeneralOpts {
LOG_LEVEL
}
-
+
/**
* Provides a configuration key for a given feature enum, prefixed by the implementingClass
*
@@ -76,7 +76,7 @@ public class ConfiguratorBase {
protected static String enumToConfKey(Class<?> implementingClass, Enum<?> e) {
return implementingClass.getSimpleName() + "." + e.getDeclaringClass().getSimpleName() + "." + StringUtils.camelize(e.name().toLowerCase());
}
-
+
/**
* Sets the connector information needed to communicate with Accumulo in this job.
*
@@ -99,14 +99,14 @@ public class ConfiguratorBase {
throws AccumuloSecurityException {
if (isConnectorInfoSet(implementingClass, conf))
throw new IllegalStateException("Connector info for " + implementingClass.getSimpleName() + " can only be set once per job");
-
+
ArgumentChecker.notNull(principal, token);
conf.setBoolean(enumToConfKey(implementingClass, ConnectorInfo.IS_CONFIGURED), true);
conf.set(enumToConfKey(implementingClass, ConnectorInfo.PRINCIPAL), principal);
conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN_CLASS), token.getClass().getCanonicalName());
conf.set(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), CredentialHelper.tokenAsBase64(token));
}
-
+
/**
* Determines if the connector info has already been set for this instance.
*
@@ -121,7 +121,7 @@ public class ConfiguratorBase {
public static Boolean isConnectorInfoSet(Class<?> implementingClass, Configuration conf) {
return conf.getBoolean(enumToConfKey(implementingClass, ConnectorInfo.IS_CONFIGURED), false);
}
-
+
/**
* Gets the user name from the configuration.
*
@@ -136,7 +136,7 @@ public class ConfiguratorBase {
public static String getPrincipal(Class<?> implementingClass, Configuration conf) {
return conf.get(enumToConfKey(implementingClass, ConnectorInfo.PRINCIPAL));
}
-
+
/**
* Gets the serialized token class from the configuration.
*
@@ -151,7 +151,7 @@ public class ConfiguratorBase {
public static String getTokenClass(Class<?> implementingClass, Configuration conf) {
return conf.get(enumToConfKey(implementingClass, ConnectorInfo.TOKEN_CLASS));
}
-
+
/**
* Gets the password from the configuration. WARNING: The password is stored in the Configuration and shared with all MapReduce tasks; It is BASE64 encoded to
* provide a charset safe conversion to a string, and is not intended to be secure.
@@ -167,7 +167,7 @@ public class ConfiguratorBase {
public static byte[] getToken(Class<?> implementingClass, Configuration conf) {
return Base64.decodeBase64(conf.get(enumToConfKey(implementingClass, ConnectorInfo.TOKEN), "").getBytes(Charset.forName("UTF-8")));
}
-
+
/**
* Configures a {@link ZooKeeperInstance} for this job.
*
@@ -186,12 +186,12 @@ public class ConfiguratorBase {
if (!conf.get(key, "").isEmpty())
throw new IllegalStateException("Instance info can only be set once per job; it has already been configured with " + conf.get(key));
conf.set(key, "ZooKeeperInstance");
-
+
ArgumentChecker.notNull(instanceName, zooKeepers);
conf.set(enumToConfKey(implementingClass, InstanceOpts.NAME), instanceName);
conf.set(enumToConfKey(implementingClass, InstanceOpts.ZOO_KEEPERS), zooKeepers);
}
-
+
/**
* Configures a {@link MockInstance} for this job.
*
@@ -208,11 +208,11 @@ public class ConfiguratorBase {
if (!conf.get(key, "").isEmpty())
throw new IllegalStateException("Instance info can only be set once per job; it has already been configured with " + conf.get(key));
conf.set(key, "MockInstance");
-
+
ArgumentChecker.notNull(instanceName);
conf.set(enumToConfKey(implementingClass, InstanceOpts.NAME), instanceName);
}
-
+
/**
* Initializes an Accumulo {@link Instance} based on the configuration.
*
@@ -237,7 +237,7 @@ public class ConfiguratorBase {
else
throw new IllegalStateException("Unrecognized instance type " + instanceType);
}
-
+
/**
* Sets the log level for this job.
*
@@ -254,7 +254,7 @@ public class ConfiguratorBase {
Logger.getLogger(implementingClass).setLevel(level);
conf.setInt(enumToConfKey(implementingClass, GeneralOpts.LOG_LEVEL), level.toInt());
}
-
+
/**
* Gets the log level from this configuration.
*
@@ -269,5 +269,5 @@ public class ConfiguratorBase {
public static Level getLogLevel(Class<?> implementingClass, Configuration conf) {
return Level.toLevel(conf.getInt(enumToConfKey(implementingClass, GeneralOpts.LOG_LEVEL), Level.INFO.toInt()));
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
index ec11335..f088b1f 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
@@ -55,25 +55,25 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
public class MockTableOperations extends TableOperationsHelper {
-
+
final private MockAccumulo acu;
final private String username;
-
+
MockTableOperations(MockAccumulo acu, String username) {
this.acu = acu;
this.username = username;
}
-
+
@Override
public SortedSet<String> list() {
return new TreeSet<String>(acu.tables.keySet());
}
-
+
@Override
public boolean exists(String tableName) {
return acu.tables.containsKey(tableName);
}
-
+
@Override
public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException {
if (!tableName.matches(Constants.VALID_TABLE_NAME_REGEX)) {
@@ -81,12 +81,12 @@ public class MockTableOperations extends TableOperationsHelper {
}
create(tableName, true, TimeType.MILLIS);
}
-
+
@Override
public void create(String tableName, boolean versioningIter) throws AccumuloException, AccumuloSecurityException, TableExistsException {
create(tableName, versioningIter, TimeType.MILLIS);
}
-
+
@Override
public void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException {
if (!tableName.matches(Constants.VALID_TABLE_NAME_REGEX)) {
@@ -96,24 +96,26 @@ public class MockTableOperations extends TableOperationsHelper {
throw new TableExistsException(tableName, tableName, "");
acu.createTable(username, tableName, versioningIter, timeType);
}
-
+
@Override
public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
acu.addSplits(tableName, partitionKeys);
}
-
+
+ @Deprecated
@Override
public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
return listSplits(tableName);
}
-
+
+ @Deprecated
@Override
public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
return listSplits(tableName);
}
-
+
@Override
public Collection<Text> listSplits(String tableName) throws TableNotFoundException {
if (!exists(tableName))
@@ -125,14 +127,14 @@ public class MockTableOperations extends TableOperationsHelper {
public Collection<Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException {
return listSplits(tableName);
}
-
+
@Override
public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
acu.tables.remove(tableName);
}
-
+
@Override
public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
TableExistsException {
@@ -143,42 +145,42 @@ public class MockTableOperations extends TableOperationsHelper {
MockTable t = acu.tables.remove(oldTableName);
acu.tables.put(newTableName, t);
}
-
+
@Deprecated
@Override
public void flush(String tableName) throws AccumuloException, AccumuloSecurityException {}
-
+
@Override
public void setProperty(String tableName, String property, String value) throws AccumuloException, AccumuloSecurityException {
acu.tables.get(tableName).settings.put(property, value);
}
-
+
@Override
public void removeProperty(String tableName, String property) throws AccumuloException, AccumuloSecurityException {
acu.tables.get(tableName).settings.remove(property);
}
-
+
@Override
public Iterable<Entry<String,String>> getProperties(String tableName) throws TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
return acu.tables.get(tableName).settings.entrySet();
}
-
+
@Override
public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
acu.tables.get(tableName).setLocalityGroups(groups);
}
-
+
@Override
public Map<String,Set<Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
return acu.tables.get(tableName).getLocalityGroups();
}
-
+
@Override
public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
@@ -186,7 +188,7 @@ public class MockTableOperations extends TableOperationsHelper {
throw new TableNotFoundException(tableName, tableName, "");
return Collections.singleton(range);
}
-
+
@Override
public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws IOException, AccumuloException,
AccumuloSecurityException, TableNotFoundException {
@@ -197,7 +199,7 @@ public class MockTableOperations extends TableOperationsHelper {
}
Path importPath = new Path(dir);
Path failurePath = new Path(failureDir);
-
+
FileSystem fs = acu.getFileSystem();
/*
* check preconditions
@@ -272,25 +274,25 @@ public class MockTableOperations extends TableOperationsHelper {
fs.delete(importStatus.getPath(), true);
}
}
-
+
@Override
public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
}
-
+
@Override
public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
}
-
+
@Override
public void clearLocatorCache(String tableName) throws TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
}
-
+
@Override
public Map<String,String> tableIdMap() {
Map<String,String> result = new HashMap<String,String>();
@@ -299,14 +301,14 @@ public class MockTableOperations extends TableOperationsHelper {
}
return result;
}
-
+
@Override
public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
acu.merge(tableName, start, end);
}
-
+
@Override
public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
if (!exists(tableName))
@@ -315,63 +317,63 @@ public class MockTableOperations extends TableOperationsHelper {
Set<Key> keep = new TreeSet<Key>(t.table.tailMap(new Key(start)).headMap(new Key(end)).keySet());
t.table.keySet().removeAll(keep);
}
-
+
@Override
public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException,
AccumuloException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
}
-
+
@Override
public void compact(String tableName, Text start, Text end, List<IteratorSetting> iterators, boolean flush, boolean wait) throws AccumuloSecurityException,
TableNotFoundException, AccumuloException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
}
-
+
@Override
public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
}
-
+
@Override
public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
throw new NotImplementedException();
}
-
+
@Override
public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
if (!exists(tableName))
throw new TableNotFoundException(tableName, tableName, "");
}
-
+
@Override
public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive)
throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
MockTable table = acu.tables.get(tableName);
if (table == null)
throw new TableNotFoundException(tableName, tableName, "no such table");
-
+
return FindMax.findMax(new MockScanner(table, auths), startRow, startInclusive, endRow, endInclusive);
}
-
+
@Override
public void importTable(String tableName, String exportDir) throws TableExistsException, AccumuloException, AccumuloSecurityException {
throw new NotImplementedException();
}
-
+
@Override
public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
throw new NotImplementedException();
}
-
+
@Override
public boolean testClassLoad(String tableName, String className, String asTypeName) throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
-
+
try {
AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
} catch (ClassNotFoundException e) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java b/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
index c2e74c3..a69c51f 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
@@ -28,40 +28,47 @@ import javax.security.auth.DestroyFailedException;
* @since 1.5.0
*/
public class NullToken implements AuthenticationToken {
-
+
@Override
public void readFields(DataInput arg0) throws IOException {
return;
}
-
+
@Override
public void write(DataOutput arg0) throws IOException {
return;
}
-
+
@Override
public void destroy() throws DestroyFailedException {
return;
}
-
+
@Override
public boolean isDestroyed() {
return false;
}
-
+
+ @Override
public NullToken clone() {
return new NullToken();
}
-
+
+ @Override
public boolean equals(Object obj) {
return obj instanceof NullToken;
}
-
+
@Override
public void init(Properties properties) {}
-
+
@Override
public Set<TokenProperty> getProperties() {
return Collections.emptySet();
}
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java b/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
index 327cf23..b546a48 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
@@ -33,56 +33,56 @@ import org.apache.accumulo.core.util.ByteBufferUtil;
import org.apache.commons.codec.binary.Base64;
public class Authorizations implements Iterable<byte[]>, Serializable {
-
+
private static final long serialVersionUID = 1L;
-
+
private HashSet<ByteSequence> auths = new HashSet<ByteSequence>();
private List<byte[]> authsList = new ArrayList<byte[]>();
private List<byte[]> immutableList = Collections.unmodifiableList(authsList);
-
+
private static final boolean[] validAuthChars = new boolean[256];
-
+
public static final String HEADER = "!AUTH1:";
-
+
static {
for (int i = 0; i < 256; i++) {
validAuthChars[i] = false;
}
-
+
for (int i = 'a'; i <= 'z'; i++) {
validAuthChars[i] = true;
}
-
+
for (int i = 'A'; i <= 'Z'; i++) {
validAuthChars[i] = true;
}
-
+
for (int i = '0'; i <= '9'; i++) {
validAuthChars[i] = true;
}
-
+
validAuthChars['_'] = true;
validAuthChars['-'] = true;
validAuthChars[':'] = true;
validAuthChars['.'] = true;
validAuthChars['/'] = true;
}
-
+
static final boolean isValidAuthChar(byte b) {
return validAuthChars[0xff & b];
}
-
+
private void checkAuths() {
-
+
for (ByteSequence bs : auths) {
if (bs.length() == 0) {
throw new IllegalArgumentException("Empty authorization");
}
-
+
authsList.add(bs.toArray());
}
}
-
+
/**
* A convenience constructor that accepts a collection of string authorizations that have each already been encoded as UTF-8 bytes.
*
@@ -94,7 +94,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
auths.add(new ArrayByteSequence(auth));
checkAuths();
}
-
+
/**
* A convenience constructor that accepts a collection of string authorizations that have each already been encoded as UTF-8 bytes.
*
@@ -107,7 +107,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
}
checkAuths();
}
-
+
/**
* Constructs an authorizations object a serialized form. This is NOT a constructor for a set of authorizations of size one.
*
@@ -115,9 +115,9 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
* a serialized authorizations string produced by {@link #getAuthorizationsArray()} or {@link #serialize()} (converted to UTF-8 bytes)
*/
public Authorizations(byte[] authorizations) {
-
+
ArgumentChecker.notNull(authorizations);
-
+
String authsString = new String(authorizations, Constants.UTF8);
if (authsString.startsWith(HEADER)) {
// it's the new format
@@ -136,14 +136,14 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
setAuthorizations(authsString.split(","));
}
}
-
+
/**
* Constructs an empty set of authorizations.
*
* @see #Authorizations(String...)
*/
public Authorizations() {}
-
+
/**
* Constructs an authorizations object from a set of human-readable authorizations.
*
@@ -153,7 +153,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
public Authorizations(String... authorizations) {
setAuthorizations(authorizations);
}
-
+
private void setAuthorizations(String... authorizations) {
ArgumentChecker.notNull(authorizations);
auths.clear();
@@ -161,10 +161,10 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
str = str.trim();
auths.add(new ArrayByteSequence(str.getBytes(Constants.UTF8)));
}
-
+
checkAuths();
}
-
+
/**
* Retrieve a serialized form of the underlying set of authorizations.
*
@@ -173,7 +173,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
public byte[] getAuthorizationsArray() {
return serialize().getBytes(Constants.UTF8);
}
-
+
/**
* Retrieve authorizations as a list of strings that have been encoded as UTF-8 bytes.
*
@@ -182,16 +182,14 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
public List<byte[]> getAuthorizations() {
return immutableList;
}
-
+
/**
* Retrieve authorizations as a list of strings that have been encoded as UTF-8 bytes.
- *
- * @see #Authorizations(List)
*/
public List<ByteBuffer> getAuthorizationsBB() {
return ByteBufferUtil.toByteBuffers(immutableList);
}
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -201,46 +199,46 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
sep = ",";
sb.append(new String(auth.toArray(), Constants.UTF8));
}
-
+
return sb.toString();
}
-
+
/**
* Checks for the existence of this UTF-8 encoded authorization.
*/
public boolean contains(byte[] auth) {
return auths.contains(new ArrayByteSequence(auth));
}
-
+
/**
* Checks for the existence of this UTF-8 encoded authorization.
*/
public boolean contains(ByteSequence auth) {
return auths.contains(auth);
}
-
+
/**
* Checks for the existence of this authorization.
*/
public boolean contains(String auth) {
return auths.contains(auth.getBytes(Constants.UTF8));
}
-
+
@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
-
+
if (o instanceof Authorizations) {
Authorizations ao = (Authorizations) o;
-
+
return auths.equals(ao.auths);
}
-
+
return false;
}
-
+
@Override
public int hashCode() {
int result = 0;
@@ -248,20 +246,20 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
result += b.hashCode();
return result;
}
-
+
public int size() {
return auths.size();
}
-
+
public boolean isEmpty() {
return auths.isEmpty();
}
-
+
@Override
public Iterator<byte[]> iterator() {
return immutableList.iterator();
}
-
+
/**
* Returns a serialized form of these authorizations. Convert to UTF-8 bytes to deserialize with {@link #Authorizations(byte[])}
*/
@@ -273,7 +271,7 @@ public class Authorizations implements Iterable<byte[]>, Serializable {
sep = ",";
sb.append(new String(Base64.encodeBase64(auth.toArray()), Constants.UTF8));
}
-
+
return sb.toString();
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java b/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
index 990ee53..1248018 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
@@ -41,108 +41,110 @@ import org.junit.Assert;
import org.junit.Test;
public class TableOperationsHelperTest {
-
+
static class Tester extends TableOperationsHelper {
Map<String,Map<String,String>> settings = new HashMap<String,Map<String,String>>();
-
+
@Override
public SortedSet<String> list() {
return null;
}
-
+
@Override
public boolean exists(String tableName) {
return true;
}
-
+
@Override
public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException {}
-
+
@Override
public void create(String tableName, boolean limitVersion) throws AccumuloException, AccumuloSecurityException, TableExistsException {
create(tableName, limitVersion, TimeType.MILLIS);
}
-
+
@Override
public void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException {}
-
+
@Override
public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {}
-
+
+ @Deprecated
@Override
public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
return null;
}
-
+
+ @Deprecated
@Override
public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
return null;
}
-
+
@Override
public Collection<Text> listSplits(String tableName) throws TableNotFoundException {
return null;
}
-
+
@Override
public Collection<Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException {
return null;
}
-
+
@Override
public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive)
throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
return null;
}
-
+
@Override
public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
-
+
}
-
+
@Override
public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {}
-
+
@Override
public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException,
AccumuloException {}
-
+
@Override
public void compact(String tableName, Text start, Text end, List<IteratorSetting> iterators, boolean flush, boolean wait) throws AccumuloSecurityException,
TableNotFoundException, AccumuloException {}
-
+
@Override
public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {}
-
+
@Override
public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {}
-
+
@Override
public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
TableExistsException {}
-
+
@Deprecated
@Override
public void flush(String tableName) throws AccumuloException, AccumuloSecurityException {}
-
+
@Override
public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {}
-
+
@Override
public void setProperty(String tableName, String property, String value) throws AccumuloException, AccumuloSecurityException {
if (!settings.containsKey(tableName))
settings.put(tableName, new TreeMap<String,String>());
settings.get(tableName).put(property, value);
}
-
+
@Override
public void removeProperty(String tableName, String property) throws AccumuloException, AccumuloSecurityException {
if (!settings.containsKey(tableName))
return;
settings.get(tableName).remove(property);
}
-
+
@Override
public Iterable<Entry<String,String>> getProperties(String tableName) throws AccumuloException, TableNotFoundException {
Map<String,String> empty = Collections.emptyMap();
@@ -150,41 +152,41 @@ public class TableOperationsHelperTest {
return empty.entrySet();
return settings.get(tableName).entrySet();
}
-
+
@Override
public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {}
-
+
@Override
public Map<String,Set<Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException {
return null;
}
-
+
@Override
public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
return null;
}
-
+
@Override
public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws TableNotFoundException, IOException,
AccumuloException, AccumuloSecurityException {}
-
+
@Override
public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
-
+
}
-
+
@Override
public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {}
-
+
@Override
public void clearLocatorCache(String tableName) throws TableNotFoundException {}
-
+
@Override
public Map<String,String> tableIdMap() {
return null;
}
-
+
void check(String tablename, String[] values) {
Map<String,String> expected = new TreeMap<String,String>();
for (String value : values) {
@@ -193,23 +195,23 @@ public class TableOperationsHelperTest {
}
Assert.assertEquals(expected, settings.get(tablename));
}
-
+
@Override
public void importTable(String tableName, String exportDir) throws TableExistsException, AccumuloException, AccumuloSecurityException {}
-
+
@Override
public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {}
-
+
@Override
public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {}
-
+
@Override
public boolean testClassLoad(String tableName, String className, String asTypeName) throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
return false;
}
}
-
+
@Test
public void testAttachIterator() throws Exception {
Tester t = new Tester();
@@ -218,7 +220,7 @@ public class TableOperationsHelperTest {
t.check("table", new String[] {"table.iterator.scan.someName=10,foo.bar",});
t.removeIterator("table", "someName", EnumSet.of(IteratorScope.scan));
t.check("table", new String[] {});
-
+
IteratorSetting setting = new IteratorSetting(10, "someName", "foo.bar");
setting.addOptions(Collections.singletonMap("key", "value"));
t.attachIterator("table", setting, EnumSet.of(IteratorScope.majc));
@@ -226,7 +228,7 @@ public class TableOperationsHelperTest {
t.attachIterator("table", setting, EnumSet.of(IteratorScope.scan));
t.check("table", new String[] {"table.iterator.majc.someName=10,foo.bar", "table.iterator.majc.someName.opt.key=value",
"table.iterator.scan.someName=10,foo.bar",});
-
+
t.removeIterator("table", "someName", EnumSet.of(IteratorScope.scan));
setting = new IteratorSetting(20, "otherName", "some.classname");
setting.addOptions(Collections.singletonMap("key", "value"));
@@ -245,7 +247,7 @@ public class TableOperationsHelperTest {
t.removeIterator("table", "someName", EnumSet.allOf(IteratorScope.class));
t.check("table", new String[] {"table.iterator.majc.otherName=20,some.classname", "table.iterator.majc.otherName.opt.key=value",
"table.iterator.scan.otherName=20,some.classname",});
-
+
setting = t.getIteratorSetting("table", "otherName", IteratorScope.scan);
Assert.assertEquals(20, setting.getPriority());
Assert.assertEquals("some.classname", setting.getIteratorClass());
@@ -258,7 +260,7 @@ public class TableOperationsHelperTest {
t.attachIterator("table", setting, EnumSet.of(IteratorScope.minc));
t.check("table", new String[] {"table.iterator.majc.otherName=20,some.classname", "table.iterator.majc.otherName.opt.key=value",
"table.iterator.minc.otherName=20,some.classname", "table.iterator.minc.otherName.opt.key=value", "table.iterator.scan.otherName=20,some.classname",});
-
+
try {
t.attachIterator("table", setting);
Assert.fail();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f403df2/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
----------------------------------------------------------------------
diff --git a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
index 46752c8..994ebf2 100644
--- a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
+++ b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/TracingExample.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.examples.simple.client;
-import java.io.IOException;
import java.util.Map.Entry;
import org.apache.accumulo.core.cli.ClientOnDefaultTable;
@@ -42,113 +41,101 @@ import com.beust.jcommander.Parameter;
/**
* A simple example showing how to use the distributed tracing API in client code
- *
+ *
*/
public class TracingExample {
-
- private static final String DEFAULT_TABLE_NAME = "test";
-
- static class Opts extends ClientOnDefaultTable {
- @Parameter(names = {"-C", "--createtable"}, description = "create table before doing anything")
- boolean createtable = false;
- @Parameter(names = {"-D", "--deletetable"}, description = "delete table when finished")
- boolean deletetable = false;
- @Parameter(names = {"-c", "--create"}, description = "create entries before any deletes")
- boolean createEntries = false;
- @Parameter(names = {"-r", "--read"}, description = "read entries after any creates/deletes")
- boolean readEntries = false;
-
- public Opts() {
- super(DEFAULT_TABLE_NAME);
- auths = new Authorizations();
- }
- }
-
- public void enableTracing(Opts opts) throws Exception {
- DistributedTrace.enable(opts.getInstance(), new ZooReader(opts.getInstance().getZooKeepers(), 1000), "myHost", "myApp");
- }
-
- public void execute(Opts opts) throws TableNotFoundException, InterruptedException, AccumuloException, AccumuloSecurityException, TableExistsException {
-
- if (opts.createtable) {
- opts.getConnector().tableOperations().create(opts.getTableName());
- }
-
- if (opts.createEntries) {
- createEntries(opts);
- }
-
- if (opts.readEntries) {
- readEntries(opts);
- }
-
- if (opts.deletetable) {
- opts.getConnector().tableOperations().delete(opts.getTableName());
- }
- }
-
- private void createEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
-
-
- BatchWriter batchWriter = opts.getConnector().createBatchWriter(opts.getTableName(), new BatchWriterConfig());
-
- Mutation m = new Mutation("row");
- m.put("cf", "cq", "value");
-
- // Trace the write operation. Note, unless you flush the BatchWriter, you will not capture
- // the write operation as it is occurs asynchronously. You can optionally create additional Spans
- // within a given Trace as seen below around the flush
- Trace.on("Client Write");
-
- batchWriter.addMutation(m);
- Span flushSpan = Trace.start("Client Flush");
- batchWriter.flush();
- flushSpan.stop();
-
- // Use Trace.offNoFlush() if you don't want the operation to block.
- Trace.off();
-
- batchWriter.close();
- }
-
- private void readEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
-
- Scanner scanner = opts.getConnector().createScanner(opts.getTableName(), opts.auths);
-
- // Trace the read operation.
- Span readSpan = Trace.on("Client Read");
-
- int numberOfEntriesRead = 0;
- for (Entry<Key,Value> entry : scanner) {
- System.out.println(entry.getKey().toString() + " -> " + entry.getValue().toString());
- ++numberOfEntriesRead;
- }
- // You can add additional metadata (key, values) to Spans which will be able to be viewed in the Monitor
- readSpan.data("Number of Entries Read", String.valueOf(numberOfEntriesRead));
-
- Trace.off();
- }
-
-
- /**
- * @param args
- * @throws AccumuloSecurityException
- * @throws AccumuloException
- * @throws TableNotFoundException
- * @throws InterruptedException
- * @throws KeeperException
- * @throws IOException
- * @throws TableExistsException
- */
- public static void main(String[] args) throws Exception {
-
- TracingExample tracingExample = new TracingExample();
- Opts opts = new Opts();
- ScannerOpts scannerOpts = new ScannerOpts();
- opts.parseArgs(TracingExample.class.getName(), args, scannerOpts);
-
- tracingExample.enableTracing(opts);
- tracingExample.execute(opts);
- }
+
+ private static final String DEFAULT_TABLE_NAME = "test";
+
+ static class Opts extends ClientOnDefaultTable {
+ @Parameter(names = {"-C", "--createtable"}, description = "create table before doing anything")
+ boolean createtable = false;
+ @Parameter(names = {"-D", "--deletetable"}, description = "delete table when finished")
+ boolean deletetable = false;
+ @Parameter(names = {"-c", "--create"}, description = "create entries before any deletes")
+ boolean createEntries = false;
+ @Parameter(names = {"-r", "--read"}, description = "read entries after any creates/deletes")
+ boolean readEntries = false;
+
+ public Opts() {
+ super(DEFAULT_TABLE_NAME);
+ auths = new Authorizations();
+ }
+ }
+
+ public void enableTracing(Opts opts) throws Exception {
+ DistributedTrace.enable(opts.getInstance(), new ZooReader(opts.getInstance().getZooKeepers(), 1000), "myHost", "myApp");
+ }
+
+ public void execute(Opts opts) throws TableNotFoundException, InterruptedException, AccumuloException, AccumuloSecurityException, TableExistsException {
+
+ if (opts.createtable) {
+ opts.getConnector().tableOperations().create(opts.getTableName());
+ }
+
+ if (opts.createEntries) {
+ createEntries(opts);
+ }
+
+ if (opts.readEntries) {
+ readEntries(opts);
+ }
+
+ if (opts.deletetable) {
+ opts.getConnector().tableOperations().delete(opts.getTableName());
+ }
+ }
+
+ private void createEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
+
+ BatchWriter batchWriter = opts.getConnector().createBatchWriter(opts.getTableName(), new BatchWriterConfig());
+
+ Mutation m = new Mutation("row");
+ m.put("cf", "cq", "value");
+
+ // Trace the write operation. Note, unless you flush the BatchWriter, you will not capture
+ // the write operation as it is occurs asynchronously. You can optionally create additional Spans
+ // within a given Trace as seen below around the flush
+ Trace.on("Client Write");
+
+ batchWriter.addMutation(m);
+ Span flushSpan = Trace.start("Client Flush");
+ batchWriter.flush();
+ flushSpan.stop();
+
+ // Use Trace.offNoFlush() if you don't want the operation to block.
+ Trace.off();
+
+ batchWriter.close();
+ }
+
+ private void readEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
+
+ Scanner scanner = opts.getConnector().createScanner(opts.getTableName(), opts.auths);
+
+ // Trace the read operation.
+ Span readSpan = Trace.on("Client Read");
+
+ int numberOfEntriesRead = 0;
+ for (Entry<Key,Value> entry : scanner) {
+ System.out.println(entry.getKey().toString() + " -> " + entry.getValue().toString());
+ ++numberOfEntriesRead;
+ }
+ // You can add additional metadata (key, values) to Spans which will be able to be viewed in the Monitor
+ readSpan.data("Number of Entries Read", String.valueOf(numberOfEntriesRead));
+
+ Trace.off();
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ TracingExample tracingExample = new TracingExample();
+ Opts opts = new Opts();
+ ScannerOpts scannerOpts = new ScannerOpts();
+ opts.parseArgs(TracingExample.class.getName(), args, scannerOpts);
+
+ tracingExample.enableTracing(opts);
+ tracingExample.execute(opts);
+ }
}