accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [42/50] [abbrv] ACCUMULO-802 Renamed "TableNamespace" to "Namespace"
Date Wed, 04 Dec 2013 23:58:34 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java
new file mode 100644
index 0000000..9036845
--- /dev/null
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java
@@ -0,0 +1,589 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.client.admin;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import jline.internal.Log;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.NamespaceExistsException;
+import org.apache.accumulo.core.client.NamespaceNotEmptyException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.TableOfflineException;
+import org.apache.accumulo.core.client.impl.ClientExec;
+import org.apache.accumulo.core.client.impl.ClientExecReturn;
+import org.apache.accumulo.core.client.impl.MasterClient;
+import org.apache.accumulo.core.client.impl.Namespaces;
+import org.apache.accumulo.core.client.impl.ServerClient;
+import org.apache.accumulo.core.client.impl.Tables;
+import org.apache.accumulo.core.client.impl.thrift.ClientService;
+import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
+import org.apache.accumulo.core.constraints.Constraint;
+import org.apache.accumulo.core.iterators.IteratorUtil;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.master.thrift.MasterClientService;
+import org.apache.accumulo.core.master.thrift.TableOperation;
+import org.apache.accumulo.core.security.Credentials;
+import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.ByteBufferUtil;
+import org.apache.accumulo.core.util.OpTimer;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.trace.instrument.Tracer;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransportException;
+
+/**
+ * Provides a class for administering namespaces
+ * 
+ */
+public class NamespaceOperationsImpl extends NamespaceOperationsHelper {
+  private Instance instance;
+  private Credentials credentials;
+
+  private static final Logger log = Logger.getLogger(TableOperations.class);
+
+  /**
+   * @param instance
+   *          the connection information for this instance
+   * @param credentials
+   *          the username/password for this connection
+   */
+  public NamespaceOperationsImpl(Instance instance, Credentials credentials) {
+    ArgumentChecker.notNull(instance, credentials);
+    this.instance = instance;
+    this.credentials = credentials;
+  }
+
+  /**
+   * Retrieve a list of namespaces in Accumulo.
+   * 
+   * @return List of namespaces in accumulo
+   */
+  @Override
+  public SortedSet<String> list() {
+    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Fetching list of namespaces...");
+    TreeSet<String> namespaces = new TreeSet<String>(Namespaces.getNameToIdMap(instance).keySet());
+    opTimer.stop("Fetched " + namespaces.size() + " namespaces in %DURATION%");
+    return namespaces;
+  }
+
+  /**
+   * A method to check if a namespace exists in Accumulo.
+   * 
+   * @param namespace
+   *          the name of the namespace
+   * @return true if the namespace exists
+   */
+  @Override
+  public boolean exists(String namespace) {
+    ArgumentChecker.notNull(namespace);
+
+    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Checking if namespace " + namespace + " exists...");
+    boolean exists = Namespaces.getNameToIdMap(instance).containsKey(namespace);
+    opTimer.stop("Checked existance of " + exists + " in %DURATION%");
+    return exists;
+  }
+
+  /**
+   * Create a namespace with no special configuration
+   * 
+   * @param namespace
+   *          the name of the namespace
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws NamespaceExistsException
+   *           if the namespace already exists
+   */
+  @Override
+  public void create(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceExistsException {
+    create(namespace, true, TimeType.MILLIS);
+  }
+
+  /**
+   * @param namespace
+   *          the name of the namespace
+   * @param limitVersion
+   *          Enables/disables the versioning iterator, which will limit the number of Key versions kept.
+   */
+  @Override
+  public void create(String namespace, boolean limitVersion) throws AccumuloException, AccumuloSecurityException, NamespaceExistsException {
+    create(namespace, limitVersion, TimeType.MILLIS);
+  }
+
+  /**
+   * @param namespace
+   *          the name of the namespace
+   * @param timeType
+   *          specifies logical or real-time based time recording for entries in the table
+   * @param limitVersion
+   *          Enables/disables the versioning iterator, which will limit the number of Key versions kept.
+   */
+  @Override
+  public void create(String namespace, boolean limitVersion, TimeType timeType) throws AccumuloException, AccumuloSecurityException, NamespaceExistsException {
+    ArgumentChecker.notNull(namespace, timeType);
+
+    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(namespace.getBytes()), ByteBuffer.wrap(timeType.name().getBytes()));
+
+    Map<String,String> opts = IteratorUtil.generateInitialTableProperties(limitVersion);
+
+    try {
+      doNamespaceOperation(TableOperation.CREATE, args, opts);
+    } catch (NamespaceNotFoundException e1) {
+      // should not happen
+      throw new RuntimeException(e1);
+    }
+  }
+
+  private long beginNamespaceOperation() throws ThriftSecurityException, TException {
+    while (true) {
+      MasterClientService.Iface client = null;
+      try {
+        client = MasterClient.getConnectionWithRetry(instance);
+        return client.beginNamespaceOperation(Tracer.traceInfo(), credentials.toThrift(instance));
+      } catch (TTransportException tte) {
+        log.debug("Failed to call beginNamespaceOperation(), retrying ... ", tte);
+        UtilWaitThread.sleep(100);
+      } finally {
+        MasterClient.close(client);
+      }
+    }
+  }
+
+  private void executeNamespaceOperation(long opid, TableOperation op, List<ByteBuffer> args, Map<String,String> opts, boolean autoCleanUp)
+      throws ThriftSecurityException, TException, ThriftTableOperationException {
+    while (true) {
+      MasterClientService.Iface client = null;
+      try {
+        client = MasterClient.getConnectionWithRetry(instance);
+        client.executeNamespaceOperation(Tracer.traceInfo(), credentials.toThrift(instance), opid, op, args, opts, autoCleanUp);
+        break;
+      } catch (TTransportException tte) {
+        log.debug("Failed to call executeTableOperation(), retrying ... ", tte);
+        UtilWaitThread.sleep(100);
+      } finally {
+        MasterClient.close(client);
+      }
+    }
+  }
+
+  private String waitForNamespaceOperation(long opid) throws ThriftSecurityException, TException, ThriftTableOperationException {
+    while (true) {
+      MasterClientService.Iface client = null;
+      try {
+        client = MasterClient.getConnectionWithRetry(instance);
+        return client.waitForNamespaceOperation(Tracer.traceInfo(), credentials.toThrift(instance), opid);
+      } catch (TTransportException tte) {
+        log.debug("Failed to call waitForTableOperation(), retrying ... ", tte);
+        UtilWaitThread.sleep(100);
+      } finally {
+        MasterClient.close(client);
+      }
+    }
+  }
+
+  private void finishNamespaceOperation(long opid) throws ThriftSecurityException, TException {
+    while (true) {
+      MasterClientService.Iface client = null;
+      try {
+        client = MasterClient.getConnectionWithRetry(instance);
+        client.finishNamespaceOperation(Tracer.traceInfo(), credentials.toThrift(instance), opid);
+        break;
+      } catch (TTransportException tte) {
+        log.debug("Failed to call finishTableOperation(), retrying ... ", tte);
+        UtilWaitThread.sleep(100);
+      } finally {
+        MasterClient.close(client);
+      }
+    }
+  }
+
+  private String doNamespaceOperation(TableOperation op, List<ByteBuffer> args, Map<String,String> opts) throws AccumuloSecurityException,
+      NamespaceExistsException, NamespaceNotFoundException, AccumuloException {
+    return doNamespaceOperation(op, args, opts, true);
+  }
+
+  private String doNamespaceOperation(TableOperation op, List<ByteBuffer> args, Map<String,String> opts, boolean wait) throws AccumuloSecurityException,
+      NamespaceExistsException, NamespaceNotFoundException, AccumuloException {
+    Long opid = null;
+
+    try {
+      opid = beginNamespaceOperation();
+      executeNamespaceOperation(opid, op, args, opts, !wait);
+      if (!wait) {
+        opid = null;
+        return null;
+      }
+      String ret = waitForNamespaceOperation(opid);
+      Tables.clearCache(instance);
+      return ret;
+    } catch (ThriftSecurityException e) {
+      String tableName = ByteBufferUtil.toString(args.get(0));
+      String tableInfo = Tables.getPrintableTableInfoFromName(instance, tableName);
+      throw new AccumuloSecurityException(e.user, e.code, tableInfo, e);
+    } catch (ThriftTableOperationException e) {
+      switch (e.getType()) {
+        case EXISTS:
+          throw new NamespaceExistsException(e);
+        case NOTFOUND:
+          throw new NamespaceNotFoundException(e);
+        case OFFLINE:
+          throw new TableOfflineException(instance, null);
+        case OTHER:
+        default:
+          throw new AccumuloException(e.description, e);
+      }
+    } catch (Exception e) {
+      throw new AccumuloException(e.getMessage(), e);
+    } finally {
+      // always finish table op, even when exception
+      if (opid != null)
+        try {
+          finishNamespaceOperation(opid);
+        } catch (Exception e) {
+          log.warn(e.getMessage(), e);
+        }
+    }
+  }
+
+  /**
+   * Delete a namespace if empty
+   * 
+   * @param namespace
+   *          the name of the namespace
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws NamespaceNotFoundException
+   *           if the namespace does not exist
+   * @throws NamespaceNotEmptyException
+   *           if the namespaces still contains tables
+   * @throws TableNotFoundException
+   *           if table not found while deleting
+   */
+  @Override
+  public void delete(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException, NamespaceNotEmptyException,
+      TableNotFoundException {
+    delete(namespace, false);
+  }
+
+  /**
+   * Delete a namespace
+   * 
+   * @param namespace
+   *          the name of the namespace
+   * @param deleteTables
+   *          boolean, if true deletes all the tables in the namespace in addition to deleting the namespace.
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws NamespaceNotFoundException
+   *           if the namespace does not exist
+   * @throws NamespaceNotEmptyException
+   *           if the namespaces still contains tables
+   * @throws TableNotFoundException
+   *           if table not found while deleting
+   */
+  @Override
+  public void delete(String namespace, boolean deleteTables) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException,
+      NamespaceNotEmptyException, TableNotFoundException {
+    ArgumentChecker.notNull(namespace);
+    String namespaceId = Namespaces.getNamespaceId(instance, namespace);
+
+    if (namespaceId.equals(Constants.SYSTEM_NAMESPACE_ID) || namespaceId.equals(Constants.DEFAULT_NAMESPACE_ID)) {
+      log.debug(credentials.getPrincipal() + " attempted to delete the " + namespaceId + " namespace");
+      throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.UNSUPPORTED_OPERATION);
+    }
+
+    if (Namespaces.getTableIds(instance, namespaceId).size() > 0) {
+      if (!deleteTables) {
+        throw new NamespaceNotEmptyException(namespaceId, namespace, null);
+      }
+      for (String table : Namespaces.getTableNames(instance, namespaceId)) {
+        try {
+          getTableOperations().delete(table);
+        } catch (TableNotFoundException e) {
+          log.debug("Table (" + table + ") not found while deleting namespace, probably deleted while we were deleting the rest of the tables");
+        }
+      }
+    }
+
+    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(namespace.getBytes()));
+    Map<String,String> opts = new HashMap<String,String>();
+
+    try {
+      doNamespaceOperation(TableOperation.DELETE, args, opts);
+    } catch (NamespaceExistsException e) {
+      // should not happen
+      throw new RuntimeException(e);
+    }
+
+  }
+
+  /**
+   * Rename a namespace
+   * 
+   * @param oldNamespaceName
+   *          the old namespace
+   * @param newNamespaceName
+   *          the new namespace
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws NamespaceNotFoundException
+   *           if the old namespace name does not exist
+   * @throws NamespaceExistsException
+   *           if the new namespace name already exists
+   */
+  @Override
+  public void rename(String oldNamespaceName, String newNamespaceName) throws AccumuloSecurityException, NamespaceNotFoundException, AccumuloException,
+      NamespaceExistsException {
+
+    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(oldNamespaceName.getBytes()), ByteBuffer.wrap(newNamespaceName.getBytes()));
+    Map<String,String> opts = new HashMap<String,String>();
+    doNamespaceOperation(TableOperation.RENAME, args, opts);
+  }
+
+  /**
+   * Sets a property on a namespace which will apply to all tables in the namespace
+   * 
+   * @param namespace
+   *          the name of the namespace
+   * @param property
+   *          the name of a per-table property
+   * @param value
+   *          the value to set a per-table property to
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   */
+  @Override
+  public void setProperty(final String namespace, final String property, final String value) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(namespace, property, value);
+
+    MasterClient.execute(instance, new ClientExec<MasterClientService.Client>() {
+      @Override
+      public void execute(MasterClientService.Client client) throws Exception {
+        client.setNamespaceProperty(Tracer.traceInfo(), credentials.toThrift(instance), namespace, property, value);
+      }
+    });
+  }
+
+  /**
+   * Removes a property from a namespace
+   * 
+   * @param namespace
+   *          the name of the namespace
+   * @param property
+   *          the name of a per-table property
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   */
+  @Override
+  public void removeProperty(final String namespace, final String property) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(namespace, property);
+
+    MasterClient.execute(instance, new ClientExec<MasterClientService.Client>() {
+      @Override
+      public void execute(MasterClientService.Client client) throws Exception {
+        client.removeNamespaceProperty(Tracer.traceInfo(), credentials.toThrift(instance), namespace, property);
+      }
+    });
+  }
+
+  /**
+   * Gets properties of a namespace
+   * 
+   * @param namespace
+   *          the name of the namespace
+   * @return all properties visible by this namespace (system and per-namespace properties)
+   * @throws NamespaceNotFoundException
+   *           if the namespace does not exist
+   */
+  @Override
+  public Iterable<Entry<String,String>> getProperties(final String namespace) throws AccumuloException, NamespaceNotFoundException {
+    ArgumentChecker.notNull(namespace);
+    try {
+      return ServerClient.executeRaw(instance, new ClientExecReturn<Map<String,String>,ClientService.Client>() {
+        @Override
+        public Map<String,String> execute(ClientService.Client client) throws Exception {
+          return client.getNamespaceConfiguration(Tracer.traceInfo(), credentials.toThrift(instance), namespace);
+        }
+      }).entrySet();
+    } catch (ThriftTableOperationException e) {
+      switch (e.getType()) {
+        case NOTFOUND:
+          throw new NamespaceNotFoundException(e);
+        case OTHER:
+        default:
+          throw new AccumuloException(e.description, e);
+      }
+    } catch (AccumuloException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new AccumuloException(e);
+    }
+
+  }
+
+  /**
+   * 
+   * @param namespace
+   *          the namespace to take offline
+   * @throws AccumuloException
+   *           when there is a general accumulo error
+   * @throws AccumuloSecurityException
+   *           when the user does not have the proper permissions
+   * @throws NamespaceNotFoundException
+   *           if the namespace does not exist
+   */
+  @Override
+  public void offline(String namespace) throws AccumuloSecurityException, AccumuloException, NamespaceNotFoundException {
+
+    ArgumentChecker.notNull(namespace);
+    String namespaceId = Namespaces.getNamespaceId(instance, namespace);
+    try {
+      for (String table : Namespaces.getTableNames(instance, namespaceId)) {
+        getTableOperations().offline(table);
+      }
+    } catch (TableNotFoundException e) {
+      Log.error("Namespace (" + namespaceId + ") contains reference to table that doesn't exist");
+    }
+  }
+
+  /**
+   * 
+   * @param namespace
+   *          the namespace to take online
+   * @throws AccumuloException
+   *           when there is a general accumulo error
+   * @throws AccumuloSecurityException
+   *           when the user does not have the proper permissions
+   * @throws NamespaceNotFoundException
+   *           if the namespace does not exist
+   */
+  @Override
+  public void online(String namespace) throws AccumuloSecurityException, AccumuloException, NamespaceNotFoundException {
+    ArgumentChecker.notNull(namespace);
+    String namespaceId = Namespaces.getNamespaceId(instance, namespace);
+    try {
+      for (String table : Namespaces.getTableNames(instance, namespaceId)) {
+        getTableOperations().online(table);
+      }
+    } catch (TableNotFoundException e) {
+      Log.warn("Namespace (" + namespaceId + ") contains a reference to a table that doesn't exist");
+    }
+  }
+
+  /**
+   * Get a mapping of namespace name to internal namespace id.
+   * 
+   * @return the map from namespace name to internal namespace id
+   */
+  @Override
+  public Map<String,String> namespaceIdMap() {
+    return Namespaces.getNameToIdMap(instance);
+  }
+
+  @Override
+  public List<DiskUsage> getDiskUsage(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException {
+    Set<String> tables = new HashSet<String>();
+    String namespaceId = Namespaces.getNamespaceId(instance, namespace);
+    tables.addAll(Namespaces.getTableNames(instance, namespaceId));
+    List<DiskUsage> du = null;
+    try {
+      du = getTableOperations().getDiskUsage(tables);
+    } catch (TableNotFoundException e) {
+      log.warn("Could not find table (" + e.getTableName() + ") reference in namespace (" + namespace + ")");
+    }
+    return du;
+  }
+
+  private TableOperations getTableOperations() throws AccumuloException, AccumuloSecurityException {
+    return new TableOperationsImpl(instance, credentials);
+  }
+
+  @Override
+  public void attachIterator(String namespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
+      NamespaceNotFoundException {
+    testClassLoad(namespace, setting.getIteratorClass(), SortedKeyValueIterator.class.getName());
+    super.attachIterator(namespace, setting, scopes);
+  }
+
+  @Override
+  public int addConstraint(String namespace, String constraintClassName) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException {
+    testClassLoad(namespace, constraintClassName, Constraint.class.getName());
+    return super.addConstraint(namespace, constraintClassName);
+  }
+
+  @Override
+  public boolean testClassLoad(final String namespace, final String className, final String asTypeName) throws NamespaceNotFoundException, AccumuloException,
+      AccumuloSecurityException {
+    ArgumentChecker.notNull(namespace, className, asTypeName);
+
+    try {
+      return ServerClient.executeRaw(instance, new ClientExecReturn<Boolean,ClientService.Client>() {
+        @Override
+        public Boolean execute(ClientService.Client client) throws Exception {
+          return client.checkNamespaceClass(Tracer.traceInfo(), credentials.toThrift(instance), namespace, className, asTypeName);
+        }
+      });
+    } catch (ThriftTableOperationException e) {
+      switch (e.getType()) {
+        case NOTFOUND:
+          throw new NamespaceNotFoundException(e);
+        case OTHER:
+        default:
+          throw new AccumuloException(e.description, e);
+      }
+    } catch (ThriftSecurityException e) {
+      throw new AccumuloSecurityException(e.user, e.code, e);
+    } catch (AccumuloException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new AccumuloException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java
index 8a93efa..b3178fd 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java
@@ -23,15 +23,15 @@ import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.NamespacePermission;
 import org.apache.accumulo.core.security.SystemPermission;
-import org.apache.accumulo.core.security.TableNamespacePermission;
 import org.apache.accumulo.core.security.TablePermission;
 
 /**
  * Provides a class for managing users and permissions
  */
 public interface SecurityOperations {
-  
+
   /**
    * Create a user
    * 
@@ -49,7 +49,7 @@ public interface SecurityOperations {
    */
   @Deprecated
   public void createUser(String user, byte[] password, Authorizations authorizations) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Create a user
    * 
@@ -64,7 +64,7 @@ public interface SecurityOperations {
    * @since 1.5.0
    */
   public void createLocalUser(String principal, PasswordToken password) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Delete a user
    * 
@@ -78,7 +78,7 @@ public interface SecurityOperations {
    */
   @Deprecated
   public void dropUser(String user) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Delete a user
    * 
@@ -91,7 +91,7 @@ public interface SecurityOperations {
    * @since 1.5.0
    */
   public void dropLocalUser(String principal) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Verify a username/password combination is valid
    * 
@@ -108,7 +108,7 @@ public interface SecurityOperations {
    */
   @Deprecated
   public boolean authenticateUser(String user, byte[] password) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Verify a username/password combination is valid
    * 
@@ -124,7 +124,7 @@ public interface SecurityOperations {
    * @since 1.5.0
    */
   public boolean authenticateUser(String principal, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Set the user's password
    * 
@@ -141,7 +141,7 @@ public interface SecurityOperations {
    */
   @Deprecated
   public void changeUserPassword(String user, byte[] password) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Set the user's password
    * 
@@ -156,7 +156,7 @@ public interface SecurityOperations {
    * @since 1.5.0
    */
   public void changeLocalUserPassword(String principal, PasswordToken token) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Set the user's record-level authorizations
    * 
@@ -170,7 +170,7 @@ public interface SecurityOperations {
    *           if the user does not have permission to modify a user
    */
   public void changeUserAuthorizations(String principal, Authorizations authorizations) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Retrieves the user's authorizations for scanning
    * 
@@ -183,7 +183,7 @@ public interface SecurityOperations {
    *           if the user does not have permission to query a user
    */
   public Authorizations getUserAuthorizations(String principal) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Verify the user has a particular system permission
    * 
@@ -198,7 +198,7 @@ public interface SecurityOperations {
    *           if the user does not have permission to query a user
    */
   public boolean hasSystemPermission(String principal, SystemPermission perm) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Verify the user has a particular table permission
    * 
@@ -215,24 +215,24 @@ public interface SecurityOperations {
    *           if the user does not have permission to query a user
    */
   public boolean hasTablePermission(String principal, String table, TablePermission perm) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
-   * Verify the user has a particular table namespace permission
+   * Verify the user has a particular namespace permission
    * 
    * @param principal
    *          the name of the user to query
-   * @param tableNamespace
-   *          the name of the table namespace to query about
+   * @param namespace
+   *          the name of the namespace to query about
    * @param perm
-   *          the table namespace permission to check for
+   *          the namespace permission to check for
    * @return true if user has that permission; false otherwise
    * @throws AccumuloException
    *           if a general error occurs
    * @throws AccumuloSecurityException
    *           if the user does not have permission to query a user
    */
-  public boolean hasTableNamespacePermission(String principal, String tableNamespace, TableNamespacePermission perm) throws AccumuloException, AccumuloSecurityException;
-  
+  public boolean hasNamespacePermission(String principal, String namespace, NamespacePermission perm) throws AccumuloException, AccumuloSecurityException;
+
   /**
    * Grant a user a system permission
    * 
@@ -246,7 +246,7 @@ public interface SecurityOperations {
    *           if the user does not have permission to grant a user permissions
    */
   public void grantSystemPermission(String principal, SystemPermission permission) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Grant a user a specific permission for a specific table
    * 
@@ -262,23 +262,23 @@ public interface SecurityOperations {
    *           if the user does not have permission to grant a user permissions
    */
   public void grantTablePermission(String principal, String table, TablePermission permission) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
-   * Grant a user a specific permission for a specific table namespace
+   * Grant a user a specific permission for a specific namespace
    * 
    * @param principal
    *          the name of the user to modify
-   * @param tableNamespace
-   *          the name of the table namespace to modify for the user
+   * @param namespace
+   *          the name of the namespace to modify for the user
    * @param permission
-   *          the table namespace permission to grant to the user
+   *          the namespace permission to grant to the user
    * @throws AccumuloException
    *           if a general error occurs
    * @throws AccumuloSecurityException
    *           if the user does not have permission to grant a user permissions
    */
-  public void grantTableNamespacePermission(String principal, String tableNamespace, TableNamespacePermission permission) throws AccumuloException, AccumuloSecurityException;
-  
+  public void grantNamespacePermission(String principal, String namespace, NamespacePermission permission) throws AccumuloException, AccumuloSecurityException;
+
   /**
    * Revoke a system permission from a user
    * 
@@ -292,7 +292,7 @@ public interface SecurityOperations {
    *           if the user does not have permission to revoke a user's permissions
    */
   public void revokeSystemPermission(String principal, SystemPermission permission) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Revoke a table permission for a specific user on a specific table
    * 
@@ -308,23 +308,23 @@ public interface SecurityOperations {
    *           if the user does not have permission to revoke a user's permissions
    */
   public void revokeTablePermission(String principal, String table, TablePermission permission) throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
-   * Revoke a table namespace permission for a specific user on a specific table namespace
+   * Revoke a namespace permission for a specific user on a specific namespace
    * 
    * @param principal
    *          the name of the user to modify
-   * @param tableNamespace
-   *          the name of the table namespace to modify for the user
+   * @param namespace
+   *          the name of the namespace to modify for the user
    * @param permission
-   *          the table namespace permission to revoke for the user
+   *          the namespace permission to revoke for the user
    * @throws AccumuloException
    *           if a general error occurs
    * @throws AccumuloSecurityException
    *           if the user does not have permission to revoke a user's permissions
    */
-  public void revokeTableNamespacePermission(String principal, String tableNamespace, TableNamespacePermission permission) throws AccumuloException, AccumuloSecurityException;
-  
+  public void revokeNamespacePermission(String principal, String namespace, NamespacePermission permission) throws AccumuloException, AccumuloSecurityException;
+
   /**
    * Return a list of users in accumulo
    * 
@@ -337,7 +337,7 @@ public interface SecurityOperations {
    */
   @Deprecated
   public Set<String> listUsers() throws AccumuloException, AccumuloSecurityException;
-  
+
   /**
    * Return a list of users in accumulo
    * 
@@ -349,5 +349,5 @@ public interface SecurityOperations {
    * @since 1.5.0
    */
   public Set<String> listLocalUsers() throws AccumuloException, AccumuloSecurityException;
-  
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
index 107ba74..ebd79ad 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
@@ -34,18 +34,18 @@ import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.Credentials;
+import org.apache.accumulo.core.security.NamespacePermission;
 import org.apache.accumulo.core.security.SystemPermission;
-import org.apache.accumulo.core.security.TableNamespacePermission;
 import org.apache.accumulo.core.security.TablePermission;
 import org.apache.accumulo.core.util.ArgumentChecker;
 import org.apache.accumulo.core.util.ByteBufferUtil;
 import org.apache.accumulo.trace.instrument.Tracer;
 
 public class SecurityOperationsImpl implements SecurityOperations {
-  
+
   private Instance instance;
   private Credentials credentials;
-  
+
   private void execute(ClientExec<ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
     try {
       ServerClient.executeRaw(instance, exec);
@@ -63,7 +63,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       throw new AccumuloException(e);
     }
   }
-  
+
   private <T> T execute(ClientExecReturn<T,ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
     try {
       return ServerClient.executeRaw(instance, exec);
@@ -81,20 +81,20 @@ public class SecurityOperationsImpl implements SecurityOperations {
       throw new AccumuloException(e);
     }
   }
-  
+
   public SecurityOperationsImpl(Instance instance, Credentials credentials) {
     ArgumentChecker.notNull(instance, credentials);
     this.instance = instance;
     this.credentials = credentials;
   }
-  
+
   @Deprecated
   @Override
   public void createUser(String user, byte[] password, final Authorizations authorizations) throws AccumuloException, AccumuloSecurityException {
     createLocalUser(user, new PasswordToken(password));
     changeUserAuthorizations(user, authorizations);
   }
-  
+
   @Override
   public void createLocalUser(final String principal, final PasswordToken password) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, password);
@@ -105,13 +105,13 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Deprecated
   @Override
   public void dropUser(final String user) throws AccumuloException, AccumuloSecurityException {
     dropLocalUser(user);
   }
-  
+
   @Override
   public void dropLocalUser(final String principal) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal);
@@ -122,13 +122,13 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Deprecated
   @Override
   public boolean authenticateUser(String user, byte[] password) throws AccumuloException, AccumuloSecurityException {
     return authenticateUser(user, new PasswordToken(password));
   }
-  
+
   @Override
   public boolean authenticateUser(final String principal, final AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, token);
@@ -140,13 +140,13 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
   @Deprecated
   public void changeUserPassword(String user, byte[] password) throws AccumuloException, AccumuloSecurityException {
     changeLocalUserPassword(user, new PasswordToken(password));
   }
-  
+
   @Override
   public void changeLocalUserPassword(final String principal, final PasswordToken token) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, token);
@@ -161,7 +161,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       this.credentials = toChange;
     }
   }
-  
+
   @Override
   public void changeUserAuthorizations(final String principal, final Authorizations authorizations) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, authorizations);
@@ -173,7 +173,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
   public Authorizations getUserAuthorizations(final String principal) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal);
@@ -184,7 +184,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
   public boolean hasSystemPermission(final String principal, final SystemPermission perm) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, perm);
@@ -195,7 +195,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
   public boolean hasTablePermission(final String principal, final String table, final TablePermission perm) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, table, perm);
@@ -206,18 +206,19 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
-  public boolean hasTableNamespacePermission(final String principal, final String tableNamespace, final TableNamespacePermission perm) throws AccumuloException, AccumuloSecurityException {
-    ArgumentChecker.notNull(principal, tableNamespace, perm);
+  public boolean hasNamespacePermission(final String principal, final String namespace, final NamespacePermission permission) throws AccumuloException,
+      AccumuloSecurityException {
+    ArgumentChecker.notNull(principal, namespace, permission);
     return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
       @Override
       public Boolean execute(ClientService.Client client) throws Exception {
-        return client.hasTableNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, tableNamespace, perm.getId());
+        return client.hasNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, namespace, permission.getId());
       }
     });
   }
-  
+
   @Override
   public void grantSystemPermission(final String principal, final SystemPermission permission) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, permission);
@@ -228,7 +229,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
   public void grantTablePermission(final String principal, final String table, final TablePermission permission) throws AccumuloException,
       AccumuloSecurityException {
@@ -240,19 +241,19 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
-  public void grantTableNamespacePermission(final String principal, final String tableNamespace, final TableNamespacePermission permission) throws AccumuloException,
+  public void grantNamespacePermission(final String principal, final String namespace, final NamespacePermission permission) throws AccumuloException,
       AccumuloSecurityException {
-    ArgumentChecker.notNull(principal, tableNamespace, permission);
+    ArgumentChecker.notNull(principal, namespace, permission);
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.grantTableNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, tableNamespace, permission.getId());
+        client.grantNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, namespace, permission.getId());
       }
     });
   }
-  
+
   @Override
   public void revokeSystemPermission(final String principal, final SystemPermission permission) throws AccumuloException, AccumuloSecurityException {
     ArgumentChecker.notNull(principal, permission);
@@ -263,7 +264,7 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
   public void revokeTablePermission(final String principal, final String table, final TablePermission permission) throws AccumuloException,
       AccumuloSecurityException {
@@ -275,25 +276,25 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
   @Override
-  public void revokeTableNamespacePermission(final String principal, final String tableNamespace, final TableNamespacePermission permission) throws AccumuloException,
+  public void revokeNamespacePermission(final String principal, final String namespace, final NamespacePermission permission) throws AccumuloException,
       AccumuloSecurityException {
-    ArgumentChecker.notNull(principal, tableNamespace, permission);
+    ArgumentChecker.notNull(principal, namespace, permission);
     execute(new ClientExec<ClientService.Client>() {
       @Override
       public void execute(ClientService.Client client) throws Exception {
-        client.revokeTableNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, tableNamespace, permission.getId());
+        client.revokeNamespacePermission(Tracer.traceInfo(), credentials.toThrift(instance), principal, namespace, permission.getId());
       }
     });
   }
-  
+
   @Deprecated
   @Override
   public Set<String> listUsers() throws AccumuloException, AccumuloSecurityException {
     return listLocalUsers();
   }
-  
+
   @Override
   public Set<String> listLocalUsers() throws AccumuloException, AccumuloSecurityException {
     return execute(new ClientExecReturn<Set<String>,ClientService.Client>() {
@@ -303,5 +304,5 @@ public class SecurityOperationsImpl implements SecurityOperations {
       }
     });
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/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
deleted file mode 100644
index d966f3c..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperations.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.core.client.admin;
-
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.SortedSet;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.TableNamespaceExistsException;
-import org.apache.accumulo.core.client.TableNamespaceNotEmptyException;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-
-/**
- * Provides a class for administering table namespaces
- * 
- */
-
-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.
-   * 
-   * @param namespace
-   *          the name of the table namespace
-   * @return true if the table namespace exists
-   */
-  public boolean exists(String namespace);
-
-  /**
-   * Create a table namespace with no special configuration
-   * 
-   * @param namespace
-   *          the name of the table namespace
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           if the user does not have permission
-   * @throws TableNamespaceExistsException
-   *           if the table namespace already exists
-   */
-  public void create(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceExistsException;
-
-  /**
-   * @param namespace
-   *          the name of the table namespace
-   * @param limitVersion
-   *          Enables/disables the versioning iterator, which will limit the number of Key versions kept.
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           if the user does not have permission
-   * @throws TableNamespaceExistsException
-   *           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
-   * @param versioningIter
-   *          Enables/disables the versioning iterator, which will limit the number of Key versions kept.
-   * @param timeType
-   *          specifies logical or real-time based time recording for entries in the table
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           if the user does not have permission
-   * @throws TableNamespaceExistsException
-   *           if the table namespace already exists
-   */
-  public void create(String namespace, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException,
-      TableNamespaceExistsException;
-
-  /**
-   * Delete a table namespace if it is empty
-   * 
-   * @param namespace
-   *          the name of the table namespace
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           if the user does not have permission
-   * @throws TableNamespaceNotFoundException
-   *           if the table namespace does not exist
-   * @throws TableNamespaceNotEmptyException
-   *           if the table namespaces still contains tables
-   * @throws TableNotFoundException
-   *           if table not found while deleting
-   */
-  public void delete(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException, TableNamespaceNotEmptyException,
-      TableNotFoundException;
-
-  /**
-   * Delete a table namespace
-   * 
-   * @param namespace
-   *          the name of the table namespace
-   * @param deleteTables
-   *          boolean, if true deletes all the tables in the namespace in addition to deleting the namespace.
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           if the user does not have permission
-   * @throws TableNamespaceNotFoundException
-   *           if the table namespace does not exist
-   * @throws TableNamespaceNotEmptyException
-   *           if the table namespaces still contains tables
-   * @throws TableNotFoundException
-   *           if table not found while deleting
-   */
-  public void delete(String namespace, boolean deleteTables) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException,
-      TableNamespaceNotEmptyException, TableNotFoundException;
-
-  /**
-   * Rename a table namespace
-   * 
-   * @param oldNamespaceName
-   *          the old table namespace name
-   * @param newNamespaceName
-   *          the new table namespace name
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           if the user does not have permission
-   * @throws TableNamespaceNotFoundException
-   *           if the old table namespace does not exist
-   * @throws TableNamespaceExistsException
-   *           if the new table namespace already exists
-   */
-  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.
-   * 
-   * @param namespace
-   *          the name of the table namespace
-   * @param property
-   *          the name of a per-table property
-   * @param value
-   *          the value to set a per-table property to
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           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.
-   * 
-   * @param namespace
-   *          the name of the table namespace
-   * @param property
-   *          the name of a per-table property
-   * @throws AccumuloException
-   *           if a general error occurs
-   * @throws AccumuloSecurityException
-   *           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.
-   * 
-   * @param namespace
-   *          the name of the table namespace
-   * @return all properties visible by this table (system and per-table properties). Note that recently changed properties may not be visible immediately.
-   * @throws TableNamespaceNotFoundException
-   *           if the table namespace does not exist
-   */
-  public Iterable<Entry<String,String>> getProperties(String namespace) throws AccumuloException, TableNamespaceNotFoundException;
-
-  /**
-   * 
-   * @param namespace
-   *          the table namespace to take offline
-   * @throws AccumuloException
-   *           when there is a general accumulo error
-   * @throws AccumuloSecurityException
-   *           when the user does not have the proper permissions
-   * @throws TableNamespaceNotFoundException
-   *           if the table namespace does not exist
-   */
-  public void offline(String namespace) throws AccumuloSecurityException, AccumuloException, TableNamespaceNotFoundException;
-
-  /**
-   * 
-   * @param namespace
-   *          the table namespace to take online
-   * @throws AccumuloException
-   *           when there is a general accumulo error
-   * @throws AccumuloSecurityException
-   *           when the user does not have the proper permissions
-   * @throws TableNamespaceNotFoundException
-   *           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
-   * 
-   * @param namespace
-   *          the table namespace to get the set of tables from
-   * 
-   * @return a list of disk usage objects containing linked table names and sizes
-   * @throws AccumuloException
-   *           when there is a general accumulo error
-   * @throws AccumuloSecurityException
-   *           when the user does not have the proper permissions
-   */
-  public List<DiskUsage> getDiskUsage(String namespace) throws AccumuloException, AccumuloSecurityException, TableNamespaceNotFoundException;
-
-  /**
-   * Add an iterator to a table namespace on all scopes.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @param setting
-   *          object specifying the properties of the iterator
-   * @throws AccumuloSecurityException
-   *           thrown if the user does not have the ability to set properties on the table namespace
-   * @throws AccumuloException
-   * @throws TableNamespaceNotFoundException
-   *           throw if the table namespace no longer exists
-   * @throws IllegalArgumentException
-   *           if the setting conflicts with any existing iterators
-   */
-  public void attachIterator(String tableNamespace, IteratorSetting setting) throws AccumuloSecurityException, AccumuloException,
-      TableNamespaceNotFoundException;
-
-  /**
-   * Add an iterator to a table namespace on the given scopes.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @param setting
-   *          object specifying the properties of the iterator
-   * @throws AccumuloSecurityException
-   *           thrown if the user does not have the ability to set properties on the table namespace
-   * @throws AccumuloException
-   * @throws TableNamespaceNotFoundException
-   *           throw if the table namespace no longer exists
-   * @throws IllegalArgumentException
-   *           if the setting conflicts with any existing iterators
-   */
-  public void attachIterator(String tableNamespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException,
-      AccumuloException, TableNamespaceNotFoundException;
-
-  /**
-   * Remove an iterator from a table namespace by name.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @param name
-   *          the name of the iterator
-   * @param scopes
-   *          the scopes of the iterator
-   * @throws AccumuloSecurityException
-   *           thrown if the user does not have the ability to set properties on the table namespace
-   * @throws AccumuloException
-   * @throws TableNamespaceNotFoundException
-   *           thrown if the table namespace no longer exists
-   */
-  public void removeIterator(String tableNamespace, String name, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
-      TableNamespaceNotFoundException;
-
-  /**
-   * Get the settings for an iterator.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @param name
-   *          the name of the iterator
-   * @param scope
-   *          the scope of the iterator
-   * @return the settings for this iterator
-   * @throws AccumuloSecurityException
-   *           thrown if the user does not have the ability to set properties on the table namespace
-   * @throws AccumuloException
-   * @throws TableNamespaceNotFoundException
-   *           thrown if the table namespace no longer exists
-   */
-  public IteratorSetting getIteratorSetting(String tableNamespace, String name, IteratorScope scope) throws AccumuloSecurityException, AccumuloException,
-      NumberFormatException, TableNamespaceNotFoundException;
-
-  /**
-   * Get a list of iterators for this table namespace.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @return a set of iterator names
-   * @throws AccumuloSecurityException
-   *           thrown if the user does not have the ability to set properties on the table namespace
-   * @throws AccumuloException
-   * @throws TableNamespaceNotFoundException
-   *           thrown if the table namespace no longer exists
-   */
-  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.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @param setting
-   *          object specifying the properties of the iterator
-   * @throws AccumuloException
-   * @throws TableNamespaceNotFoundException
-   *           thrown if the table namespace no longer exists
-   * @throws IllegalStateException
-   *           if the setting conflicts with any existing iterators
-   */
-  public void checkIteratorConflicts(String tableNamespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloException,
-      TableNamespaceNotFoundException;
-
-  /**
-   * Add a new constraint to a table namespace.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @param constraintClassName
-   *          the full name of the constraint class
-   * @return the unique number assigned to the constraint
-   * @throws AccumuloException
-   *           thrown if the constraint has already been added to the table or if there are errors in the configuration of existing constraints
-   * @throws AccumuloSecurityException
-   *           thrown if the user doesn't have permission to add the constraint
-   * @throws TableNamespaceNotFoundException
-   *           thrown if the table namespace no longer exists
-   */
-  public int addConstraint(String tableNamespace, String constraintClassName) throws AccumuloException, AccumuloSecurityException,
-      TableNamespaceNotFoundException;
-
-  /**
-   * Remove a constraint from a table namespace.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @param number
-   *          the unique number assigned to the constraint
-   * @throws AccumuloException
-   * @throws AccumuloSecurityException
-   *           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.
-   * 
-   * @param tableNamespace
-   *          the name of the table namespace
-   * @return a map from constraint class name to assigned number
-   * @throws AccumuloException
-   *           thrown if there are errors in the configuration of existing constraints
-   * @throws TableNamespaceNotFoundException
-   *           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.
-   * 
-   * @return true if the instance can load the given class as the given type, false otherwise
-   */
-  boolean testClassLoad(String namespace, String className, String asTypeName) throws TableNamespaceNotFoundException, AccumuloException,
-      AccumuloSecurityException;
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/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
deleted file mode 100644
index c73d8e9..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableNamespaceOperationsHelper.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.core.client.admin;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
-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 {
-    checkIteratorConflicts(tableNamespace, setting, scopes);
-    for (IteratorScope scope : scopes) {
-      String root = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase(), setting.getName());
-      for (Entry<String,String> prop : setting.getOptions().entrySet()) {
-        this.setProperty(tableNamespace, root + ".opt." + prop.getKey(), prop.getValue());
-      }
-      this.setProperty(tableNamespace, root, setting.getPriority() + "," + setting.getIteratorClass());
-    }
-  }
-
-  @Override
-  public void removeIterator(String tableNamespace, String name, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
-      TableNamespaceNotFoundException {
-    if (!exists(tableNamespace))
-      throw new TableNamespaceNotFoundException(null, tableNamespace, null);
-    Map<String,String> copy = new TreeMap<String,String>();
-    for (Entry<String,String> property : this.getProperties(tableNamespace)) {
-      copy.put(property.getKey(), property.getValue());
-    }
-    for (IteratorScope scope : scopes) {
-      String root = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase(), name);
-      for (Entry<String,String> property : copy.entrySet()) {
-        if (property.getKey().equals(root) || property.getKey().startsWith(root + ".opt."))
-          this.removeProperty(tableNamespace, property.getKey());
-      }
-    }
-  }
-
-  @Override
-  public IteratorSetting getIteratorSetting(String tableNamespace, String name, IteratorScope scope) throws AccumuloSecurityException, AccumuloException,
-      TableNamespaceNotFoundException {
-    if (!exists(tableNamespace))
-      throw new TableNamespaceNotFoundException(null, tableNamespace, null);
-    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)) {
-      if (property.getKey().equals(root)) {
-        String parts[] = property.getValue().split(",");
-        if (parts.length != 2) {
-          throw new AccumuloException("Bad value for iterator setting: " + property.getValue());
-        }
-        priority = Integer.parseInt(parts[0]);
-        classname = parts[1];
-      } else if (property.getKey().startsWith(opt)) {
-        settings.put(property.getKey().substring(opt.length()), property.getValue());
-      }
-    }
-    if (priority <= 0 || classname == null) {
-      return null;
-    }
-    return new IteratorSetting(priority, name, classname, settings);
-  }
-
-  @Override
-  public Map<String,EnumSet<IteratorScope>> listIterators(String tableNamespace) throws AccumuloSecurityException, AccumuloException,
-      TableNamespaceNotFoundException {
-    if (!exists(tableNamespace))
-      throw new TableNamespaceNotFoundException(null, tableNamespace, null);
-    Map<String,EnumSet<IteratorScope>> result = new TreeMap<String,EnumSet<IteratorScope>>();
-    for (Entry<String,String> property : this.getProperties(tableNamespace)) {
-      String name = property.getKey();
-      String[] parts = name.split("\\.");
-      if (parts.length == 4) {
-        if (parts[0].equals("table") && parts[1].equals("iterator")) {
-          IteratorScope scope = IteratorScope.valueOf(parts[2]);
-          if (!result.containsKey(parts[3]))
-            result.put(parts[3], EnumSet.noneOf(IteratorScope.class));
-          result.get(parts[3]).add(scope);
-        }
-      }
-    }
-    return result;
-  }
-
-  @Override
-  public void checkIteratorConflicts(String tableNamespace, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloException,
-      TableNamespaceNotFoundException {
-    if (!exists(tableNamespace))
-      throw new TableNamespaceNotFoundException(null, tableNamespace, null);
-    for (IteratorScope scope : scopes) {
-      String scopeStr = String.format("%s%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase());
-      String nameStr = String.format("%s.%s", scopeStr, setting.getName());
-      String optStr = String.format("%s.opt.", nameStr);
-      Map<String,String> optionConflicts = new TreeMap<String,String>();
-      for (Entry<String,String> property : this.getProperties(tableNamespace)) {
-        if (property.getKey().startsWith(scopeStr)) {
-          if (property.getKey().equals(nameStr))
-            throw new AccumuloException(new IllegalArgumentException("iterator name conflict for " + setting.getName() + ": " + property.getKey() + "="
-                + property.getValue()));
-          if (property.getKey().startsWith(optStr))
-            optionConflicts.put(property.getKey(), property.getValue());
-          if (property.getKey().contains(".opt."))
-            continue;
-          String parts[] = property.getValue().split(",");
-          if (parts.length != 2)
-            throw new AccumuloException("Bad value for existing iterator setting: " + property.getKey() + "=" + property.getValue());
-          try {
-            if (Integer.parseInt(parts[0]) == setting.getPriority())
-              throw new AccumuloException(new IllegalArgumentException("iterator priority conflict: " + property.getKey() + "=" + property.getValue()));
-          } catch (NumberFormatException e) {
-            throw new AccumuloException("Bad value for existing iterator setting: " + property.getKey() + "=" + property.getValue());
-          }
-        }
-      }
-      if (optionConflicts.size() > 0)
-        throw new AccumuloException(new IllegalArgumentException("iterator options conflict for " + setting.getName() + ": " + optionConflicts));
-    }
-  }
-
-  @Override
-  public int addConstraint(String tableNamespace, String constraintClassName) throws AccumuloException, AccumuloSecurityException,
-      TableNamespaceNotFoundException {
-    TreeSet<Integer> constraintNumbers = new TreeSet<Integer>();
-    TreeMap<String,Integer> constraintClasses = new TreeMap<String,Integer>();
-    int i;
-    for (Entry<String,String> property : this.getProperties(tableNamespace)) {
-      if (property.getKey().startsWith(Property.TABLE_CONSTRAINT_PREFIX.toString())) {
-        try {
-          i = Integer.parseInt(property.getKey().substring(Property.TABLE_CONSTRAINT_PREFIX.toString().length()));
-        } catch (NumberFormatException e) {
-          throw new AccumuloException("Bad key for existing constraint: " + property.toString());
-        }
-        constraintNumbers.add(i);
-        constraintClasses.put(property.getValue(), i);
-      }
-    }
-    i = 1;
-    while (constraintNumbers.contains(i))
-      i++;
-    if (constraintClasses.containsKey(constraintClassName))
-      throw new AccumuloException("Constraint " + constraintClassName + " already exists for table namespace " + tableNamespace + " with number "
-          + constraintClasses.get(constraintClassName));
-    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>();
-    for (Entry<String,String> property : this.getProperties(tableNamespace)) {
-      if (property.getKey().startsWith(Property.TABLE_CONSTRAINT_PREFIX.toString())) {
-        if (constraints.containsKey(property.getValue()))
-          throw new AccumuloException("Same constraint configured twice: " + property.getKey() + "=" + Property.TABLE_CONSTRAINT_PREFIX
-              + constraints.get(property.getValue()) + "=" + property.getKey());
-        try {
-          constraints.put(property.getValue(), Integer.parseInt(property.getKey().substring(Property.TABLE_CONSTRAINT_PREFIX.toString().length())));
-        } catch (NumberFormatException e) {
-          throw new AccumuloException("Bad key for existing constraint: " + property.toString());
-        }
-      }
-    }
-    return constraints;
-  }
-}


Mime
View raw message