accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [44/61] [abbrv] [partial] accumulo git commit: ACCUMULO-722 put trunk in my sandbox
Date Thu, 03 Mar 2016 22:00:09 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
new file mode 100644
index 0000000..c0a2741
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
@@ -0,0 +1,280 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.impl.ConnectorImpl;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.file.FileUtil;
+import org.apache.accumulo.core.security.thrift.AuthInfo;
+import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.ByteBufferUtil;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.core.util.OpTimer;
+import org.apache.accumulo.core.util.TextUtil;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooCache;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+/**
+ * <p>
+ * An implementation of instance that looks in zookeeper to find information needed to connect to an instance of accumulo.
+ * 
+ * <p>
+ * The advantage of using zookeeper to obtain information about accumulo is that zookeeper is highly available, very responsive, and supports caching.
+ * 
+ * <p>
+ * Because it is possible for multiple instances of accumulo to share a single set of zookeeper servers, all constructors require an accumulo instance name.
+ * 
+ * If you do not know the instance names then run accumulo org.apache.accumulo.server.util.ListInstances on an accumulo server.
+ * 
+ */
+
+public class ZooKeeperInstance implements Instance {
+  
+  private static final Logger log = Logger.getLogger(ZooKeeperInstance.class);
+  
+  private String instanceId = null;
+  private String instanceName = null;
+  
+  private ZooCache zooCache;
+  
+  private String zooKeepers;
+  
+  private int zooKeepersSessionTimeOut;
+  
+  /**
+   * 
+   * @param instanceName
+   *          The name of specific accumulo instance. This is set at initialization time.
+   * @param zooKeepers
+   *          A comma separated list of zoo keeper server locations. Each location can contain an optional port, of the format host:port.
+   */
+  
+  public ZooKeeperInstance(String instanceName, String zooKeepers) {
+    this(instanceName, zooKeepers, (int) AccumuloConfiguration.getDefaultConfiguration().getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
+  }
+  
+  /**
+   * 
+   * @param instanceName
+   *          The name of specific accumulo instance. This is set at initialization time.
+   * @param zooKeepers
+   *          A comma separated list of zoo keeper server locations. Each location can contain an optional port, of the format host:port.
+   * @param sessionTimeout
+   *          zoo keeper session time out in milliseconds.
+   */
+  
+  public ZooKeeperInstance(String instanceName, String zooKeepers, int sessionTimeout) {
+    ArgumentChecker.notNull(instanceName, zooKeepers);
+    this.instanceName = instanceName;
+    this.zooKeepers = zooKeepers;
+    this.zooKeepersSessionTimeOut = sessionTimeout;
+    zooCache = ZooCache.getInstance(zooKeepers, sessionTimeout);
+    getInstanceID();
+  }
+  
+  /**
+   * 
+   * @param instanceId
+   *          The UUID that identifies the accumulo instance you want to connect to.
+   * @param zooKeepers
+   *          A comma separated list of zoo keeper server locations. Each location can contain an optional port, of the format host:port.
+   */
+  
+  public ZooKeeperInstance(UUID instanceId, String zooKeepers) {
+    this(instanceId, zooKeepers, (int) AccumuloConfiguration.getDefaultConfiguration().getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
+  }
+  
+  /**
+   * 
+   * @param instanceId
+   *          The UUID that identifies the accumulo instance you want to connect to.
+   * @param zooKeepers
+   *          A comma separated list of zoo keeper server locations. Each location can contain an optional port, of the format host:port.
+   * @param sessionTimeout
+   *          zoo keeper session time out in milliseconds.
+   */
+  
+  public ZooKeeperInstance(UUID instanceId, String zooKeepers, int sessionTimeout) {
+    ArgumentChecker.notNull(instanceId, zooKeepers);
+    this.instanceId = instanceId.toString();
+    this.zooKeepers = zooKeepers;
+    this.zooKeepersSessionTimeOut = sessionTimeout;
+    zooCache = ZooCache.getInstance(zooKeepers, sessionTimeout);
+  }
+  
+  @Override
+  public String getInstanceID() {
+    if (instanceId == null) {
+      // want the instance id to be stable for the life of this instance object,
+      // so only get it once
+      String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + instanceName;
+      byte[] iidb = zooCache.get(instanceNamePath);
+      if (iidb == null) {
+        throw new RuntimeException("Instance name " + instanceName
+            + " does not exist in zookeeper.  Run \"accumulo org.apache.accumulo.server.util.ListInstances\" to see a list.");
+      }
+      instanceId = new String(iidb);
+    }
+    
+    if (zooCache.get(Constants.ZROOT + "/" + instanceId) == null) {
+      if (instanceName == null)
+        throw new RuntimeException("Instance id " + instanceId + " does not exist in zookeeper");
+      throw new RuntimeException("Instance id " + instanceId + " pointed to by the name " + instanceName + " does not exist in zookeeper");
+    }
+    
+    return instanceId;
+  }
+  
+  @Override
+  public List<String> getMasterLocations() {
+    String masterLocPath = ZooUtil.getRoot(this) + Constants.ZMASTER_LOCK;
+    
+    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up master location in zoocache.");
+    byte[] loc = ZooUtil.getLockData(zooCache, masterLocPath);
+    opTimer.stop("Found master at " + (loc == null ? null : new String(loc)) + " in %DURATION%");
+    
+    if (loc == null) {
+      return Collections.emptyList();
+    }
+    
+    return Collections.singletonList(new String(loc));
+  }
+  
+  @Override
+  public String getRootTabletLocation() {
+    String zRootLocPath = ZooUtil.getRoot(this) + Constants.ZROOT_TABLET_LOCATION;
+    
+    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up root tablet location in zookeeper.");
+    byte[] loc = zooCache.get(zRootLocPath);
+    opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc)) + " in %DURATION%");
+    
+    if (loc == null) {
+      return null;
+    }
+    
+    return new String(loc).split("\\|")[0];
+  }
+  
+  @Override
+  public String getInstanceName() {
+    if (instanceName == null)
+      instanceName = lookupInstanceName(zooCache, UUID.fromString(getInstanceID()));
+    
+    return instanceName;
+  }
+  
+  @Override
+  public String getZooKeepers() {
+    return zooKeepers;
+  }
+  
+  @Override
+  public int getZooKeepersSessionTimeOut() {
+    return zooKeepersSessionTimeOut;
+  }
+  
+  @Override
+  public Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException {
+    return getConnector(user, TextUtil.getBytes(new Text(pass.toString())));
+  }
+  
+  @Override
+  public Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException {
+    return getConnector(user, ByteBufferUtil.toBytes(pass));
+  }
+  
+  // Suppress deprecation, ConnectorImpl is deprecated to warn clients against using.
+  @SuppressWarnings("deprecation")
+  @Override
+  public Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException {
+    return new ConnectorImpl(this, user, pass);
+  }
+  
+  private AccumuloConfiguration conf = null;
+  
+  @Override
+  public AccumuloConfiguration getConfiguration() {
+    if (conf == null)
+      conf = AccumuloConfiguration.getDefaultConfiguration();
+    return conf;
+  }
+  
+  @Override
+  public void setConfiguration(AccumuloConfiguration conf) {
+    this.conf = conf;
+  }
+  
+  /**
+   * Given a zooCache and instanceId, look up the instance name.
+   * 
+   * @param zooCache
+   * @param instanceId
+   * @return the instance name
+   */
+  public static String lookupInstanceName(ZooCache zooCache, UUID instanceId) {
+    ArgumentChecker.notNull(zooCache, instanceId);
+    for (String name : zooCache.getChildren(Constants.ZROOT + Constants.ZINSTANCES)) {
+      String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
+      UUID iid = UUID.fromString(new String(zooCache.get(instanceNamePath)));
+      if (iid.equals(instanceId)) {
+        return name;
+      }
+    }
+    return null;
+  }
+  
+  // To be moved to server code. Only lives here to support the Accumulo Shell
+  @Deprecated
+  public static String getInstanceIDFromHdfs(Path instanceDirectory) {
+    try {
+      FileSystem fs = FileUtil.getFileSystem(CachedConfiguration.getInstance(), AccumuloConfiguration.getSiteConfiguration());
+      FileStatus[] files = fs.listStatus(instanceDirectory);
+      log.debug("Trying to read instance id from " + instanceDirectory);
+      if (files == null || files.length == 0) {
+        log.error("unable obtain instance id at " + instanceDirectory);
+        throw new RuntimeException("Accumulo not initialized, there is no instance id at " + instanceDirectory);
+      } else if (files.length != 1) {
+        log.error("multiple potential instances in " + instanceDirectory);
+        throw new RuntimeException("Accumulo found multiple possible instance ids in " + instanceDirectory);
+      } else {
+        String result = files[0].getPath().getName();
+        return result;
+      }
+    } catch (IOException e) {
+      throw new RuntimeException("Accumulo not initialized, there is no instance id at " + instanceDirectory, e);
+    }
+  }
+  
+  @Override
+  public Connector getConnector(AuthInfo auth) throws AccumuloException, AccumuloSecurityException {
+    return getConnector(auth.user, auth.password);
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java
new file mode 100644
index 0000000..cfd83d4
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java
@@ -0,0 +1,160 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.impl.Tables;
+import org.apache.accumulo.core.data.Column;
+import org.apache.accumulo.core.data.KeyExtent;
+import org.apache.accumulo.core.data.thrift.IterInfo;
+import org.apache.accumulo.core.data.thrift.TColumn;
+
+/**
+ * A class that contains information about an ActiveScan
+ * 
+ */
+
+public class ActiveScan {
+  
+  private long scanid;
+  private String client;
+  private String table;
+  private long age;
+  private long idle;
+  private ScanType type;
+  private ScanState state;
+  private KeyExtent extent;
+  private List<Column> columns;
+  private List<String> ssiList;
+  private Map<String,Map<String,String>> ssio;
+  private String user;
+  
+  ActiveScan(Instance instance, org.apache.accumulo.core.tabletserver.thrift.ActiveScan activeScan) throws TableNotFoundException {
+    this.client = activeScan.client;
+    this.user = activeScan.user;
+    this.age = activeScan.age;
+    this.idle = activeScan.idleTime;
+    this.table = Tables.getTableName(instance, activeScan.tableId);
+    this.type = ScanType.valueOf(activeScan.getType().name());
+    this.state = ScanState.valueOf(activeScan.state.name());
+    this.extent = new KeyExtent(activeScan.extent);
+    
+    this.columns = new ArrayList<Column>(activeScan.columns.size());
+    
+    for (TColumn tcolumn : activeScan.columns)
+      this.columns.add(new Column(tcolumn));
+    
+    this.ssiList = new ArrayList<String>();
+    for (IterInfo ii : activeScan.ssiList) {
+      this.ssiList.add(ii.iterName + "=" + ii.priority + "," + ii.className);
+    }
+    this.ssio = activeScan.ssio;
+  }
+  
+  /**
+   * @return an id that uniquely identifies that scan on the server
+   */
+  public long getScanid() {
+    return scanid;
+  }
+  
+  /**
+   * @return the address of the client that initiated the scan
+   */
+  
+  public String getClient() {
+    return client;
+  }
+  
+  /**
+   * @return the user that initiated the scan
+   */
+  
+  public String getUser() {
+    return user;
+  }
+  
+  /**
+   * @return the table the scan is running against
+   */
+  
+  public String getTable() {
+    return table;
+  }
+  
+  /**
+   * @return the age of the scan in milliseconds
+   */
+  
+  public long getAge() {
+    return age;
+  }
+  
+  /**
+   * @return milliseconds since last time client read data from the scan
+   */
+  
+  public long getLastContactTime() {
+    return idle;
+  }
+  
+  public ScanType getType() {
+    return type;
+  }
+  
+  public ScanState getState() {
+    return state;
+  }
+  
+  /**
+   * @return tablet the scan is running against, if a batch scan may be one of many or null
+   */
+  
+  public KeyExtent getExtent() {
+    return extent;
+  }
+  
+  /**
+   * @return columns requested by the scan
+   */
+  
+  public List<Column> getColumns() {
+    return columns;
+  }
+  
+  /**
+   * @return server side iterators used by the scan
+   */
+  
+  public List<String> getSsiList() {
+    return ssiList;
+  }
+  
+  /**
+   * @return server side iterator options
+   */
+  
+  public Map<String,Map<String,String>> getSsio() {
+    return ssio;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/FindMax.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/FindMax.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/FindMax.java
new file mode 100644
index 0000000..ec67d46
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/FindMax.java
@@ -0,0 +1,170 @@
+/*
+ * 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.io.ByteArrayOutputStream;
+import java.math.BigInteger;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.PartialKey;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.SortedKeyIterator;
+import org.apache.hadoop.io.Text;
+
+public class FindMax {
+  private static void appendZeros(ByteArrayOutputStream baos, int num) {
+    for (int i = 0; i < num; i++)
+      baos.write(0);
+  }
+  
+  private static Text findMidPoint(Text minBS, Text maxBS) {
+    ByteArrayOutputStream startOS = new ByteArrayOutputStream();
+    startOS.write(0); // add a leading zero so bigint does not think its negative
+    startOS.write(minBS.getBytes(), 0, minBS.getLength());
+    
+    ByteArrayOutputStream endOS = new ByteArrayOutputStream();
+    endOS.write(0);// add a leading zero so bigint does not think its negative
+    endOS.write(maxBS.getBytes(), 0, maxBS.getLength());
+    
+    // make the numbers of the same magnitude
+    if (startOS.size() < endOS.size())
+      appendZeros(startOS, endOS.size() - startOS.size());
+    else if (endOS.size() < startOS.size())
+      appendZeros(endOS, startOS.size() - endOS.size());
+    
+    BigInteger min = new BigInteger(startOS.toByteArray());
+    BigInteger max = new BigInteger(endOS.toByteArray());
+    
+    BigInteger mid = max.subtract(min).divide(BigInteger.valueOf(2)).add(min);
+    
+    byte[] ba = mid.toByteArray();
+    
+    Text ret = new Text();
+    
+    if (ba.length == startOS.size()) {
+      if (ba[0] != 0)
+        throw new RuntimeException();
+      
+      // big int added a zero so it would not be negative, drop it
+      ret.set(ba, 1, ba.length - 1);
+    } else {
+      int expLen = Math.max(minBS.getLength(), maxBS.getLength());
+      // big int will drop leading 0x0 bytes
+      for (int i = ba.length; i < expLen; i++) {
+        ret.append(new byte[] {0}, 0, 1);
+      }
+      
+      ret.append(ba, 0, ba.length);
+    }
+    
+    // remove trailing 0x0 bytes
+    while (ret.getLength() > 0 && ret.getBytes()[ret.getLength() - 1] == 0 && ret.compareTo(minBS) > 0) {
+      Text t = new Text();
+      t.set(ret.getBytes(), 0, ret.getLength() - 1);
+      ret = t;
+    }
+    
+    return ret;
+  }
+  
+  private static Text _findMax(Scanner scanner, Text start, boolean inclStart, Text end, boolean inclEnd) {
+    
+    // System.out.printf("findMax(%s, %s, %s, %s)\n", Key.toPrintableString(start.getBytes(), 0, start.getLength(), 1000), inclStart,
+    // Key.toPrintableString(end.getBytes(), 0, end.getLength(), 1000), inclEnd);
+    
+    int cmp = start.compareTo(end);
+    
+    if (cmp >= 0) {
+      if (inclStart && inclEnd && cmp == 0) {
+        scanner.setRange(new Range(start, true, end, true));
+        Iterator<Entry<Key,Value>> iter = scanner.iterator();
+        if (iter.hasNext())
+          return iter.next().getKey().getRow();
+      }
+      
+      return null;
+    }
+    
+    Text mid = findMidPoint(start, end);
+    // System.out.println("mid = :"+Key.toPrintableString(mid.getBytes(), 0, mid.getLength(), 1000)+":");
+    
+    scanner.setRange(new Range(mid, mid.equals(start) ? inclStart : true, end, inclEnd));
+    
+    Iterator<Entry<Key,Value>> iter = scanner.iterator();
+    
+    if (iter.hasNext()) {
+      Key next = iter.next().getKey();
+      
+      int count = 0;
+      while (count < 10 && iter.hasNext()) {
+        next = iter.next().getKey();
+        count++;
+      }
+      
+      if (!iter.hasNext())
+        return next.getRow();
+      
+      Text ret = _findMax(scanner, next.followingKey(PartialKey.ROW).getRow(), true, end, inclEnd);
+      if (ret == null)
+        return next.getRow();
+      else
+        return ret;
+    } else {
+      
+      return _findMax(scanner, start, inclStart, mid, mid.equals(start) ? inclStart : false);
+    }
+  }
+  
+  private static Text findInitialEnd(Scanner scanner) {
+    Text end = new Text(new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff});
+    
+    scanner.setRange(new Range(end, null));
+    
+    while (scanner.iterator().hasNext()) {
+      Text t = new Text();
+      t.append(end.getBytes(), 0, end.getLength());
+      t.append(end.getBytes(), 0, end.getLength());
+      end = t;
+      scanner.setRange(new Range(end, null));
+    }
+    
+    return end;
+  }
+  
+  public static Text findMax(Scanner scanner, Text start, boolean is, Text end, boolean ie) throws TableNotFoundException {
+    
+    scanner.setBatchSize(12);
+    IteratorSetting cfg = new IteratorSetting(Integer.MAX_VALUE, SortedKeyIterator.class);
+    scanner.addScanIterator(cfg);
+    
+    if (start == null) {
+      start = new Text();
+      is = true;
+    }
+    
+    if (end == null)
+      end = findInitialEnd(scanner);
+    
+    return _findMax(scanner, start, is, end, ie);
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
new file mode 100644
index 0000000..c74497a
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
@@ -0,0 +1,90 @@
+/**
+ * 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.List;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+
+/**
+ * 
+ */
+public interface InstanceOperations {
+  
+  /**
+   * Sets an instance property in zookeeper. Tablet servers will pull this setting and override the equivalent setting in accumulo-site.xml
+   * 
+   * @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(final String property, final String value) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Removes a instance property from zookeeper
+   * 
+   * @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(final String property) throws AccumuloException, AccumuloSecurityException;
+  
+  public Map<String,String> getSystemConfiguration() throws AccumuloException, AccumuloSecurityException;
+  
+  public Map<String,String> getSiteConfiguration() throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * List the currently active tablet servers participating in the accumulo instance
+   * 
+   * @return A list of currently active tablet servers.
+   */
+  
+  public List<String> getTabletServers();
+  
+  /**
+   * List the active scans on tablet server.
+   * 
+   * @param tserver
+   *          The tablet server address should be of the form <ip address>:<port>
+   * @return A list of active scans on tablet server.
+   * @throws AccumuloException
+   * @throws AccumuloSecurityException
+   */
+  
+  public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Test to see if the instance can load the given class as the given type.
+   * 
+   * @param className
+   * @param asTypeName
+   * @return true if the instance can load the given class as the given type, false otherwise
+   * @throws AccumuloException
+   */
+  public boolean testClassLoad(final String className, final String asTypeName) throws AccumuloException, AccumuloSecurityException;
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
new file mode 100644
index 0000000..bda342e
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
@@ -0,0 +1,177 @@
+/*
+ * 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.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.accumulo.cloudtrace.instrument.Tracer;
+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.TableNotFoundException;
+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.ServerClient;
+import org.apache.accumulo.core.client.impl.thrift.ClientService;
+import org.apache.accumulo.core.client.impl.thrift.ConfigurationType;
+import org.apache.accumulo.core.master.thrift.MasterClientService;
+import org.apache.accumulo.core.security.thrift.AuthInfo;
+import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
+import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client;
+import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.ThriftUtil;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.zookeeper.ZooCache;
+
+/**
+ * Provides a class for administering the accumulo instance
+ */
+public class InstanceOperationsImpl implements InstanceOperations {
+  private Instance instance;
+  private AuthInfo credentials;
+  
+  /**
+   * @param instance
+   *          the connection information for this instance
+   * @param credentials
+   *          the username/password for this connection
+   */
+  public InstanceOperationsImpl(Instance instance, AuthInfo credentials) {
+    ArgumentChecker.notNull(instance, credentials);
+    this.instance = instance;
+    this.credentials = credentials;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.accumulo.core.client.admin.InstanceOperations#setProperty(java.lang.String, java.lang.String)
+   */
+  @Override
+  public void setProperty(final String property, final String value) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(property, value);
+    MasterClient.execute(instance, new ClientExec<MasterClientService.Client>() {
+      @Override
+      public void execute(MasterClientService.Client client) throws Exception {
+        client.setSystemProperty(Tracer.traceInfo(), credentials, property, value);
+      }
+    });
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.accumulo.core.client.admin.InstanceOperations#removeProperty(java.lang.String)
+   */
+  @Override
+  public void removeProperty(final String property) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(property);
+    MasterClient.execute(instance, new ClientExec<MasterClientService.Client>() {
+      @Override
+      public void execute(MasterClientService.Client client) throws Exception {
+        client.removeSystemProperty(Tracer.traceInfo(), credentials, property);
+      }
+    });
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.accumulo.core.client.admin.InstanceOperations#getSystemConfiguration()
+   */
+  @Override
+  public Map<String,String> getSystemConfiguration() throws AccumuloException, AccumuloSecurityException {
+    return ServerClient.execute(instance, new ClientExecReturn<Map<String,String>,ClientService.Client>() {
+      @Override
+      public Map<String,String> execute(ClientService.Client client) throws Exception {
+        return client.getConfiguration(ConfigurationType.CURRENT);
+      }
+    });
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.accumulo.core.client.admin.InstanceOperations#getSiteConfiguration()
+   */
+  @Override
+  public Map<String,String> getSiteConfiguration() throws AccumuloException, AccumuloSecurityException {
+    return ServerClient.execute(instance, new ClientExecReturn<Map<String,String>,ClientService.Client>() {
+      @Override
+      public Map<String,String> execute(ClientService.Client client) throws Exception {
+        return client.getConfiguration(ConfigurationType.SITE);
+      }
+    });
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.accumulo.core.client.admin.InstanceOperations#getTabletServers()
+   */
+  
+  @Override
+  public List<String> getTabletServers() {
+    ZooCache cache = ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
+    String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
+    List<String> results = new ArrayList<String>();
+    for (String candidate : cache.getChildren(path)) {
+      List<String> children = cache.getChildren(path + "/" + candidate);
+      if (children != null && children.size() > 0) {
+        List<String> copy = new ArrayList<String>(children);
+        Collections.sort(copy);
+        byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0));
+        if (data != null && !"master".equals(new String(data))) {
+          results.add(candidate);
+        }
+      }
+    }
+    return results;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.accumulo.core.client.admin.InstanceOperations#getActiveScans(java.lang.String)
+   */
+  
+  @Override
+  public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException {
+    List<org.apache.accumulo.core.tabletserver.thrift.ActiveScan> tas = ThriftUtil.execute(tserver, instance.getConfiguration(),
+        new ClientExecReturn<List<org.apache.accumulo.core.tabletserver.thrift.ActiveScan>,TabletClientService.Client>() {
+          @Override
+          public List<org.apache.accumulo.core.tabletserver.thrift.ActiveScan> execute(TabletClientService.Client client) throws Exception {
+            return client.getActiveScans(Tracer.traceInfo(), credentials);
+          }
+        });
+    List<ActiveScan> as = new ArrayList<ActiveScan>();
+    for (org.apache.accumulo.core.tabletserver.thrift.ActiveScan activeScan : tas) {
+      try {
+        as.add(new ActiveScan(instance, activeScan));
+      } catch (TableNotFoundException e) {
+        throw new AccumuloException(e);
+      }
+    }
+    return as;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.accumulo.core.client.admin.InstanceOperations#testClassLoad(java.lang.String, java.lang.String)
+   */
+  @Override
+  public boolean testClassLoad(final String className, final String asTypeName) throws AccumuloException, AccumuloSecurityException {
+    return ServerClient.execute(instance, new ClientExecReturn<Boolean,ClientService.Client>() {
+      @Override
+      public Boolean execute(ClientService.Client client) throws Exception {
+        return client.checkClass(Tracer.traceInfo(), className, asTypeName);
+      }
+    });
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanState.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanState.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanState.java
new file mode 100644
index 0000000..c0edd30
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanState.java
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+public enum ScanState {
+  IDLE, RUNNING, QUEUED
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanType.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanType.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanType.java
new file mode 100644
index 0000000..70b995a
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/ScanType.java
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+public enum ScanType {
+  SINGLE, BATCH
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java
new file mode 100644
index 0000000..a3f2f91
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java
@@ -0,0 +1,221 @@
+/*
+ * 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.Set;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.SystemPermission;
+import org.apache.accumulo.core.security.TablePermission;
+
+/**
+ * Provides a class for managing users and permissions
+ * 
+ */
+
+public interface SecurityOperations {
+  
+  /**
+   * Create a user
+   * 
+   * @param user
+   *          the name of the user to create
+   * @param password
+   *          the plaintext password for the user
+   * @param authorizations
+   *          the authorizations that the user has for scanning
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to create a user
+   */
+  public void createUser(String user, byte[] password, Authorizations authorizations) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Delete a user
+   * 
+   * @param user
+   *          the user name to delete
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to delete a user
+   */
+  public void dropUser(String user) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Verify a username/password combination is valid
+   * 
+   * @param user
+   *          the name of the user to authenticate
+   * @param password
+   *          the plaintext password for the user
+   * @return true if the user asking is allowed to know and the specified user/password is valid, false otherwise
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to ask
+   */
+  public boolean authenticateUser(String user, byte[] password) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Set the user's password
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param password
+   *          the plaintext password for the user
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to modify a user
+   */
+  public void changeUserPassword(String user, byte[] password) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Set the user's record-level authorizations
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param authorizations
+   *          the authorizations that the user has for scanning
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to modify a user
+   */
+  public void changeUserAuthorizations(String user, Authorizations authorizations) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Retrieves the user's authorizations for scanning
+   * 
+   * @param user
+   *          the name of the user to query
+   * @return the set of authorizations the user has available for scanning
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to query a user
+   */
+  public Authorizations getUserAuthorizations(String user) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Verify the user has a particular system permission
+   * 
+   * @param user
+   *          the name of the user to query
+   * @param perm
+   *          the system 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 hasSystemPermission(String user, SystemPermission perm) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Verify the user has a particular table permission
+   * 
+   * @param user
+   *          the name of the user to query
+   * @param table
+   *          the name of the table to query about
+   * @param perm
+   *          the table 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 hasTablePermission(String user, String table, TablePermission perm) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Grant a user a system permission
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param permission
+   *          the system 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 grantSystemPermission(String user, SystemPermission permission) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Grant a user a specific permission for a specific table
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param table
+   *          the name of the table to modify for the user
+   * @param permission
+   *          the table 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 grantTablePermission(String user, String table, TablePermission permission) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Revoke a system permission from a user
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param permission
+   *          the system 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 revokeSystemPermission(String user, SystemPermission permission) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Revoke a table permission for a specific user on a specific table
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param table
+   *          the name of the table to modify for the user
+   * @param permission
+   *          the table 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 revokeTablePermission(String user, String table, TablePermission permission) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Return a list of users in accumulo
+   * 
+   * @return a set of user names
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to query users
+   */
+  public Set<String> listUsers() throws AccumuloException, AccumuloSecurityException;
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
new file mode 100644
index 0000000..c8871c2
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
@@ -0,0 +1,389 @@
+/*
+ * 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.Set;
+
+import org.apache.accumulo.cloudtrace.instrument.Tracer;
+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.impl.ClientExec;
+import org.apache.accumulo.core.client.impl.ClientExecReturn;
+import org.apache.accumulo.core.client.impl.ServerClient;
+import org.apache.accumulo.core.client.impl.thrift.ClientService;
+import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
+import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.SystemPermission;
+import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.core.security.thrift.AuthInfo;
+import org.apache.accumulo.core.security.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.security.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.accumulo.core.util.ByteBufferUtil;
+
+public class SecurityOperationsImpl implements SecurityOperations {
+  
+  private Instance instance;
+  private AuthInfo credentials;
+  
+  private void execute(ClientExec<ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
+    try {
+      ServerClient.executeRaw(instance, exec);
+    } catch (ThriftTableOperationException ttoe) {
+      // recast missing table
+      if (ttoe.getType() == TableOperationExceptionType.NOTFOUND)
+        throw new AccumuloSecurityException(null, SecurityErrorCode.TABLE_DOESNT_EXIST);
+      else
+        throw new AccumuloException(ttoe);
+    } catch (ThriftSecurityException e) {
+      throw new AccumuloSecurityException(e.user, e.code, e);
+    } catch (AccumuloException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new AccumuloException(e);
+    }
+  }
+  
+  private <T> T execute(ClientExecReturn<T,ClientService.Client> exec) throws AccumuloException, AccumuloSecurityException {
+    try {
+      return ServerClient.executeRaw(instance, exec);
+    } catch (ThriftTableOperationException ttoe) {
+      // recast missing table
+      if (ttoe.getType() == TableOperationExceptionType.NOTFOUND)
+        throw new AccumuloSecurityException(null, SecurityErrorCode.TABLE_DOESNT_EXIST);
+      else
+        throw new AccumuloException(ttoe);
+    } catch (ThriftSecurityException e) {
+      throw new AccumuloSecurityException(e.user, e.code, e);
+    } catch (AccumuloException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new AccumuloException(e);
+    }
+  }
+  
+  /**
+   * @param instance
+   *          the connection information
+   * @param credentials
+   *          the user credentials to use for security operations
+   */
+  public SecurityOperationsImpl(Instance instance, AuthInfo credentials) {
+    ArgumentChecker.notNull(instance, credentials);
+    this.instance = instance;
+    this.credentials = credentials;
+  }
+  
+  /**
+   * Create a user
+   * 
+   * @param user
+   *          the name of the user to create
+   * @param password
+   *          the plaintext password for the user
+   * @param authorizations
+   *          the authorizations that the user has for scanning
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to create a user
+   */
+  public void createUser(final String user, final byte[] password, final Authorizations authorizations) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, password, authorizations);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.createUser(Tracer.traceInfo(), credentials, user, ByteBuffer.wrap(password), ByteBufferUtil.toByteBuffers(authorizations.getAuthorizations()));
+      }
+    });
+  }
+  
+  /**
+   * Delete a user
+   * 
+   * @param user
+   *          the user name to delete
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to delete a user
+   */
+  public void dropUser(final String user) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.dropUser(Tracer.traceInfo(), credentials, user);
+      }
+    });
+  }
+  
+  /**
+   * Verify a username/password combination is valid
+   * 
+   * @param user
+   *          the name of the user to authenticate
+   * @param password
+   *          the plaintext password for the user
+   * @return true if the user asking is allowed to know and the specified user/password is valid, false otherwise
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to ask
+   */
+  public boolean authenticateUser(final String user, final byte[] password) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, password);
+    return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
+      @Override
+      public Boolean execute(ClientService.Client client) throws Exception {
+        return client.authenticateUser(Tracer.traceInfo(), credentials, user, ByteBuffer.wrap(password));
+      }
+    });
+  }
+  
+  /**
+   * Set the user's password
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param password
+   *          the plaintext password for the user
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to modify a user
+   */
+  public void changeUserPassword(final String user, final byte[] password) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, password);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.changePassword(Tracer.traceInfo(), credentials, user, ByteBuffer.wrap(password));
+      }
+    });
+    if (this.credentials.user.equals(user)) {
+      this.credentials.password = ByteBuffer.wrap(Arrays.copyOf(password, password.length));
+    }
+  }
+  
+  /**
+   * Set the user's record-level authorizations
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param authorizations
+   *          the authorizations that the user has for scanning
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to modify a user
+   */
+  public void changeUserAuthorizations(final String user, final Authorizations authorizations) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, authorizations);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.changeAuthorizations(Tracer.traceInfo(), credentials, user, ByteBufferUtil.toByteBuffers(authorizations.getAuthorizations()));
+      }
+    });
+  }
+  
+  /**
+   * Retrieves the user's authorizations for scanning
+   * 
+   * @param user
+   *          the name of the user to query
+   * @return the set of authorizations the user has available for scanning
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to query a user
+   */
+  public Authorizations getUserAuthorizations(final String user) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user);
+    return execute(new ClientExecReturn<Authorizations,ClientService.Client>() {
+      @Override
+      public Authorizations execute(ClientService.Client client) throws Exception {
+        return new Authorizations(client.getUserAuthorizations(Tracer.traceInfo(), credentials, user));
+      }
+    });
+  }
+  
+  /**
+   * Verify the user has a particular system permission
+   * 
+   * @param user
+   *          the name of the user to query
+   * @param perm
+   *          the system 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 hasSystemPermission(final String user, final SystemPermission perm) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, perm);
+    return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
+      @Override
+      public Boolean execute(ClientService.Client client) throws Exception {
+        return client.hasSystemPermission(Tracer.traceInfo(), credentials, user, perm.getId());
+      }
+    });
+  }
+  
+  /**
+   * Verify the user has a particular table permission
+   * 
+   * @param user
+   *          the name of the user to query
+   * @param table
+   *          the name of the table to query about
+   * @param perm
+   *          the table 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 hasTablePermission(final String user, final String table, final TablePermission perm) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, table, perm);
+    return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
+      @Override
+      public Boolean execute(ClientService.Client client) throws Exception {
+        return client.hasTablePermission(Tracer.traceInfo(), credentials, user, table, perm.getId());
+      }
+    });
+  }
+  
+  /**
+   * Grant a user a system permission
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param permission
+   *          the system 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 grantSystemPermission(final String user, final SystemPermission permission) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, permission);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.grantSystemPermission(Tracer.traceInfo(), credentials, user, permission.getId());
+      }
+    });
+  }
+  
+  /**
+   * Grant a user a specific permission for a specific table
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param table
+   *          the name of the table to modify for the user
+   * @param permission
+   *          the table 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 grantTablePermission(final String user, final String table, final TablePermission permission) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, table, permission);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.grantTablePermission(Tracer.traceInfo(), credentials, user, table, permission.getId());
+      }
+    });
+  }
+  
+  /**
+   * Revoke a system permission from a user
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param permission
+   *          the system 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 revokeSystemPermission(final String user, final SystemPermission permission) throws AccumuloException, AccumuloSecurityException {
+    ArgumentChecker.notNull(user, permission);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.revokeSystemPermission(Tracer.traceInfo(), credentials, user, permission.getId());
+      }
+    });
+  }
+  
+  /**
+   * Revoke a table permission for a specific user on a specific table
+   * 
+   * @param user
+   *          the name of the user to modify
+   * @param table
+   *          the name of the table to modify for the user
+   * @param permission
+   *          the table 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 revokeTablePermission(final String user, final String table, final TablePermission permission) throws AccumuloException,
+      AccumuloSecurityException {
+    ArgumentChecker.notNull(user, table, permission);
+    execute(new ClientExec<ClientService.Client>() {
+      @Override
+      public void execute(ClientService.Client client) throws Exception {
+        client.revokeTablePermission(Tracer.traceInfo(), credentials, user, table, permission.getId());
+      }
+    });
+  }
+  
+  /**
+   * Return a list of users in accumulo
+   * 
+   * @return a set of user names
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission to query users
+   */
+  public Set<String> listUsers() throws AccumuloException, AccumuloSecurityException {
+    return execute(new ClientExecReturn<Set<String>,ClientService.Client>() {
+      @Override
+      public Set<String> execute(ClientService.Client client) throws Exception {
+        return client.listUsers(Tracer.traceInfo(), credentials);
+      }
+    });
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7bdbfccb/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
----------------------------------------------------------------------
diff --git a/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
new file mode 100644
index 0000000..39a9336
--- /dev/null
+++ b/1.5/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
@@ -0,0 +1,623 @@
+/*
+ * 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.io.IOException;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+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.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Provides a class for administering tables
+ * 
+ */
+
+public interface TableOperations {
+  
+  public SortedSet<String> list();
+  
+  /**
+   * A method to check if a table exists in Accumulo.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @return true if the table exists
+   */
+  public boolean exists(String tableName);
+  
+  /**
+   * Create a table with no special configuration
+   * 
+   * @param tableName
+   *          the name of the table
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws TableExistsException
+   *           if the table already exists
+   */
+  public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException;
+  
+  /**
+   * @param tableName
+   *          the name of the table
+   * @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 TableExistsException
+   *           if the table already exists
+   */
+  public void create(String tableName, boolean limitVersion) throws AccumuloException, AccumuloSecurityException, TableExistsException;
+  
+  /**
+   * @param tableName
+   *          the name of the table
+   * @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 TableExistsException
+   *           if the table already exists
+   */
+  public void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException;
+  
+  /**
+   * Imports a table exported via exportTable and copied via hadoop distcp.
+   * 
+   * @param tableName
+   *          Name of a table to create and import into.
+   * @param importDir
+   *          Directory that contains the files copied by distcp from exportTable
+   * @throws TableExistsException
+   * @throws AccumuloException
+   * @throws AccumuloSecurityException
+   */
+  public void importTable(String tableName, String importDir) throws TableExistsException, AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Exports a table. The tables data is not exported, just table metadata and a list of files to distcp. The table being exported must be offline and stay
+   * offline for the duration of distcp. To avoid losing access to a table it can be cloned and the clone taken offline for export.
+   * 
+   * <p>
+   * See docs/examples/README.export
+   * 
+   * @param tableName
+   *          Name of the table to export.
+   * @param exportDir
+   *          An empty directory in HDFS where files containing table metadata and list of files to distcp will be placed.
+   * @throws TableNotFoundException
+   * @throws AccumuloException
+   * @throws AccumuloSecurityException
+   */
+  public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException;
+
+  /**
+   * @param tableName
+   *          the name of the table
+   * @param partitionKeys
+   *          a sorted set of row key values to pre-split the table on
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   */
+  public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * @param tableName
+   *          the name of the table
+   * @return the split points (end-row names) for the table's current split profile
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   */
+  public Collection<Text> getSplits(String tableName) throws TableNotFoundException;
+  
+  /**
+   * @param tableName
+   *          the name of the table
+   * @param maxSplits
+   *          specifies the maximum number of splits to return
+   * @return the split points (end-row names) for the table's current split profile, grouped into fewer splits so as not to exceed maxSplits
+   * @throws TableNotFoundException
+   */
+  public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException;
+  
+  /**
+   * Finds the max row within a given range. To find the max row in a table, pass null for start and end row.
+   * 
+   * @param tableName
+   * @param auths
+   *          find the max row that can seen with these auths
+   * @param startRow
+   *          row to start looking at, null means -Infinity
+   * @param startInclusive
+   *          determines if the start row is included
+   * @param endRow
+   *          row to stop looking at, null means Infinity
+   * @param endInclusive
+   *          determines if the end row is included
+   * 
+   * @return The max row in the range, or null if there is no visible data in the range.
+   * 
+   * @throws AccumuloSecurityException
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   */
+  public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive)
+      throws TableNotFoundException, AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Merge tablets between (start, end]
+   * 
+   * @param tableName
+   *          the table to merge
+   * @param start
+   *          first tablet to be merged contains the row after this row, null means the first tablet
+   * @param end
+   *          last tablet to be merged contains this row, null means the last tablet
+   */
+  public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
+  
+  /**
+   * Delete rows between (start, end]
+   * 
+   * @param tableName
+   *          the table to merge
+   * @param start
+   *          delete rows after this, null means the first row of the table
+   * @param end
+   *          last row to be deleted, inclusive, null means the last row of the table
+   */
+  public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
+  
+  /**
+   * Starts a full major compaction of the tablets in the range (start, end]. The compaction is preformed even for tablets that have only one file.
+   * 
+   * @param tableName
+   *          the table to compact
+   * @param start
+   *          first tablet to be compacted contains the row after this row, null means the first tablet in table
+   * @param end
+   *          last tablet to be merged contains this row, null means the last tablet in table
+   * @param flush
+   *          when true, table memory is flushed before compaction starts
+   * @param wait
+   *          when true, the call will not return until compactions are finished
+   */
+  public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException,
+      AccumuloException;
+  
+  /**
+   * Starts a full major compaction of the tablets in the range (start, end]. The compaction is preformed even for tablets that have only one file.
+   * 
+   * @param tableName
+   *          the table to compact
+   * @param start
+   *          first tablet to be compacted contains the row after this row, null means the first tablet in table
+   * @param end
+   *          last tablet to be merged contains this row, null means the last tablet in table
+   * @param iterators
+   *          A set of iterators that will be applied to each tablet compacted
+   * @param flush
+   *          when true, table memory is flushed before compaction starts
+   * @param wait
+   *          when true, the call will not return until compactions are finished
+   */
+  public void compact(String tableName, Text start, Text end, List<IteratorSetting> iterators, boolean flush, boolean wait) throws AccumuloSecurityException,
+      TableNotFoundException, AccumuloException;
+  
+  /**
+   * Delete a table
+   * 
+   * @param tableName
+   *          the name of the table
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   */
+  public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
+  
+  /**
+   * Clone a table from an existing table. The cloned table will have the same data as the source table it was created from. After cloning, the two tables can
+   * mutate independently. Initially the cloned table should not use any extra space, however as the source table and cloned table major compact extra space
+   * will be used by the clone.
+   * 
+   * Initially the cloned table is only readable and writable by the user who created it.
+   * 
+   * @param srcTableName
+   *          the table to clone
+   * @param newTableName
+   *          the name of the clone
+   * @param flush
+   *          determines if memory is flushed in the source table before cloning.
+   * @param propertiesToSet
+   *          the sources tables properties are copied, this allows overriding of those properties
+   * @param propertiesToExclude
+   *          do not copy these properties from the source table, just revert to system defaults
+   */
+  
+  public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
+      throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException;
+  
+  /**
+   * Rename a table
+   * 
+   * @param oldTableName
+   *          the old table name
+   * @param newTableName
+   *          the new table name
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws TableNotFoundException
+   *           if the old table name does not exist
+   * @throws TableExistsException
+   *           if the new table name already exists
+   */
+  public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
+      TableExistsException;
+  
+  /**
+   * Initiate a flush of a tables data that is in memory
+   * 
+   * @param tableName
+   *          the name of the table
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * 
+   * @deprecated As of release 1.4, replaced by {@link #flush(String, Text, Text, boolean)}
+   */
+  public void flush(String tableName) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Flush a tables data that is currently in memory.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @param wait
+   *          if true the call will not return until all data present in memory when the call was is flushed if false will initiate a flush of data in memory,
+   *          but will not wait for it to complete
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws TableNotFoundException
+   */
+  public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
+  
+  /**
+   * Sets a property on a table
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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 tableName, String property, String value) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Removes a property from a table
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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 tableName, String property) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * Gets properties of a table
+   * 
+   * @param tableName
+   *          the name of the table
+   * @return all properties visible by this table (system and per-table properties)
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   */
+  public Iterable<Entry<String,String>> getProperties(String tableName) throws AccumuloException, TableNotFoundException;
+  
+  /**
+   * Sets a tables locality groups. A tables locality groups can be changed at any time.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @param groups
+   *          mapping of locality group names to column families in the locality group
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   */
+  public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
+  
+  /**
+   * 
+   * Gets the locality groups currently set for a table.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @return mapping of locality group names to column families in the locality group
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   */
+  public Map<String,Set<Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException;
+  
+  /**
+   * @param tableName
+   *          the name of the table
+   * @param range
+   *          a range to split
+   * @param maxSplits
+   *          the maximum number of splits
+   * @return the range, split into smaller ranges that fall on boundaries of the table's split points as evenly as possible
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws AccumuloSecurityException
+   *           if the user does not have permission
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   */
+  public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException;
+  
+  /**
+   * Bulk import all the files in a directory into a table.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @param dir
+   *          the HDFS directory to find files for importing
+   * @param failureDir
+   *          the HDFS directory to place files that failed to be imported, must exist and be empty
+   * @throws IOException
+   *           when there is an error reading/writing to HDFS
+   * @throws AccumuloException
+   *           when there is a general accumulo error
+   * @throws AccumuloSecurityException
+   *           when the user does not have the proper permissions
+   * @throws TableNotFoundException
+   *           when the table no longer exists
+   * 
+   */
+  public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws TableNotFoundException, IOException, AccumuloException,
+      AccumuloSecurityException;
+  
+  /**
+   * 
+   * @param tableName
+   *          the table to take offline
+   * @throws AccumuloException
+   *           when there is a general accumulo error
+   * @throws AccumuloSecurityException
+   *           when the user does not have the proper permissions
+   * @throws TableNotFoundException
+   */
+  public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException;
+  
+  /**
+   * 
+   * @param tableName
+   *          the table to take online
+   * @throws AccumuloException
+   *           when there is a general accumulo error
+   * @throws AccumuloSecurityException
+   *           when the user does not have the proper permissions
+   * @throws TableNotFoundException
+   */
+  public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException;
+  
+  /**
+   * Clears the tablet locator cache for a specified table
+   * 
+   * @param tableName
+   *          the name of the table
+   * @throws TableNotFoundException
+   *           if table does not exist
+   */
+  public void clearLocatorCache(String tableName) throws TableNotFoundException;
+  
+  /**
+   * Get a mapping of table name to internal table id.
+   * 
+   * @return the map from table name to internal table id
+   */
+  public Map<String,String> tableIdMap();
+  
+  /**
+   * Add an iterator to a table on all scopes.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   *           throw if the table no longer exists
+   * @throws IllegalArgumentException
+   *           if the setting conflicts with any existing iterators
+   */
+  public void attachIterator(String tableName, IteratorSetting setting) throws AccumuloSecurityException, AccumuloException, TableNotFoundException;
+  
+  /**
+   * Add an iterator to a table on the given scopes.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   *           throw if the table no longer exists
+   * @throws IllegalArgumentException
+   *           if the setting conflicts with any existing iterators
+   */
+  public void attachIterator(String tableName, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
+      TableNotFoundException;
+  
+  /**
+   * Remove an iterator from a table by name.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   *           throw if the table no longer exists
+   */
+  public void removeIterator(String tableName, String name, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
+      TableNotFoundException;
+  
+  /**
+   * Get the settings for an iterator.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   *           throw if the table no longer exists
+   */
+  public IteratorSetting getIteratorSetting(String tableName, String name, IteratorScope scope) throws AccumuloSecurityException, AccumuloException,
+      TableNotFoundException;
+  
+  /**
+   * Get a list of iterators for this table.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @return a set of iterator names
+   * @throws AccumuloSecurityException
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   */
+  public Map<String,EnumSet<IteratorScope>> listIterators(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException;
+  
+  /**
+   * 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 tableName
+   *          the name of the table
+   * @param setting
+   *          object specifying the properties of the iterator
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   * @throws IllegalStateException
+   *           if the setting conflicts with any existing iterators
+   */
+  public void checkIteratorConflicts(String tableName, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloException, TableNotFoundException;
+  
+  /**
+   * Add a new constraint to a table.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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 TableNotFoundException
+   */
+  public int addConstraint(String tableName, String constraintClassName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException;
+  
+  /**
+   * Remove a constraint from a table.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @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 tableName, int number) throws AccumuloException, AccumuloSecurityException;
+  
+  /**
+   * List constraints on a table with their assigned numbers.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @return a map from constraint class name to assigned number
+   * @throws AccumuloException
+   *           thrown if there are errors in the configuration of existing constraints
+   * @throws TableNotFoundException
+   */
+  public Map<String,Integer> listConstraints(String tableName) throws AccumuloException, TableNotFoundException;
+}


Mime
View raw message