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/12/05 00:58:39 UTC
[47/50] [abbrv] git commit: ACCUMULO-802 Fixup formatting
ACCUMULO-802 Fixup formatting
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/bbba3f58
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/bbba3f58
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/bbba3f58
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: bbba3f5811c4774904c8cee88e0d1caec760044e
Parents: bf7c1db
Author: Christopher Tubbs <ct...@apache.org>
Authored: Thu Oct 31 21:50:40 2013 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Wed Dec 4 18:46:11 2013 -0500
----------------------------------------------------------------------
.../client/TableNamespaceExistsException.java | 11 +-
.../client/TableNamespaceNotEmptyException.java | 15 +--
.../client/TableNamespaceNotFoundException.java | 15 +--
.../client/admin/TableNamespaceOperations.java | 52 +++++-----
.../admin/TableNamespaceOperationsHelper.java | 20 ++--
.../core/client/impl/TableNamespaces.java | 22 ++--
.../core/client/mock/MockTableNamespace.java | 7 +-
.../mock/MockTableNamespaceOperations.java | 9 +-
.../core/security/TableNamespacePermission.java | 20 ++--
.../shell/commands/CloneNamespaceCommand.java | 31 +++---
.../shell/commands/CreateNamespaceCommand.java | 31 +++---
.../shell/commands/DeleteNamespaceCommand.java | 19 ++--
.../commands/NamespacePermissionsCommand.java | 4 +-
.../util/shell/commands/NamespacesCommand.java | 21 ++--
.../shell/commands/RenameNamespaceCommand.java | 14 +--
.../client/mock/MockTableNamespacesTest.java | 101 ++++++++++---------
.../server/conf/TableNamespaceConfWatcher.java | 16 +--
.../conf/TableNamespaceConfiguration.java | 4 +-
.../server/conf/TableParentConfiguration.java | 7 +-
.../accumulo/server/util/NamespacePropUtil.java | 14 +--
.../concurrent/CloneTableNamespace.java | 10 +-
.../concurrent/CreateTableNamespace.java | 10 +-
.../concurrent/DeleteTableNamespace.java | 10 +-
.../concurrent/OfflineTableNamespace.java | 12 +--
.../concurrent/RenameTableNamespace.java | 10 +-
25 files changed, 245 insertions(+), 240 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceExistsException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceExistsException.java b/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceExistsException.java
index ddddc4f..c6a8591 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceExistsException.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceExistsException.java
@@ -27,7 +27,7 @@ public class TableNamespaceExistsException extends Exception {
*
*/
private static final long serialVersionUID = 1L;
-
+
/**
* @param namespaceId
* the internal id of the table namespace that exists
@@ -37,10 +37,11 @@ public class TableNamespaceExistsException extends Exception {
* the specific reason why it failed
*/
public TableNamespaceExistsException(String namespaceId, String namespaceName, String description) {
- super("Table namespace" + (namespaceName != null && !namespaceName.isEmpty() ? " " + namespaceName : "") + (namespaceId != null && !namespaceId.isEmpty() ? " (Id=" + namespaceId + ")" : "")
- + " exists" + (description != null && !description.isEmpty() ? " (" + description + ")" : ""));
+ super("Table namespace" + (namespaceName != null && !namespaceName.isEmpty() ? " " + namespaceName : "")
+ + (namespaceId != null && !namespaceId.isEmpty() ? " (Id=" + namespaceId + ")" : "") + " exists"
+ + (description != null && !description.isEmpty() ? " (" + description + ")" : ""));
}
-
+
/**
* @param namespaceId
* the internal id of the table namespace that exists
@@ -55,7 +56,7 @@ public class TableNamespaceExistsException extends Exception {
this(namespaceId, namespaceName, description);
super.initCause(cause);
}
-
+
/**
* @param e
* constructs an exception from a thrift exception
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotEmptyException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotEmptyException.java b/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotEmptyException.java
index e333693..04195e3 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotEmptyException.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotEmptyException.java
@@ -24,9 +24,9 @@ import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException
public class TableNamespaceNotEmptyException extends Exception {
private static final long serialVersionUID = 1L;
-
+
private String namespace;
-
+
/**
* @param namespaceId
* the internal id of the table namespace
@@ -36,11 +36,12 @@ public class TableNamespaceNotEmptyException extends Exception {
* the specific reason why it failed
*/
public TableNamespaceNotEmptyException(String namespaceId, String namespaceName, String description) {
- super("Table namespace" + (namespaceName != null && !namespaceName.isEmpty() ? " " + namespaceName : "") + (namespaceId != null && !namespaceId.isEmpty() ? " (Id=" + namespaceId + ")" : "")
- + " it not empty, contains at least one table" + (description != null && !description.isEmpty() ? " (" + description + ")" : ""));
+ super("Table namespace" + (namespaceName != null && !namespaceName.isEmpty() ? " " + namespaceName : "")
+ + (namespaceId != null && !namespaceId.isEmpty() ? " (Id=" + namespaceId + ")" : "") + " it not empty, contains at least one table"
+ + (description != null && !description.isEmpty() ? " (" + description + ")" : ""));
this.namespace = namespaceName;
}
-
+
/**
* @param namespaceId
* the internal id of the table namespace
@@ -55,7 +56,7 @@ public class TableNamespaceNotEmptyException extends Exception {
this(namespaceId, namespaceName, description);
super.initCause(cause);
}
-
+
/**
* @param e
* constructs an exception from a thrift exception
@@ -63,7 +64,7 @@ public class TableNamespaceNotEmptyException extends Exception {
public TableNamespaceNotEmptyException(ThriftTableOperationException e) {
this(e.getTableId(), e.getTableName(), e.getDescription(), e);
}
-
+
/**
* @return the name of the table namespace
*/
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotFoundException.java b/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotFoundException.java
index 30e63c3..c4db89b 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotFoundException.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/TableNamespaceNotFoundException.java
@@ -27,9 +27,9 @@ public class TableNamespaceNotFoundException extends Exception {
*
*/
private static final long serialVersionUID = 1L;
-
+
private String namespace;
-
+
/**
* @param namespaceId
* the internal id of the table namespace that was sought
@@ -39,11 +39,12 @@ public class TableNamespaceNotFoundException extends Exception {
* the specific reason why it failed
*/
public TableNamespaceNotFoundException(String namespaceId, String namespaceName, String description) {
- super("Table namespace" + (namespaceName != null && !namespaceName.isEmpty() ? " " + namespaceName : "") + (namespaceId != null && !namespaceId.isEmpty() ? " (Id=" + namespaceId + ")" : "")
- + " does not exist" + (description != null && !description.isEmpty() ? " (" + description + ")" : ""));
+ super("Table namespace" + (namespaceName != null && !namespaceName.isEmpty() ? " " + namespaceName : "")
+ + (namespaceId != null && !namespaceId.isEmpty() ? " (Id=" + namespaceId + ")" : "") + " does not exist"
+ + (description != null && !description.isEmpty() ? " (" + description + ")" : ""));
this.namespace = namespaceName;
}
-
+
/**
* @param namespaceId
* the internal id of the table namespace that was sought
@@ -58,7 +59,7 @@ public class TableNamespaceNotFoundException extends Exception {
this(namespaceId, namespaceName, description);
super.initCause(cause);
}
-
+
/**
* @param e
* constructs an exception from a thrift exception
@@ -66,7 +67,7 @@ public class TableNamespaceNotFoundException extends Exception {
public TableNamespaceNotFoundException(ThriftTableOperationException e) {
this(e.getTableId(), e.getTableName(), e.getDescription(), e);
}
-
+
/**
* @return the name of the table namespace sought
*/
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperations.java
index 136f79b..313a899 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperations.java
@@ -38,14 +38,14 @@ import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
*/
public interface TableNamespaceOperations {
-
+
/**
* Retrieve a list of table namespaces in Accumulo.
*
* @return List of table namespaces in accumulo
*/
public SortedSet<String> list();
-
+
/**
* A method to check if a table namespace exists in Accumulo.
*
@@ -54,7 +54,7 @@ public interface TableNamespaceOperations {
* @return true if the table namespace exists
*/
public boolean exists(String namespace);
-
+
/**
* Create a table namespace with no special configuration
*
@@ -68,7 +68,7 @@ public interface TableNamespaceOperations {
* if the table namespace already exists
*/
public void create(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceExistsException;
-
+
/**
* @param namespace
* the name of the table namespace
@@ -82,7 +82,7 @@ public interface TableNamespaceOperations {
* if the table namespace already exists
*/
public void create(String namespace, boolean limitVersion) throws AccumuloException, AccumuloSecurityException, TableNamespaceExistsException;
-
+
/**
* @param namespace
* the name of the table namespace
@@ -99,7 +99,7 @@ public interface TableNamespaceOperations {
*/
public void create(String namespace, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException,
TableNamespaceExistsException;
-
+
/**
* Delete a table namespace if it is empty
*
@@ -118,7 +118,7 @@ public interface TableNamespaceOperations {
*/
public void delete(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException, TableNamespaceNotEmptyException,
TableNotFoundException;
-
+
/**
* Delete a table namespace
*
@@ -139,7 +139,7 @@ public interface TableNamespaceOperations {
*/
public void delete(String namespace, boolean deleteTables) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException,
TableNamespaceNotEmptyException, TableNotFoundException;
-
+
/**
* Rename a table namespace
*
@@ -158,7 +158,7 @@ public interface TableNamespaceOperations {
*/
public void rename(String oldNamespaceName, String newNamespaceName) throws AccumuloSecurityException, TableNamespaceNotFoundException, AccumuloException,
TableNamespaceExistsException;
-
+
/**
* Sets a property on a table namespace which applies to all tables in the namespace. Note that it may take a short period of time (a second) to propagate the
* change everywhere.
@@ -175,7 +175,7 @@ public interface TableNamespaceOperations {
* if the user does not have permission
*/
public void setProperty(String namespace, String property, String value) throws AccumuloException, AccumuloSecurityException;
-
+
/**
* Removes a property from a table namespace. Note that it may take a short period of time (a second) to propagate the change everywhere.
*
@@ -189,7 +189,7 @@ public interface TableNamespaceOperations {
* if the user does not have permission
*/
public void removeProperty(String namespace, String property) throws AccumuloException, AccumuloSecurityException;
-
+
/**
* Gets properties of a table namespace. Note that recently changed properties may not be available immediately.
*
@@ -200,7 +200,7 @@ public interface TableNamespaceOperations {
* if the table namespace does not exist
*/
public Iterable<Entry<String,String>> getProperties(String namespace) throws AccumuloException, TableNamespaceNotFoundException;
-
+
/**
*
* @param namespace
@@ -213,7 +213,7 @@ public interface TableNamespaceOperations {
* if the table namespace does not exist
*/
public void offline(String namespace) throws AccumuloSecurityException, AccumuloException, TableNamespaceNotFoundException;
-
+
/**
*
* @param namespace
@@ -226,14 +226,14 @@ public interface TableNamespaceOperations {
* if the table namespace does not exist
*/
public void online(String namespace) throws AccumuloSecurityException, AccumuloException, TableNamespaceNotFoundException;
-
+
/**
* Get a mapping of table namespace name to internal table namespace id.
*
* @return the map from table namespace name to internal table namespace id
*/
public Map<String,String> namespaceIdMap();
-
+
/**
* Gets the number of bytes being used in the files for the set of tables in this namespace
*
@@ -247,7 +247,7 @@ public interface TableNamespaceOperations {
* when the user does not have the proper permissions
*/
public List<DiskUsage> getDiskUsage(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException;
-
+
/**
* Clone a all the tables in a table namespace to a new table namespace. Optionally copy all their properties as well.
*
@@ -274,7 +274,7 @@ public interface TableNamespaceOperations {
*/
public void clone(String srcName, String newName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude, Boolean copyTableProps)
throws AccumuloSecurityException, AccumuloException, TableNamespaceNotFoundException, TableNamespaceExistsException;
-
+
/**
* Add an iterator to a table namespace on all scopes.
*
@@ -292,7 +292,7 @@ public interface TableNamespaceOperations {
*/
public void attachIterator(String tableNamespace, IteratorSetting setting) throws AccumuloSecurityException, AccumuloException,
TableNamespaceNotFoundException;
-
+
/**
* Add an iterator to a table namespace on the given scopes.
*
@@ -310,7 +310,7 @@ public interface TableNamespaceOperations {
*/
public void attachIterator(String tableNamespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException,
AccumuloException, TableNamespaceNotFoundException;
-
+
/**
* Remove an iterator from a table namespace by name.
*
@@ -328,7 +328,7 @@ public interface TableNamespaceOperations {
*/
public void removeIterator(String tableNamespace, String name, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
TableNamespaceNotFoundException;
-
+
/**
* Get the settings for an iterator.
*
@@ -347,7 +347,7 @@ public interface TableNamespaceOperations {
*/
public IteratorSetting getIteratorSetting(String tableNamespace, String name, IteratorScope scope) throws AccumuloSecurityException, AccumuloException,
NumberFormatException, TableNamespaceNotFoundException;
-
+
/**
* Get a list of iterators for this table namespace.
*
@@ -362,7 +362,7 @@ public interface TableNamespaceOperations {
*/
public Map<String,EnumSet<IteratorScope>> listIterators(String tableNamespace) throws AccumuloSecurityException, AccumuloException,
TableNamespaceNotFoundException;
-
+
/**
* Check whether a given iterator configuration conflicts with existing configuration; in particular, determine if the name or priority are already in use for
* the specified scopes.
@@ -379,7 +379,7 @@ public interface TableNamespaceOperations {
*/
public void checkIteratorConflicts(String tableNamespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloException,
TableNamespaceNotFoundException;
-
+
/**
* Add a new constraint to a table namespace.
*
@@ -397,7 +397,7 @@ public interface TableNamespaceOperations {
*/
public int addConstraint(String tableNamespace, String constraintClassName) throws AccumuloException, AccumuloSecurityException,
TableNamespaceNotFoundException;
-
+
/**
* Remove a constraint from a table namespace.
*
@@ -410,7 +410,7 @@ public interface TableNamespaceOperations {
* thrown if the user doesn't have permission to remove the constraint
*/
public void removeConstraint(String tableNamespace, int number) throws AccumuloException, AccumuloSecurityException;
-
+
/**
* List constraints on a table namespace with their assigned numbers.
*
@@ -423,7 +423,7 @@ public interface TableNamespaceOperations {
* thrown if the table namespace no longer exists
*/
public Map<String,Integer> listConstraints(String tableNamespace) throws AccumuloException, TableNamespaceNotFoundException;
-
+
/**
* Test to see if the instance can load the given class as the given type. This check uses the table classpath property if it is set.
*
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperationsHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperationsHelper.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperationsHelper.java
index 7ba1497..c73d8e9 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperationsHelper.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperationsHelper.java
@@ -31,13 +31,13 @@ import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
public abstract class TableNamespaceOperationsHelper implements TableNamespaceOperations {
-
+
@Override
public void attachIterator(String tableNamespace, IteratorSetting setting) throws AccumuloSecurityException, AccumuloException,
TableNamespaceNotFoundException {
attachIterator(tableNamespace, setting, EnumSet.allOf(IteratorScope.class));
}
-
+
@Override
public void attachIterator(String tableNamespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException,
AccumuloException, TableNamespaceNotFoundException {
@@ -50,7 +50,7 @@ public abstract class TableNamespaceOperationsHelper implements TableNamespaceOp
this.setProperty(tableNamespace, root, setting.getPriority() + "," + setting.getIteratorClass());
}
}
-
+
@Override
public void removeIterator(String tableNamespace, String name, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
TableNamespaceNotFoundException {
@@ -68,7 +68,7 @@ public abstract class TableNamespaceOperationsHelper implements TableNamespaceOp
}
}
}
-
+
@Override
public IteratorSetting getIteratorSetting(String tableNamespace, String name, IteratorScope scope) throws AccumuloSecurityException, AccumuloException,
TableNamespaceNotFoundException {
@@ -77,7 +77,7 @@ public abstract class TableNamespaceOperationsHelper implements TableNamespaceOp
int priority = -1;
String classname = null;
Map<String,String> settings = new HashMap<String,String>();
-
+
String root = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase(), name);
String opt = root + ".opt.";
for (Entry<String,String> property : this.getProperties(tableNamespace)) {
@@ -97,7 +97,7 @@ public abstract class TableNamespaceOperationsHelper implements TableNamespaceOp
}
return new IteratorSetting(priority, name, classname, settings);
}
-
+
@Override
public Map<String,EnumSet<IteratorScope>> listIterators(String tableNamespace) throws AccumuloSecurityException, AccumuloException,
TableNamespaceNotFoundException {
@@ -118,7 +118,7 @@ public abstract class TableNamespaceOperationsHelper implements TableNamespaceOp
}
return result;
}
-
+
@Override
public void checkIteratorConflicts(String tableNamespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloException,
TableNamespaceNotFoundException {
@@ -153,7 +153,7 @@ public abstract class TableNamespaceOperationsHelper implements TableNamespaceOp
throw new AccumuloException(new IllegalArgumentException("iterator options conflict for " + setting.getName() + ": " + optionConflicts));
}
}
-
+
@Override
public int addConstraint(String tableNamespace, String constraintClassName) throws AccumuloException, AccumuloSecurityException,
TableNamespaceNotFoundException {
@@ -180,12 +180,12 @@ public abstract class TableNamespaceOperationsHelper implements TableNamespaceOp
this.setProperty(tableNamespace, Property.TABLE_CONSTRAINT_PREFIX.toString() + i, constraintClassName);
return i;
}
-
+
@Override
public void removeConstraint(String tableNamespace, int number) throws AccumuloException, AccumuloSecurityException {
this.removeProperty(tableNamespace, Property.TABLE_CONSTRAINT_PREFIX.toString() + number);
}
-
+
@Override
public Map<String,Integer> listConstraints(String tableNamespace) throws AccumuloException, TableNamespaceNotFoundException {
Map<String,Integer> constraints = new TreeMap<String,Integer>();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/impl/TableNamespaces.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TableNamespaces.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TableNamespaces.java
index e3de9db..935cf16 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TableNamespaces.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TableNamespaces.java
@@ -30,7 +30,7 @@ import org.apache.accumulo.fate.zookeeper.ZooCache;
public class TableNamespaces {
private static SecurityPermission TABLES_PERMISSION = new SecurityPermission("tablesPermission");
-
+
private static ZooCache getZooCache(Instance instance) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -38,14 +38,14 @@ public class TableNamespaces {
}
return ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
}
-
+
private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) {
ZooCache zc = getZooCache(instance);
-
+
List<String> namespaceIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES);
-
+
TreeMap<String,String> namespaceMap = new TreeMap<String,String>();
-
+
for (String id : namespaceIds) {
byte[] path = zc.get(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES + "/" + id + Constants.ZNAMESPACE_NAME);
if (path != null) {
@@ -57,29 +57,29 @@ public class TableNamespaces {
}
return namespaceMap;
}
-
+
public static String getNamespaceId(Instance instance, String namespace) throws TableNamespaceNotFoundException {
String id = getNameToIdMap(instance).get(namespace);
if (id == null)
throw new TableNamespaceNotFoundException(null, namespace, "getNamespaceId() failed to find namespace");
return id;
}
-
+
public static String getNamespaceName(Instance instance, String namespaceId) throws TableNamespaceNotFoundException {
String namespaceName = getIdToNameMap(instance).get(namespaceId);
if (namespaceName == null)
throw new TableNamespaceNotFoundException(namespaceId, null, "getNamespaceName() failed to find namespace");
return namespaceName;
}
-
+
public static SortedMap<String,String> getNameToIdMap(Instance instance) {
return getMap(instance, true);
}
-
+
public static SortedMap<String,String> getIdToNameMap(Instance instance) {
return getMap(instance, false);
}
-
+
public static List<String> getTableIds(Instance instance, String namespaceId) throws TableNamespaceNotFoundException {
List<String> l = new LinkedList<String>();
for (String id : Tables.getIdToNameMap(instance).keySet()) {
@@ -89,7 +89,7 @@ public class TableNamespaces {
}
return l;
}
-
+
public static List<String> getTableNames(Instance instance, String namespaceId) throws TableNamespaceNotFoundException {
ZooCache zc = getZooCache(instance);
List<String> ids = getTableIds(instance, namespaceId);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespace.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespace.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespace.java
index 1798dd1..8523145 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespace.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespace.java
@@ -27,12 +27,11 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.security.TableNamespacePermission;
-
public class MockTableNamespace {
-
+
final Map<String,String> settings;
Map<String,EnumSet<TableNamespacePermission>> userPermissions = new HashMap<String,EnumSet<TableNamespacePermission>>();
-
+
public MockTableNamespace() {
settings = new HashMap<String,String>();
for (Entry<String,String> entry : AccumuloConfiguration.getDefaultConfiguration()) {
@@ -42,7 +41,7 @@ public class MockTableNamespace {
}
}
}
-
+
public List<String> getTables(MockAccumulo acu) {
List<String> l = new LinkedList<String>();
for (String t : acu.tables.keySet()) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespaceOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespaceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespaceOperations.java
index 5b53fbd..28fff21 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespaceOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableNamespaceOperations.java
@@ -39,8 +39,6 @@ import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
import org.apache.commons.lang.NotImplementedException;
-
-
public class MockTableNamespaceOperations extends TableNamespaceOperationsHelper {
final private MockAccumulo acu;
@@ -88,7 +86,8 @@ public class MockTableNamespaceOperations extends TableNamespaceOperationsHelper
}
@Override
- public void delete(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException, TableNamespaceNotEmptyException, TableNotFoundException {
+ public void delete(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException, TableNamespaceNotEmptyException,
+ TableNotFoundException {
delete(namespace, false);
}
@@ -182,11 +181,11 @@ public class MockTableNamespaceOperations extends TableNamespaceOperationsHelper
// TODO Implement clone in Mock
throw new NotImplementedException();
}
-
+
@Override
public boolean testClassLoad(String namespace, String className, String asTypeName) throws AccumuloException, AccumuloSecurityException,
TableNamespaceNotFoundException {
-
+
try {
AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
} catch (ClassNotFoundException e) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java b/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java
index 9354b02..2cf57c7 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java
@@ -28,39 +28,39 @@ public enum TableNamespacePermission {
ALTER_TABLE((byte) 4),
CREATE_TABLE((byte) 5),
DROP_TABLE((byte) 6);
-
+
final private byte permID;
-
+
final private static TableNamespacePermission mapping[] = new TableNamespacePermission[8];
static {
for (TableNamespacePermission perm : TableNamespacePermission.values())
mapping[perm.permID] = perm;
}
-
+
private TableNamespacePermission(byte id) {
this.permID = id;
}
-
+
public byte getId() {
return this.permID;
}
-
+
public static List<String> printableValues() {
TableNamespacePermission[] a = TableNamespacePermission.values();
-
+
List<String> list = new ArrayList<String>(a.length);
-
+
for (TableNamespacePermission p : a)
list.add("Namespace." + p);
-
+
return list;
}
-
+
public static TableNamespacePermission getPermissionById(byte id) {
TableNamespacePermission result = mapping[id];
if (result != null)
return result;
throw new IndexOutOfBoundsException("No such permission");
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneNamespaceCommand.java
index 21f5a9f..dade389 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneNamespaceCommand.java
@@ -35,21 +35,21 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
public class CloneNamespaceCommand extends Command {
-
+
private Option setPropsOption;
private Option excludePropsOption;
private Option noFlushOption;
private Option copyTablePropsOption;
-
+
@Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
- TableExistsException, TableNamespaceNotFoundException, TableNamespaceExistsException {
-
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
+ TableNotFoundException, TableExistsException, TableNamespaceNotFoundException, TableNamespaceExistsException {
+
final HashMap<String,String> props = new HashMap<String,String>();
final HashSet<String> exclude = new HashSet<String>();
boolean flush = true;
boolean copyTableProps = false;
-
+
if (cl.hasOption(setPropsOption.getOpt())) {
String[] keyVals = cl.getOptionValue(setPropsOption.getOpt()).split(",");
for (String keyVal : keyVals) {
@@ -57,40 +57,41 @@ public class CloneNamespaceCommand extends Command {
props.put(sa[0], sa[1]);
}
}
-
+
if (cl.hasOption(excludePropsOption.getOpt())) {
String[] keys = cl.getOptionValue(excludePropsOption.getOpt()).split(",");
for (String key : keys) {
exclude.add(key);
}
}
-
+
if (cl.hasOption(noFlushOption.getOpt())) {
flush = false;
}
-
+
if (cl.hasOption(noFlushOption.getOpt())) {
copyTableProps = true;
}
-
+
shellState.getConnector().tableNamespaceOperations().clone(cl.getArgs()[0], cl.getArgs()[1], flush, props, exclude, copyTableProps);
return 0;
}
-
+
@Override
public String usage() {
return getName() + " <current name> <new name>";
}
-
+
@Override
public String description() {
return "clones a table namespace";
}
-
+
+ @Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
registerCompletionForTableNamespaces(root, completionSet);
}
-
+
@Override
public Options getOptions() {
final Options o = new Options();
@@ -104,7 +105,7 @@ public class CloneNamespaceCommand extends Command {
o.addOption(copyTablePropsOption);
return o;
}
-
+
@Override
public int numArgs() {
return 2;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
index a869070..7434767 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
@@ -36,18 +36,19 @@ import org.apache.commons.cli.Options;
public class CreateNamespaceCommand extends Command {
private Option createTableOptCopyConfig, createTableNamespaceOptCopyConfig;
private Option base64Opt;
-
+
+ @Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
TableExistsException, TableNotFoundException, IOException, ClassNotFoundException, TableNamespaceExistsException, TableNamespaceNotFoundException {
-
+
if (createTableOptCopyConfig == null) {
getOptions();
}
-
+
String namespace = cl.getArgs()[0];
-
+
shellState.getConnector().tableNamespaceOperations().create(namespace);
-
+
// Copy options if flag was set
Iterable<Entry<String,String>> configuration = null;
if (cl.hasOption(createTableNamespaceOptCopyConfig.getOpt())) {
@@ -68,41 +69,41 @@ public class CreateNamespaceCommand extends Command {
}
}
}
-
+
return 0;
}
-
+
@Override
public String description() {
return "creates a new table namespace";
}
-
+
@Override
public String usage() {
return getName() + " <namespaceName>";
}
-
+
@Override
public Options getOptions() {
final Options o = new Options();
-
+
createTableNamespaceOptCopyConfig = new Option("cc", "copy-config", true, "table namespace to copy configuration from");
createTableNamespaceOptCopyConfig.setArgName("tableNamespace");
-
+
createTableOptCopyConfig = new Option("ctc", "copy-table-config", true, "table to copy configuration from");
createTableOptCopyConfig.setArgName("tableName");
-
+
base64Opt = new Option("b64", "base64encoded", false, "decode encoded split points");
o.addOption(base64Opt);
OptionGroup ogp = new OptionGroup();
ogp.addOption(createTableOptCopyConfig);
ogp.addOption(createTableNamespaceOptCopyConfig);
-
+
o.addOptionGroup(ogp);
-
+
return o;
}
-
+
@Override
public int numArgs() {
return 1;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
index 27d669b..e1b41cd 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
@@ -24,15 +24,16 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
import org.apache.accumulo.core.client.impl.TableNamespaces;
import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Token;
import org.apache.accumulo.core.util.shell.Shell.Command;
+import org.apache.accumulo.core.util.shell.Token;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
public class DeleteNamespaceCommand extends Command {
private Option forceOpt;
-
+
+ @Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
boolean force = false;
boolean operate = true;
@@ -40,7 +41,7 @@ public class DeleteNamespaceCommand extends Command {
force = true;
}
String namespace = cl.getArgs()[0];
-
+
if (!force) {
shellState.getReader().flush();
String line = shellState.getReader().readLine(getName() + " { " + namespace + " } (yes|no)? ");
@@ -51,19 +52,19 @@ public class DeleteNamespaceCommand extends Command {
}
return 0;
}
-
+
@Override
public String description() {
return "deletes a table namespace";
}
-
+
protected void doTableOp(final Shell shellState, final String namespace, boolean force) throws Exception {
boolean resetContext = false;
String currentTable = shellState.getTableName();
if (!TableNamespaces.getNameToIdMap(shellState.getInstance()).containsKey(namespace)) {
throw new TableNamespaceNotFoundException(null, namespace, null);
}
-
+
String namespaceId = TableNamespaces.getNamespaceId(shellState.getInstance(), namespace);
List<String> tables = TableNamespaces.getTableNames(shellState.getInstance(), namespaceId);
resetContext = tables.contains(currentTable);
@@ -82,12 +83,12 @@ public class DeleteNamespaceCommand extends Command {
shellState.setTableName("");
}
}
-
+
@Override
public Options getOptions() {
forceOpt = new Option("f", "force", false, "force deletion without prompting");
final Options opts = super.getOptions();
-
+
opts.addOption(forceOpt);
return opts;
}
@@ -96,7 +97,7 @@ public class DeleteNamespaceCommand extends Command {
public int numArgs() {
return 1;
}
-
+
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
registerCompletionForTableNamespaces(root, special);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
index 822522e..f3e0e6f 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
@@ -31,12 +31,12 @@ public class NamespacePermissionsCommand extends Command {
}
return 0;
}
-
+
@Override
public String description() {
return "displays a list of valid table namespace permissions";
}
-
+
@Override
public int numArgs() {
return 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
index ad30699..2056afd 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
@@ -18,8 +18,8 @@ package org.apache.accumulo.core.util.shell.commands;
import java.io.IOException;
import java.util.Iterator;
-import java.util.TreeMap;
import java.util.Map.Entry;
+import java.util.TreeMap;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -32,13 +32,14 @@ import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
public class NamespacesCommand extends Command {
private Option disablePaginationOpt, namespaceIdOption;
-
+
@SuppressWarnings("unchecked")
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
- Iterator<String> names = shellState.getConnector().tableNamespaceOperations().list().iterator();
- Iterator<String> ids = new NamespaceIdIterator(new TreeMap<String,String>(shellState.getConnector().tableNamespaceOperations().namespaceIdMap()).entrySet().iterator());
-
+ Iterator<String> names = shellState.getConnector().tableNamespaceOperations().list().iterator();
+ Iterator<String> ids = new NamespaceIdIterator(new TreeMap<String,String>(shellState.getConnector().tableNamespaceOperations().namespaceIdMap()).entrySet()
+ .iterator());
+
if (cl.hasOption(namespaceIdOption.getOpt())) {
shellState.printLines(ids, !cl.hasOption(disablePaginationOpt.getOpt()));
} else {
@@ -46,7 +47,7 @@ public class NamespacesCommand extends Command {
}
return 0;
}
-
+
/**
* Decorator that formats the id and name for display.
*/
@@ -54,7 +55,7 @@ public class NamespacesCommand extends Command {
public NamespaceIdIterator(Iterator<Entry<String,String>> iterator) {
super(iterator);
}
-
+
@SuppressWarnings("rawtypes")
@Override
public Object next() {
@@ -62,12 +63,12 @@ public class NamespacesCommand extends Command {
return String.format("%-15s => %10s%n", entry.getKey(), entry.getValue());
}
}
-
+
@Override
public String description() {
return "displays a list of all existing table namespaces";
}
-
+
@Override
public Options getOptions() {
final Options o = new Options();
@@ -77,7 +78,7 @@ public class NamespacesCommand extends Command {
o.addOption(disablePaginationOpt);
return o;
}
-
+
@Override
public int numArgs() {
return 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
index 9f4596a..34fd9fa 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
@@ -47,31 +47,31 @@ public class RenameNamespaceCommand extends Command {
currentTableId = Tables.getTableId(shellState.getInstance(), shellState.getTableName());
resetContext = tableIds.contains(currentTableId);
}
-
+
shellState.getConnector().tableNamespaceOperations().rename(old, newer);
-
+
if (resetContext) {
shellState.setTableName(Tables.getTableName(shellState.getInstance(), currentTableId));
}
-
+
return 0;
}
-
+
@Override
public String usage() {
return getName() + " <current table namespace> <new table namespace>";
}
-
+
@Override
public String description() {
return "renames a table namespace";
}
-
+
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
registerCompletionForTableNamespaces(root, special);
}
-
+
@Override
public int numArgs() {
return 2;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableNamespacesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableNamespacesTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableNamespacesTest.java
index 2ba1006..2cf0541 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableNamespacesTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableNamespacesTest.java
@@ -20,9 +20,9 @@ package org.apache.accumulo.core.client.mock;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.util.Map.Entry;
import java.util.EnumSet;
import java.util.HashSet;
+import java.util.Map.Entry;
import java.util.Random;
import org.apache.accumulo.core.Constants;
@@ -48,10 +48,10 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class MockTableNamespacesTest {
-
+
Random random = new Random();
public static TemporaryFolder folder = new TemporaryFolder();
-
+
/**
* This test creates a table without specifying a namespace. In this case, it puts the table into the default namespace.
*
@@ -62,12 +62,12 @@ public class MockTableNamespacesTest {
String tableName = "test";
Instance instance = new MockInstance("default");
Connector c = instance.getConnector("user", new PasswordToken("pass"));
-
+
assertTrue(c.tableNamespaceOperations().exists(Constants.DEFAULT_TABLE_NAMESPACE));
c.tableOperations().create(tableName);
assertTrue(c.tableOperations().exists(tableName));
}
-
+
/**
* This test creates a new namespace "testing" and a table "testing.table1" which puts "table1" into the "testing" namespace. Then we create "testing.table2"
* which creates "table2" and puts it into "testing" as well. Then we make sure that you can't delete a namespace with tables in it, and then we delete the
@@ -80,19 +80,19 @@ public class MockTableNamespacesTest {
String namespace = "testing";
String tableName1 = namespace + ".table1";
String tableName2 = namespace + ".table2";
-
+
Instance instance = new MockInstance("createdelete");
Connector c = instance.getConnector("user", new PasswordToken("pass"));
-
+
c.tableNamespaceOperations().create(namespace);
assertTrue(c.tableNamespaceOperations().exists(namespace));
-
+
c.tableOperations().create(tableName1);
assertTrue(c.tableOperations().exists(tableName1));
-
+
c.tableOperations().create(tableName2);
assertTrue(c.tableOperations().exists(tableName2));
-
+
// deleting
try {
// can't delete a namespace with tables in it
@@ -104,17 +104,17 @@ public class MockTableNamespacesTest {
assertTrue(c.tableNamespaceOperations().exists(namespace));
assertTrue(c.tableOperations().exists(tableName1));
assertTrue(c.tableOperations().exists(tableName2));
-
+
c.tableOperations().delete(tableName2);
assertTrue(!c.tableOperations().exists(tableName2));
assertTrue(c.tableNamespaceOperations().exists(namespace));
-
+
c.tableOperations().delete(tableName1);
assertTrue(!c.tableOperations().exists(tableName1));
c.tableNamespaceOperations().delete(namespace);
assertTrue(!c.tableNamespaceOperations().exists(namespace));
}
-
+
/**
* This test creates a namespace, modifies it's properties, and checks to make sure that those properties are applied to its tables. To do something on a
* namespace-wide level, use TableNamespaceOperations.
@@ -125,72 +125,72 @@ public class MockTableNamespacesTest {
*
* @throws Exception
*/
-
+
@Test
public void testNamespaceProperties() throws Exception {
String namespace = "propchange";
String tableName1 = namespace + ".table1";
String tableName2 = namespace + ".table2";
-
+
String propKey = Property.TABLE_SCAN_MAXMEM.getKey();
String propVal = "42K";
-
+
Instance instance = new MockInstance("props");
Connector c = instance.getConnector("user", new PasswordToken("pass"));
-
+
c.tableNamespaceOperations().create(namespace);
c.tableOperations().create(tableName1);
c.tableNamespaceOperations().setProperty(namespace, propKey, propVal);
-
+
// check the namespace has the property
assertTrue(checkTableNamespaceHasProp(c, namespace, propKey, propVal));
-
+
// check that the table gets it from the namespace
assertTrue(checkTableHasProp(c, tableName1, propKey, propVal));
-
+
// test a second table to be sure the first wasn't magical
// (also, changed the order, the namespace has the property already)
c.tableOperations().create(tableName2);
assertTrue(checkTableHasProp(c, tableName2, propKey, propVal));
-
+
// test that table properties override namespace properties
String propKey2 = Property.TABLE_FILE_MAX.getKey();
String propVal2 = "42";
String tablePropVal = "13";
-
+
c.tableOperations().setProperty(tableName2, propKey2, tablePropVal);
c.tableNamespaceOperations().setProperty("propchange", propKey2, propVal2);
-
+
assertTrue(checkTableHasProp(c, tableName2, propKey2, tablePropVal));
-
+
// now check that you can change the default namespace's properties
propVal = "13K";
String tableName = "some_table";
c.tableOperations().create(tableName);
c.tableNamespaceOperations().setProperty(Constants.DEFAULT_TABLE_NAMESPACE, propKey, propVal);
-
+
assertTrue(checkTableHasProp(c, tableName, propKey, propVal));
-
+
// test the properties server-side by configuring an iterator.
// should not show anything with column-family = 'a'
String tableName3 = namespace + ".table3";
c.tableOperations().create(tableName3);
-
+
IteratorSetting setting = new IteratorSetting(250, "thing", SimpleFilter.class.getName());
c.tableNamespaceOperations().attachIterator(namespace, setting);
-
+
BatchWriter bw = c.createBatchWriter(tableName3, new BatchWriterConfig());
Mutation m = new Mutation("r");
m.put("a", "b", new Value("abcde".getBytes()));
bw.addMutation(m);
bw.flush();
bw.close();
-
+
// Scanner s = c.createScanner(tableName3, Authorizations.EMPTY);
// do scanners work correctly in mock?
// assertTrue(!s.iterator().hasNext());
}
-
+
/**
* This test renames and clones two separate table into different namespaces. different namespace.
*
@@ -203,19 +203,19 @@ public class MockTableNamespacesTest {
String tableName = "table";
String tableName1 = "renamed.table1";
// String tableName2 = "cloned.table2";
-
+
Instance instance = new MockInstance("renameclone");
Connector c = instance.getConnector("user", new PasswordToken("pass"));
-
+
c.tableOperations().create(tableName);
c.tableNamespaceOperations().create(namespace1);
c.tableNamespaceOperations().create(namespace2);
-
+
c.tableOperations().rename(tableName, tableName1);
-
+
assertTrue(c.tableOperations().exists(tableName1));
assertTrue(!c.tableOperations().exists(tableName));
-
+
// TODO implement clone in mock
/*
* c.tableOperations().clone(tableName1, tableName2, false, null, null);
@@ -224,7 +224,7 @@ public class MockTableNamespacesTest {
*/
return;
}
-
+
/**
* This test renames a table namespace and ensures that its tables are still correct
*/
@@ -233,21 +233,21 @@ public class MockTableNamespacesTest {
String namespace1 = "n1";
String namespace2 = "n2";
String table = "t";
-
+
Instance instance = new MockInstance("rename");
Connector c = instance.getConnector("user", new PasswordToken("pass"));
-
+
c.tableNamespaceOperations().create(namespace1);
c.tableOperations().create(namespace1 + "." + table);
-
+
c.tableNamespaceOperations().rename(namespace1, namespace2);
-
+
assertTrue(!c.tableNamespaceOperations().exists(namespace1));
assertTrue(c.tableNamespaceOperations().exists(namespace2));
assertTrue(!c.tableOperations().exists(namespace1 + "." + table));
assertTrue(c.tableOperations().exists(namespace2 + "." + table));
}
-
+
/**
* This tests adding iterators to a namespace, listing them, and removing them
*/
@@ -255,34 +255,34 @@ public class MockTableNamespacesTest {
public void testNamespaceIterators() throws Exception {
Instance instance = new MockInstance("Iterators");
Connector c = instance.getConnector("user", new PasswordToken("pass"));
-
+
String namespace = "iterator";
String tableName = namespace + ".table";
String iter = "thing";
-
+
c.tableNamespaceOperations().create(namespace);
c.tableOperations().create(tableName);
-
+
IteratorSetting setting = new IteratorSetting(250, iter, SimpleFilter.class.getName());
HashSet<IteratorScope> scope = new HashSet<IteratorScope>();
scope.add(IteratorScope.scan);
c.tableNamespaceOperations().attachIterator(namespace, setting, EnumSet.copyOf(scope));
-
+
BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
Mutation m = new Mutation("r");
m.put("a", "b", new Value("abcde".getBytes(Constants.UTF8)));
bw.addMutation(m);
bw.flush();
-
+
Scanner s = c.createScanner(tableName, Authorizations.EMPTY);
System.out.println(s.iterator().next());
// do scanners work correctly in mock?
// assertTrue(!s.iterator().hasNext());
-
+
assertTrue(c.tableNamespaceOperations().listIterators(namespace).containsKey(iter));
c.tableNamespaceOperations().removeIterator(namespace, iter, EnumSet.copyOf(scope));
}
-
+
private boolean checkTableHasProp(Connector c, String t, String propKey, String propVal) throws AccumuloException, TableNotFoundException {
for (Entry<String,String> e : c.tableOperations().getProperties(t)) {
if (e.getKey().equals(propKey) && e.getValue().equals(propVal)) {
@@ -291,7 +291,7 @@ public class MockTableNamespacesTest {
}
return false;
}
-
+
private boolean checkTableNamespaceHasProp(Connector c, String n, String propKey, String propVal) throws AccumuloException, TableNamespaceNotFoundException {
for (Entry<String,String> e : c.tableNamespaceOperations().getProperties(n)) {
if (e.getKey().equals(propKey) && e.getValue().equals(propVal)) {
@@ -300,8 +300,9 @@ public class MockTableNamespacesTest {
}
return false;
}
-
+
public static class SimpleFilter extends Filter {
+ @Override
public boolean accept(Key k, Value v) {
if (k.getColumnFamily().toString().equals("a"))
return false;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfWatcher.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfWatcher.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfWatcher.java
index 8bb33b8..b331940 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfWatcher.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfWatcher.java
@@ -29,25 +29,25 @@ class TableNamespaceConfWatcher implements Watcher {
Logger.getLogger("org.apache.zookeeper").setLevel(Level.WARN);
Logger.getLogger("org.apache.hadoop.io.compress").setLevel(Level.WARN);
}
-
+
private static final Logger log = Logger.getLogger(TableNamespaceConfWatcher.class);
private Instance instance = null;
-
+
TableNamespaceConfWatcher(Instance instance) {
this.instance = instance;
}
-
+
@Override
public void process(WatchedEvent event) {
String path = event.getPath();
if (log.isTraceEnabled())
log.trace("WatchEvent : " + path + " " + event.getState() + " " + event.getType());
-
+
String namespacesPrefix = ZooUtil.getRoot(instance) + Constants.ZNAMESPACES + "/";
-
+
String namespaceId = null;
String key = null;
-
+
if (path != null) {
if (path.startsWith(namespacesPrefix)) {
namespaceId = path.substring(namespacesPrefix.length());
@@ -57,13 +57,13 @@ class TableNamespaceConfWatcher implements Watcher {
key = path.substring((namespacesPrefix + namespaceId + Constants.ZNAMESPACE_CONF + "/").length());
}
}
-
+
if (namespaceId == null) {
log.warn("Zookeeper told me about a path I was not watching " + path + " state=" + event.getState() + " type=" + event.getType());
return;
}
}
-
+
switch (event.getType()) {
case NodeDataChanged:
if (log.isTraceEnabled())
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
index 2ebe338..b4e9598 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
@@ -43,7 +43,7 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration {
protected String namespaceId = null;
protected Instance inst = null;
private Set<ConfigurationObserver> observers;
-
+
public TableNamespaceConfiguration(String namespaceId, AccumuloConfiguration parent) {
inst = HdfsZooInstance.getInstance();
this.parent = parent;
@@ -152,7 +152,7 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration {
for (ConfigurationObserver co : copy)
co.propertiesChanged();
}
-
+
protected boolean isIterConst(Entry<String,String> e) {
if (e.getKey().startsWith(Property.TABLE_ITERATOR_PREFIX.getKey()) || e.getKey().startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey())) {
return true;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java
index f8d8411..8608a3e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java
@@ -19,22 +19,21 @@ package org.apache.accumulo.server.conf;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
-
/**
* Used by TableConfiguration to dynamically get the TableNamespaceConfiguration if the namespace changes
*/
public class TableParentConfiguration extends TableNamespaceConfiguration {
private String tableId;
-
+
public TableParentConfiguration(String tableId, AccumuloConfiguration parent) {
super(null, parent);
this.tableId = tableId;
this.namespaceId = getNamespaceId();
}
-
+
@Override
protected String getNamespaceId() {
- return Tables.getNamespace(inst, tableId);
+ return Tables.getNamespace(inst, tableId);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java
index 61ba133..4e5df9e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java
@@ -29,31 +29,31 @@ public class NamespacePropUtil {
public static boolean setNamespaceProperty(String namespaceId, String property, String value) throws KeeperException, InterruptedException {
if (!isPropertyValid(property, value))
return false;
-
+
// create the zk node for per-namespace properties for this namespace if it doesn't already exist
String zkNamespacePath = getPath(namespaceId);
ZooReaderWriter.getInstance().putPersistentData(zkNamespacePath, new byte[0], NodeExistsPolicy.SKIP);
-
+
// create the zk node for this property and set it's data to the specified value
String zPath = zkNamespacePath + "/" + property;
ZooReaderWriter.getInstance().putPersistentData(zPath, value.getBytes(Constants.UTF8), NodeExistsPolicy.OVERWRITE);
-
+
return true;
}
-
+
public static boolean isPropertyValid(String property, String value) {
Property p = Property.getPropertyByKey(property);
if ((p != null && !p.getType().isValidFormat(value)) || !Property.isValidTablePropertyKey(property))
return false;
-
+
return true;
}
-
+
public static void removeNamespaceProperty(String namespaceId, String property) throws InterruptedException, KeeperException {
String zPath = getPath(namespaceId) + "/" + property;
ZooReaderWriter.getInstance().recursiveDelete(zPath, NodeMissingPolicy.SKIP);
}
-
+
private static String getPath(String namespaceId) {
return ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZNAMESPACES + "/" + namespaceId + Constants.ZNAMESPACE_CONF;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CloneTableNamespace.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CloneTableNamespace.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CloneTableNamespace.java
index c6a923f..2c35173 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CloneTableNamespace.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CloneTableNamespace.java
@@ -29,20 +29,20 @@ import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class CloneTableNamespace extends Test {
-
+
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
-
+
Random rand = (Random) state.get("rand");
-
+
@SuppressWarnings("unchecked")
List<String> namespaces = (List<String>) state.get("namespaces");
-
+
String srcName = namespaces.get(rand.nextInt(namespaces.size()));
String newName = namespaces.get(rand.nextInt(namespaces.size()));
boolean flush = rand.nextBoolean();
-
+
try {
log.debug("Cloning table namespace " + srcName + " " + newName + " " + flush);
conn.tableNamespaceOperations().clone(srcName, newName, flush, new HashMap<String,String>(), new HashSet<String>(), true);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTableNamespace.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTableNamespace.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTableNamespace.java
index 749fa0f..a65043d 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTableNamespace.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTableNamespace.java
@@ -26,18 +26,18 @@ import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class CreateTableNamespace extends Test {
-
+
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
-
+
Random rand = (Random) state.get("rand");
-
+
@SuppressWarnings("unchecked")
List<String> namespaces = (List<String>) state.get("namespaces");
-
+
String namespace = namespaces.get(rand.nextInt(namespaces.size()));
-
+
try {
conn.tableNamespaceOperations().create(namespace);
log.debug("Created namespace " + namespace);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTableNamespace.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTableNamespace.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTableNamespace.java
index 16ad555..ca6e39c 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTableNamespace.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTableNamespace.java
@@ -26,18 +26,18 @@ import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class DeleteTableNamespace extends Test {
-
+
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
-
+
Random rand = (Random) state.get("rand");
-
+
@SuppressWarnings("unchecked")
List<String> namespaces = (List<String>) state.get("namespaces");
-
+
String namespace = namespaces.get(rand.nextInt(namespaces.size()));
-
+
try {
conn.tableNamespaceOperations().delete(namespace, true);
log.debug("Deleted table namespace " + namespace);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTableNamespace.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTableNamespace.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTableNamespace.java
index c895d04..4ee2417 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTableNamespace.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTableNamespace.java
@@ -27,18 +27,18 @@ import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class OfflineTableNamespace extends Test {
-
+
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
-
+
Random rand = (Random) state.get("rand");
-
+
@SuppressWarnings("unchecked")
List<String> namespaces = (List<String>) state.get("namespaces");
-
+
String namespace = namespaces.get(rand.nextInt(namespaces.size()));
-
+
try {
conn.tableNamespaceOperations().offline(namespace);
log.debug("Offlined namespace " + namespace);
@@ -48,6 +48,6 @@ public class OfflineTableNamespace extends Test {
} catch (TableNamespaceNotFoundException tne) {
log.debug("offline or online failed " + namespace + ", doesnt exist");
}
-
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/bbba3f58/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTableNamespace.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTableNamespace.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTableNamespace.java
index fdd4cef..15c7c00 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTableNamespace.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTableNamespace.java
@@ -27,19 +27,19 @@ import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class RenameTableNamespace extends Test {
-
+
@Override
public void visit(State state, Properties props) throws Exception {
Connector conn = state.getConnector();
-
+
Random rand = (Random) state.get("rand");
-
+
@SuppressWarnings("unchecked")
List<String> namespaces = (List<String>) state.get("namespaces");
-
+
String srcName = namespaces.get(rand.nextInt(namespaces.size()));
String newName = namespaces.get(rand.nextInt(namespaces.size()));
-
+
try {
conn.tableNamespaceOperations().rename(srcName, newName);
log.debug("Renamed table namespace " + srcName + " " + newName);