You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2014/01/02 18:42:28 UTC

[01/10] git commit: ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it)

Updated Branches:
  refs/heads/1.4.5-SNAPSHOT 0b6749a4f -> 27ee23670
  refs/heads/1.5.1-SNAPSHOT 712e946d1 -> 8729dba76
  refs/heads/1.6.0-SNAPSHOT 417902e21 -> a95831a20


ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it)


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/27ee2367
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/27ee2367
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/27ee2367

Branch: refs/heads/1.4.5-SNAPSHOT
Commit: 27ee2367056e5ad0cb6175f91154cd13d49e2c95
Parents: 0b6749a
Author: Eric Newton <er...@gmail.com>
Authored: Thu Jan 2 12:02:00 2014 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Thu Jan 2 12:02:00 2014 -0500

----------------------------------------------------------------------
 src/proxy/examples/python/TestClient.py         |  4 ++--
 src/proxy/examples/ruby/test_client.rb          |  8 ++++----
 .../org/apache/accumulo/proxy/ProxyServer.java  |  6 ++----
 .../org/apache/accumulo/proxy/thrift/Key.java   |  6 ++++--
 src/proxy/src/main/thrift/proxy.thrift          |  4 +++-
 .../org/apache/accumulo/proxy/SimpleTest.java   | 20 ++++++++++++++++++++
 6 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/python/TestClient.py
----------------------------------------------------------------------
diff --git a/src/proxy/examples/python/TestClient.py b/src/proxy/examples/python/TestClient.py
index 7ecf367..5509ded 100644
--- a/src/proxy/examples/python/TestClient.py
+++ b/src/proxy/examples/python/TestClient.py
@@ -21,8 +21,8 @@ from thrift.transport import TSocket
 from thrift.transport import TTransport
 from thrift.protocol import TCompactProtocol
 
-from proxy import AccumuloProxy
-from proxy.ttypes import *
+from accumulo import AccumuloProxy
+from accumulo.ttypes import *
 
 transport = TSocket.TSocket('localhost', 42424)
 transport = TTransport.TFramedTransport(transport)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/ruby/test_client.rb
----------------------------------------------------------------------
diff --git a/src/proxy/examples/ruby/test_client.rb b/src/proxy/examples/ruby/test_client.rb
index d5ee5f5..6310a2f 100644
--- a/src/proxy/examples/ruby/test_client.rb
+++ b/src/proxy/examples/ruby/test_client.rb
@@ -23,7 +23,7 @@ server = ARGV[0] || 'localhost'
 socket = Thrift::Socket.new(server, 42424, 9001)
 transport = Thrift::FramedTransport.new(socket)
 proto = Thrift::CompactProtocol.new(transport)
-proxy = AccumuloProxy::Client.new(proto)
+proxy = Accumulo::AccumuloProxy::Client.new(proto)
 
 # open up the connect
 transport.open()
@@ -35,10 +35,10 @@ login = proxy.login('root', {'password' => 'secret'})
 puts "List of tables: #{proxy.listTables(login).inspect}"
 
 testtable = "rubytest"
-proxy.createTable(login, testtable, true, TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
+proxy.createTable(login, testtable, true, Accumulo::TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
 
-update1 = ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
-update2 = ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
+update1 = Accumulo::ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
+update2 = Accumulo::ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
 proxy.updateAndFlush(login,testtable,{'row1' => [update1,update2]})
 
 cookie = proxy.createScanner(login,testtable,nil)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index d749723..bf050e4 100644
--- a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -1328,6 +1328,7 @@ public class ProxyServer implements AccumuloProxy.Iface {
       return null;
     org.apache.accumulo.proxy.thrift.Key result = new org.apache.accumulo.proxy.thrift.Key(TextUtil.getByteBuffer(k.getRow()), TextUtil.getByteBuffer(k
         .getColumnFamily()), TextUtil.getByteBuffer(k.getColumnQualifier()), TextUtil.getByteBuffer(k.getColumnVisibility()));
+    result.setTimestamp(k.getTimestamp());
     return result;
   }
   
@@ -1346,12 +1347,9 @@ public class ProxyServer implements AccumuloProxy.Iface {
     }
   }
   
-  static private final ByteBuffer EMPTY = ByteBuffer.wrap(new byte[] {});
-  
   @Override
   public org.apache.accumulo.proxy.thrift.Range getRowRange(ByteBuffer row) throws TException {
-    return new org.apache.accumulo.proxy.thrift.Range(new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true,
-        new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true);
+    return getRange(new Range(ByteBufferUtil.toText(row)));
   }
   
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
index 5d8a31c..422149c 100644
--- a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
+++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
@@ -143,6 +143,8 @@ import org.slf4j.LoggerFactory;
   }
 
   public Key() {
+    this.timestamp = 9223372036854775807L;
+
   }
 
   public Key(
@@ -193,8 +195,8 @@ import org.slf4j.LoggerFactory;
     this.colFamily = null;
     this.colQualifier = null;
     this.colVisibility = null;
-    setTimestampIsSet(false);
-    this.timestamp = 0;
+    this.timestamp = 9223372036854775807L;
+
   }
 
   public byte[] getRow() {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/thrift/proxy.thrift
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/thrift/proxy.thrift b/src/proxy/src/main/thrift/proxy.thrift
index 1cebf55..872e253 100644
--- a/src/proxy/src/main/thrift/proxy.thrift
+++ b/src/proxy/src/main/thrift/proxy.thrift
@@ -16,13 +16,15 @@
 */
 namespace cpp accumulo
 namespace java org.apache.accumulo.proxy.thrift
+namespace rb Accumulo
+namespace py accumulo
 
 struct Key {
   1:binary row;
   2:binary colFamily;
   3:binary colQualifier;
   4:binary colVisibility;
-  5:optional i64 timestamp
+  5:optional i64 timestamp = 0x7FFFFFFFFFFFFFFF
 }
 
 enum PartialKey {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index d3b45ae..67b36a6 100644
--- a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@ -798,6 +798,26 @@ public class SimpleTest {
     return toRet;
   }
   
+  static private ByteBuffer t2bb(Text t) {
+    return ByteBuffer.wrap(t.getBytes());
+  }
+  
+  @Test
+  public void testGetRowRange() throws Exception {
+    Range range = client.getRowRange(s2bb("xyzzy"));
+    org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy")); 
+    assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow())));
+    assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow())));
+    assertEquals(range.startInclusive, range2.isStartKeyInclusive());
+    assertEquals(range.stopInclusive, range2.isEndKeyInclusive());
+    assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily())));
+    assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier())));
+    assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily())));
+    assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier())));
+    assertEquals(range.start.timestamp, range.start.timestamp);
+    assertEquals(range.stop.timestamp, range.stop.timestamp);
+  }
+  
   @AfterClass
   public static void tearDownMiniCluster() throws Exception {
     accumulo.stop();


[06/10] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Posted by ec...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8729dba7
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8729dba7
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8729dba7

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 8729dba7694dbf2edeba5df472840a41ab77d18d
Parents: 712e946 27ee236
Author: Eric Newton <er...@gmail.com>
Authored: Thu Jan 2 12:02:24 2014 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Thu Jan 2 12:02:24 2014 -0500

----------------------------------------------------------------------
 proxy/examples/python/TestClient.py             |  4 ++--
 proxy/examples/ruby/test_client.rb              |  8 ++++----
 .../org/apache/accumulo/proxy/ProxyServer.java  |  6 ++----
 .../org/apache/accumulo/proxy/thrift/Key.java   |  6 ++++--
 proxy/src/main/thrift/proxy.thrift              |  4 +++-
 .../org/apache/accumulo/proxy/SimpleTest.java   | 20 ++++++++++++++++++++
 6 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/examples/python/TestClient.py
----------------------------------------------------------------------
diff --cc proxy/examples/python/TestClient.py
index 7ecf367,0000000..5509ded
mode 100644,000000..100644
--- a/proxy/examples/python/TestClient.py
+++ b/proxy/examples/python/TestClient.py
@@@ -1,46 -1,0 +1,46 @@@
 +#!/usr/bin/env python
 +# 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.
 +
 +import sys
 +
 +from thrift import Thrift
 +from thrift.transport import TSocket
 +from thrift.transport import TTransport
 +from thrift.protocol import TCompactProtocol
 +
- from proxy import AccumuloProxy
- from proxy.ttypes import *
++from accumulo import AccumuloProxy
++from accumulo.ttypes import *
 +
 +transport = TSocket.TSocket('localhost', 42424)
 +transport = TTransport.TFramedTransport(transport)
 +protocol = TCompactProtocol.TCompactProtocol(transport)
 +client = AccumuloProxy.Client(protocol)
 +transport.open()
 +
 +login = client.login('root', {'password':'secret'})
 +
 +print client.listTables(login)
 +
 +testtable = "pythontest"
 +if not client.tableExists(login, testtable):
 +    client.createTable(login, testtable, True, TimeType.MILLIS)
 +
 +row1 = {'a':[ColumnUpdate('a','a',value='value1'), ColumnUpdate('b','b',value='value2')]}
 +client.updateAndFlush(login, testtable, row1)
 +
 +cookie = client.createScanner(login, testtable, None)
 +for entry in client.nextK(cookie, 10).results:
 +   print entry

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/examples/ruby/test_client.rb
----------------------------------------------------------------------
diff --cc proxy/examples/ruby/test_client.rb
index d5ee5f5,0000000..6310a2f
mode 100644,000000..100644
--- a/proxy/examples/ruby/test_client.rb
+++ b/proxy/examples/ruby/test_client.rb
@@@ -1,48 -1,0 +1,48 @@@
 +
 +# 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.
 +
 +require 'rubygems'
 +require 'thrift'
 +require 'accumulo_proxy'
 +
 +server = ARGV[0] || 'localhost'
 +
 +socket = Thrift::Socket.new(server, 42424, 9001)
 +transport = Thrift::FramedTransport.new(socket)
 +proto = Thrift::CompactProtocol.new(transport)
- proxy = AccumuloProxy::Client.new(proto)
++proxy = Accumulo::AccumuloProxy::Client.new(proto)
 +
 +# open up the connect
 +transport.open()
 +
 +# Test if the server is up
 +login = proxy.login('root', {'password' => 'secret'})
 +
 +# print out a table list
 +puts "List of tables: #{proxy.listTables(login).inspect}"
 +
 +testtable = "rubytest"
- proxy.createTable(login, testtable, true, TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
++proxy.createTable(login, testtable, true, Accumulo::TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
 +
- update1 = ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
- update2 = ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
++update1 = Accumulo::ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
++update2 = Accumulo::ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
 +proxy.updateAndFlush(login,testtable,{'row1' => [update1,update2]})
 +
 +cookie = proxy.createScanner(login,testtable,nil)
 +result = proxy.nextK(cookie,10)
 +result.results.each{ |keyvalue| puts "Key: #{keyvalue.key.inspect} Value: #{keyvalue.value}" }
 +
 +transport.close()

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --cc proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index c6e74f1,0000000..2a9a055
mode 100644,000000..100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@@ -1,1473 -1,0 +1,1471 @@@
 +/*
 + * 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.proxy;
 +
 +import java.nio.ByteBuffer;
 +import java.util.ArrayList;
 +import java.util.Collection;
 +import java.util.EnumSet;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.Iterator;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Properties;
 +import java.util.Set;
 +import java.util.SortedSet;
 +import java.util.TreeSet;
 +import java.util.UUID;
 +import java.util.concurrent.TimeUnit;
 +
 +import org.apache.accumulo.core.client.AccumuloException;
 +import org.apache.accumulo.core.client.AccumuloSecurityException;
 +import org.apache.accumulo.core.client.BatchScanner;
 +import org.apache.accumulo.core.client.BatchWriter;
 +import org.apache.accumulo.core.client.BatchWriterConfig;
 +import org.apache.accumulo.core.client.Connector;
 +import org.apache.accumulo.core.client.Instance;
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.client.MutationsRejectedException;
 +import org.apache.accumulo.core.client.Scanner;
 +import org.apache.accumulo.core.client.ScannerBase;
 +import org.apache.accumulo.core.client.TableExistsException;
 +import org.apache.accumulo.core.client.TableNotFoundException;
 +import org.apache.accumulo.core.client.ZooKeeperInstance;
 +import org.apache.accumulo.core.client.admin.ActiveCompaction;
 +import org.apache.accumulo.core.client.admin.ActiveScan;
 +import org.apache.accumulo.core.client.admin.TimeType;
 +import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
 +import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
 +import org.apache.accumulo.core.client.mock.MockInstance;
 +import org.apache.accumulo.core.client.security.SecurityErrorCode;
 +import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 +import org.apache.accumulo.core.data.Column;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.KeyExtent;
 +import org.apache.accumulo.core.data.Mutation;
 +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.IteratorUtil.IteratorScope;
 +import org.apache.accumulo.core.security.Authorizations;
 +import org.apache.accumulo.core.security.ColumnVisibility;
 +import org.apache.accumulo.core.security.CredentialHelper;
 +import org.apache.accumulo.core.security.SystemPermission;
 +import org.apache.accumulo.core.security.TablePermission;
 +import org.apache.accumulo.core.security.thrift.TCredentials;
 +import org.apache.accumulo.core.util.ByteBufferUtil;
 +import org.apache.accumulo.core.util.TextUtil;
 +import org.apache.accumulo.proxy.thrift.AccumuloProxy;
 +import org.apache.accumulo.proxy.thrift.BatchScanOptions;
 +import org.apache.accumulo.proxy.thrift.ColumnUpdate;
 +import org.apache.accumulo.proxy.thrift.CompactionReason;
 +import org.apache.accumulo.proxy.thrift.CompactionType;
 +import org.apache.accumulo.proxy.thrift.KeyValue;
 +import org.apache.accumulo.proxy.thrift.KeyValueAndPeek;
 +import org.apache.accumulo.proxy.thrift.NoMoreEntriesException;
 +import org.apache.accumulo.proxy.thrift.ScanColumn;
 +import org.apache.accumulo.proxy.thrift.ScanOptions;
 +import org.apache.accumulo.proxy.thrift.ScanResult;
 +import org.apache.accumulo.proxy.thrift.ScanState;
 +import org.apache.accumulo.proxy.thrift.ScanType;
 +import org.apache.accumulo.proxy.thrift.UnknownScanner;
 +import org.apache.accumulo.proxy.thrift.UnknownWriter;
 +import org.apache.accumulo.proxy.thrift.WriterOptions;
 +import org.apache.hadoop.io.Text;
 +import org.apache.log4j.Logger;
 +import org.apache.thrift.TException;
 +
 +import com.google.common.cache.Cache;
 +import com.google.common.cache.CacheBuilder;
 +import com.google.common.cache.RemovalListener;
 +import com.google.common.cache.RemovalNotification;
 +
 +/**
 + * Proxy Server exposing the Accumulo API via Thrift..
 + * 
 + * @since 1.5
 + */
 +public class ProxyServer implements AccumuloProxy.Iface {
 +  
 +  public static final Logger logger = Logger.getLogger(ProxyServer.class);
 +  protected Instance instance;
 +  
 +  protected Class<? extends AuthenticationToken> tokenClass;
 +  
 +  static protected class ScannerPlusIterator {
 +    public ScannerBase scanner;
 +    public Iterator<Map.Entry<Key,Value>> iterator;
 +  }
 +  
 +  static protected class BatchWriterPlusException {
 +    public BatchWriter writer;
 +    public MutationsRejectedException exception = null;
 +  }
 +  
 +  static class CloseWriter implements RemovalListener<UUID,BatchWriterPlusException> {
 +    @Override
 +    public void onRemoval(RemovalNotification<UUID,BatchWriterPlusException> notification) {
 +      try {
 +        BatchWriterPlusException value = notification.getValue();
 +        if (value.exception != null)
 +          throw value.exception;
 +        notification.getValue().writer.close();
 +      } catch (MutationsRejectedException e) {
 +        logger.warn(e, e);
 +      }
 +    }
 +    
 +    public CloseWriter() {}
 +  }
 +  
 +  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
 +    @Override
 +    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
 +      final ScannerBase base = notification.getValue().scanner;
 +      if (base instanceof BatchScanner) {
 +        final BatchScanner scanner = (BatchScanner) base;
 +        scanner.close();
 +      }
 +    }
 +    
 +    public CloseScanner() {}
 +  }
 +  
 +  protected Cache<UUID,ScannerPlusIterator> scannerCache;
 +  protected Cache<UUID,BatchWriterPlusException> writerCache;
 +  
 +  public ProxyServer(Properties props) {
 +    
 +    String useMock = props.getProperty("useMockInstance");
 +    if (useMock != null && Boolean.parseBoolean(useMock))
 +      instance = new MockInstance();
 +    else
 +      instance = new ZooKeeperInstance(props.getProperty("instance"), props.getProperty("zookeepers"));
 +    
 +    try {
 +      String tokenProp = props.getProperty("tokenClass", PasswordToken.class.getName());
 +      tokenClass = Class.forName(tokenProp).asSubclass(AuthenticationToken.class);
 +    } catch (ClassNotFoundException e) {
 +      throw new RuntimeException(e);
 +    }
 +    
 +    scannerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseScanner()).build();
 +    
 +    writerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseWriter()).build();
 +  }
 +  
 +  protected Connector getConnector(ByteBuffer login) throws Exception {
 +    TCredentials user = CredentialHelper.fromByteArray(ByteBufferUtil.toBytes(login));
 +    if (user == null)
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException("unknown user");
 +    Connector connector = instance.getConnector(user.getPrincipal(), CredentialHelper.extractToken(user));
 +    return connector;
 +  }
 +  
 +  private void handleAccumuloException(AccumuloException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.AccumuloException {
 +    if (e.getCause() instanceof ThriftTableOperationException) {
 +      ThriftTableOperationException ttoe = (ThriftTableOperationException) e.getCause();
 +      if (ttoe.type == TableOperationExceptionType.NOTFOUND) {
 +        throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString());
 +      }
 +    }
 +    throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +  }
 +  
 +  private void handleAccumuloSecurityException(AccumuloSecurityException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException {
 +    if (e.getSecurityErrorCode().equals(SecurityErrorCode.TABLE_DOESNT_EXIST))
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString());
 +    throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString());
 +  }
 +
 +  private void handleExceptionTNF(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      throw ex;
 +    } catch (AccumuloException e) {
 +      handleAccumuloException(e);
 +    } catch (AccumuloSecurityException e) {
 +      handleAccumuloSecurityException(e);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(ex.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +
 +  private void handleExceptionTEE(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      throw ex;
 +    } catch (AccumuloException e) {
 +      handleAccumuloException(e);
 +    } catch (AccumuloSecurityException e) {
 +      handleAccumuloSecurityException(e);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(ex.toString());
 +    } catch (TableExistsException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableExistsException(e.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +  
 +  private void handleExceptionMRE(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      throw ex;
 +    } catch (MutationsRejectedException e) {
 +      throw new org.apache.accumulo.proxy.thrift.MutationsRejectedException(ex.toString());
 +    } catch (AccumuloException e) {
 +      handleAccumuloException(e);
 +    } catch (AccumuloSecurityException e) {
 +      handleAccumuloSecurityException(e);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(ex.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +  
 +  private void handleException(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      throw ex;
 +    } catch (AccumuloException e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    } catch (AccumuloSecurityException e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +
 +  @Override
 +  public int addConstraint(ByteBuffer login, String tableName, String constraintClassName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      return getConnector(login).tableOperations().addConstraint(tableName, constraintClassName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return -1;
 +    }
 +  }
 +  
 +  @Override
 +  public void addSplits(ByteBuffer login, String tableName, Set<ByteBuffer> splits) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      SortedSet<Text> sorted = new TreeSet<Text>();
 +      for (ByteBuffer split : splits) {
 +        sorted.add(ByteBufferUtil.toText(split));
 +      }
 +      getConnector(login).tableOperations().addSplits(tableName, sorted);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void clearLocatorCache(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().clearLocatorCache(tableName);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString());
 +    } catch (Exception e) {
 +      throw new TException(e.toString());
 +    }
 +  }
 +  
 +  @Override
 +  public void compactTable(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow,
 +      List<org.apache.accumulo.proxy.thrift.IteratorSetting> iterators, boolean flush, boolean wait)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.AccumuloException, TException {
 +    try {
 +      getConnector(login).tableOperations().compact(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow), getIteratorSettings(iterators),
 +          flush, wait);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void cancelCompaction(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().cancelCompaction(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  private List<IteratorSetting> getIteratorSettings(List<org.apache.accumulo.proxy.thrift.IteratorSetting> iterators) {
 +    List<IteratorSetting> result = new ArrayList<IteratorSetting>();
 +    if (iterators != null) {
 +      for (org.apache.accumulo.proxy.thrift.IteratorSetting is : iterators) {
 +        result.add(getIteratorSetting(is));
 +      }
 +    }
 +    return result;
 +  }
 +  
 +  @Override
 +  public void createTable(ByteBuffer login, String tableName, boolean versioningIter, org.apache.accumulo.proxy.thrift.TimeType type)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      if (type == null)
 +        type = org.apache.accumulo.proxy.thrift.TimeType.MILLIS;
 +      
 +      getConnector(login).tableOperations().create(tableName, versioningIter, TimeType.valueOf(type.toString()));
 +    } catch (TableExistsException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableExistsException(e.toString());
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void deleteTable(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().delete(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void deleteRows(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().deleteRows(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public boolean tableExists(ByteBuffer login, String tableName) throws TException {
 +    try {
 +      return getConnector(login).tableOperations().exists(tableName);
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void flushTable(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow, boolean wait)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().flush(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow), wait);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,Set<String>> getLocalityGroups(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,Set<Text>> groups = getConnector(login).tableOperations().getLocalityGroups(tableName);
 +      Map<String,Set<String>> ret = new HashMap<String,Set<String>>();
 +      for (String key : groups.keySet()) {
 +        ret.put(key, new HashSet<String>());
 +        for (Text val : groups.get(key)) {
 +          ret.get(key).add(val.toString());
 +        }
 +      }
 +      return ret;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public ByteBuffer getMaxRow(ByteBuffer login, String tableName, Set<ByteBuffer> auths, ByteBuffer startRow, boolean startInclusive, ByteBuffer endRow,
 +      boolean endInclusive) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Connector connector = getConnector(login);
 +      Text startText = ByteBufferUtil.toText(startRow);
 +      Text endText = ByteBufferUtil.toText(endRow);
 +      Authorizations auth;
 +      if (auths != null) {
 +        auth = getAuthorizations(auths);
 +      } else {
 +        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
 +      }
 +      Text max = connector.tableOperations().getMaxRow(tableName, auth, startText, startInclusive, endText, endInclusive);
 +      return TextUtil.getByteBuffer(max);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> getTableProperties(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,String> ret = new HashMap<String,String>();
 +      
 +      for (Map.Entry<String,String> entry : getConnector(login).tableOperations().getProperties(tableName)) {
 +        ret.put(entry.getKey(), entry.getValue());
 +      }
 +      return ret;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public List<ByteBuffer> listSplits(ByteBuffer login, String tableName, int maxSplits) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Collection<Text> splits = getConnector(login).tableOperations().listSplits(tableName, maxSplits);
 +      List<ByteBuffer> ret = new ArrayList<ByteBuffer>();
 +      for (Text split : splits) {
 +        ret.add(TextUtil.getByteBuffer(split));
 +      }
 +      return ret;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Set<String> listTables(ByteBuffer login) throws TException {
 +    try {
 +      return getConnector(login).tableOperations().list();
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,Integer> listConstraints(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      return getConnector(login).tableOperations().listConstraints(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void mergeTablets(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().merge(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void offlineTable(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().offline(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void onlineTable(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().online(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void removeConstraint(ByteBuffer login, String tableName, int constraint) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().removeConstraint(tableName, constraint);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void removeTableProperty(ByteBuffer login, String tableName, String property) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().removeProperty(tableName, property);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void renameTable(ByteBuffer login, String oldTableName, String newTableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      getConnector(login).tableOperations().rename(oldTableName, newTableName);
 +    } catch (Exception e) {
 +      handleExceptionTEE(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void setLocalityGroups(ByteBuffer login, String tableName, Map<String,Set<String>> groupStrings)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,Set<Text>> groups = new HashMap<String,Set<Text>>();
 +      for (String key : groupStrings.keySet()) {
 +        groups.put(key, new HashSet<Text>());
 +        for (String val : groupStrings.get(key)) {
 +          groups.get(key).add(new Text(val));
 +        }
 +      }
 +      getConnector(login).tableOperations().setLocalityGroups(tableName, groups);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void setTableProperty(ByteBuffer login, String tableName, String property, String value) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().setProperty(tableName, property, value);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> tableIdMap(ByteBuffer login) throws TException {
 +    try {
 +      return getConnector(login).tableOperations().tableIdMap();
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> getSiteConfiguration(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).instanceOperations().getSiteConfiguration();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> getSystemConfiguration(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).instanceOperations().getSystemConfiguration();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public List<String> getTabletServers(ByteBuffer login) throws TException {
 +    try {
 +      return getConnector(login).instanceOperations().getTabletServers();
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public List<org.apache.accumulo.proxy.thrift.ActiveScan> getActiveScans(ByteBuffer login, String tserver)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    List<org.apache.accumulo.proxy.thrift.ActiveScan> result = new ArrayList<org.apache.accumulo.proxy.thrift.ActiveScan>();
 +    try {
 +      List<ActiveScan> activeScans = getConnector(login).instanceOperations().getActiveScans(tserver);
 +      for (ActiveScan scan : activeScans) {
 +        org.apache.accumulo.proxy.thrift.ActiveScan pscan = new org.apache.accumulo.proxy.thrift.ActiveScan();
 +        pscan.client = scan.getClient();
 +        pscan.user = scan.getUser();
 +        pscan.table = scan.getTable();
 +        pscan.age = scan.getAge();
 +        pscan.idleTime = scan.getIdleTime();
 +        pscan.type = ScanType.valueOf(scan.getType().toString());
 +        pscan.state = ScanState.valueOf(scan.getState().toString());
 +        KeyExtent e = scan.getExtent();
 +        pscan.extent = new org.apache.accumulo.proxy.thrift.KeyExtent(e.getTableId().toString(), TextUtil.getByteBuffer(e.getEndRow()),
 +            TextUtil.getByteBuffer(e.getPrevEndRow()));
 +        pscan.columns = new ArrayList<org.apache.accumulo.proxy.thrift.Column>();
 +        if (scan.getColumns() != null) {
 +          for (Column c : scan.getColumns()) {
 +            org.apache.accumulo.proxy.thrift.Column column = new org.apache.accumulo.proxy.thrift.Column();
 +            column.setColFamily(c.getColumnFamily());
 +            column.setColQualifier(c.getColumnQualifier());
 +            column.setColVisibility(c.getColumnVisibility());
 +            pscan.columns.add(column);
 +          }
 +        }
 +        pscan.iterators = new ArrayList<org.apache.accumulo.proxy.thrift.IteratorSetting>();
 +        for (String iteratorString : scan.getSsiList()) {
 +          String[] parts = iteratorString.split("[=,]");
 +          if (parts.length == 3) {
 +            String name = parts[0];
 +            int priority = Integer.parseInt(parts[1]);
 +            String classname = parts[2];
 +            org.apache.accumulo.proxy.thrift.IteratorSetting settings = new org.apache.accumulo.proxy.thrift.IteratorSetting(priority, name, classname, scan
 +                .getSsio().get(name));
 +            pscan.iterators.add(settings);
 +          }
 +        }
 +        pscan.authorizations = new ArrayList<ByteBuffer>();
 +        if (scan.getAuthorizations() != null) {
 +          for (byte[] a : scan.getAuthorizations()) {
 +            pscan.authorizations.add(ByteBuffer.wrap(a));
 +          }
 +        }
 +        result.add(pscan);
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public List<org.apache.accumulo.proxy.thrift.ActiveCompaction> getActiveCompactions(ByteBuffer login, String tserver)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    
 +    try {
 +      List<org.apache.accumulo.proxy.thrift.ActiveCompaction> result = new ArrayList<org.apache.accumulo.proxy.thrift.ActiveCompaction>();
 +      List<ActiveCompaction> active = getConnector(login).instanceOperations().getActiveCompactions(tserver);
 +      for (ActiveCompaction comp : active) {
 +        org.apache.accumulo.proxy.thrift.ActiveCompaction pcomp = new org.apache.accumulo.proxy.thrift.ActiveCompaction();
 +        pcomp.age = comp.getAge();
 +        pcomp.entriesRead = comp.getEntriesRead();
 +        pcomp.entriesWritten = comp.getEntriesWritten();
 +        KeyExtent e = comp.getExtent();
 +        pcomp.extent = new org.apache.accumulo.proxy.thrift.KeyExtent(e.getTableId().toString(), TextUtil.getByteBuffer(e.getEndRow()),
 +            TextUtil.getByteBuffer(e.getPrevEndRow()));
 +        pcomp.inputFiles = new ArrayList<String>();
 +        if (comp.getInputFiles() != null) {
 +          pcomp.inputFiles.addAll(comp.getInputFiles());
 +        }
 +        pcomp.localityGroup = comp.getLocalityGroup();
 +        pcomp.outputFile = comp.getOutputFile();
 +        pcomp.reason = CompactionReason.valueOf(comp.getReason().toString());
 +        pcomp.type = CompactionType.valueOf(comp.getType().toString());
 +        
 +        pcomp.iterators = new ArrayList<org.apache.accumulo.proxy.thrift.IteratorSetting>();
 +        if (comp.getIterators() != null) {
 +          for (IteratorSetting setting : comp.getIterators()) {
 +            org.apache.accumulo.proxy.thrift.IteratorSetting psetting = new org.apache.accumulo.proxy.thrift.IteratorSetting(setting.getPriority(),
 +                setting.getName(), setting.getIteratorClass(), setting.getOptions());
 +            pcomp.iterators.add(psetting);
 +          }
 +        }
 +        result.add(pcomp);
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void removeProperty(ByteBuffer login, String property) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).instanceOperations().removeProperty(property);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void setProperty(ByteBuffer login, String property, String value) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).instanceOperations().setProperty(property, value);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public boolean testClassLoad(ByteBuffer login, String className, String asTypeName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).instanceOperations().testClassLoad(className, asTypeName);
 +    } catch (Exception e) {
 +      handleException(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public boolean authenticateUser(ByteBuffer login, String user, Map<String,String> properties) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().authenticateUser(user, getToken(user, properties));
 +    } catch (Exception e) {
 +      handleException(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public void changeUserAuthorizations(ByteBuffer login, String user, Set<ByteBuffer> authorizations)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      Set<String> auths = new HashSet<String>();
 +      for (ByteBuffer auth : authorizations) {
 +        auths.add(ByteBufferUtil.toString(auth));
 +      }
 +      getConnector(login).securityOperations().changeUserAuthorizations(user, new Authorizations(auths.toArray(new String[0])));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void changeLocalUserPassword(ByteBuffer login, String user, ByteBuffer password) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().changeLocalUserPassword(user, new PasswordToken(password));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void createLocalUser(ByteBuffer login, String user, ByteBuffer password) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().createLocalUser(user, new PasswordToken(password));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void dropLocalUser(ByteBuffer login, String user) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().dropLocalUser(user);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public List<ByteBuffer> getUserAuthorizations(ByteBuffer login, String user) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().getUserAuthorizations(user).getAuthorizationsBB();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void grantSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().grantSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void grantTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).securityOperations().grantTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public boolean hasSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().hasSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleException(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public boolean hasTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      return getConnector(login).securityOperations().hasTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public Set<String> listLocalUsers(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().listLocalUsers();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void revokeSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().revokeSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void revokeTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).securityOperations().revokeTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  private Authorizations getAuthorizations(Set<ByteBuffer> authorizations) {
 +    List<String> auths = new ArrayList<String>();
 +    for (ByteBuffer bbauth : authorizations) {
 +      auths.add(ByteBufferUtil.toString(bbauth));
 +    }
 +    return new Authorizations(auths.toArray(new String[0]));
 +  }
 +  
 +  @Override
 +  public String createScanner(ByteBuffer login, String tableName, ScanOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Connector connector = getConnector(login);
 +      
 +      Authorizations auth;
 +      if (opts != null && opts.isSetAuthorizations()) {
 +        auth = getAuthorizations(opts.authorizations);
 +      } else {
 +        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
 +      }
 +      Scanner scanner = connector.createScanner(tableName, auth);
 +      
 +      if (opts != null) {
 +        if (opts.iterators != null) {
 +          for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) {
 +            IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(), iter.getIteratorClass(), iter.getProperties());
 +            scanner.addScanIterator(is);
 +          }
 +        }
 +        org.apache.accumulo.proxy.thrift.Range prange = opts.range;
 +        if (prange != null) {
 +          Range range = new Range(Util.fromThrift(prange.getStart()), prange.startInclusive, Util.fromThrift(prange.getStop()), prange.stopInclusive);
 +          scanner.setRange(range);
 +        }
 +        if (opts.columns != null) {
 +          for (ScanColumn col : opts.columns) {
 +            if (col.isSetColQualifier())
 +              scanner.fetchColumn(ByteBufferUtil.toText(col.colFamily), ByteBufferUtil.toText(col.colQualifier));
 +            else
 +              scanner.fetchColumnFamily(ByteBufferUtil.toText(col.colFamily));
 +          }
 +        }
 +      }
 +      
 +      UUID uuid = UUID.randomUUID();
 +      
 +      ScannerPlusIterator spi = new ScannerPlusIterator();
 +      spi.scanner = scanner;
 +      spi.iterator = scanner.iterator();
 +      scannerCache.put(uuid, spi);
 +      return uuid.toString();
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public String createBatchScanner(ByteBuffer login, String tableName, BatchScanOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Connector connector = getConnector(login);
 +      
 +      int threads = 10;
 +      Authorizations auth;
 +      if (opts != null && opts.isSetAuthorizations()) {
 +        auth = getAuthorizations(opts.authorizations);
 +      } else {
 +        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
 +      }
 +      if (opts != null && opts.threads > 0)
 +        threads = opts.threads;
 +      
 +      BatchScanner scanner = connector.createBatchScanner(tableName, auth, threads);
 +      
 +      if (opts != null) {
 +        if (opts.iterators != null) {
 +          for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) {
 +            IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(), iter.getIteratorClass(), iter.getProperties());
 +            scanner.addScanIterator(is);
 +          }
 +        }
 +        
 +        ArrayList<Range> ranges = new ArrayList<Range>();
 +        
 +        if (opts.ranges == null) {
 +          ranges.add(new Range());
 +        } else {
 +          for (org.apache.accumulo.proxy.thrift.Range range : opts.ranges) {
 +            Range aRange = new Range(range.getStart() == null ? null : Util.fromThrift(range.getStart()), true, range.getStop() == null ? null
 +                : Util.fromThrift(range.getStop()), false);
 +            ranges.add(aRange);
 +          }
 +        }
 +        scanner.setRanges(ranges);
 +        
 +        if (opts.columns != null) {
 +          for (ScanColumn col : opts.columns) {
 +            if (col.isSetColQualifier())
 +              scanner.fetchColumn(ByteBufferUtil.toText(col.colFamily), ByteBufferUtil.toText(col.colQualifier));
 +            else
 +              scanner.fetchColumnFamily(ByteBufferUtil.toText(col.colFamily));
 +          }
 +        }
 +      }
 +      
 +      UUID uuid = UUID.randomUUID();
 +      
 +      ScannerPlusIterator spi = new ScannerPlusIterator();
 +      spi.scanner = scanner;
 +      spi.iterator = scanner.iterator();
 +      scannerCache.put(uuid, spi);
 +      return uuid.toString();
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  private ScannerPlusIterator getScanner(String scanner) throws UnknownScanner {
 +    
 +    UUID uuid = null;
 +    try {
 +      uuid = UUID.fromString(scanner);
 +    } catch (IllegalArgumentException e) {
 +      throw new UnknownScanner(e.getMessage());
 +    }
 +    
 +    ScannerPlusIterator spi = scannerCache.getIfPresent(uuid);
 +    if (spi == null) {
 +      throw new UnknownScanner("Scanner never existed or no longer exists");
 +    }
 +    return spi;
 +  }
 +  
 +  @Override
 +  public boolean hasNext(String scanner) throws UnknownScanner, TException {
 +    ScannerPlusIterator spi = getScanner(scanner);
 +    
 +    return (spi.iterator.hasNext());
 +  }
 +  
 +  @Override
 +  public KeyValueAndPeek nextEntry(String scanner) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      TException {
 +    
 +    ScanResult scanResult = nextK(scanner, 1);
 +    if (scanResult.results.size() > 0) {
 +      return new KeyValueAndPeek(scanResult.results.get(0), scanResult.isMore());
 +    } else {
 +      throw new NoMoreEntriesException();
 +    }
 +  }
 +  
 +  @Override
 +  public ScanResult nextK(String scanner, int k) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      TException {
 +    
 +    // fetch the scanner
 +    ScannerPlusIterator spi = getScanner(scanner);
 +    Iterator<Map.Entry<Key,Value>> batchScanner = spi.iterator;
 +    // synchronized to prevent race conditions
 +    synchronized (batchScanner) {
 +      ScanResult ret = new ScanResult();
 +      ret.setResults(new ArrayList<KeyValue>());
 +      int numRead = 0;
 +      try {
 +        while (batchScanner.hasNext() && numRead < k) {
 +          Map.Entry<Key,Value> next = batchScanner.next();
 +          ret.addToResults(new KeyValue(Util.toThrift(next.getKey()), ByteBuffer.wrap(next.getValue().get())));
 +          numRead++;
 +        }
 +        ret.setMore(numRead == k);
 +      } catch (Exception ex) {
 +        closeScanner(scanner);
 +        throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(ex.toString());
 +      }
 +      return ret;
 +    }
 +  }
 +
 +  @Override
 +  public void closeScanner(String scanner) throws UnknownScanner, TException {
 +    UUID uuid = null;
 +    try {
 +      uuid = UUID.fromString(scanner);
 +    } catch (IllegalArgumentException e) {
 +      throw new UnknownScanner(e.getMessage());
 +    }
 +
 +    try {
 +      if (scannerCache.asMap().remove(uuid) == null) {
 +        throw new UnknownScanner("Scanner never existed or no longer exists");
 +      }
 +    } catch (UnknownScanner e) {
 +      throw e;
 +    } catch (Exception e) {
 +      throw new TException(e.toString());
 +    }
 +  }
 +  
 +  @Override
 +  public void updateAndFlush(ByteBuffer login, String tableName, Map<ByteBuffer,List<ColumnUpdate>> cells)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(login, tableName, null);
 +      addCellsToWriter(cells, bwpe);
 +      if (bwpe.exception != null)
 +        throw bwpe.exception;
 +      bwpe.writer.flush();
 +      bwpe.writer.close();
 +    } catch (Exception e) {
 +      handleExceptionMRE(e);
 +    }
 +  }
 +  
 +  private static final ColumnVisibility EMPTY_VIS = new ColumnVisibility();
 +  
 +  private void addCellsToWriter(Map<ByteBuffer,List<ColumnUpdate>> cells, BatchWriterPlusException bwpe) {
 +    if (bwpe.exception != null)
 +      return;
 +    
 +    HashMap<Text,ColumnVisibility> vizMap = new HashMap<Text,ColumnVisibility>();
 +    
 +    for (Map.Entry<ByteBuffer,List<ColumnUpdate>> entry : cells.entrySet()) {
 +      Mutation m = new Mutation(ByteBufferUtil.toBytes(entry.getKey()));
 +      
 +      for (ColumnUpdate update : entry.getValue()) {
 +        ColumnVisibility viz = EMPTY_VIS;
 +        if (update.isSetColVisibility()) {
 +          Text vizText = new Text(update.getColVisibility());
 +          viz = vizMap.get(vizText);
 +          if (viz == null) {
 +            vizMap.put(vizText, viz = new ColumnVisibility(vizText));
 +          }
 +        }
 +        byte[] value = new byte[0];
 +        if (update.isSetValue())
 +          value = update.getValue();
 +        if (update.isSetTimestamp()) {
 +          if (update.isSetDeleteCell()) {
 +            m.putDelete(update.getColFamily(), update.getColQualifier(), viz, update.getTimestamp());
 +          } else {
 +            m.put(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz, update.getTimestamp(), new Value(value));
 +            }
 +        } else {
 +          if (update.isSetDeleteCell()) {
 +            m.putDelete(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz);
 +          } else {
 +            m.put(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz, new Value(value));
 +          }
 +        }
 +      }
 +      try {
 +        bwpe.writer.addMutation(m);
 +      } catch (MutationsRejectedException mre) {
 +        bwpe.exception = mre;
 +      }
 +    }
 +  }
 +  
 +  @Override
 +  public String createWriter(ByteBuffer login, String tableName, WriterOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      BatchWriterPlusException writer = getWriter(login, tableName, opts);
 +      UUID uuid = UUID.randomUUID();
 +      writerCache.put(uuid, writer);
 +      return uuid.toString();
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void update(String writer, Map<ByteBuffer,List<ColumnUpdate>> cells) throws TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(writer);
 +      addCellsToWriter(cells, bwpe);
 +    } catch (UnknownWriter e) {
 +      // just drop it, this is a oneway thrift call and throwing a TException seems to make all subsequent thrift calls fail
 +    }
 +  }
 +  
 +  @Override
 +  public void flush(String writer) throws UnknownWriter, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(writer);
 +      if (bwpe.exception != null)
 +        throw bwpe.exception;
 +      bwpe.writer.flush();
 +    } catch (MutationsRejectedException e) {
 +      throw new org.apache.accumulo.proxy.thrift.MutationsRejectedException(e.toString());
 +    } catch (UnknownWriter uw) {
 +      throw uw;
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void closeWriter(String writer) throws UnknownWriter, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(writer);
 +      if (bwpe.exception != null)
 +        throw bwpe.exception;
 +      bwpe.writer.close();
 +      writerCache.invalidate(UUID.fromString(writer));
 +    } catch (UnknownWriter uw) {
 +      throw uw;
 +    } catch (MutationsRejectedException e) {
 +      throw new org.apache.accumulo.proxy.thrift.MutationsRejectedException(e.toString());
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +
 +  private BatchWriterPlusException getWriter(String writer) throws UnknownWriter {
 +    UUID uuid = null;
 +    try {
 +      uuid = UUID.fromString(writer);
 +    } catch (IllegalArgumentException iae) {
 +      throw new UnknownWriter(iae.getMessage());
 +    }
 +    
 +    BatchWriterPlusException bwpe = writerCache.getIfPresent(uuid);
 +    if (bwpe == null) {
 +      throw new UnknownWriter("Writer never existed or no longer exists");
 +    }
 +    return bwpe;
 +  }
 +  
 +  private BatchWriterPlusException getWriter(ByteBuffer login, String tableName, WriterOptions opts) throws Exception {
 +    BatchWriterConfig cfg = new BatchWriterConfig();
 +    if (opts != null) {
 +      if (opts.maxMemory != 0)
 +        cfg.setMaxMemory(opts.maxMemory);
 +      if (opts.threads != 0)
 +        cfg.setMaxWriteThreads(opts.threads);
 +      if (opts.timeoutMs != 0)
 +        cfg.setTimeout(opts.timeoutMs, TimeUnit.MILLISECONDS);
 +      if (opts.latencyMs != 0)
 +        cfg.setMaxLatency(opts.latencyMs, TimeUnit.MILLISECONDS);
 +    }
 +    BatchWriterPlusException result = new BatchWriterPlusException();
 +    result.writer = getConnector(login).createBatchWriter(tableName, cfg);
 +    return result;
 +  }
 +  
 +  private IteratorSetting getIteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting setting) {
 +    return new IteratorSetting(setting.priority, setting.name, setting.iteratorClass, setting.getProperties());
 +  }
 +  
 +  private IteratorScope getIteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope scope) {
 +    return IteratorScope.valueOf(scope.toString().toLowerCase());
 +  }
 +  
 +  private EnumSet<IteratorScope> getIteratorScopes(Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) {
 +    EnumSet<IteratorScope> scopes_ = EnumSet.noneOf(IteratorScope.class);
 +    for (org.apache.accumulo.proxy.thrift.IteratorScope scope : scopes) {
 +      scopes_.add(getIteratorScope(scope));
 +    }
 +    return scopes_;
 +  }
 +  
 +  private EnumSet<org.apache.accumulo.proxy.thrift.IteratorScope> getProxyIteratorScopes(Set<IteratorScope> scopes) {
 +    EnumSet<org.apache.accumulo.proxy.thrift.IteratorScope> scopes_ = EnumSet.noneOf(org.apache.accumulo.proxy.thrift.IteratorScope.class);
 +    for (IteratorScope scope : scopes) {
 +      scopes_.add(org.apache.accumulo.proxy.thrift.IteratorScope.valueOf(scope.toString().toUpperCase()));
 +    }
 +    return scopes_;
 +  }
 +  
 +  @Override
 +  public void attachIterator(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.IteratorSetting setting,
 +      Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().attachIterator(tableName, getIteratorSetting(setting), getIteratorScopes(scopes));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void checkIteratorConflicts(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.IteratorSetting setting,
 +      Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().checkIteratorConflicts(tableName, getIteratorSetting(setting), getIteratorScopes(scopes));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void cloneTable(ByteBuffer login, String tableName, String newTableName, boolean flush, Map<String,String> propertiesToSet,
 +      Set<String> propertiesToExclude) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      propertiesToExclude = propertiesToExclude == null ? new HashSet<String>() : propertiesToExclude;
 +      propertiesToSet = propertiesToSet == null ? new HashMap<String,String>() : propertiesToSet;
 +      
 +      getConnector(login).tableOperations().clone(tableName, newTableName, flush, propertiesToSet, propertiesToExclude);
 +    } catch (Exception e) {
 +      handleExceptionTEE(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void exportTable(ByteBuffer login, String tableName, String exportDir) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().exportTable(tableName, exportDir);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void importTable(ByteBuffer login, String tableName, String importDir) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().importTable(tableName, importDir);
 +    } catch (TableExistsException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableExistsException(e.toString());
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public org.apache.accumulo.proxy.thrift.IteratorSetting getIteratorSetting(ByteBuffer login, String tableName, String iteratorName,
 +      org.apache.accumulo.proxy.thrift.IteratorScope scope) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      IteratorSetting is = getConnector(login).tableOperations().getIteratorSetting(tableName, iteratorName, getIteratorScope(scope));
 +      return new org.apache.accumulo.proxy.thrift.IteratorSetting(is.getPriority(), is.getName(), is.getIteratorClass(), is.getOptions());
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>> listIterators(ByteBuffer login, String tableName)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,EnumSet<IteratorScope>> iterMap = getConnector(login).tableOperations().listIterators(tableName);
 +      Map<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>> result = new HashMap<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>>();
 +      for (Map.Entry<String,EnumSet<IteratorScope>> entry : iterMap.entrySet()) {
 +        result.put(entry.getKey(), getProxyIteratorScopes(entry.getValue()));
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void removeIterator(ByteBuffer login, String tableName, String iterName, Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().removeIterator(tableName, iterName, getIteratorScopes(scopes));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Set<org.apache.accumulo.proxy.thrift.Range> splitRangeByTablets(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.Range range,
 +      int maxSplits) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Set<Range> ranges = getConnector(login).tableOperations().splitRangeByTablets(tableName, getRange(range), maxSplits);
 +      Set<org.apache.accumulo.proxy.thrift.Range> result = new HashSet<org.apache.accumulo.proxy.thrift.Range>();
 +      for (Range r : ranges) {
 +        result.add(getRange(r));
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  private org.apache.accumulo.proxy.thrift.Range getRange(Range r) {
 +    return new org.apache.accumulo.proxy.thrift.Range(getProxyKey(r.getStartKey()), r.isStartKeyInclusive(), getProxyKey(r.getEndKey()), r.isEndKeyInclusive());
 +  }
 +  
 +  private org.apache.accumulo.proxy.thrift.Key getProxyKey(Key k) {
 +    if (k == null)
 +      return null;
 +    org.apache.accumulo.proxy.thrift.Key result = new org.apache.accumulo.proxy.thrift.Key(TextUtil.getByteBuffer(k.getRow()), TextUtil.getByteBuffer(k
 +        .getColumnFamily()), TextUtil.getByteBuffer(k.getColumnQualifier()), TextUtil.getByteBuffer(k.getColumnVisibility()));
++    result.setTimestamp(k.getTimestamp());
 +    return result;
 +  }
 +  
 +  private Range getRange(org.apache.accumulo.proxy.thrift.Range range) {
 +    return new Range(Util.fromThrift(range.start), Util.fromThrift(range.stop));
 +  }
 +  
 +  @Override
 +  public void importDirectory(ByteBuffer login, String tableName, String importDir, String failureDir, boolean setTime)
 +      throws org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).tableOperations().importDirectory(tableName, importDir, failureDir, setTime);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
-   static private final ByteBuffer EMPTY = ByteBuffer.wrap(new byte[] {});
-   
 +  @Override
 +  public org.apache.accumulo.proxy.thrift.Range getRowRange(ByteBuffer row) throws TException {
-     return new org.apache.accumulo.proxy.thrift.Range(new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true,
-         new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true);
++    return getRange(new Range(ByteBufferUtil.toText(row)));
 +  }
 +  
 +  @Override
 +  public org.apache.accumulo.proxy.thrift.Key getFollowing(org.apache.accumulo.proxy.thrift.Key key, org.apache.accumulo.proxy.thrift.PartialKey part)
 +      throws TException {
 +    Key key_ = Util.fromThrift(key);
 +    PartialKey part_ = PartialKey.valueOf(part.toString());
 +    Key followingKey = key_.followingKey(part_);
 +    return getProxyKey(followingKey);
 +  }
 +  
 +  @Override
 +  public void pingTabletServer(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).instanceOperations().ping(tserver);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public ByteBuffer login(String principal, Map<String,String> loginProperties) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      AuthenticationToken token = getToken(principal, loginProperties);
 +      TCredentials credential = CredentialHelper.create(principal, token, instance.getInstanceID());
 +      ByteBuffer login = ByteBuffer.wrap(CredentialHelper.asByteArray(credential));
 +      getConnector(login); // check to make sure user exists
 +      return login;
 +    } catch (AccumuloSecurityException e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString());
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  private AuthenticationToken getToken(String principal, Map<String,String> properties) throws AccumuloSecurityException, AccumuloException {
 +    AuthenticationToken.Properties props = new AuthenticationToken.Properties();
 +    props.putAllStrings(properties);
 +    AuthenticationToken token;
 +    try {
 +      token = tokenClass.newInstance();
 +    } catch (InstantiationException e) {
 +      throw new AccumuloException(e);
 +    } catch (IllegalAccessException e) {
 +      throw new AccumuloException(e);
 +    }
 +    token.init(props);
 +    return token;
 +  }
 +  
 +  @Override
 +  public boolean testTableClassLoad(ByteBuffer login, String tableName, String className, String asTypeName)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      return getConnector(login).tableOperations().testClassLoad(tableName, className, asTypeName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return false;
 +    }
 +  }
 +}


[10/10] git commit: Merge branch '1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT

Posted by ec...@apache.org.
Merge branch '1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT

Conflicts:
	proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a95831a2
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a95831a2
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a95831a2

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: a95831a20d07e0e60ed99a4d4e605bf6aad1d9d3
Parents: 417902e 8729dba
Author: Eric Newton <er...@gmail.com>
Authored: Thu Jan 2 12:03:38 2014 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Thu Jan 2 12:03:38 2014 -0500

----------------------------------------------------------------------
 proxy/examples/python/TestClient.py             |  4 ++--
 proxy/examples/ruby/test_client.rb              |  8 ++++----
 .../org/apache/accumulo/proxy/ProxyServer.java  |  6 ++----
 .../org/apache/accumulo/proxy/thrift/Key.java   |  6 ++++--
 proxy/src/main/thrift/proxy.thrift              |  4 +++-
 .../apache/accumulo/proxy/SimpleProxyIT.java    | 20 ++++++++++++++++++++
 6 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a95831a2/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a95831a2/proxy/src/main/thrift/proxy.thrift
----------------------------------------------------------------------
diff --cc proxy/src/main/thrift/proxy.thrift
index aabaa5e,7fd2c3f..6488f4f
--- a/proxy/src/main/thrift/proxy.thrift
+++ b/proxy/src/main/thrift/proxy.thrift
@@@ -14,20 -14,10 +14,22 @@@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 +
 +/*
 + * Compatibility.
 + *
 + * Its possible that over time that this IDL may change in ways that breaks
 + * client code.  However newer versions of the proxy server will use thrift
 + * mechanisms to maintain compatibility with older versions of the proxy IDL.
 + * So proxy clients using 1.4.x or 1.5.x IDL can use a 1.6.x proxy server.
 + * Therefore if changes to this IDL break your client code, then using an older
 + * version of the IDL with a new version of the proxy server is an option.
 + */
 +
  namespace cpp accumulo
  namespace java org.apache.accumulo.proxy.thrift
+ namespace rb Accumulo
+ namespace py accumulo
  
  struct Key {
    1:binary row;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a95831a2/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java
----------------------------------------------------------------------
diff --cc proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java
index ecb1c89,0000000..91f04b2
mode 100644,000000..100644
--- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java
+++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java
@@@ -1,1505 -1,0 +1,1525 @@@
 +/*
 + * 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.proxy;
 +
 +import static org.junit.Assert.assertEquals;
 +import static org.junit.Assert.assertFalse;
 +import static org.junit.Assert.assertNotEquals;
 +import static org.junit.Assert.assertTrue;
 +import static org.junit.Assert.fail;
 +
 +import java.io.BufferedReader;
 +import java.io.File;
 +import java.io.InputStreamReader;
 +import java.nio.ByteBuffer;
 +import java.util.ArrayList;
 +import java.util.Arrays;
 +import java.util.Collections;
 +import java.util.EnumSet;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Properties;
 +import java.util.Random;
 +import java.util.Set;
 +import java.util.TreeMap;
 +import java.util.UUID;
 +import java.util.concurrent.atomic.AtomicInteger;
 +
 +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 +import org.apache.accumulo.core.conf.DefaultConfiguration;
 +import org.apache.accumulo.core.conf.Property;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.core.file.FileOperations;
 +import org.apache.accumulo.core.file.FileSKVWriter;
 +import org.apache.accumulo.core.iterators.DevNull;
 +import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 +import org.apache.accumulo.core.iterators.user.SummingCombiner;
 +import org.apache.accumulo.core.iterators.user.VersioningIterator;
 +import org.apache.accumulo.core.metadata.MetadataTable;
 +import org.apache.accumulo.core.util.ByteBufferUtil;
 +import org.apache.accumulo.core.util.UtilWaitThread;
 +import org.apache.accumulo.examples.simple.constraints.NumericValueConstraint;
 +import org.apache.accumulo.minicluster.MiniAccumuloCluster;
 +import org.apache.accumulo.minicluster.MiniAccumuloConfig;
 +import org.apache.accumulo.proxy.thrift.AccumuloProxy.Client;
 +import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
 +import org.apache.accumulo.proxy.thrift.ActiveCompaction;
 +import org.apache.accumulo.proxy.thrift.ActiveScan;
 +import org.apache.accumulo.proxy.thrift.BatchScanOptions;
 +import org.apache.accumulo.proxy.thrift.Column;
 +import org.apache.accumulo.proxy.thrift.ColumnUpdate;
 +import org.apache.accumulo.proxy.thrift.CompactionReason;
 +import org.apache.accumulo.proxy.thrift.CompactionType;
 +import org.apache.accumulo.proxy.thrift.Condition;
 +import org.apache.accumulo.proxy.thrift.ConditionalStatus;
 +import org.apache.accumulo.proxy.thrift.ConditionalUpdates;
 +import org.apache.accumulo.proxy.thrift.ConditionalWriterOptions;
 +import org.apache.accumulo.proxy.thrift.DiskUsage;
 +import org.apache.accumulo.proxy.thrift.IteratorScope;
 +import org.apache.accumulo.proxy.thrift.IteratorSetting;
 +import org.apache.accumulo.proxy.thrift.Key;
 +import org.apache.accumulo.proxy.thrift.KeyValue;
 +import org.apache.accumulo.proxy.thrift.MutationsRejectedException;
 +import org.apache.accumulo.proxy.thrift.PartialKey;
 +import org.apache.accumulo.proxy.thrift.Range;
 +import org.apache.accumulo.proxy.thrift.ScanColumn;
 +import org.apache.accumulo.proxy.thrift.ScanOptions;
 +import org.apache.accumulo.proxy.thrift.ScanResult;
 +import org.apache.accumulo.proxy.thrift.ScanState;
 +import org.apache.accumulo.proxy.thrift.ScanType;
 +import org.apache.accumulo.proxy.thrift.SystemPermission;
 +import org.apache.accumulo.proxy.thrift.TableExistsException;
 +import org.apache.accumulo.proxy.thrift.TableNotFoundException;
 +import org.apache.accumulo.proxy.thrift.TablePermission;
 +import org.apache.accumulo.proxy.thrift.TimeType;
 +import org.apache.accumulo.proxy.thrift.UnknownScanner;
 +import org.apache.accumulo.proxy.thrift.UnknownWriter;
 +import org.apache.accumulo.proxy.thrift.WriterOptions;
 +import org.apache.accumulo.server.util.PortUtils;
 +import org.apache.accumulo.test.functional.SlowIterator;
 +import org.apache.commons.io.FileUtils;
 +import org.apache.hadoop.conf.Configuration;
 +import org.apache.hadoop.fs.FSDataInputStream;
 +import org.apache.hadoop.fs.FileSystem;
 +import org.apache.hadoop.fs.Path;
 +import org.apache.hadoop.io.Text;
 +import org.apache.thrift.TException;
 +import org.apache.thrift.protocol.TProtocolFactory;
 +import org.apache.thrift.server.TServer;
 +import org.junit.AfterClass;
 +import org.junit.BeforeClass;
 +import org.junit.Rule;
 +import org.junit.Test;
 +import org.junit.rules.TemporaryFolder;
 +import org.junit.rules.TestName;
 +
 +/**
 + * Call every method on the proxy and try to verify that it works.
 + */
 +public class SimpleProxyIT {
 +
 +  public static File macTestFolder = new File(System.getProperty("user.dir") + "/target/" + SimpleProxyIT.class.getName());
 +
 +  private static MiniAccumuloCluster accumulo;
 +  private static String secret = "superSecret";
 +  private static Random random = new Random();
 +  private static TServer proxyServer;
 +  private static Thread thread;
 +  private static int proxyPort;
 +  private static org.apache.accumulo.proxy.thrift.AccumuloProxy.Client client;
 +  private static String principal = "root";
 +
 +  private static Map<String,String> properties = new TreeMap<String,String>() {
 +    private static final long serialVersionUID = 1L;
 +
 +    {
 +      put("password", secret);
 +    }
 +  };
 +  private static ByteBuffer creds = null;
 +
 +  private static Class<? extends TProtocolFactory> protocolClass;
 +
 +  static Class<? extends TProtocolFactory> getRandomProtocol() {
 +    List<Class<? extends TProtocolFactory>> protocolFactories = new ArrayList<Class<? extends TProtocolFactory>>();
 +    protocolFactories.add(org.apache.thrift.protocol.TJSONProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TBinaryProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TTupleProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TCompactProtocol.Factory.class);
 +
 +    return protocolFactories.get(random.nextInt(protocolFactories.size()));
 +  }
 +
 +  private static final AtomicInteger tableCounter = new AtomicInteger(0);
 +
 +  private static String makeTableName() {
 +    return "test" + tableCounter.getAndIncrement();
 +  }
 +
 +  @Rule
 +  public TemporaryFolder tempFolder = new TemporaryFolder(macTestFolder);
 +
 +  @Rule
 +  public TestName testName = new TestName();
 +
 +  @BeforeClass
 +  public static void setupMiniCluster() throws Exception {
 +    FileUtils.deleteQuietly(macTestFolder);
 +    macTestFolder.mkdirs();
 +    MiniAccumuloConfig config = new MiniAccumuloConfig(macTestFolder, secret).setNumTservers(1);
 +    accumulo = new MiniAccumuloCluster(config);
 +    accumulo.start();
 +
 +    Properties props = new Properties();
 +    props.put("instance", accumulo.getConfig().getInstanceName());
 +    props.put("zookeepers", accumulo.getConfig().getZooKeepers());
 +    props.put("tokenClass", PasswordToken.class.getName());
 +
 +    protocolClass = getRandomProtocol();
 +
 +    proxyPort = PortUtils.getRandomFreePort();
 +    proxyServer = Proxy.createProxyServer(org.apache.accumulo.proxy.thrift.AccumuloProxy.class, org.apache.accumulo.proxy.ProxyServer.class, proxyPort,
 +        protocolClass, props);
 +    thread = new Thread() {
 +      @Override
 +      public void run() {
 +        proxyServer.serve();
 +      }
 +    };
 +    thread.start();
 +    while (!proxyServer.isServing())
 +      UtilWaitThread.sleep(100);
 +    client = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +    creds = client.login(principal, properties);
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void security() throws Exception {
 +    client.createLocalUser(creds, "user", s2bb(secret));
 +    ByteBuffer badLogin = client.login("user", properties);
 +    client.dropLocalUser(creds, "user");
 +    final String table = makeTableName();
 +    client.createTable(creds, table, false, TimeType.MILLIS);
 +
 +    final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +
 +    try {
 +      client.addConstraint(badLogin, table, NumericValueConstraint.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.addSplits(badLogin, table, Collections.singleton(s2bb("1")));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.clearLocatorCache(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.compactTable(badLogin, table, null, null, null, true, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.cancelCompaction(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createTable(badLogin, table, false, TimeType.MILLIS);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.deleteTable(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.deleteRows(badLogin, table, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.tableExists(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.flushTable(badLogin, table, null, null, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getLocalityGroups(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getMaxRow(badLogin, table, Collections.<ByteBuffer> emptySet(), null, false, null, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getTableProperties(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listSplits(badLogin, table, 10000);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listTables(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.listConstraints(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.mergeTablets(badLogin, table, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.offlineTable(badLogin, table, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.onlineTable(badLogin, table, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeConstraint(badLogin, table, 0);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeTableProperty(badLogin, table, Property.TABLE_FILE_MAX.getKey());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.renameTable(badLogin, table, "someTableName");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      Map<String,Set<String>> groups = new HashMap<String,Set<String>>();
 +      groups.put("group1", Collections.singleton("cf1"));
 +      groups.put("group2", Collections.singleton("cf2"));
 +      client.setLocalityGroups(badLogin, table, groups);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.setTableProperty(badLogin, table, Property.TABLE_FILE_MAX.getKey(), "0");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.tableIdMap(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.getSiteConfiguration(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getSystemConfiguration(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getTabletServers(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.getActiveScans(badLogin, "fake");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getActiveCompactions(badLogin, "fakse");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeProperty(badLogin, "table.split.threshold");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.setProperty(badLogin, "table.split.threshold", "500M");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.testClassLoad(badLogin, DevNull.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.authenticateUser(badLogin, "root", s2pp(secret));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      HashSet<ByteBuffer> auths = new HashSet<ByteBuffer>(Arrays.asList(s2bb("A"), s2bb("B")));
 +      client.changeUserAuthorizations(badLogin, "stooge", auths);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.changeLocalUserPassword(badLogin, "stooge", s2bb(""));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createLocalUser(badLogin, "stooge", s2bb("password"));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.dropLocalUser(badLogin, "stooge");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getUserAuthorizations(badLogin, "stooge");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.grantSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.grantTablePermission(badLogin, "root", table, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.hasSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.hasTablePermission(badLogin, "root", table, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listLocalUsers(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.revokeSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.revokeTablePermission(badLogin, "root", table, TablePermission.ALTER_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createScanner(badLogin, table, new ScanOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createBatchScanner(badLogin, table, new BatchScanOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.updateAndFlush(badLogin, table, new HashMap<ByteBuffer,List<ColumnUpdate>>());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createWriter(badLogin, table, new WriterOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.attachIterator(badLogin, "slow", setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.checkIteratorConflicts(badLogin, table, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      final String TABLE_TEST = makeTableName();
 +      client.cloneTable(badLogin, table, TABLE_TEST, false, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.exportTable(badLogin, table, "/tmp");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.importTable(badLogin, "testify", "/tmp");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getIteratorSetting(badLogin, table, "foo", IteratorScope.SCAN);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listIterators(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeIterator(badLogin, table, "name", EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.splitRangeByTablets(badLogin, table, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      File importDir = tempFolder.newFolder("importDir");
 +      File failuresDir = tempFolder.newFolder("failuresDir");
 +      client.importDirectory(badLogin, table, importDir.getAbsolutePath(), failuresDir.getAbsolutePath(), true);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.pingTabletServer(badLogin, "fake");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.login("badUser", properties);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.testTableClassLoad(badLogin, table, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createConditionalWriter(badLogin, table, new ConditionalWriterOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void tableNotFound() throws Exception {
 +    final String doesNotExist = "doesNotExists";
 +    try {
 +      client.addConstraint(creds, doesNotExist, NumericValueConstraint.class.getName());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.addSplits(creds, doesNotExist, Collections.<ByteBuffer> emptySet());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    try {
 +      client.attachIterator(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.cancelCompaction(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.checkIteratorConflicts(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.clearLocatorCache(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      final String TABLE_TEST = makeTableName();
 +      client.cloneTable(creds, doesNotExist, TABLE_TEST, false, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.compactTable(creds, doesNotExist, null, null, null, true, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createBatchScanner(creds, doesNotExist, new BatchScanOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createScanner(creds, doesNotExist, new ScanOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createWriter(creds, doesNotExist, new WriterOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.deleteRows(creds, doesNotExist, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.deleteTable(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.exportTable(creds, doesNotExist, "/tmp");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.flushTable(creds, doesNotExist, null, null, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getIteratorSetting(creds, doesNotExist, "foo", IteratorScope.SCAN);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getLocalityGroups(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getMaxRow(creds, doesNotExist, Collections.<ByteBuffer> emptySet(), null, false, null, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getTableProperties(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.grantTablePermission(creds, "root", doesNotExist, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.hasTablePermission(creds, "root", doesNotExist, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      File importDir = tempFolder.newFolder("importDir");
 +      File failuresDir = tempFolder.newFolder("failuresDir");
 +      client.importDirectory(creds, doesNotExist, importDir.getAbsolutePath(), failuresDir.getAbsolutePath(), true);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.listConstraints(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.listSplits(creds, doesNotExist, 10000);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.mergeTablets(creds, doesNotExist, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.offlineTable(creds, doesNotExist, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.onlineTable(creds, doesNotExist, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeConstraint(creds, doesNotExist, 0);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeIterator(creds, doesNotExist, "name", EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.renameTable(creds, doesNotExist, "someTableName");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.revokeTablePermission(creds, "root", doesNotExist, TablePermission.ALTER_TABLE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.setTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey(), "0");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.splitRangeByTablets(creds, doesNotExist, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.updateAndFlush(creds, doesNotExist, new HashMap<ByteBuffer,List<ColumnUpdate>>());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getDiskUsage(creds, Collections.singleton(doesNotExist));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.testTableClassLoad(creds, doesNotExist, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createConditionalWriter(creds, doesNotExist, new ConditionalWriterOptions());
 +    } catch (TableNotFoundException ex) {}
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void testExists() throws Exception {
 +    client.createTable(creds, "ett1", false, TimeType.MILLIS);
 +    client.createTable(creds, "ett2", false, TimeType.MILLIS);
 +    try {
 +      client.createTable(creds, "ett1", false, TimeType.MILLIS);
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +    try {
 +      client.renameTable(creds, "ett1", "ett2");
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +    try {
 +      client.cloneTable(creds, "ett1", "ett2", false, new HashMap<String,String>(), new HashSet<String>());
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void testUnknownScanner() throws Exception {
 +    final String TABLE_TEST = makeTableName();
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    assertFalse(client.hasNext(scanner));
 +    client.closeScanner(scanner);
 +
 +    try {
 +      client.hasNext(scanner);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +
 +    try {
 +      client.closeScanner(scanner);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +
 +    try {
 +      client.nextEntry("99999999");
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.nextK("99999999", 6);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.hasNext("99999999");
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.hasNext(UUID.randomUUID().toString());
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void testUnknownWriter() throws Exception {
 +    final String TABLE_TEST = makeTableName();
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +
 +    String writer = client.createWriter(creds, TABLE_TEST, null);
 +    client.update(writer, mutation("row0", "cf", "cq", "value"));
 +    client.flush(writer);
 +    client.update(writer, mutation("row2", "cf", "cq", "value2"));
 +    client.closeWriter(writer);
 +
 +    // this is a oneway call, so it does not throw exceptions
 +    client.update(writer, mutation("row2", "cf", "cq", "value2"));
 +
 +    try {
 +      client.flush(writer);
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.flush("99999");
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.flush(UUID.randomUUID().toString());
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.closeWriter("99999");
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void testDelete() throws Exception {
 +    final String TABLE_TEST = makeTableName();
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row0", "cf", "cq", "value"));
 +
 +    assertScan(new String[][] {{"row0", "cf", "cq", "value"}}, TABLE_TEST);
 +
 +    ColumnUpdate upd = new ColumnUpdate(s2bb("cf"), s2bb("cq"));
 +    upd.setDeleteCell(true);
 +    Map<ByteBuffer,List<ColumnUpdate>> delete = Collections.singletonMap(s2bb("row0"), Collections.singletonList(upd));
 +
 +    client.updateAndFlush(creds, TABLE_TEST, delete);
 +
 +    assertScan(new String[][] {}, TABLE_TEST);
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void testInstanceOperations() throws Exception {
 +    int tservers = 0;
 +    for (String tserver : client.getTabletServers(creds)) {
 +      client.pingTabletServer(creds, tserver);
 +      tservers++;
 +    }
 +    assertTrue(tservers > 0);
 +
 +    // get something we know is in the site config
 +    Map<String,String> cfg = client.getSiteConfiguration(creds);
 +    assertTrue(cfg.get("instance.dfs.dir").startsWith(macTestFolder.getPath()));
 +
 +    // set a property in zookeeper
 +    client.setProperty(creds, "table.split.threshold", "500M");
 +
 +    // check that we can read it
 +    for (int i = 0; i < 5; i++) {
 +      cfg = client.getSystemConfiguration(creds);
 +      if ("500M".equals(cfg.get("table.split.threshold")))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertEquals("500M", cfg.get("table.split.threshold"));
 +
 +    // unset the setting, check that it's not what it was
 +    client.removeProperty(creds, "table.split.threshold");
 +    for (int i = 0; i < 5; i++) {
 +      cfg = client.getSystemConfiguration(creds);
 +      if (!"500M".equals(cfg.get("table.split.threshold")))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertNotEquals("500M", cfg.get("table.split.threshold"));
 +
 +    // try to load some classes via the proxy
 +    assertTrue(client.testClassLoad(creds, DevNull.class.getName(), SortedKeyValueIterator.class.getName()));
 +    assertFalse(client.testClassLoad(creds, "foo.bar", SortedKeyValueIterator.class.getName()));
 +
 +    // create a table that's very slow, so we can look for scans/compactions
 +    client.createTable(creds, "slow", true, TimeType.MILLIS);
 +    IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    client.attachIterator(creds, "slow", setting, EnumSet.allOf(IteratorScope.class));
 +    client.updateAndFlush(creds, "slow", mutation("row", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row2", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row3", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row4", "cf", "cq", "value"));
 +
 +    // scan
 +    Thread t = new Thread() {
 +      @Override
 +      public void run() {
 +        String scanner;
 +        try {
 +          Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +          scanner = client2.createScanner(creds, "slow", null);
 +          client2.nextK(scanner, 10);
 +          client2.closeScanner(scanner);
 +        } catch (Exception e) {
 +          throw new RuntimeException(e);
 +        }
 +      }
 +    };
 +    t.start();
 +    // look for the scan
 +    List<ActiveScan> scans = Collections.emptyList();
 +    loop: for (int i = 0; i < 100; i++) {
 +      for (String tserver : client.getTabletServers(creds)) {
 +        scans = client.getActiveScans(creds, tserver);
 +        if (!scans.isEmpty())
 +          break loop;
 +        UtilWaitThread.sleep(10);
 +      }
 +    }
 +    t.join();
 +    assertFalse(scans.isEmpty());
 +    ActiveScan scan = scans.get(0);
 +    assertEquals("root", scan.getUser());
 +    assertTrue(ScanState.RUNNING.equals(scan.getState()) || ScanState.QUEUED.equals(scan.getState()));
 +    assertEquals(ScanType.SINGLE, scan.getType());
 +    assertEquals("slow", scan.getTable());
 +    Map<String,String> map = client.tableIdMap(creds);
 +    assertEquals(map.get("slow"), scan.getExtent().tableId);
 +    assertTrue(scan.getExtent().endRow == null);
 +    assertTrue(scan.getExtent().prevEndRow == null);
 +
 +    // start a compaction
 +    t = new Thread() {
 +      @Override
 +      public void run() {
 +        try {
 +          Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +          client2.compactTable(creds, "slow", null, null, null, true, true);
 +        } catch (Exception e) {
 +          throw new RuntimeException(e);
 +        }
 +      }
 +    };
 +    t.start();
 +
 +    // try to catch it in the act
 +    List<ActiveCompaction> compactions = Collections.emptyList();
 +    loop2: for (int i = 0; i < 100; i++) {
 +      for (String tserver : client.getTabletServers(creds)) {
 +        compactions = client.getActiveCompactions(creds, tserver);
 +        if (!compactions.isEmpty())
 +          break loop2;
 +      }
 +      UtilWaitThread.sleep(10);
 +    }
 +    t.join();
 +    // verify the compaction information
 +    assertFalse(compactions.isEmpty());
 +    ActiveCompaction c = compactions.get(0);
 +    assertEquals(map.get("slow"), c.getExtent().tableId);
 +    assertTrue(c.inputFiles.isEmpty());
 +    assertEquals(CompactionType.MINOR, c.getType());
 +    assertEquals(CompactionReason.USER, c.getReason());
 +    assertEquals("", c.localityGroup);
 +    assertTrue(c.outputFile.contains("default_tablet"));
 +  }
 +
 +  @Test
 +  public void testSecurityOperations() throws Exception {
 +    final String TABLE_TEST = makeTableName();
 +
 +    // check password
 +    assertTrue(client.authenticateUser(creds, "root", s2pp(secret)));
 +    assertFalse(client.authenticateUser(creds, "root", s2pp("")));
 +
 +    // create a user
 +    client.createLocalUser(creds, "stooge", s2bb("password"));
 +    // change auths
 +    Set<String> users = client.listLocalUsers(creds);
 +    assertEquals(new HashSet<String>(Arrays.asList("root", "stooge")), users);
 +    HashSet<ByteBuffer> auths = new HashSet<ByteBuffer>(Arrays.asList(s2bb("A"), s2bb("B")));
 +    client.changeUserAuthorizations(creds, "stooge", auths);
 +    List<ByteBuffer> update = client.getUserAuthorizations(creds, "stooge");
 +    assertEquals(auths, new HashSet<ByteBuffer>(update));
 +
 +    // change password
 +    client.changeLocalUserPassword(creds, "stooge", s2bb(""));
 +    assertTrue(client.authenticateUser(creds, "stooge", s2pp("")));
 +
 +    // check permission failure
 +    @SuppressWarnings("serial")
 +    ByteBuffer stooge = client.login("stooge", new TreeMap<String,String>() {
 +      {
 +        put("password", "");
 +      }
 +    });
 +
 +    try {
 +      client.createTable(stooge, "fail", true, TimeType.MILLIS);
 +      fail("should not create the table");
 +    } catch (AccumuloSecurityException ex) {
 +      assertFalse(client.listTables(creds).contains("fail"));
 +    }
 +    // grant permissions and test
 +    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    client.grantSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
 +    assertTrue(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    client.createTable(stooge, "success", true, TimeType.MILLIS);
 +    client.listTables(creds).contains("succcess");
 +
 +    // revoke permissions
 +    client.revokeSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
 +    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    try {
 +      client.createTable(stooge, "fail", true, TimeType.MILLIS);
 +      fail("should not create the table");
 +    } catch (AccumuloSecurityException ex) {
 +      assertFalse(client.listTables(creds).contains("fail"));
 +    }
 +    // create a table to test table permissions
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    // denied!
 +    try {
 +      String scanner = client.createScanner(stooge, TABLE_TEST, null);
 +      client.nextK(scanner, 100);
 +      fail("stooge should not read table test");
 +    } catch (AccumuloSecurityException ex) {}
 +    // grant
 +    assertFalse(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    client.grantTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ);
 +    assertTrue(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    String scanner = client.createScanner(stooge, TABLE_TEST, null);
 +    client.nextK(scanner, 10);
 +    client.closeScanner(scanner);
 +    // revoke
 +    client.revokeTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ);
 +    assertFalse(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    try {
 +      scanner = client.createScanner(stooge, TABLE_TEST, null);
 +      client.nextK(scanner, 100);
 +      fail("stooge should not read table test");
 +    } catch (AccumuloSecurityException ex) {}
 +
 +    // delete user
 +    client.dropLocalUser(creds, "stooge");
 +    users = client.listLocalUsers(creds);
 +    assertEquals(1, users.size());
 +
 +  }
 +
 +  @Test
 +  public void testBatchWriter() throws Exception {
 +    final String TABLE_TEST = makeTableName();
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
 +
 +    WriterOptions writerOptions = new WriterOptions();
 +    writerOptions.setLatencyMs(10000);
 +    writerOptions.setMaxMemory(2);
 +    writerOptions.setThreads(1);
 +    writerOptions.setTimeoutMs(100000);
 +
 +    String batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    try {
 +      client.flush(batchWriter);
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException ex) {}
 +    try {
 +      client.closeWriter(batchWriter);
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException e) {}
 +
 +    client.removeConstraint(creds, TABLE_TEST, 2);
 +
 +    assertScan(new String[][] {}, TABLE_TEST);
 +
 +    writerOptions = new WriterOptions();
 +    writerOptions.setLatencyMs(10000);
 +    writerOptions.setMaxMemory(3000);
 +    writerOptions.setThreads(1);
 +    writerOptions.setTimeoutMs(100000);
 +
 +    batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
 +
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    client.flush(batchWriter);
 +    client.closeWriter(batchWriter);
 +
 +    assertScan(new String[][] {{"row1", "cf", "cq", "x"}}, TABLE_TEST);
 +
 +    client.deleteTable(creds, TABLE_TEST);
 +  }
 +
 +  @Test
 +  public void testTableOperations() throws Exception {
 +    final String TABLE_TEST = makeTableName();
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    // constraints
 +    client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
 +    assertEquals(2, client.listConstraints(creds, TABLE_TEST).size());
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "123"));
 +
 +    try {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException ex) {}
 +
 +    client.removeConstraint(creds, TABLE_TEST, 2);
 +    assertEquals(1, client.listConstraints(creds, TABLE_TEST).size());
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
 +    assertScan(new String[][] {{"row1", "cf", "cq", "x"}}, TABLE_TEST);
 +    // splits, merge
 +    client.addSplits(creds, TABLE_TEST, new HashSet<ByteBuffer>(Arrays.asList(s2bb("a"), s2bb("m"), s2bb("z"))));
 +    List<ByteBuffer> splits = client.listSplits(creds, TABLE_TEST, 1);
 +    assertEquals(Arrays.asList(s2bb("m")), splits);
 +    client.mergeTablets(creds, TABLE_TEST, null, s2bb("m"));
 +    splits = client.listSplits(creds, TABLE_TEST, 10);
 +    assertEquals(Arrays.asList(s2bb("m"), s2bb("z")), splits);
 +    client.mergeTablets(creds, TABLE_TEST, null, null);
 +    splits = client.listSplits(creds, TABLE_TEST, 10);
 +    List<ByteBuffer> empty = Collections.emptyList();
 +    assertEquals(empty, splits);
 +    // iterators
 +    client.deleteTable(creds, TABLE_TEST);
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    HashMap<String,String> options = new HashMap<String,String>();
 +    options.put("type", "STRING");
 +    options.put("columns", "cf");
 +    IteratorSetting setting = new IteratorSetting(10, TABLE_TEST, SummingCombiner.class.getName(), options);
 +    client.attachIterator(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
 +    for (int i = 0; i < 10; i++) {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "1"));
 +    }
 +    assertScan(new String[][] {{"row1", "cf", "cq", "10"}}, TABLE_TEST);
 +    try {
 +      client.checkIteratorConflicts(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("checkIteratorConflicts did not throw an exception");
 +    } catch (Exception ex) {}
 +    client.deleteRows(creds, TABLE_TEST, null, null);
 +    client.removeIterator(creds, TABLE_TEST, "test", EnumSet.allOf(IteratorScope.class));
 +    String expected[][] = new String[10][];
 +    for (int i = 0; i < 10; i++) {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row" + i, "cf", "cq", "" + i));
 +      expected[i] = new String[] {"row" + i, "cf", "cq", "" + i};
 +      client.flushTable(creds, TABLE_TEST, null, null, true);
 +    }
 +    assertScan(expected, TABLE_TEST);
 +    // clone
 +    final String TABLE_TEST2 = makeTableName();
 +    client.cloneTable(creds, TABLE_TEST, TABLE_TEST2, true, null, null);
 +    assertScan(expected, TABLE_TEST2);
 +    client.deleteTable(creds, TABLE_TEST2);
 +
 +    // don't know how to test this, call it just for fun
 +    client.clearLocatorCache(creds, TABLE_TEST);
 +
 +    // compact
 +    client.compactTable(creds, TABLE_TEST, null, null, null, true, true);
 +    assertEquals(1, countFiles(TABLE_TEST));
 +    assertScan(expected, TABLE_TEST);
 +
 +    // get disk usage
 +    client.cloneTable(creds, TABLE_TEST, TABLE_TEST2, true, null, null);
 +    Set<String> tablesToScan = new HashSet<String>();
 +    tablesToScan.add(TABLE_TEST);
 +    tablesToScan.add(TABLE_TEST2);
 +    tablesToScan.add("foo");
 +    client.createTable(creds, "foo", true, TimeType.MILLIS);
 +    List<DiskUsage> diskUsage = (client.getDiskUsage(creds, tablesToScan));
 +    assertEquals(2, diskUsage.size());
 +    assertEquals(1, diskUsage.get(0).getTables().size());
 +    assertEquals(2, diskUsage.get(1).getTables().size());
 +    client.compactTable(creds, TABLE_TEST2, null, null, null, true, true);
 +    diskUsage = (client.getDiskUsage(creds, tablesToScan));
 +    assertEquals(3, diskUsage.size());
 +    assertEquals(1, diskUsage.get(0).getTables().size());
 +    assertEquals(1, diskUsage.get(1).getTables().size());
 +    assertEquals(1, diskUsage.get(2).getTables().size());
 +    client.deleteTable(creds, "foo");
 +    client.deleteTable(creds, TABLE_TEST2);
 +
 +    // export/import
 +    File dir = tempFolder.newFolder("test");
 +    File destDir = tempFolder.newFolder("test_dest");
 +    client.offlineTable(creds, TABLE_TEST, false);
 +    client.exportTable(creds, TABLE_TEST, dir.getAbsolutePath());
 +    // copy files to a new location
 +    FileSystem fs = FileSystem.get(new Configuration());
 +    FSDataInputStream is = fs.open(new Path(dir + "/distcp.txt"));
 +    BufferedReader r = new BufferedReader(new InputStreamReader(is));
 +    while (true) {
 +      String line = r.readLine();
 +      if (line == null)
 +        break;
 +      Path srcPath = new Path(line);
 +      FileUtils.copyFile(new File(srcPath.toUri().getPath()), new File(destDir, srcPath.getName()));
 +    }
 +    client.deleteTable(creds, TABLE_TEST);
 +    client.importTable(creds, "testify", destDir.getAbsolutePath());
 +    assertScan(expected, "testify");
 +    client.deleteTable(creds, "testify");
 +
 +    try {
 +      // ACCUMULO-1558 a second import from the same dir should fail, the first import moved the files
 +      client.importTable(creds, "testify2", destDir.getAbsolutePath());
 +      fail();
 +    } catch (Exception e) {}
 +
 +    assertFalse(client.listTables(creds).contains("testify2"));
 +
 +    // Locality groups
 +    client.createTable(creds, "test", true, TimeType.MILLIS);
 +    Map<String,Set<String>> groups = new HashMap<String,Set<String>>();
 +    groups.put("group1", Collections.singleton("cf1"));
 +    groups.put("group2", Collections.singleton("cf2"));
 +    client.setLocalityGroups(creds, "test", groups);
 +    assertEquals(groups, client.getLocalityGroups(creds, "test"));
 +    // table properties
 +    Map<String,String> orig = client.getTableProperties(creds, "test");
 +    client.setTableProperty(creds, "test", "table.split.threshold", "500M");
 +    Map<String,String> update = client.getTableProperties(creds, "test");
 +    for (int i = 0; i < 5; i++) {
 +      if (update.get("table.split.threshold").equals("500M"))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertEquals(update.get("table.split.threshold"), "500M");
 +    client.removeTableProperty(creds, "test", "table.split.threshold");
 +    update = client.getTableProperties(creds, "test");
 +    assertEquals(orig, update);
 +    // rename table
 +    Map<String,String> tables = client.tableIdMap(creds);
 +    client.renameTable(creds, "test", "bar");
 +    Map<String,String> tables2 = client.tableIdMap(creds);
 +    assertEquals(tables.get("test"), tables2.get("bar"));
 +    // table exists
 +    assertTrue(client.tableExists(creds, "bar"));
 +    assertFalse(client.tableExists(creds, "test"));
 +    // bulk import
 +    String filename = dir + "/bulk/import/rfile.rf";
 +    FileSKVWriter writer = FileOperations.getInstance().openWriter(filename, fs, fs.getConf(), DefaultConfiguration.getInstance());
 +    writer.startDefaultLocalityGroup();
 +    writer.append(new org.apache.accumulo.core.data.Key(new Text("a"), new Text("b"), new Text("c")), new Value("value".getBytes()));
 +    writer.close();
 +    fs.mkdirs(new Path(dir + "/bulk/fail"));
 +    client.importDirectory(creds, "bar", dir + "/bulk/import", dir + "/bulk/fail", true);
 +    String scanner = client.createScanner(creds, "bar", null);
 +    ScanResult more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(1, more.results.size());
 +    ByteBuffer maxRow = client.getMaxRow(creds, "bar", null, null, false, null, false);
 +    assertEquals(s2bb("a"), maxRow);
 +
 +    assertFalse(client.testTableClassLoad(creds, "bar", "abc123", SortedKeyValueIterator.class.getName()));
 +    assertTrue(client.testTableClassLoad(creds, "bar", VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName()));
 +  }
 +
 +  private Condition newCondition(String cf, String cq) {
 +    return new Condition(new Column(s2bb(cf), s2bb(cq), s2bb("")));
 +  }
 +
 +  private Condition newCondition(String cf, String cq, String val) {
 +    return newCondition(cf, cq).setValue(s2bb(val));
 +  }
 +
 +  private Condition newCondition(String cf, String cq, long ts, String val) {
 +    return newCondition(cf, cq).setValue(s2bb(val)).setTimestamp(ts);
 +  }
 +
 +  private ColumnUpdate newColUpdate(String cf, String cq, String val) {
 +    return new ColumnUpdate(s2bb(cf), s2bb(cq)).setValue(s2bb(val));
 +  }
 +
 +  private ColumnUpdate newColUpdate(String cf, String cq, long ts, String val) {
 +    return new ColumnUpdate(s2bb(cf), s2bb(cq)).setTimestamp(ts).setValue(s2bb(val));
 +  }
 +
 +  private void assertScan(String[][] expected, String table) throws Exception {
 +    String scid = client.createScanner(creds, table, new ScanOptions());
 +    ScanResult keyValues = client.nextK(scid, expected.length + 1);
 +
 +    assertEquals(expected.length, keyValues.results.size());
 +    assertFalse(keyValues.more);
 +
 +    for (int i = 0; i < keyValues.results.size(); i++) {
 +      checkKey(expected[i][0], expected[i][1], expected[i][2], expected[i][3], keyValues.results.get(i));
 +    }
 +
 +    client.closeScanner(scid);
 +  }
 +
 +  @Test
 +  public void testConditionalWriter() throws Exception {
 +    final String TABLE_TEST = makeTableName();
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +
 +    client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
 +
 +    String cwid = client.createConditionalWriter(creds, TABLE_TEST, new ConditionalWriterOptions());
 +
 +    Map<ByteBuffer,ConditionalUpdates> updates = new HashMap<ByteBuffer,ConditionalUpdates>();
 +
 +    updates.put(
 +        s2bb("00345"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq")), Arrays.asList(newColUpdate("meta", "seq", 10, "1"),
 +            newColUpdate("data", "img", "73435435"))));
 +
 +    Map<ByteBuffer,ConditionalStatus> results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00345")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "73435435"}, {"00345", "meta", "seq", "1"}}, TABLE_TEST);
 +
 +    // test not setting values on conditions
 +    updates.clear();
 +
 +    updates.put(s2bb("00345"), new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq")), Arrays.asList(newColUpdate("meta", "seq", "2"))));
 +    updates.put(s2bb("00346"), new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq")), Arrays.asList(newColUpdate("meta", "seq", "1"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(2, results.size());
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00345")));
 +    assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00346")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "73435435"}, {"00345", "meta", "seq", "1"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
 +
 +    // test setting values on conditions
 +    updates.clear();
 +
 +    updates.put(
 +        s2bb("00345"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", "1")), Arrays.asList(newColUpdate("meta", "seq", 20, "2"),
 +            newColUpdate("data", "img", "567890"))));
 +
 +    updates.put(s2bb("00346"), new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", "2")), Arrays.asList(newColUpdate("meta", "seq", "3"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(2, results.size());
 +    assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00345")));
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00346")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "567890"}, {"00345", "meta", "seq", "2"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
 +
 +    // test setting timestamp on condition to a non-existant version
 +    updates.clear();
 +
 +    updates.put(
 +        s2bb("00345"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", 10, "2")), Arrays.asList(newColUpdate("meta", "seq", 30, "3"),
 +            newColUpdate("data", "img", "1234567890"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00345")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "567890"}, {"00345", "meta", "seq", "2"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
 +
 +    // test setting timestamp to an existing version
 +
 +    updates.clear();
 +
 +    updates.put(
 +        s2bb("00345"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", 20, "2")), Arrays.asList(newColUpdate("meta", "seq", 30, "3"),
 +            newColUpdate("data", "img", "1234567890"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00345")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
 +
 +    // run test w/ condition that has iterators
 +    // following should fail w/o iterator
 +    client.updateAndFlush(creds, TABLE_TEST, Collections.singletonMap(s2bb("00347"), Arrays.asList(newColUpdate("data", "count", "1"))));
 +    client.updateAndFlush(creds, TABLE_TEST, Collections.singletonMap(s2bb("00347"), Arrays.asList(newColUpdate("data", "count", "1"))));
 +    client.updateAndFlush(creds, TABLE_TEST, Collections.singletonMap(s2bb("00347"), Arrays.asList(newColUpdate("data", "count", "1"))));
 +
 +    updates.clear();
 +    updates.put(s2bb("00347"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("data", "count", "3")), Arrays.asList(newColUpdate("data", "img", "1234567890"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "1"}}, TABLE_TEST);
 +
 +    // following test w/ iterator setup should succeed
 +    Condition iterCond = newCondition("data", "count", "3");
 +    Map<String,String> props = new HashMap<String,String>();
 +    props.put("type", "STRING");
 +    props.put("columns", "data:count");
 +    IteratorSetting is = new IteratorSetting(1, "sumc", SummingCombiner.class.getName(), props);
 +    iterCond.setIterators(Arrays.asList(is));
 +
 +    updates.clear();
 +    updates.put(s2bb("00347"), new ConditionalUpdates(Arrays.asList(iterCond), Arrays.asList(newColUpdate("data", "img", "1234567890"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00347")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
 +
 +    // test a mutation that violated a constraint
 +    updates.clear();
 +    updates.put(s2bb("00347"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "1234567890")), Arrays.asList(newColUpdate("data", "count", "A"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.VIOLATED, results.get(s2bb("00347")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
 +
 +    // run test with two conditions
 +    // both conditions should fail
 +    updates.clear();
 +    updates.put(
 +        s2bb("00347"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "565"), newCondition("data", "count", "2")), Arrays.asList(
 +            newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
 +
 +    // one condition should fail
 +    updates.clear();
 +    updates.put(
 +        s2bb("00347"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "1234567890"), newCondition("data", "count", "2")), Arrays.asList(
 +            newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
 +
 +    // one condition should fail
 +    updates.clear();
 +    updates.put(
 +        s2bb("00347"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "565"), newCondition("data", "count", "1")), Arrays.asList(
 +            newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
 +
 +    // both conditions should succeed
 +
 +    ConditionalStatus result = client.updateRowConditionally(
 +        creds,
 +        TABLE_TEST,
 +        s2bb("00347"),
 +        new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "1234567890"), newCondition("data", "count", "1")), Arrays.asList(
 +            newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
 +
 +    assertEquals(ConditionalStatus.ACCEPTED, result);
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}}, TABLE_TEST);
 +
 +    client.closeConditionalWriter(cwid);
 +    try {
 +      client.updateRowsConditionally(cwid, updates);
 +      fail("conditional writer not closed");
 +    } catch (UnknownWriter uk) {}
 +
 +    // run test with colvis
 +    client.createLocalUser(creds, "cwuser", s2bb("bestpasswordever"));
 +    client.changeUserAuthorizations(creds, "cwuser", Collections.singleton(s2bb("A")));
 +    client.grantTablePermission(creds, "cwuser", TABLE_TEST, TablePermission.WRITE);
 +    client.grantTablePermission(creds, "cwuser", TABLE_TEST, TablePermission.READ);
 +
 +    ByteBuffer cwuCreds = client.login("cwuser", Collections.singletonMap("password", "bestpasswordever"));
 +
 +    cwid = client.createConditionalWriter(cwuCreds, TABLE_TEST, new ConditionalWriterOptions().setAuthorizations(Collections.singleton(s2bb("A"))));
 +
 +    updates.clear();
 +    updates.put(
 +        s2bb("00348"),
 +        new ConditionalUpdates(Arrays.asList(new Condition(new Column(s2bb("data"), s2bb("c"), s2bb("A")))), Arrays.asList(newColUpdate("data", "seq", "1"),
 +            newColUpdate("data", "c", "1").setColVisibility(s2bb("A")))));
 +    updates.put(s2bb("00349"),
 +        new ConditionalUpdates(Arrays.asList(new Condition(new Column(s2bb("data"), s2bb("c"), s2bb("B")))), Arrays.asList(newColUpdate("data", "seq", "1"))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(2, results.size());
 +    assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00348")));
 +    assertEquals(ConditionalStatus.INVISIBLE_VISIBILITY, results.get(s2bb("00349")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}, {"00348", "data", "seq", "1"}}, TABLE_TEST);
 +
 +    updates.clear();
 +
 +    updates.clear();
 +    updates.put(
 +        s2bb("00348"),
 +        new ConditionalUpdates(Arrays.asList(new Condition(new Column(s2bb("data"), s2bb("c"), s2bb("A"))).setValue(s2bb("0"))), Arrays.asList(
 +            newColUpdate("data", "seq", "2"), newColUpdate("data", "c", "2").setColVisibility(s2bb("A")))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00348")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}, {"00348", "data", "seq", "1"}}, TABLE_TEST);
 +
 +    updates.clear();
 +    updates.put(
 +        s2bb("00348"),
 +        new ConditionalUpdates(Arrays.asList(new Condition(new Column(s2bb("data"), s2bb("c"), s2bb("A"))).setValue(s2bb("1"))), Arrays.asList(
 +            newColUpdate("data", "seq", "2"), newColUpdate("data", "c", "2").setColVisibility(s2bb("A")))));
 +
 +    results = client.updateRowsConditionally(cwid, updates);
 +
 +    assertEquals(1, results.size());
 +    assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00348")));
 +
 +    assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
 +        {"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}, {"00348", "data", "seq", "2"}}, TABLE_TEST);
 +
 +    client.closeConditionalWriter(cwid);
 +    try {
 +      client.updateRowsConditionally(cwid, updates);
 +      fail("conditional writer not closed");
 +    } catch (UnknownWriter uk) {}
 +
 +    client.dropLocalUser(creds, "cwuser");
 +
 +  }
 +
 +  private void checkKey(String row, String cf, String cq, String val, KeyValue keyValue) {
 +    assertEquals(row, ByteBufferUtil.toString(keyValue.key.row));
 +    assertEquals(cf, ByteBufferUtil.toString(keyValue.key.colFamily));
 +    assertEquals(cq, ByteBufferUtil.toString(keyValue.key.colQualifier));
 +    assertEquals("", ByteBufferUtil.toString(keyValue.key.colVisibility));
 +    assertEquals(val, ByteBufferUtil.toString(keyValue.value));
 +  }
 +
 +  // scan metadata for file entries for the given table
 +  private int countFiles(String table) throws Exception {
 +    Map<String,String> tableIdMap = client.tableIdMap(creds);
 +    String tableId = tableIdMap.get(table);
 +    Key start = new Key();
 +    start.row = s2bb(tableId + ";");
 +    Key end = new Key();
 +    end.row = s2bb(tableId + "<");
 +    end = client.getFollowing(end, PartialKey.ROW);
 +    ScanOptions opt = new ScanOptions();
 +    opt.range = new Range(start, true, end, false);
 +    opt.columns = Collections.singletonList(new ScanColumn(s2bb("file")));
 +    String scanner = client.createScanner(creds, MetadataTable.NAME, opt);
 +    int result = 0;
 +    while (true) {
 +      ScanResult more = client.nextK(scanner, 100);
 +      result += more.getResults().size();
 +      if (!more.more)
 +        break;
 +    }
 +    return result;
 +  }
 +
 +  private Map<ByteBuffer,List<ColumnUpdate>> mutation(String row, String cf, String cq, String value) {
 +    ColumnUpdate upd = new ColumnUpdate(s2bb(cf), s2bb(cq));
 +    upd.setValue(value.getBytes());
 +    return Collections.singletonMap(s2bb(row), Collections.singletonList(upd));
 +  }
 +
 +  private ByteBuffer s2bb(String cf) {
 +    return ByteBuffer.wrap(cf.getBytes());
 +  }
 +
 +  private Map<String,String> s2pp(String cf) {
 +    Map<String,String> toRet = new TreeMap<String,String>();
 +    toRet.put("password", cf);
 +    return toRet;
 +  }
 +
++  static private ByteBuffer t2bb(Text t) {
++    return ByteBuffer.wrap(t.getBytes());
++  }
++  
++  @Test
++  public void testGetRowRange() throws Exception {
++    Range range = client.getRowRange(s2bb("xyzzy"));
++    org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy")); 
++    assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow())));
++    assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow())));
++    assertEquals(range.startInclusive, range2.isStartKeyInclusive());
++    assertEquals(range.stopInclusive, range2.isEndKeyInclusive());
++    assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily())));
++    assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier())));
++    assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily())));
++    assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier())));
++    assertEquals(range.start.timestamp, range.start.timestamp);
++    assertEquals(range.stop.timestamp, range.stop.timestamp);
++  }
++  
 +  @AfterClass
 +  public static void tearDownMiniCluster() throws Exception {
 +    accumulo.stop();
 +  }
 +}


[07/10] Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --cc proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index 3bd552d,0000000..6e591af
mode 100644,000000..100644
--- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@@ -1,1159 -1,0 +1,1179 @@@
 +/*
 + * 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.proxy;
 +
 +import static org.junit.Assert.assertEquals;
 +import static org.junit.Assert.assertFalse;
 +import static org.junit.Assert.assertNotEquals;
 +import static org.junit.Assert.assertTrue;
 +import static org.junit.Assert.fail;
 +
 +import java.io.BufferedReader;
 +import java.io.File;
 +import java.io.InputStreamReader;
 +import java.nio.ByteBuffer;
 +import java.util.ArrayList;
 +import java.util.Arrays;
 +import java.util.Collections;
 +import java.util.EnumSet;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Properties;
 +import java.util.Random;
 +import java.util.Set;
 +import java.util.TreeMap;
 +import java.util.UUID;
 +
 +import org.apache.accumulo.core.Constants;
 +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 +import org.apache.accumulo.core.conf.DefaultConfiguration;
 +import org.apache.accumulo.core.conf.Property;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.core.file.FileOperations;
 +import org.apache.accumulo.core.file.FileSKVWriter;
 +import org.apache.accumulo.core.iterators.DevNull;
 +import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 +import org.apache.accumulo.core.iterators.user.SummingCombiner;
 +import org.apache.accumulo.core.iterators.user.VersioningIterator;
 +import org.apache.accumulo.core.util.UtilWaitThread;
 +import org.apache.accumulo.examples.simple.constraints.NumericValueConstraint;
 +import org.apache.accumulo.minicluster.MiniAccumuloCluster;
 +import org.apache.accumulo.minicluster.MiniAccumuloConfig;
 +import org.apache.accumulo.proxy.thrift.AccumuloProxy.Client;
 +import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
 +import org.apache.accumulo.proxy.thrift.ActiveCompaction;
 +import org.apache.accumulo.proxy.thrift.ActiveScan;
 +import org.apache.accumulo.proxy.thrift.BatchScanOptions;
 +import org.apache.accumulo.proxy.thrift.ColumnUpdate;
 +import org.apache.accumulo.proxy.thrift.CompactionReason;
 +import org.apache.accumulo.proxy.thrift.CompactionType;
 +import org.apache.accumulo.proxy.thrift.IteratorScope;
 +import org.apache.accumulo.proxy.thrift.IteratorSetting;
 +import org.apache.accumulo.proxy.thrift.Key;
 +import org.apache.accumulo.proxy.thrift.MutationsRejectedException;
 +import org.apache.accumulo.proxy.thrift.PartialKey;
 +import org.apache.accumulo.proxy.thrift.Range;
 +import org.apache.accumulo.proxy.thrift.ScanColumn;
 +import org.apache.accumulo.proxy.thrift.ScanOptions;
 +import org.apache.accumulo.proxy.thrift.ScanResult;
 +import org.apache.accumulo.proxy.thrift.ScanState;
 +import org.apache.accumulo.proxy.thrift.ScanType;
 +import org.apache.accumulo.proxy.thrift.SystemPermission;
 +import org.apache.accumulo.proxy.thrift.TableExistsException;
 +import org.apache.accumulo.proxy.thrift.TableNotFoundException;
 +import org.apache.accumulo.proxy.thrift.TablePermission;
 +import org.apache.accumulo.proxy.thrift.TimeType;
 +import org.apache.accumulo.proxy.thrift.UnknownScanner;
 +import org.apache.accumulo.proxy.thrift.UnknownWriter;
 +import org.apache.accumulo.proxy.thrift.WriterOptions;
 +import org.apache.accumulo.server.util.PortUtils;
 +import org.apache.accumulo.test.functional.SlowIterator;
 +import org.apache.commons.io.FileUtils;
 +import org.apache.hadoop.conf.Configuration;
 +import org.apache.hadoop.fs.FSDataInputStream;
 +import org.apache.hadoop.fs.FileSystem;
 +import org.apache.hadoop.fs.Path;
 +import org.apache.hadoop.io.Text;
 +import org.apache.thrift.TException;
 +import org.apache.thrift.protocol.TProtocolFactory;
 +import org.apache.thrift.server.TServer;
 +import org.junit.AfterClass;
 +import org.junit.BeforeClass;
 +import org.junit.Test;
 +import org.junit.rules.TemporaryFolder;
 +
 +/**
 + * Call every method on the proxy and try to verify that it works.
 + */
 +public class SimpleTest {
 +  
 +  public static TemporaryFolder folder = new TemporaryFolder();
 +  
 +  public static final String TABLE_TEST = "test";
 +  
 +  private static MiniAccumuloCluster accumulo;
 +  private static String secret = "superSecret";
 +  private static Random random = new Random();
 +  private static TServer proxyServer;
 +  private static Thread thread;
 +  private static int proxyPort;
 +  private static org.apache.accumulo.proxy.thrift.AccumuloProxy.Client client;
 +  private static String principal = "root";
 +  @SuppressWarnings("serial")
 +  private static Map<String,String> properties = new TreeMap<String,String>() {
 +    {
 +      put("password", secret);
 +    }
 +  };
 +  private static ByteBuffer creds = null;
 +  
 +  private static Class<? extends TProtocolFactory> protocolClass;
 +  
 +  static Class<? extends TProtocolFactory> getRandomProtocol() {
 +    List<Class<? extends TProtocolFactory>> protocolFactories = new ArrayList<Class<? extends TProtocolFactory>>();
 +    protocolFactories.add(org.apache.thrift.protocol.TJSONProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TBinaryProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TTupleProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TCompactProtocol.Factory.class);
 +    
 +    return protocolFactories.get(random.nextInt(protocolFactories.size()));
 +  }
 +  
 +  @BeforeClass
 +  public static void setupMiniCluster() throws Exception {
 +    folder.create();
 +    MiniAccumuloConfig config = new MiniAccumuloConfig(folder.getRoot(), secret)
 +            .setNumTservers (1);
 +    accumulo = new MiniAccumuloCluster(config);
 +    accumulo.start();
 +    
 +    Properties props = new Properties();
 +    props.put("instance", accumulo.getInstanceName());
 +    props.put("zookeepers", accumulo.getZooKeepers());
 +    props.put("tokenClass", PasswordToken.class.getName());
 +    
 +    protocolClass = getRandomProtocol();
 +    System.out.println(protocolClass.getName());
 +    
 +    proxyPort = PortUtils.getRandomFreePort();
 +    proxyServer = Proxy.createProxyServer(org.apache.accumulo.proxy.thrift.AccumuloProxy.class, org.apache.accumulo.proxy.ProxyServer.class, proxyPort,
 +        protocolClass, props);
 +    thread = new Thread() {
 +      @Override
 +      public void run() {
 +        proxyServer.serve();
 +      }
 +    };
 +    thread.start();
 +    while (!proxyServer.isServing())
 +      UtilWaitThread.sleep(100);
 +    client = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +    creds = client.login(principal, properties);
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void security() throws Exception {
 +    client.createLocalUser(creds, "user", s2bb(secret));
 +    ByteBuffer badLogin = client.login("user", properties);
 +    client.dropLocalUser(creds, "user");
 +    String table = "test1";
 +    client.createTable(creds, table, false, TimeType.MILLIS);
 +    
 +    final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    
 +    try {
 +      client.addConstraint(badLogin, table, NumericValueConstraint.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.addSplits(badLogin, table, Collections.singleton(s2bb("1")));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.clearLocatorCache(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.compactTable(badLogin, table, null, null, null, true, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.cancelCompaction(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createTable(badLogin, table, false, TimeType.MILLIS);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.deleteTable(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.deleteRows(badLogin, table, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.tableExists(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.flushTable(badLogin, table, null, null, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getLocalityGroups(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getMaxRow(badLogin, table, Collections.<ByteBuffer> emptySet(), null, false, null, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getTableProperties(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listSplits(badLogin, table, 10000);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listTables(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.listConstraints(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.mergeTablets(badLogin, table, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.offlineTable(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.onlineTable(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeConstraint(badLogin, table, 0);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeTableProperty(badLogin, table, Property.TABLE_FILE_MAX.getKey());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.renameTable(badLogin, table, "someTableName");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      Map<String,Set<String>> groups = new HashMap<String,Set<String>>();
 +      groups.put("group1", Collections.singleton("cf1"));
 +      groups.put("group2", Collections.singleton("cf2"));
 +      client.setLocalityGroups(badLogin, table, groups);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.setTableProperty(badLogin, table, Property.TABLE_FILE_MAX.getKey(), "0");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.tableIdMap(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.getSiteConfiguration(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getSystemConfiguration(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getTabletServers(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.getActiveScans(badLogin, "fake");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getActiveCompactions(badLogin, "fakse");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeProperty(badLogin, "table.split.threshold");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.setProperty(badLogin, "table.split.threshold", "500M");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.testClassLoad(badLogin, DevNull.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.authenticateUser(badLogin, "root", s2pp(secret));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      HashSet<ByteBuffer> auths = new HashSet<ByteBuffer>(Arrays.asList(s2bb("A"), s2bb("B")));
 +      client.changeUserAuthorizations(badLogin, "stooge", auths);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.changeLocalUserPassword(badLogin, "stooge", s2bb(""));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createLocalUser(badLogin, "stooge", s2bb("password"));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.dropLocalUser(badLogin, "stooge");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getUserAuthorizations(badLogin, "stooge");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.grantSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.grantTablePermission(badLogin, "root", table, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.hasSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.hasTablePermission(badLogin, "root", table, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listLocalUsers(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.revokeSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.revokeTablePermission(badLogin, "root", table, TablePermission.ALTER_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createScanner(badLogin, table, new ScanOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createBatchScanner(badLogin, table, new BatchScanOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.updateAndFlush(badLogin, table, new HashMap<ByteBuffer,List<ColumnUpdate>>());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createWriter(badLogin, table, new WriterOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.attachIterator(badLogin, "slow", setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.checkIteratorConflicts(badLogin, table, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.cloneTable(badLogin, table, TABLE_TEST, false, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.exportTable(badLogin, table, "/tmp");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.importTable(badLogin, "testify", "/tmp");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getIteratorSetting(badLogin, table, "foo", IteratorScope.SCAN);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listIterators(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeIterator(badLogin, table, "name", EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.splitRangeByTablets(badLogin, table, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      File newFolder = folder.newFolder();
 +      client.importDirectory(badLogin, table, "/tmp", newFolder.getAbsolutePath(), true);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.pingTabletServer(badLogin, "fake");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.login("badUser", properties);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.testTableClassLoad(badLogin, table, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void tableNotFound() throws Exception {
 +    final String doesNotExist = "doesNotExists";
 +    try {
 +      client.addConstraint(creds, doesNotExist, NumericValueConstraint.class.getName());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.addSplits(creds, doesNotExist, Collections.<ByteBuffer> emptySet());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    try {
 +      client.attachIterator(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.cancelCompaction(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.checkIteratorConflicts(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.clearLocatorCache(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.cloneTable(creds, doesNotExist, TABLE_TEST, false, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.compactTable(creds, doesNotExist, null, null, null, true, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createBatchScanner(creds, doesNotExist, new BatchScanOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createScanner(creds, doesNotExist, new ScanOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createWriter(creds, doesNotExist, new WriterOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.deleteRows(creds, doesNotExist, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.deleteTable(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.exportTable(creds, doesNotExist, "/tmp");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.flushTable(creds, doesNotExist, null, null, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getIteratorSetting(creds, doesNotExist, "foo", IteratorScope.SCAN);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getLocalityGroups(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getMaxRow(creds, doesNotExist, Collections.<ByteBuffer> emptySet(), null, false, null, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getTableProperties(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.grantTablePermission(creds, "root", doesNotExist, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.hasTablePermission(creds, "root", doesNotExist, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      File newFolder = folder.newFolder();
 +      client.importDirectory(creds, doesNotExist, "/tmp", newFolder.getAbsolutePath(), true);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.listConstraints(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.listSplits(creds, doesNotExist, 10000);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.mergeTablets(creds, doesNotExist, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.offlineTable(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.onlineTable(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeConstraint(creds, doesNotExist, 0);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeIterator(creds, doesNotExist, "name", EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.renameTable(creds, doesNotExist, "someTableName");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.revokeTablePermission(creds, "root", doesNotExist, TablePermission.ALTER_TABLE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.setTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey(), "0");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.splitRangeByTablets(creds, doesNotExist, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.updateAndFlush(creds, doesNotExist, new HashMap<ByteBuffer,List<ColumnUpdate>>());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.testTableClassLoad(creds, doesNotExist, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testExists() throws Exception {
 +    client.createTable(creds, "ett1", false, TimeType.MILLIS);
 +    client.createTable(creds, "ett2", false, TimeType.MILLIS);
 +    try {
 +      client.createTable(creds, "ett1", false, TimeType.MILLIS);
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +    try {
 +      client.renameTable(creds, "ett1", "ett2");
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +    try {
 +      client.cloneTable(creds, "ett1", "ett2", false, new HashMap<String,String>(), new HashSet<String>());
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testUnknownScanner() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    assertFalse(client.hasNext(scanner));
 +    client.closeScanner(scanner);
 +    
 +    try {
 +      client.hasNext(scanner);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    
 +    try {
 +      client.closeScanner(scanner);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    
 +    try {
 +      client.nextEntry("99999999");
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.nextK("99999999", 6);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.hasNext("99999999");
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.hasNext(UUID.randomUUID().toString());
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testUnknownWriter() throws Exception {
 +    
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    
 +    String writer = client.createWriter(creds, TABLE_TEST, null);
 +    client.update(writer, mutation("row0", "cf", "cq", "value"));
 +    client.flush(writer);
 +    client.update(writer, mutation("row2", "cf", "cq", "value2"));
 +    client.closeWriter(writer);
 +    
 +    // this is a oneway call, so it does not throw exceptions
 +    client.update(writer, mutation("row2", "cf", "cq", "value2"));
 +    
 +    try {
 +      client.flush(writer);
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.flush("99999");
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.flush(UUID.randomUUID().toString());
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.closeWriter("99999");
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testDelete() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row0", "cf", "cq", "value"));
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    ScanResult entries = client.nextK(scanner, 10);
 +    client.closeScanner(scanner);
 +    assertFalse(entries.more);
 +    assertEquals(1, entries.results.size());
 +    
 +    ColumnUpdate upd = new ColumnUpdate(s2bb("cf"), s2bb("cq"));
 +    upd.setDeleteCell(true);
 +    Map<ByteBuffer,List<ColumnUpdate>> delete = Collections.singletonMap(s2bb("row0"), Collections.singletonList(upd));
 +    
 +    client.updateAndFlush(creds, TABLE_TEST, delete);
 +    
 +    scanner = client.createScanner(creds, TABLE_TEST, null);
 +    entries = client.nextK(scanner, 10);
 +    client.closeScanner(scanner);
 +    assertEquals(0, entries.results.size());
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void testInstanceOperations() throws Exception {
 +    int tservers = 0;
 +    for (String tserver : client.getTabletServers(creds)) {
 +      client.pingTabletServer(creds, tserver);
 +      tservers++;
 +    }
 +    assertTrue(tservers > 0);
 +    
 +    // get something we know is in the site config
 +    Map<String,String> cfg = client.getSiteConfiguration(creds);
 +    assertTrue(cfg.get("instance.dfs.dir").startsWith(folder.getRoot().toString()));
 +    
 +    // set a property in zookeeper
 +    client.setProperty(creds, "table.split.threshold", "500M");
 +    
 +    // check that we can read it
 +    for (int i = 0; i < 5; i++) {
 +      cfg = client.getSystemConfiguration(creds);
 +      if ("500M".equals(cfg.get("table.split.threshold")))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertEquals("500M", cfg.get("table.split.threshold"));
 +    
 +    // unset the setting, check that it's not what it was
 +    client.removeProperty(creds, "table.split.threshold");
 +    for (int i = 0; i < 5; i++) {
 +      cfg = client.getSystemConfiguration(creds);
 +      if (!"500M".equals(cfg.get("table.split.threshold")))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertNotEquals("500M", cfg.get("table.split.threshold"));
 +    
 +    // try to load some classes via the proxy
 +    assertTrue(client.testClassLoad(creds, DevNull.class.getName(), SortedKeyValueIterator.class.getName()));
 +    assertFalse(client.testClassLoad(creds, "foo.bar", SortedKeyValueIterator.class.getName()));
 +    
 +    // create a table that's very slow, so we can look for scans/compactions
 +    client.createTable(creds, "slow", true, TimeType.MILLIS);
 +    IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    client.attachIterator(creds, "slow", setting, EnumSet.allOf(IteratorScope.class));
 +    client.updateAndFlush(creds, "slow", mutation("row", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row2", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row3", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row4", "cf", "cq", "value"));
 +    
 +    // scan
 +    Thread t = new Thread() {
 +      @Override
 +      public void run() {
 +        String scanner;
 +        try {
 +          Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +          scanner = client2.createScanner(creds, "slow", null);
 +          client2.nextK(scanner, 10);
 +          client2.closeScanner(scanner);
 +        } catch (Exception e) {
 +          throw new RuntimeException(e);
 +        }
 +      }
 +    };
 +    t.start();
 +    // look for the scan
 +    List<ActiveScan> scans = Collections.emptyList();
 +    loop: for (int i = 0; i < 100; i++) {
 +      for (String tserver : client.getTabletServers(creds)) {
 +        scans = client.getActiveScans(creds, tserver);
 +        if (!scans.isEmpty())
 +          break loop;
 +        UtilWaitThread.sleep(10);
 +      }
 +    }
 +    t.join();
 +    assertFalse(scans.isEmpty());
 +    ActiveScan scan = scans.get(0);
 +    assertEquals("root", scan.getUser());
 +    assertTrue(ScanState.RUNNING.equals(scan.getState()) || ScanState.QUEUED.equals(scan.getState()));
 +    assertEquals(ScanType.SINGLE, scan.getType());
 +    assertEquals("slow", scan.getTable());
 +    Map<String,String> map = client.tableIdMap(creds);
 +    assertEquals(map.get("slow"), scan.getExtent().tableId);
 +    assertTrue(scan.getExtent().endRow == null);
 +    assertTrue(scan.getExtent().prevEndRow == null);
 +    
 +    // start a compaction
 +    t = new Thread() {
 +      @Override
 +      public void run() {
 +        try {
 +          Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +          client2.compactTable(creds, "slow", null, null, null, true, true);
 +        } catch (Exception e) {
 +          throw new RuntimeException(e);
 +        }
 +      }
 +    };
 +    t.start();
 +    
 +    // try to catch it in the act
 +    List<ActiveCompaction> compactions = Collections.emptyList();
 +    loop2: for (int i = 0; i < 100; i++) {
 +      for (String tserver : client.getTabletServers(creds)) {
 +        compactions = client.getActiveCompactions(creds, tserver);
 +        if (!compactions.isEmpty())
 +          break loop2;
 +      }
 +      UtilWaitThread.sleep(10);
 +    }
 +    t.join();
 +    // verify the compaction information
 +    assertFalse(compactions.isEmpty());
 +    ActiveCompaction c = compactions.get(0);
 +    assertEquals(map.get("slow"), c.getExtent().tableId);
 +    assertTrue(c.inputFiles.isEmpty());
 +    assertEquals(CompactionType.MINOR, c.getType());
 +    assertEquals(CompactionReason.USER, c.getReason());
 +    assertEquals("", c.localityGroup);
 +    assertTrue(c.outputFile.contains("default_tablet"));
 +  }
 +  
 +  @Test
 +  public void testSecurityOperations() throws Exception {
 +    // check password
 +    assertTrue(client.authenticateUser(creds, "root", s2pp(secret)));
 +    assertFalse(client.authenticateUser(creds, "root", s2pp("")));
 +    
 +    // create a user
 +    client.createLocalUser(creds, "stooge", s2bb("password"));
 +    // change auths
 +    Set<String> users = client.listLocalUsers(creds);
 +    assertEquals(new HashSet<String>(Arrays.asList("root", "stooge")), users);
 +    HashSet<ByteBuffer> auths = new HashSet<ByteBuffer>(Arrays.asList(s2bb("A"), s2bb("B")));
 +    client.changeUserAuthorizations(creds, "stooge", auths);
 +    List<ByteBuffer> update = client.getUserAuthorizations(creds, "stooge");
 +    assertEquals(auths, new HashSet<ByteBuffer>(update));
 +    
 +    // change password
 +    client.changeLocalUserPassword(creds, "stooge", s2bb(""));
 +    assertTrue(client.authenticateUser(creds, "stooge", s2pp("")));
 +    
 +    // check permission failure
 +    @SuppressWarnings("serial")
 +    ByteBuffer stooge = client.login("stooge", new TreeMap<String,String>() {
 +      {
 +        put("password", "");
 +      }
 +    });
 +    
 +    try {
 +      client.createTable(stooge, "fail", true, TimeType.MILLIS);
 +      fail("should not create the table");
 +    } catch (AccumuloSecurityException ex) {
 +      assertFalse(client.listTables(creds).contains("fail"));
 +    }
 +    // grant permissions and test
 +    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    client.grantSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
 +    assertTrue(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    client.createTable(stooge, "success", true, TimeType.MILLIS);
 +    client.listTables(creds).contains("succcess");
 +    
 +    // revoke permissions
 +    client.revokeSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
 +    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    try {
 +      client.createTable(stooge, "fail", true, TimeType.MILLIS);
 +      fail("should not create the table");
 +    } catch (AccumuloSecurityException ex) {
 +      assertFalse(client.listTables(creds).contains("fail"));
 +    }
 +    // create a table to test table permissions
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    // denied!
 +    try {
 +      String scanner = client.createScanner(stooge, TABLE_TEST, null);
 +      client.nextK(scanner, 100);
 +      fail("stooge should not read table test");
 +    } catch (AccumuloSecurityException ex) {}
 +    // grant
 +    assertFalse(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    client.grantTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ);
 +    assertTrue(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    String scanner = client.createScanner(stooge, TABLE_TEST, null);
 +    client.nextK(scanner, 10);
 +    client.closeScanner(scanner);
 +    // revoke
 +    client.revokeTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ);
 +    assertFalse(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    try {
 +      scanner = client.createScanner(stooge, TABLE_TEST, null);
 +      client.nextK(scanner, 100);
 +      fail("stooge should not read table test");
 +    } catch (AccumuloSecurityException ex) {}
 +    
 +    // delete user
 +    client.dropLocalUser(creds, "stooge");
 +    users = client.listLocalUsers(creds);
 +    assertEquals(1, users.size());
 +    
 +  }
 +  
 +  @Test
 +  public void testBatchWriter() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
 +    
 +    WriterOptions writerOptions = new WriterOptions();
 +    writerOptions.setLatencyMs(10000);
 +    writerOptions.setMaxMemory(2);
 +    writerOptions.setThreads(1);
 +    writerOptions.setTimeoutMs(100000);
 +    
 +    String batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    try {
 +      client.flush(batchWriter);
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException ex) {}
 +    try {
 +      client.closeWriter(batchWriter);
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException e) {}
 +    
 +    client.removeConstraint(creds, TABLE_TEST, 1);
 +    
 +    writerOptions = new WriterOptions();
 +    writerOptions.setLatencyMs(10000);
 +    writerOptions.setMaxMemory(3000);
 +    writerOptions.setThreads(1);
 +    writerOptions.setTimeoutMs(100000);
 +    
 +    batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
 +    
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    client.flush(batchWriter);
 +    client.closeWriter(batchWriter);
 +    
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    ScanResult more = client.nextK(scanner, 2);
 +    assertEquals(1, more.getResults().size());
 +    client.closeScanner(scanner);
 +    
 +    client.deleteTable(creds, TABLE_TEST);
 +  }
 +  
 +  @Test
 +  public void testTableOperations() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    // constraints
 +    client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "123"));
 +    
 +    try {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException ex) {}
 +    
 +    client.removeConstraint(creds, TABLE_TEST, 1);
 +    assertEquals(0, client.listConstraints(creds, TABLE_TEST).size());
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    ScanResult more = client.nextK(scanner, 2);
 +    client.closeScanner(scanner);
 +    assertFalse(more.isMore());
 +    assertEquals(1, more.getResults().size());
 +    assertEquals(s2bb("x"), more.getResults().get(0).value);
 +    // splits, merge
 +    client.addSplits(creds, TABLE_TEST, new HashSet<ByteBuffer>(Arrays.asList(s2bb("a"), s2bb("m"), s2bb("z"))));
 +    List<ByteBuffer> splits = client.listSplits(creds, TABLE_TEST, 1);
 +    assertEquals(Arrays.asList(s2bb("m")), splits);
 +    client.mergeTablets(creds, TABLE_TEST, null, s2bb("m"));
 +    splits = client.listSplits(creds, TABLE_TEST, 10);
 +    assertEquals(Arrays.asList(s2bb("m"), s2bb("z")), splits);
 +    client.mergeTablets(creds, TABLE_TEST, null, null);
 +    splits = client.listSplits(creds, TABLE_TEST, 10);
 +    List<ByteBuffer> empty = Collections.emptyList();
 +    assertEquals(empty, splits);
 +    // iterators
 +    client.deleteTable(creds, TABLE_TEST);
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    HashMap<String,String> options = new HashMap<String,String>();
 +    options.put("type", "STRING");
 +    options.put("columns", "cf");
 +    IteratorSetting setting = new IteratorSetting(10, TABLE_TEST, SummingCombiner.class.getName(), options);
 +    client.attachIterator(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
 +    for (int i = 0; i < 10; i++) {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "1"));
 +    }
 +    scanner = client.createScanner(creds, TABLE_TEST, null);
 +    more = client.nextK(scanner, 2);
 +    client.closeScanner(scanner);
 +    assertEquals("10", new String(more.getResults().get(0).getValue()));
 +    try {
 +      client.checkIteratorConflicts(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("checkIteratorConflicts did not throw and exception");
 +    } catch (Exception ex) {}
 +    client.deleteRows(creds, TABLE_TEST, null, null);
 +    client.removeIterator(creds, TABLE_TEST, "test", EnumSet.allOf(IteratorScope.class));
 +    for (int i = 0; i < 10; i++) {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row" + i, "cf", "cq", "" + i));
 +      client.flushTable(creds, TABLE_TEST, null, null, true);
 +    }
 +    scanner = client.createScanner(creds, TABLE_TEST, null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(10, more.getResults().size());
 +    // clone
 +    client.cloneTable(creds, TABLE_TEST, "test2", true, null, null);
 +    scanner = client.createScanner(creds, "test2", null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(10, more.getResults().size());
 +    client.deleteTable(creds, "test2");
 +    
 +    // don't know how to test this, call it just for fun
 +    client.clearLocatorCache(creds, TABLE_TEST);
 +    
 +    // compact
 +    client.compactTable(creds, TABLE_TEST, null, null, null, true, true);
 +    assertEquals(1, countFiles(TABLE_TEST));
 +    
 +    // export/import
 +    String dir = folder.getRoot() + "/test";
 +    String destDir = folder.getRoot() + "/test_dest";
 +    client.offlineTable(creds, TABLE_TEST);
 +    client.exportTable(creds, TABLE_TEST, dir);
 +    // copy files to a new location
 +    FileSystem fs = FileSystem.get(new Configuration());
 +    FSDataInputStream is = fs.open(new Path(dir + "/distcp.txt"));
 +    BufferedReader r = new BufferedReader(new InputStreamReader(is));
 +    while (true) {
 +      String line = r.readLine();
 +      if (line == null)
 +        break;
 +      Path srcPath = new Path(line);
 +      FileUtils.copyFile(new File(srcPath.toUri().getPath()), new File(destDir, srcPath.getName()));
 +    }
 +    client.deleteTable(creds, TABLE_TEST);
 +    client.importTable(creds, "testify", destDir);
 +    scanner = client.createScanner(creds, "testify", null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(10, more.results.size());
 +    
 +    try {
 +      // ACCUMULO-1558 a second import from the same dir should fail, the first import moved the files
 +      client.importTable(creds, "testify2", destDir);
 +      fail();
 +    } catch (Exception e) {}
 +
 +    assertFalse(client.listTables(creds).contains("testify2"));
 +
 +    // Locality groups
 +    client.createTable(creds, "test", true, TimeType.MILLIS);
 +    Map<String,Set<String>> groups = new HashMap<String,Set<String>>();
 +    groups.put("group1", Collections.singleton("cf1"));
 +    groups.put("group2", Collections.singleton("cf2"));
 +    client.setLocalityGroups(creds, "test", groups);
 +    assertEquals(groups, client.getLocalityGroups(creds, "test"));
 +    // table properties
 +    Map<String,String> orig = client.getTableProperties(creds, "test");
 +    client.setTableProperty(creds, "test", "table.split.threshold", "500M");
 +    Map<String,String> update = client.getTableProperties(creds, "test");
 +    for (int i = 0; i < 5; i++) {
 +      if (update.get("table.split.threshold").equals("500M"))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertEquals(update.get("table.split.threshold"), "500M");
 +    client.removeTableProperty(creds, "test", "table.split.threshold");
 +    update = client.getTableProperties(creds, "test");
 +    assertEquals(orig, update);
 +    // rename table
 +    Map<String,String> tables = client.tableIdMap(creds);
 +    client.renameTable(creds, "test", "bar");
 +    Map<String,String> tables2 = client.tableIdMap(creds);
 +    assertEquals(tables.get("test"), tables2.get("bar"));
 +    // table exists
 +    assertTrue(client.tableExists(creds, "bar"));
 +    assertFalse(client.tableExists(creds, "test"));
 +    // bulk import
 +    String filename = dir + "/bulk/import/rfile.rf";
 +    FileSKVWriter writer = FileOperations.getInstance().openWriter(filename, fs, fs.getConf(), DefaultConfiguration.getInstance());
 +    writer.startDefaultLocalityGroup();
 +    writer.append(new org.apache.accumulo.core.data.Key(new Text("a"), new Text("b"), new Text("c")), new Value("value".getBytes()));
 +    writer.close();
 +    fs.mkdirs(new Path(dir + "/bulk/fail"));
 +    client.importDirectory(creds, "bar", dir + "/bulk/import", dir + "/bulk/fail", true);
 +    scanner = client.createScanner(creds, "bar", null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(1, more.results.size());
 +    ByteBuffer maxRow = client.getMaxRow(creds, "bar", null, null, false, null, false);
 +    assertEquals(s2bb("a"), maxRow);
 +    
 +    assertFalse(client.testTableClassLoad(creds, "bar", "abc123", SortedKeyValueIterator.class.getName()));
 +    assertTrue(client.testTableClassLoad(creds, "bar", VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName()));
 +  }
 +  
 +  // scan !METADATA table for file entries for the given table
 +  private int countFiles(String table) throws Exception {
 +    Map<String,String> tableIdMap = client.tableIdMap(creds);
 +    String tableId = tableIdMap.get(table);
 +    Key start = new Key();
 +    start.row = s2bb(tableId + ";");
 +    Key end = new Key();
 +    end.row = s2bb(tableId + "<");
 +    end = client.getFollowing(end, PartialKey.ROW);
 +    ScanOptions opt = new ScanOptions();
 +    opt.range = new Range(start, true, end, false);
 +    opt.columns = Collections.singletonList(new ScanColumn(s2bb("file")));
 +    String scanner = client.createScanner(creds, Constants.METADATA_TABLE_NAME, opt);
 +    int result = 0;
 +    while (true) {
 +      ScanResult more = client.nextK(scanner, 100);
 +      result += more.getResults().size();
 +      if (!more.more)
 +        break;
 +    }
 +    return result;
 +  }
 +  
 +  private Map<ByteBuffer,List<ColumnUpdate>> mutation(String row, String cf, String cq, String value) {
 +    ColumnUpdate upd = new ColumnUpdate(s2bb(cf), s2bb(cq));
 +    upd.setValue(value.getBytes());
 +    return Collections.singletonMap(s2bb(row), Collections.singletonList(upd));
 +  }
 +  
 +  private ByteBuffer s2bb(String cf) {
 +    return ByteBuffer.wrap(cf.getBytes());
 +  }
 +  
 +  private Map<String,String> s2pp(String cf) {
 +    Map<String,String> toRet = new TreeMap<String,String>();
 +    toRet.put("password", cf);
 +    return toRet;
 +  }
 +  
++  static private ByteBuffer t2bb(Text t) {
++    return ByteBuffer.wrap(t.getBytes());
++  }
++  
++  @Test
++  public void testGetRowRange() throws Exception {
++    Range range = client.getRowRange(s2bb("xyzzy"));
++    org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy")); 
++    assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow())));
++    assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow())));
++    assertEquals(range.startInclusive, range2.isStartKeyInclusive());
++    assertEquals(range.stopInclusive, range2.isEndKeyInclusive());
++    assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily())));
++    assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier())));
++    assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily())));
++    assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier())));
++    assertEquals(range.start.timestamp, range.start.timestamp);
++    assertEquals(range.stop.timestamp, range.stop.timestamp);
++  }
++  
 +  @AfterClass
 +  public static void tearDownMiniCluster() throws Exception {
 +    accumulo.stop();
 +    folder.delete();
 +  }
 +  
 +}


[09/10] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Posted by ec...@apache.org.
Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8729dba7
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8729dba7
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8729dba7

Branch: refs/heads/1.5.1-SNAPSHOT
Commit: 8729dba7694dbf2edeba5df472840a41ab77d18d
Parents: 712e946 27ee236
Author: Eric Newton <er...@gmail.com>
Authored: Thu Jan 2 12:02:24 2014 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Thu Jan 2 12:02:24 2014 -0500

----------------------------------------------------------------------
 proxy/examples/python/TestClient.py             |  4 ++--
 proxy/examples/ruby/test_client.rb              |  8 ++++----
 .../org/apache/accumulo/proxy/ProxyServer.java  |  6 ++----
 .../org/apache/accumulo/proxy/thrift/Key.java   |  6 ++++--
 proxy/src/main/thrift/proxy.thrift              |  4 +++-
 .../org/apache/accumulo/proxy/SimpleTest.java   | 20 ++++++++++++++++++++
 6 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/examples/python/TestClient.py
----------------------------------------------------------------------
diff --cc proxy/examples/python/TestClient.py
index 7ecf367,0000000..5509ded
mode 100644,000000..100644
--- a/proxy/examples/python/TestClient.py
+++ b/proxy/examples/python/TestClient.py
@@@ -1,46 -1,0 +1,46 @@@
 +#!/usr/bin/env python
 +# 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.
 +
 +import sys
 +
 +from thrift import Thrift
 +from thrift.transport import TSocket
 +from thrift.transport import TTransport
 +from thrift.protocol import TCompactProtocol
 +
- from proxy import AccumuloProxy
- from proxy.ttypes import *
++from accumulo import AccumuloProxy
++from accumulo.ttypes import *
 +
 +transport = TSocket.TSocket('localhost', 42424)
 +transport = TTransport.TFramedTransport(transport)
 +protocol = TCompactProtocol.TCompactProtocol(transport)
 +client = AccumuloProxy.Client(protocol)
 +transport.open()
 +
 +login = client.login('root', {'password':'secret'})
 +
 +print client.listTables(login)
 +
 +testtable = "pythontest"
 +if not client.tableExists(login, testtable):
 +    client.createTable(login, testtable, True, TimeType.MILLIS)
 +
 +row1 = {'a':[ColumnUpdate('a','a',value='value1'), ColumnUpdate('b','b',value='value2')]}
 +client.updateAndFlush(login, testtable, row1)
 +
 +cookie = client.createScanner(login, testtable, None)
 +for entry in client.nextK(cookie, 10).results:
 +   print entry

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/examples/ruby/test_client.rb
----------------------------------------------------------------------
diff --cc proxy/examples/ruby/test_client.rb
index d5ee5f5,0000000..6310a2f
mode 100644,000000..100644
--- a/proxy/examples/ruby/test_client.rb
+++ b/proxy/examples/ruby/test_client.rb
@@@ -1,48 -1,0 +1,48 @@@
 +
 +# 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.
 +
 +require 'rubygems'
 +require 'thrift'
 +require 'accumulo_proxy'
 +
 +server = ARGV[0] || 'localhost'
 +
 +socket = Thrift::Socket.new(server, 42424, 9001)
 +transport = Thrift::FramedTransport.new(socket)
 +proto = Thrift::CompactProtocol.new(transport)
- proxy = AccumuloProxy::Client.new(proto)
++proxy = Accumulo::AccumuloProxy::Client.new(proto)
 +
 +# open up the connect
 +transport.open()
 +
 +# Test if the server is up
 +login = proxy.login('root', {'password' => 'secret'})
 +
 +# print out a table list
 +puts "List of tables: #{proxy.listTables(login).inspect}"
 +
 +testtable = "rubytest"
- proxy.createTable(login, testtable, true, TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
++proxy.createTable(login, testtable, true, Accumulo::TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
 +
- update1 = ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
- update2 = ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
++update1 = Accumulo::ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
++update2 = Accumulo::ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
 +proxy.updateAndFlush(login,testtable,{'row1' => [update1,update2]})
 +
 +cookie = proxy.createScanner(login,testtable,nil)
 +result = proxy.nextK(cookie,10)
 +result.results.each{ |keyvalue| puts "Key: #{keyvalue.key.inspect} Value: #{keyvalue.value}" }
 +
 +transport.close()

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --cc proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index c6e74f1,0000000..2a9a055
mode 100644,000000..100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@@ -1,1473 -1,0 +1,1471 @@@
 +/*
 + * 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.proxy;
 +
 +import java.nio.ByteBuffer;
 +import java.util.ArrayList;
 +import java.util.Collection;
 +import java.util.EnumSet;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.Iterator;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Properties;
 +import java.util.Set;
 +import java.util.SortedSet;
 +import java.util.TreeSet;
 +import java.util.UUID;
 +import java.util.concurrent.TimeUnit;
 +
 +import org.apache.accumulo.core.client.AccumuloException;
 +import org.apache.accumulo.core.client.AccumuloSecurityException;
 +import org.apache.accumulo.core.client.BatchScanner;
 +import org.apache.accumulo.core.client.BatchWriter;
 +import org.apache.accumulo.core.client.BatchWriterConfig;
 +import org.apache.accumulo.core.client.Connector;
 +import org.apache.accumulo.core.client.Instance;
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.client.MutationsRejectedException;
 +import org.apache.accumulo.core.client.Scanner;
 +import org.apache.accumulo.core.client.ScannerBase;
 +import org.apache.accumulo.core.client.TableExistsException;
 +import org.apache.accumulo.core.client.TableNotFoundException;
 +import org.apache.accumulo.core.client.ZooKeeperInstance;
 +import org.apache.accumulo.core.client.admin.ActiveCompaction;
 +import org.apache.accumulo.core.client.admin.ActiveScan;
 +import org.apache.accumulo.core.client.admin.TimeType;
 +import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
 +import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
 +import org.apache.accumulo.core.client.mock.MockInstance;
 +import org.apache.accumulo.core.client.security.SecurityErrorCode;
 +import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 +import org.apache.accumulo.core.data.Column;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.KeyExtent;
 +import org.apache.accumulo.core.data.Mutation;
 +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.IteratorUtil.IteratorScope;
 +import org.apache.accumulo.core.security.Authorizations;
 +import org.apache.accumulo.core.security.ColumnVisibility;
 +import org.apache.accumulo.core.security.CredentialHelper;
 +import org.apache.accumulo.core.security.SystemPermission;
 +import org.apache.accumulo.core.security.TablePermission;
 +import org.apache.accumulo.core.security.thrift.TCredentials;
 +import org.apache.accumulo.core.util.ByteBufferUtil;
 +import org.apache.accumulo.core.util.TextUtil;
 +import org.apache.accumulo.proxy.thrift.AccumuloProxy;
 +import org.apache.accumulo.proxy.thrift.BatchScanOptions;
 +import org.apache.accumulo.proxy.thrift.ColumnUpdate;
 +import org.apache.accumulo.proxy.thrift.CompactionReason;
 +import org.apache.accumulo.proxy.thrift.CompactionType;
 +import org.apache.accumulo.proxy.thrift.KeyValue;
 +import org.apache.accumulo.proxy.thrift.KeyValueAndPeek;
 +import org.apache.accumulo.proxy.thrift.NoMoreEntriesException;
 +import org.apache.accumulo.proxy.thrift.ScanColumn;
 +import org.apache.accumulo.proxy.thrift.ScanOptions;
 +import org.apache.accumulo.proxy.thrift.ScanResult;
 +import org.apache.accumulo.proxy.thrift.ScanState;
 +import org.apache.accumulo.proxy.thrift.ScanType;
 +import org.apache.accumulo.proxy.thrift.UnknownScanner;
 +import org.apache.accumulo.proxy.thrift.UnknownWriter;
 +import org.apache.accumulo.proxy.thrift.WriterOptions;
 +import org.apache.hadoop.io.Text;
 +import org.apache.log4j.Logger;
 +import org.apache.thrift.TException;
 +
 +import com.google.common.cache.Cache;
 +import com.google.common.cache.CacheBuilder;
 +import com.google.common.cache.RemovalListener;
 +import com.google.common.cache.RemovalNotification;
 +
 +/**
 + * Proxy Server exposing the Accumulo API via Thrift..
 + * 
 + * @since 1.5
 + */
 +public class ProxyServer implements AccumuloProxy.Iface {
 +  
 +  public static final Logger logger = Logger.getLogger(ProxyServer.class);
 +  protected Instance instance;
 +  
 +  protected Class<? extends AuthenticationToken> tokenClass;
 +  
 +  static protected class ScannerPlusIterator {
 +    public ScannerBase scanner;
 +    public Iterator<Map.Entry<Key,Value>> iterator;
 +  }
 +  
 +  static protected class BatchWriterPlusException {
 +    public BatchWriter writer;
 +    public MutationsRejectedException exception = null;
 +  }
 +  
 +  static class CloseWriter implements RemovalListener<UUID,BatchWriterPlusException> {
 +    @Override
 +    public void onRemoval(RemovalNotification<UUID,BatchWriterPlusException> notification) {
 +      try {
 +        BatchWriterPlusException value = notification.getValue();
 +        if (value.exception != null)
 +          throw value.exception;
 +        notification.getValue().writer.close();
 +      } catch (MutationsRejectedException e) {
 +        logger.warn(e, e);
 +      }
 +    }
 +    
 +    public CloseWriter() {}
 +  }
 +  
 +  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
 +    @Override
 +    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
 +      final ScannerBase base = notification.getValue().scanner;
 +      if (base instanceof BatchScanner) {
 +        final BatchScanner scanner = (BatchScanner) base;
 +        scanner.close();
 +      }
 +    }
 +    
 +    public CloseScanner() {}
 +  }
 +  
 +  protected Cache<UUID,ScannerPlusIterator> scannerCache;
 +  protected Cache<UUID,BatchWriterPlusException> writerCache;
 +  
 +  public ProxyServer(Properties props) {
 +    
 +    String useMock = props.getProperty("useMockInstance");
 +    if (useMock != null && Boolean.parseBoolean(useMock))
 +      instance = new MockInstance();
 +    else
 +      instance = new ZooKeeperInstance(props.getProperty("instance"), props.getProperty("zookeepers"));
 +    
 +    try {
 +      String tokenProp = props.getProperty("tokenClass", PasswordToken.class.getName());
 +      tokenClass = Class.forName(tokenProp).asSubclass(AuthenticationToken.class);
 +    } catch (ClassNotFoundException e) {
 +      throw new RuntimeException(e);
 +    }
 +    
 +    scannerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseScanner()).build();
 +    
 +    writerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseWriter()).build();
 +  }
 +  
 +  protected Connector getConnector(ByteBuffer login) throws Exception {
 +    TCredentials user = CredentialHelper.fromByteArray(ByteBufferUtil.toBytes(login));
 +    if (user == null)
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException("unknown user");
 +    Connector connector = instance.getConnector(user.getPrincipal(), CredentialHelper.extractToken(user));
 +    return connector;
 +  }
 +  
 +  private void handleAccumuloException(AccumuloException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.AccumuloException {
 +    if (e.getCause() instanceof ThriftTableOperationException) {
 +      ThriftTableOperationException ttoe = (ThriftTableOperationException) e.getCause();
 +      if (ttoe.type == TableOperationExceptionType.NOTFOUND) {
 +        throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString());
 +      }
 +    }
 +    throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +  }
 +  
 +  private void handleAccumuloSecurityException(AccumuloSecurityException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException {
 +    if (e.getSecurityErrorCode().equals(SecurityErrorCode.TABLE_DOESNT_EXIST))
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString());
 +    throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString());
 +  }
 +
 +  private void handleExceptionTNF(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      throw ex;
 +    } catch (AccumuloException e) {
 +      handleAccumuloException(e);
 +    } catch (AccumuloSecurityException e) {
 +      handleAccumuloSecurityException(e);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(ex.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +
 +  private void handleExceptionTEE(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      throw ex;
 +    } catch (AccumuloException e) {
 +      handleAccumuloException(e);
 +    } catch (AccumuloSecurityException e) {
 +      handleAccumuloSecurityException(e);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(ex.toString());
 +    } catch (TableExistsException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableExistsException(e.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +  
 +  private void handleExceptionMRE(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      throw ex;
 +    } catch (MutationsRejectedException e) {
 +      throw new org.apache.accumulo.proxy.thrift.MutationsRejectedException(ex.toString());
 +    } catch (AccumuloException e) {
 +      handleAccumuloException(e);
 +    } catch (AccumuloSecurityException e) {
 +      handleAccumuloSecurityException(e);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(ex.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +  
 +  private void handleException(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      throw ex;
 +    } catch (AccumuloException e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    } catch (AccumuloSecurityException e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString());
 +    } catch (Exception e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString());
 +    }
 +  }
 +
 +  @Override
 +  public int addConstraint(ByteBuffer login, String tableName, String constraintClassName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      return getConnector(login).tableOperations().addConstraint(tableName, constraintClassName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return -1;
 +    }
 +  }
 +  
 +  @Override
 +  public void addSplits(ByteBuffer login, String tableName, Set<ByteBuffer> splits) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      SortedSet<Text> sorted = new TreeSet<Text>();
 +      for (ByteBuffer split : splits) {
 +        sorted.add(ByteBufferUtil.toText(split));
 +      }
 +      getConnector(login).tableOperations().addSplits(tableName, sorted);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void clearLocatorCache(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().clearLocatorCache(tableName);
 +    } catch (TableNotFoundException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString());
 +    } catch (Exception e) {
 +      throw new TException(e.toString());
 +    }
 +  }
 +  
 +  @Override
 +  public void compactTable(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow,
 +      List<org.apache.accumulo.proxy.thrift.IteratorSetting> iterators, boolean flush, boolean wait)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.AccumuloException, TException {
 +    try {
 +      getConnector(login).tableOperations().compact(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow), getIteratorSettings(iterators),
 +          flush, wait);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void cancelCompaction(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().cancelCompaction(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  private List<IteratorSetting> getIteratorSettings(List<org.apache.accumulo.proxy.thrift.IteratorSetting> iterators) {
 +    List<IteratorSetting> result = new ArrayList<IteratorSetting>();
 +    if (iterators != null) {
 +      for (org.apache.accumulo.proxy.thrift.IteratorSetting is : iterators) {
 +        result.add(getIteratorSetting(is));
 +      }
 +    }
 +    return result;
 +  }
 +  
 +  @Override
 +  public void createTable(ByteBuffer login, String tableName, boolean versioningIter, org.apache.accumulo.proxy.thrift.TimeType type)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      if (type == null)
 +        type = org.apache.accumulo.proxy.thrift.TimeType.MILLIS;
 +      
 +      getConnector(login).tableOperations().create(tableName, versioningIter, TimeType.valueOf(type.toString()));
 +    } catch (TableExistsException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableExistsException(e.toString());
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void deleteTable(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().delete(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void deleteRows(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().deleteRows(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public boolean tableExists(ByteBuffer login, String tableName) throws TException {
 +    try {
 +      return getConnector(login).tableOperations().exists(tableName);
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void flushTable(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow, boolean wait)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().flush(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow), wait);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,Set<String>> getLocalityGroups(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,Set<Text>> groups = getConnector(login).tableOperations().getLocalityGroups(tableName);
 +      Map<String,Set<String>> ret = new HashMap<String,Set<String>>();
 +      for (String key : groups.keySet()) {
 +        ret.put(key, new HashSet<String>());
 +        for (Text val : groups.get(key)) {
 +          ret.get(key).add(val.toString());
 +        }
 +      }
 +      return ret;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public ByteBuffer getMaxRow(ByteBuffer login, String tableName, Set<ByteBuffer> auths, ByteBuffer startRow, boolean startInclusive, ByteBuffer endRow,
 +      boolean endInclusive) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Connector connector = getConnector(login);
 +      Text startText = ByteBufferUtil.toText(startRow);
 +      Text endText = ByteBufferUtil.toText(endRow);
 +      Authorizations auth;
 +      if (auths != null) {
 +        auth = getAuthorizations(auths);
 +      } else {
 +        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
 +      }
 +      Text max = connector.tableOperations().getMaxRow(tableName, auth, startText, startInclusive, endText, endInclusive);
 +      return TextUtil.getByteBuffer(max);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> getTableProperties(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,String> ret = new HashMap<String,String>();
 +      
 +      for (Map.Entry<String,String> entry : getConnector(login).tableOperations().getProperties(tableName)) {
 +        ret.put(entry.getKey(), entry.getValue());
 +      }
 +      return ret;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public List<ByteBuffer> listSplits(ByteBuffer login, String tableName, int maxSplits) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Collection<Text> splits = getConnector(login).tableOperations().listSplits(tableName, maxSplits);
 +      List<ByteBuffer> ret = new ArrayList<ByteBuffer>();
 +      for (Text split : splits) {
 +        ret.add(TextUtil.getByteBuffer(split));
 +      }
 +      return ret;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Set<String> listTables(ByteBuffer login) throws TException {
 +    try {
 +      return getConnector(login).tableOperations().list();
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,Integer> listConstraints(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      return getConnector(login).tableOperations().listConstraints(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void mergeTablets(ByteBuffer login, String tableName, ByteBuffer startRow, ByteBuffer endRow)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().merge(tableName, ByteBufferUtil.toText(startRow), ByteBufferUtil.toText(endRow));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void offlineTable(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().offline(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void onlineTable(ByteBuffer login, String tableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().online(tableName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void removeConstraint(ByteBuffer login, String tableName, int constraint) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().removeConstraint(tableName, constraint);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void removeTableProperty(ByteBuffer login, String tableName, String property) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().removeProperty(tableName, property);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void renameTable(ByteBuffer login, String oldTableName, String newTableName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
 +      org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      getConnector(login).tableOperations().rename(oldTableName, newTableName);
 +    } catch (Exception e) {
 +      handleExceptionTEE(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void setLocalityGroups(ByteBuffer login, String tableName, Map<String,Set<String>> groupStrings)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,Set<Text>> groups = new HashMap<String,Set<Text>>();
 +      for (String key : groupStrings.keySet()) {
 +        groups.put(key, new HashSet<Text>());
 +        for (String val : groupStrings.get(key)) {
 +          groups.get(key).add(new Text(val));
 +        }
 +      }
 +      getConnector(login).tableOperations().setLocalityGroups(tableName, groups);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void setTableProperty(ByteBuffer login, String tableName, String property, String value) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().setProperty(tableName, property, value);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> tableIdMap(ByteBuffer login) throws TException {
 +    try {
 +      return getConnector(login).tableOperations().tableIdMap();
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> getSiteConfiguration(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).instanceOperations().getSiteConfiguration();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,String> getSystemConfiguration(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).instanceOperations().getSystemConfiguration();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public List<String> getTabletServers(ByteBuffer login) throws TException {
 +    try {
 +      return getConnector(login).instanceOperations().getTabletServers();
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public List<org.apache.accumulo.proxy.thrift.ActiveScan> getActiveScans(ByteBuffer login, String tserver)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    List<org.apache.accumulo.proxy.thrift.ActiveScan> result = new ArrayList<org.apache.accumulo.proxy.thrift.ActiveScan>();
 +    try {
 +      List<ActiveScan> activeScans = getConnector(login).instanceOperations().getActiveScans(tserver);
 +      for (ActiveScan scan : activeScans) {
 +        org.apache.accumulo.proxy.thrift.ActiveScan pscan = new org.apache.accumulo.proxy.thrift.ActiveScan();
 +        pscan.client = scan.getClient();
 +        pscan.user = scan.getUser();
 +        pscan.table = scan.getTable();
 +        pscan.age = scan.getAge();
 +        pscan.idleTime = scan.getIdleTime();
 +        pscan.type = ScanType.valueOf(scan.getType().toString());
 +        pscan.state = ScanState.valueOf(scan.getState().toString());
 +        KeyExtent e = scan.getExtent();
 +        pscan.extent = new org.apache.accumulo.proxy.thrift.KeyExtent(e.getTableId().toString(), TextUtil.getByteBuffer(e.getEndRow()),
 +            TextUtil.getByteBuffer(e.getPrevEndRow()));
 +        pscan.columns = new ArrayList<org.apache.accumulo.proxy.thrift.Column>();
 +        if (scan.getColumns() != null) {
 +          for (Column c : scan.getColumns()) {
 +            org.apache.accumulo.proxy.thrift.Column column = new org.apache.accumulo.proxy.thrift.Column();
 +            column.setColFamily(c.getColumnFamily());
 +            column.setColQualifier(c.getColumnQualifier());
 +            column.setColVisibility(c.getColumnVisibility());
 +            pscan.columns.add(column);
 +          }
 +        }
 +        pscan.iterators = new ArrayList<org.apache.accumulo.proxy.thrift.IteratorSetting>();
 +        for (String iteratorString : scan.getSsiList()) {
 +          String[] parts = iteratorString.split("[=,]");
 +          if (parts.length == 3) {
 +            String name = parts[0];
 +            int priority = Integer.parseInt(parts[1]);
 +            String classname = parts[2];
 +            org.apache.accumulo.proxy.thrift.IteratorSetting settings = new org.apache.accumulo.proxy.thrift.IteratorSetting(priority, name, classname, scan
 +                .getSsio().get(name));
 +            pscan.iterators.add(settings);
 +          }
 +        }
 +        pscan.authorizations = new ArrayList<ByteBuffer>();
 +        if (scan.getAuthorizations() != null) {
 +          for (byte[] a : scan.getAuthorizations()) {
 +            pscan.authorizations.add(ByteBuffer.wrap(a));
 +          }
 +        }
 +        result.add(pscan);
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public List<org.apache.accumulo.proxy.thrift.ActiveCompaction> getActiveCompactions(ByteBuffer login, String tserver)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    
 +    try {
 +      List<org.apache.accumulo.proxy.thrift.ActiveCompaction> result = new ArrayList<org.apache.accumulo.proxy.thrift.ActiveCompaction>();
 +      List<ActiveCompaction> active = getConnector(login).instanceOperations().getActiveCompactions(tserver);
 +      for (ActiveCompaction comp : active) {
 +        org.apache.accumulo.proxy.thrift.ActiveCompaction pcomp = new org.apache.accumulo.proxy.thrift.ActiveCompaction();
 +        pcomp.age = comp.getAge();
 +        pcomp.entriesRead = comp.getEntriesRead();
 +        pcomp.entriesWritten = comp.getEntriesWritten();
 +        KeyExtent e = comp.getExtent();
 +        pcomp.extent = new org.apache.accumulo.proxy.thrift.KeyExtent(e.getTableId().toString(), TextUtil.getByteBuffer(e.getEndRow()),
 +            TextUtil.getByteBuffer(e.getPrevEndRow()));
 +        pcomp.inputFiles = new ArrayList<String>();
 +        if (comp.getInputFiles() != null) {
 +          pcomp.inputFiles.addAll(comp.getInputFiles());
 +        }
 +        pcomp.localityGroup = comp.getLocalityGroup();
 +        pcomp.outputFile = comp.getOutputFile();
 +        pcomp.reason = CompactionReason.valueOf(comp.getReason().toString());
 +        pcomp.type = CompactionType.valueOf(comp.getType().toString());
 +        
 +        pcomp.iterators = new ArrayList<org.apache.accumulo.proxy.thrift.IteratorSetting>();
 +        if (comp.getIterators() != null) {
 +          for (IteratorSetting setting : comp.getIterators()) {
 +            org.apache.accumulo.proxy.thrift.IteratorSetting psetting = new org.apache.accumulo.proxy.thrift.IteratorSetting(setting.getPriority(),
 +                setting.getName(), setting.getIteratorClass(), setting.getOptions());
 +            pcomp.iterators.add(psetting);
 +          }
 +        }
 +        result.add(pcomp);
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void removeProperty(ByteBuffer login, String property) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).instanceOperations().removeProperty(property);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void setProperty(ByteBuffer login, String property, String value) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).instanceOperations().setProperty(property, value);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public boolean testClassLoad(ByteBuffer login, String className, String asTypeName) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).instanceOperations().testClassLoad(className, asTypeName);
 +    } catch (Exception e) {
 +      handleException(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public boolean authenticateUser(ByteBuffer login, String user, Map<String,String> properties) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().authenticateUser(user, getToken(user, properties));
 +    } catch (Exception e) {
 +      handleException(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public void changeUserAuthorizations(ByteBuffer login, String user, Set<ByteBuffer> authorizations)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      Set<String> auths = new HashSet<String>();
 +      for (ByteBuffer auth : authorizations) {
 +        auths.add(ByteBufferUtil.toString(auth));
 +      }
 +      getConnector(login).securityOperations().changeUserAuthorizations(user, new Authorizations(auths.toArray(new String[0])));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void changeLocalUserPassword(ByteBuffer login, String user, ByteBuffer password) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().changeLocalUserPassword(user, new PasswordToken(password));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void createLocalUser(ByteBuffer login, String user, ByteBuffer password) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().createLocalUser(user, new PasswordToken(password));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void dropLocalUser(ByteBuffer login, String user) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().dropLocalUser(user);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public List<ByteBuffer> getUserAuthorizations(ByteBuffer login, String user) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().getUserAuthorizations(user).getAuthorizationsBB();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void grantSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().grantSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void grantTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).securityOperations().grantTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public boolean hasSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().hasSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleException(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public boolean hasTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      return getConnector(login).securityOperations().hasTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return false;
 +    }
 +  }
 +  
 +  @Override
 +  public Set<String> listLocalUsers(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      return getConnector(login).securityOperations().listLocalUsers();
 +    } catch (Exception e) {
 +      handleException(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void revokeSystemPermission(ByteBuffer login, String user, org.apache.accumulo.proxy.thrift.SystemPermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).securityOperations().revokeSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void revokeTablePermission(ByteBuffer login, String user, String table, org.apache.accumulo.proxy.thrift.TablePermission perm)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).securityOperations().revokeTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  private Authorizations getAuthorizations(Set<ByteBuffer> authorizations) {
 +    List<String> auths = new ArrayList<String>();
 +    for (ByteBuffer bbauth : authorizations) {
 +      auths.add(ByteBufferUtil.toString(bbauth));
 +    }
 +    return new Authorizations(auths.toArray(new String[0]));
 +  }
 +  
 +  @Override
 +  public String createScanner(ByteBuffer login, String tableName, ScanOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Connector connector = getConnector(login);
 +      
 +      Authorizations auth;
 +      if (opts != null && opts.isSetAuthorizations()) {
 +        auth = getAuthorizations(opts.authorizations);
 +      } else {
 +        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
 +      }
 +      Scanner scanner = connector.createScanner(tableName, auth);
 +      
 +      if (opts != null) {
 +        if (opts.iterators != null) {
 +          for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) {
 +            IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(), iter.getIteratorClass(), iter.getProperties());
 +            scanner.addScanIterator(is);
 +          }
 +        }
 +        org.apache.accumulo.proxy.thrift.Range prange = opts.range;
 +        if (prange != null) {
 +          Range range = new Range(Util.fromThrift(prange.getStart()), prange.startInclusive, Util.fromThrift(prange.getStop()), prange.stopInclusive);
 +          scanner.setRange(range);
 +        }
 +        if (opts.columns != null) {
 +          for (ScanColumn col : opts.columns) {
 +            if (col.isSetColQualifier())
 +              scanner.fetchColumn(ByteBufferUtil.toText(col.colFamily), ByteBufferUtil.toText(col.colQualifier));
 +            else
 +              scanner.fetchColumnFamily(ByteBufferUtil.toText(col.colFamily));
 +          }
 +        }
 +      }
 +      
 +      UUID uuid = UUID.randomUUID();
 +      
 +      ScannerPlusIterator spi = new ScannerPlusIterator();
 +      spi.scanner = scanner;
 +      spi.iterator = scanner.iterator();
 +      scannerCache.put(uuid, spi);
 +      return uuid.toString();
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public String createBatchScanner(ByteBuffer login, String tableName, BatchScanOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Connector connector = getConnector(login);
 +      
 +      int threads = 10;
 +      Authorizations auth;
 +      if (opts != null && opts.isSetAuthorizations()) {
 +        auth = getAuthorizations(opts.authorizations);
 +      } else {
 +        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
 +      }
 +      if (opts != null && opts.threads > 0)
 +        threads = opts.threads;
 +      
 +      BatchScanner scanner = connector.createBatchScanner(tableName, auth, threads);
 +      
 +      if (opts != null) {
 +        if (opts.iterators != null) {
 +          for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) {
 +            IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(), iter.getIteratorClass(), iter.getProperties());
 +            scanner.addScanIterator(is);
 +          }
 +        }
 +        
 +        ArrayList<Range> ranges = new ArrayList<Range>();
 +        
 +        if (opts.ranges == null) {
 +          ranges.add(new Range());
 +        } else {
 +          for (org.apache.accumulo.proxy.thrift.Range range : opts.ranges) {
 +            Range aRange = new Range(range.getStart() == null ? null : Util.fromThrift(range.getStart()), true, range.getStop() == null ? null
 +                : Util.fromThrift(range.getStop()), false);
 +            ranges.add(aRange);
 +          }
 +        }
 +        scanner.setRanges(ranges);
 +        
 +        if (opts.columns != null) {
 +          for (ScanColumn col : opts.columns) {
 +            if (col.isSetColQualifier())
 +              scanner.fetchColumn(ByteBufferUtil.toText(col.colFamily), ByteBufferUtil.toText(col.colQualifier));
 +            else
 +              scanner.fetchColumnFamily(ByteBufferUtil.toText(col.colFamily));
 +          }
 +        }
 +      }
 +      
 +      UUID uuid = UUID.randomUUID();
 +      
 +      ScannerPlusIterator spi = new ScannerPlusIterator();
 +      spi.scanner = scanner;
 +      spi.iterator = scanner.iterator();
 +      scannerCache.put(uuid, spi);
 +      return uuid.toString();
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  private ScannerPlusIterator getScanner(String scanner) throws UnknownScanner {
 +    
 +    UUID uuid = null;
 +    try {
 +      uuid = UUID.fromString(scanner);
 +    } catch (IllegalArgumentException e) {
 +      throw new UnknownScanner(e.getMessage());
 +    }
 +    
 +    ScannerPlusIterator spi = scannerCache.getIfPresent(uuid);
 +    if (spi == null) {
 +      throw new UnknownScanner("Scanner never existed or no longer exists");
 +    }
 +    return spi;
 +  }
 +  
 +  @Override
 +  public boolean hasNext(String scanner) throws UnknownScanner, TException {
 +    ScannerPlusIterator spi = getScanner(scanner);
 +    
 +    return (spi.iterator.hasNext());
 +  }
 +  
 +  @Override
 +  public KeyValueAndPeek nextEntry(String scanner) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      TException {
 +    
 +    ScanResult scanResult = nextK(scanner, 1);
 +    if (scanResult.results.size() > 0) {
 +      return new KeyValueAndPeek(scanResult.results.get(0), scanResult.isMore());
 +    } else {
 +      throw new NoMoreEntriesException();
 +    }
 +  }
 +  
 +  @Override
 +  public ScanResult nextK(String scanner, int k) throws NoMoreEntriesException, UnknownScanner, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      TException {
 +    
 +    // fetch the scanner
 +    ScannerPlusIterator spi = getScanner(scanner);
 +    Iterator<Map.Entry<Key,Value>> batchScanner = spi.iterator;
 +    // synchronized to prevent race conditions
 +    synchronized (batchScanner) {
 +      ScanResult ret = new ScanResult();
 +      ret.setResults(new ArrayList<KeyValue>());
 +      int numRead = 0;
 +      try {
 +        while (batchScanner.hasNext() && numRead < k) {
 +          Map.Entry<Key,Value> next = batchScanner.next();
 +          ret.addToResults(new KeyValue(Util.toThrift(next.getKey()), ByteBuffer.wrap(next.getValue().get())));
 +          numRead++;
 +        }
 +        ret.setMore(numRead == k);
 +      } catch (Exception ex) {
 +        closeScanner(scanner);
 +        throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(ex.toString());
 +      }
 +      return ret;
 +    }
 +  }
 +
 +  @Override
 +  public void closeScanner(String scanner) throws UnknownScanner, TException {
 +    UUID uuid = null;
 +    try {
 +      uuid = UUID.fromString(scanner);
 +    } catch (IllegalArgumentException e) {
 +      throw new UnknownScanner(e.getMessage());
 +    }
 +
 +    try {
 +      if (scannerCache.asMap().remove(uuid) == null) {
 +        throw new UnknownScanner("Scanner never existed or no longer exists");
 +      }
 +    } catch (UnknownScanner e) {
 +      throw e;
 +    } catch (Exception e) {
 +      throw new TException(e.toString());
 +    }
 +  }
 +  
 +  @Override
 +  public void updateAndFlush(ByteBuffer login, String tableName, Map<ByteBuffer,List<ColumnUpdate>> cells)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(login, tableName, null);
 +      addCellsToWriter(cells, bwpe);
 +      if (bwpe.exception != null)
 +        throw bwpe.exception;
 +      bwpe.writer.flush();
 +      bwpe.writer.close();
 +    } catch (Exception e) {
 +      handleExceptionMRE(e);
 +    }
 +  }
 +  
 +  private static final ColumnVisibility EMPTY_VIS = new ColumnVisibility();
 +  
 +  private void addCellsToWriter(Map<ByteBuffer,List<ColumnUpdate>> cells, BatchWriterPlusException bwpe) {
 +    if (bwpe.exception != null)
 +      return;
 +    
 +    HashMap<Text,ColumnVisibility> vizMap = new HashMap<Text,ColumnVisibility>();
 +    
 +    for (Map.Entry<ByteBuffer,List<ColumnUpdate>> entry : cells.entrySet()) {
 +      Mutation m = new Mutation(ByteBufferUtil.toBytes(entry.getKey()));
 +      
 +      for (ColumnUpdate update : entry.getValue()) {
 +        ColumnVisibility viz = EMPTY_VIS;
 +        if (update.isSetColVisibility()) {
 +          Text vizText = new Text(update.getColVisibility());
 +          viz = vizMap.get(vizText);
 +          if (viz == null) {
 +            vizMap.put(vizText, viz = new ColumnVisibility(vizText));
 +          }
 +        }
 +        byte[] value = new byte[0];
 +        if (update.isSetValue())
 +          value = update.getValue();
 +        if (update.isSetTimestamp()) {
 +          if (update.isSetDeleteCell()) {
 +            m.putDelete(update.getColFamily(), update.getColQualifier(), viz, update.getTimestamp());
 +          } else {
 +            m.put(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz, update.getTimestamp(), new Value(value));
 +            }
 +        } else {
 +          if (update.isSetDeleteCell()) {
 +            m.putDelete(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz);
 +          } else {
 +            m.put(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz, new Value(value));
 +          }
 +        }
 +      }
 +      try {
 +        bwpe.writer.addMutation(m);
 +      } catch (MutationsRejectedException mre) {
 +        bwpe.exception = mre;
 +      }
 +    }
 +  }
 +  
 +  @Override
 +  public String createWriter(ByteBuffer login, String tableName, WriterOptions opts) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      BatchWriterPlusException writer = getWriter(login, tableName, opts);
 +      UUID uuid = UUID.randomUUID();
 +      writerCache.put(uuid, writer);
 +      return uuid.toString();
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void update(String writer, Map<ByteBuffer,List<ColumnUpdate>> cells) throws TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(writer);
 +      addCellsToWriter(cells, bwpe);
 +    } catch (UnknownWriter e) {
 +      // just drop it, this is a oneway thrift call and throwing a TException seems to make all subsequent thrift calls fail
 +    }
 +  }
 +  
 +  @Override
 +  public void flush(String writer) throws UnknownWriter, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(writer);
 +      if (bwpe.exception != null)
 +        throw bwpe.exception;
 +      bwpe.writer.flush();
 +    } catch (MutationsRejectedException e) {
 +      throw new org.apache.accumulo.proxy.thrift.MutationsRejectedException(e.toString());
 +    } catch (UnknownWriter uw) {
 +      throw uw;
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void closeWriter(String writer) throws UnknownWriter, org.apache.accumulo.proxy.thrift.MutationsRejectedException, TException {
 +    try {
 +      BatchWriterPlusException bwpe = getWriter(writer);
 +      if (bwpe.exception != null)
 +        throw bwpe.exception;
 +      bwpe.writer.close();
 +      writerCache.invalidate(UUID.fromString(writer));
 +    } catch (UnknownWriter uw) {
 +      throw uw;
 +    } catch (MutationsRejectedException e) {
 +      throw new org.apache.accumulo.proxy.thrift.MutationsRejectedException(e.toString());
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +
 +  private BatchWriterPlusException getWriter(String writer) throws UnknownWriter {
 +    UUID uuid = null;
 +    try {
 +      uuid = UUID.fromString(writer);
 +    } catch (IllegalArgumentException iae) {
 +      throw new UnknownWriter(iae.getMessage());
 +    }
 +    
 +    BatchWriterPlusException bwpe = writerCache.getIfPresent(uuid);
 +    if (bwpe == null) {
 +      throw new UnknownWriter("Writer never existed or no longer exists");
 +    }
 +    return bwpe;
 +  }
 +  
 +  private BatchWriterPlusException getWriter(ByteBuffer login, String tableName, WriterOptions opts) throws Exception {
 +    BatchWriterConfig cfg = new BatchWriterConfig();
 +    if (opts != null) {
 +      if (opts.maxMemory != 0)
 +        cfg.setMaxMemory(opts.maxMemory);
 +      if (opts.threads != 0)
 +        cfg.setMaxWriteThreads(opts.threads);
 +      if (opts.timeoutMs != 0)
 +        cfg.setTimeout(opts.timeoutMs, TimeUnit.MILLISECONDS);
 +      if (opts.latencyMs != 0)
 +        cfg.setMaxLatency(opts.latencyMs, TimeUnit.MILLISECONDS);
 +    }
 +    BatchWriterPlusException result = new BatchWriterPlusException();
 +    result.writer = getConnector(login).createBatchWriter(tableName, cfg);
 +    return result;
 +  }
 +  
 +  private IteratorSetting getIteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting setting) {
 +    return new IteratorSetting(setting.priority, setting.name, setting.iteratorClass, setting.getProperties());
 +  }
 +  
 +  private IteratorScope getIteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope scope) {
 +    return IteratorScope.valueOf(scope.toString().toLowerCase());
 +  }
 +  
 +  private EnumSet<IteratorScope> getIteratorScopes(Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) {
 +    EnumSet<IteratorScope> scopes_ = EnumSet.noneOf(IteratorScope.class);
 +    for (org.apache.accumulo.proxy.thrift.IteratorScope scope : scopes) {
 +      scopes_.add(getIteratorScope(scope));
 +    }
 +    return scopes_;
 +  }
 +  
 +  private EnumSet<org.apache.accumulo.proxy.thrift.IteratorScope> getProxyIteratorScopes(Set<IteratorScope> scopes) {
 +    EnumSet<org.apache.accumulo.proxy.thrift.IteratorScope> scopes_ = EnumSet.noneOf(org.apache.accumulo.proxy.thrift.IteratorScope.class);
 +    for (IteratorScope scope : scopes) {
 +      scopes_.add(org.apache.accumulo.proxy.thrift.IteratorScope.valueOf(scope.toString().toUpperCase()));
 +    }
 +    return scopes_;
 +  }
 +  
 +  @Override
 +  public void attachIterator(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.IteratorSetting setting,
 +      Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().attachIterator(tableName, getIteratorSetting(setting), getIteratorScopes(scopes));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void checkIteratorConflicts(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.IteratorSetting setting,
 +      Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().checkIteratorConflicts(tableName, getIteratorSetting(setting), getIteratorScopes(scopes));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void cloneTable(ByteBuffer login, String tableName, String newTableName, boolean flush, Map<String,String> propertiesToSet,
 +      Set<String> propertiesToExclude) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    try {
 +      propertiesToExclude = propertiesToExclude == null ? new HashSet<String>() : propertiesToExclude;
 +      propertiesToSet = propertiesToSet == null ? new HashMap<String,String>() : propertiesToSet;
 +      
 +      getConnector(login).tableOperations().clone(tableName, newTableName, flush, propertiesToSet, propertiesToExclude);
 +    } catch (Exception e) {
 +      handleExceptionTEE(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void exportTable(ByteBuffer login, String tableName, String exportDir) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().exportTable(tableName, exportDir);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public void importTable(ByteBuffer login, String tableName, String importDir) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableExistsException, TException {
 +    
 +    try {
 +      getConnector(login).tableOperations().importTable(tableName, importDir);
 +    } catch (TableExistsException e) {
 +      throw new org.apache.accumulo.proxy.thrift.TableExistsException(e.toString());
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public org.apache.accumulo.proxy.thrift.IteratorSetting getIteratorSetting(ByteBuffer login, String tableName, String iteratorName,
 +      org.apache.accumulo.proxy.thrift.IteratorScope scope) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      IteratorSetting is = getConnector(login).tableOperations().getIteratorSetting(tableName, iteratorName, getIteratorScope(scope));
 +      return new org.apache.accumulo.proxy.thrift.IteratorSetting(is.getPriority(), is.getName(), is.getIteratorClass(), is.getOptions());
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public Map<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>> listIterators(ByteBuffer login, String tableName)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Map<String,EnumSet<IteratorScope>> iterMap = getConnector(login).tableOperations().listIterators(tableName);
 +      Map<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>> result = new HashMap<String,Set<org.apache.accumulo.proxy.thrift.IteratorScope>>();
 +      for (Map.Entry<String,EnumSet<IteratorScope>> entry : iterMap.entrySet()) {
 +        result.put(entry.getKey(), getProxyIteratorScopes(entry.getValue()));
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  @Override
 +  public void removeIterator(ByteBuffer login, String tableName, String iterName, Set<org.apache.accumulo.proxy.thrift.IteratorScope> scopes)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      getConnector(login).tableOperations().removeIterator(tableName, iterName, getIteratorScopes(scopes));
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
 +  @Override
 +  public Set<org.apache.accumulo.proxy.thrift.Range> splitRangeByTablets(ByteBuffer login, String tableName, org.apache.accumulo.proxy.thrift.Range range,
 +      int maxSplits) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      Set<Range> ranges = getConnector(login).tableOperations().splitRangeByTablets(tableName, getRange(range), maxSplits);
 +      Set<org.apache.accumulo.proxy.thrift.Range> result = new HashSet<org.apache.accumulo.proxy.thrift.Range>();
 +      for (Range r : ranges) {
 +        result.add(getRange(r));
 +      }
 +      return result;
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return null;
 +    }
 +  }
 +  
 +  private org.apache.accumulo.proxy.thrift.Range getRange(Range r) {
 +    return new org.apache.accumulo.proxy.thrift.Range(getProxyKey(r.getStartKey()), r.isStartKeyInclusive(), getProxyKey(r.getEndKey()), r.isEndKeyInclusive());
 +  }
 +  
 +  private org.apache.accumulo.proxy.thrift.Key getProxyKey(Key k) {
 +    if (k == null)
 +      return null;
 +    org.apache.accumulo.proxy.thrift.Key result = new org.apache.accumulo.proxy.thrift.Key(TextUtil.getByteBuffer(k.getRow()), TextUtil.getByteBuffer(k
 +        .getColumnFamily()), TextUtil.getByteBuffer(k.getColumnQualifier()), TextUtil.getByteBuffer(k.getColumnVisibility()));
++    result.setTimestamp(k.getTimestamp());
 +    return result;
 +  }
 +  
 +  private Range getRange(org.apache.accumulo.proxy.thrift.Range range) {
 +    return new Range(Util.fromThrift(range.start), Util.fromThrift(range.stop));
 +  }
 +  
 +  @Override
 +  public void importDirectory(ByteBuffer login, String tableName, String importDir, String failureDir, boolean setTime)
 +      throws org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).tableOperations().importDirectory(tableName, importDir, failureDir, setTime);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +    }
 +  }
 +  
-   static private final ByteBuffer EMPTY = ByteBuffer.wrap(new byte[] {});
-   
 +  @Override
 +  public org.apache.accumulo.proxy.thrift.Range getRowRange(ByteBuffer row) throws TException {
-     return new org.apache.accumulo.proxy.thrift.Range(new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true,
-         new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true);
++    return getRange(new Range(ByteBufferUtil.toText(row)));
 +  }
 +  
 +  @Override
 +  public org.apache.accumulo.proxy.thrift.Key getFollowing(org.apache.accumulo.proxy.thrift.Key key, org.apache.accumulo.proxy.thrift.PartialKey part)
 +      throws TException {
 +    Key key_ = Util.fromThrift(key);
 +    PartialKey part_ = PartialKey.valueOf(part.toString());
 +    Key followingKey = key_.followingKey(part_);
 +    return getProxyKey(followingKey);
 +  }
 +  
 +  @Override
 +  public void pingTabletServer(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException,
 +      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      getConnector(login).instanceOperations().ping(tserver);
 +    } catch (Exception e) {
 +      handleException(e);
 +    }
 +  }
 +  
 +  @Override
 +  public ByteBuffer login(String principal, Map<String,String> loginProperties) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 +    try {
 +      AuthenticationToken token = getToken(principal, loginProperties);
 +      TCredentials credential = CredentialHelper.create(principal, token, instance.getInstanceID());
 +      ByteBuffer login = ByteBuffer.wrap(CredentialHelper.asByteArray(credential));
 +      getConnector(login); // check to make sure user exists
 +      return login;
 +    } catch (AccumuloSecurityException e) {
 +      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString());
 +    } catch (Exception e) {
 +      throw new TException(e);
 +    }
 +  }
 +  
 +  private AuthenticationToken getToken(String principal, Map<String,String> properties) throws AccumuloSecurityException, AccumuloException {
 +    AuthenticationToken.Properties props = new AuthenticationToken.Properties();
 +    props.putAllStrings(properties);
 +    AuthenticationToken token;
 +    try {
 +      token = tokenClass.newInstance();
 +    } catch (InstantiationException e) {
 +      throw new AccumuloException(e);
 +    } catch (IllegalAccessException e) {
 +      throw new AccumuloException(e);
 +    }
 +    token.init(props);
 +    return token;
 +  }
 +  
 +  @Override
 +  public boolean testTableClassLoad(ByteBuffer login, String tableName, String className, String asTypeName)
 +      throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
 +      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
 +    try {
 +      return getConnector(login).tableOperations().testClassLoad(tableName, className, asTypeName);
 +    } catch (Exception e) {
 +      handleExceptionTNF(e);
 +      return false;
 +    }
 +  }
 +}


[05/10] Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
----------------------------------------------------------------------
diff --cc proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
index 1a677a1,0000000..80f2ecd
mode 100644,000000..100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
@@@ -1,846 -1,0 +1,848 @@@
 +/*
 + * 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.
 + */
 +/**
 + * Autogenerated by Thrift Compiler (0.9.0)
 + *
 + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 + *  @generated
 + */
 +package org.apache.accumulo.proxy.thrift;
 +
 +import org.apache.thrift.scheme.IScheme;
 +import org.apache.thrift.scheme.SchemeFactory;
 +import org.apache.thrift.scheme.StandardScheme;
 +
 +import org.apache.thrift.scheme.TupleScheme;
 +import org.apache.thrift.protocol.TTupleProtocol;
 +import org.apache.thrift.protocol.TProtocolException;
 +import org.apache.thrift.EncodingUtils;
 +import org.apache.thrift.TException;
 +import java.util.List;
 +import java.util.ArrayList;
 +import java.util.Map;
 +import java.util.HashMap;
 +import java.util.EnumMap;
 +import java.util.Set;
 +import java.util.HashSet;
 +import java.util.EnumSet;
 +import java.util.Collections;
 +import java.util.BitSet;
 +import java.nio.ByteBuffer;
 +import java.util.Arrays;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +@SuppressWarnings("all") public class Key implements org.apache.thrift.TBase<Key, Key._Fields>, java.io.Serializable, Cloneable {
 +  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Key");
 +
 +  private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
 +  private static final org.apache.thrift.protocol.TField COL_FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("colFamily", org.apache.thrift.protocol.TType.STRING, (short)2);
 +  private static final org.apache.thrift.protocol.TField COL_QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("colQualifier", org.apache.thrift.protocol.TType.STRING, (short)3);
 +  private static final org.apache.thrift.protocol.TField COL_VISIBILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("colVisibility", org.apache.thrift.protocol.TType.STRING, (short)4);
 +  private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)5);
 +
 +  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
 +  static {
 +    schemes.put(StandardScheme.class, new KeyStandardSchemeFactory());
 +    schemes.put(TupleScheme.class, new KeyTupleSchemeFactory());
 +  }
 +
 +  public ByteBuffer row; // required
 +  public ByteBuffer colFamily; // required
 +  public ByteBuffer colQualifier; // required
 +  public ByteBuffer colVisibility; // required
 +  public long timestamp; // optional
 +
 +  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
 +  @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
 +    ROW((short)1, "row"),
 +    COL_FAMILY((short)2, "colFamily"),
 +    COL_QUALIFIER((short)3, "colQualifier"),
 +    COL_VISIBILITY((short)4, "colVisibility"),
 +    TIMESTAMP((short)5, "timestamp");
 +
 +    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 +
 +    static {
 +      for (_Fields field : EnumSet.allOf(_Fields.class)) {
 +        byName.put(field.getFieldName(), field);
 +      }
 +    }
 +
 +    /**
 +     * Find the _Fields constant that matches fieldId, or null if its not found.
 +     */
 +    public static _Fields findByThriftId(int fieldId) {
 +      switch(fieldId) {
 +        case 1: // ROW
 +          return ROW;
 +        case 2: // COL_FAMILY
 +          return COL_FAMILY;
 +        case 3: // COL_QUALIFIER
 +          return COL_QUALIFIER;
 +        case 4: // COL_VISIBILITY
 +          return COL_VISIBILITY;
 +        case 5: // TIMESTAMP
 +          return TIMESTAMP;
 +        default:
 +          return null;
 +      }
 +    }
 +
 +    /**
 +     * Find the _Fields constant that matches fieldId, throwing an exception
 +     * if it is not found.
 +     */
 +    public static _Fields findByThriftIdOrThrow(int fieldId) {
 +      _Fields fields = findByThriftId(fieldId);
 +      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
 +      return fields;
 +    }
 +
 +    /**
 +     * Find the _Fields constant that matches name, or null if its not found.
 +     */
 +    public static _Fields findByName(String name) {
 +      return byName.get(name);
 +    }
 +
 +    private final short _thriftId;
 +    private final String _fieldName;
 +
 +    _Fields(short thriftId, String fieldName) {
 +      _thriftId = thriftId;
 +      _fieldName = fieldName;
 +    }
 +
 +    public short getThriftFieldId() {
 +      return _thriftId;
 +    }
 +
 +    public String getFieldName() {
 +      return _fieldName;
 +    }
 +  }
 +
 +  // isset id assignments
 +  private static final int __TIMESTAMP_ISSET_ID = 0;
 +  private byte __isset_bitfield = 0;
 +  private _Fields optionals[] = {_Fields.TIMESTAMP};
 +  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
 +  static {
 +    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
 +    tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.COL_FAMILY, new org.apache.thrift.meta_data.FieldMetaData("colFamily", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.COL_QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("colQualifier", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.COL_VISIBILITY, new org.apache.thrift.meta_data.FieldMetaData("colVisibility", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
 +    metaDataMap = Collections.unmodifiableMap(tmpMap);
 +    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Key.class, metaDataMap);
 +  }
 +
 +  public Key() {
++    this.timestamp = 9223372036854775807L;
++
 +  }
 +
 +  public Key(
 +    ByteBuffer row,
 +    ByteBuffer colFamily,
 +    ByteBuffer colQualifier,
 +    ByteBuffer colVisibility)
 +  {
 +    this();
 +    this.row = row;
 +    this.colFamily = colFamily;
 +    this.colQualifier = colQualifier;
 +    this.colVisibility = colVisibility;
 +  }
 +
 +  /**
 +   * Performs a deep copy on <i>other</i>.
 +   */
 +  public Key(Key other) {
 +    __isset_bitfield = other.__isset_bitfield;
 +    if (other.isSetRow()) {
 +      this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
 +;
 +    }
 +    if (other.isSetColFamily()) {
 +      this.colFamily = org.apache.thrift.TBaseHelper.copyBinary(other.colFamily);
 +;
 +    }
 +    if (other.isSetColQualifier()) {
 +      this.colQualifier = org.apache.thrift.TBaseHelper.copyBinary(other.colQualifier);
 +;
 +    }
 +    if (other.isSetColVisibility()) {
 +      this.colVisibility = org.apache.thrift.TBaseHelper.copyBinary(other.colVisibility);
 +;
 +    }
 +    this.timestamp = other.timestamp;
 +  }
 +
 +  public Key deepCopy() {
 +    return new Key(this);
 +  }
 +
 +  @Override
 +  public void clear() {
 +    this.row = null;
 +    this.colFamily = null;
 +    this.colQualifier = null;
 +    this.colVisibility = null;
-     setTimestampIsSet(false);
-     this.timestamp = 0;
++    this.timestamp = 9223372036854775807L;
++
 +  }
 +
 +  public byte[] getRow() {
 +    setRow(org.apache.thrift.TBaseHelper.rightSize(row));
 +    return row == null ? null : row.array();
 +  }
 +
 +  public ByteBuffer bufferForRow() {
 +    return row;
 +  }
 +
 +  public Key setRow(byte[] row) {
 +    setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
 +    return this;
 +  }
 +
 +  public Key setRow(ByteBuffer row) {
 +    this.row = row;
 +    return this;
 +  }
 +
 +  public void unsetRow() {
 +    this.row = null;
 +  }
 +
 +  /** Returns true if field row is set (has been assigned a value) and false otherwise */
 +  public boolean isSetRow() {
 +    return this.row != null;
 +  }
 +
 +  public void setRowIsSet(boolean value) {
 +    if (!value) {
 +      this.row = null;
 +    }
 +  }
 +
 +  public byte[] getColFamily() {
 +    setColFamily(org.apache.thrift.TBaseHelper.rightSize(colFamily));
 +    return colFamily == null ? null : colFamily.array();
 +  }
 +
 +  public ByteBuffer bufferForColFamily() {
 +    return colFamily;
 +  }
 +
 +  public Key setColFamily(byte[] colFamily) {
 +    setColFamily(colFamily == null ? (ByteBuffer)null : ByteBuffer.wrap(colFamily));
 +    return this;
 +  }
 +
 +  public Key setColFamily(ByteBuffer colFamily) {
 +    this.colFamily = colFamily;
 +    return this;
 +  }
 +
 +  public void unsetColFamily() {
 +    this.colFamily = null;
 +  }
 +
 +  /** Returns true if field colFamily is set (has been assigned a value) and false otherwise */
 +  public boolean isSetColFamily() {
 +    return this.colFamily != null;
 +  }
 +
 +  public void setColFamilyIsSet(boolean value) {
 +    if (!value) {
 +      this.colFamily = null;
 +    }
 +  }
 +
 +  public byte[] getColQualifier() {
 +    setColQualifier(org.apache.thrift.TBaseHelper.rightSize(colQualifier));
 +    return colQualifier == null ? null : colQualifier.array();
 +  }
 +
 +  public ByteBuffer bufferForColQualifier() {
 +    return colQualifier;
 +  }
 +
 +  public Key setColQualifier(byte[] colQualifier) {
 +    setColQualifier(colQualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(colQualifier));
 +    return this;
 +  }
 +
 +  public Key setColQualifier(ByteBuffer colQualifier) {
 +    this.colQualifier = colQualifier;
 +    return this;
 +  }
 +
 +  public void unsetColQualifier() {
 +    this.colQualifier = null;
 +  }
 +
 +  /** Returns true if field colQualifier is set (has been assigned a value) and false otherwise */
 +  public boolean isSetColQualifier() {
 +    return this.colQualifier != null;
 +  }
 +
 +  public void setColQualifierIsSet(boolean value) {
 +    if (!value) {
 +      this.colQualifier = null;
 +    }
 +  }
 +
 +  public byte[] getColVisibility() {
 +    setColVisibility(org.apache.thrift.TBaseHelper.rightSize(colVisibility));
 +    return colVisibility == null ? null : colVisibility.array();
 +  }
 +
 +  public ByteBuffer bufferForColVisibility() {
 +    return colVisibility;
 +  }
 +
 +  public Key setColVisibility(byte[] colVisibility) {
 +    setColVisibility(colVisibility == null ? (ByteBuffer)null : ByteBuffer.wrap(colVisibility));
 +    return this;
 +  }
 +
 +  public Key setColVisibility(ByteBuffer colVisibility) {
 +    this.colVisibility = colVisibility;
 +    return this;
 +  }
 +
 +  public void unsetColVisibility() {
 +    this.colVisibility = null;
 +  }
 +
 +  /** Returns true if field colVisibility is set (has been assigned a value) and false otherwise */
 +  public boolean isSetColVisibility() {
 +    return this.colVisibility != null;
 +  }
 +
 +  public void setColVisibilityIsSet(boolean value) {
 +    if (!value) {
 +      this.colVisibility = null;
 +    }
 +  }
 +
 +  public long getTimestamp() {
 +    return this.timestamp;
 +  }
 +
 +  public Key setTimestamp(long timestamp) {
 +    this.timestamp = timestamp;
 +    setTimestampIsSet(true);
 +    return this;
 +  }
 +
 +  public void unsetTimestamp() {
 +    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TIMESTAMP_ISSET_ID);
 +  }
 +
 +  /** Returns true if field timestamp is set (has been assigned a value) and false otherwise */
 +  public boolean isSetTimestamp() {
 +    return EncodingUtils.testBit(__isset_bitfield, __TIMESTAMP_ISSET_ID);
 +  }
 +
 +  public void setTimestampIsSet(boolean value) {
 +    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TIMESTAMP_ISSET_ID, value);
 +  }
 +
 +  public void setFieldValue(_Fields field, Object value) {
 +    switch (field) {
 +    case ROW:
 +      if (value == null) {
 +        unsetRow();
 +      } else {
 +        setRow((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case COL_FAMILY:
 +      if (value == null) {
 +        unsetColFamily();
 +      } else {
 +        setColFamily((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case COL_QUALIFIER:
 +      if (value == null) {
 +        unsetColQualifier();
 +      } else {
 +        setColQualifier((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case COL_VISIBILITY:
 +      if (value == null) {
 +        unsetColVisibility();
 +      } else {
 +        setColVisibility((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case TIMESTAMP:
 +      if (value == null) {
 +        unsetTimestamp();
 +      } else {
 +        setTimestamp((Long)value);
 +      }
 +      break;
 +
 +    }
 +  }
 +
 +  public Object getFieldValue(_Fields field) {
 +    switch (field) {
 +    case ROW:
 +      return getRow();
 +
 +    case COL_FAMILY:
 +      return getColFamily();
 +
 +    case COL_QUALIFIER:
 +      return getColQualifier();
 +
 +    case COL_VISIBILITY:
 +      return getColVisibility();
 +
 +    case TIMESTAMP:
 +      return Long.valueOf(getTimestamp());
 +
 +    }
 +    throw new IllegalStateException();
 +  }
 +
 +  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
 +  public boolean isSet(_Fields field) {
 +    if (field == null) {
 +      throw new IllegalArgumentException();
 +    }
 +
 +    switch (field) {
 +    case ROW:
 +      return isSetRow();
 +    case COL_FAMILY:
 +      return isSetColFamily();
 +    case COL_QUALIFIER:
 +      return isSetColQualifier();
 +    case COL_VISIBILITY:
 +      return isSetColVisibility();
 +    case TIMESTAMP:
 +      return isSetTimestamp();
 +    }
 +    throw new IllegalStateException();
 +  }
 +
 +  @Override
 +  public boolean equals(Object that) {
 +    if (that == null)
 +      return false;
 +    if (that instanceof Key)
 +      return this.equals((Key)that);
 +    return false;
 +  }
 +
 +  public boolean equals(Key that) {
 +    if (that == null)
 +      return false;
 +
 +    boolean this_present_row = true && this.isSetRow();
 +    boolean that_present_row = true && that.isSetRow();
 +    if (this_present_row || that_present_row) {
 +      if (!(this_present_row && that_present_row))
 +        return false;
 +      if (!this.row.equals(that.row))
 +        return false;
 +    }
 +
 +    boolean this_present_colFamily = true && this.isSetColFamily();
 +    boolean that_present_colFamily = true && that.isSetColFamily();
 +    if (this_present_colFamily || that_present_colFamily) {
 +      if (!(this_present_colFamily && that_present_colFamily))
 +        return false;
 +      if (!this.colFamily.equals(that.colFamily))
 +        return false;
 +    }
 +
 +    boolean this_present_colQualifier = true && this.isSetColQualifier();
 +    boolean that_present_colQualifier = true && that.isSetColQualifier();
 +    if (this_present_colQualifier || that_present_colQualifier) {
 +      if (!(this_present_colQualifier && that_present_colQualifier))
 +        return false;
 +      if (!this.colQualifier.equals(that.colQualifier))
 +        return false;
 +    }
 +
 +    boolean this_present_colVisibility = true && this.isSetColVisibility();
 +    boolean that_present_colVisibility = true && that.isSetColVisibility();
 +    if (this_present_colVisibility || that_present_colVisibility) {
 +      if (!(this_present_colVisibility && that_present_colVisibility))
 +        return false;
 +      if (!this.colVisibility.equals(that.colVisibility))
 +        return false;
 +    }
 +
 +    boolean this_present_timestamp = true && this.isSetTimestamp();
 +    boolean that_present_timestamp = true && that.isSetTimestamp();
 +    if (this_present_timestamp || that_present_timestamp) {
 +      if (!(this_present_timestamp && that_present_timestamp))
 +        return false;
 +      if (this.timestamp != that.timestamp)
 +        return false;
 +    }
 +
 +    return true;
 +  }
 +
 +  @Override
 +  public int hashCode() {
 +    return 0;
 +  }
 +
 +  public int compareTo(Key other) {
 +    if (!getClass().equals(other.getClass())) {
 +      return getClass().getName().compareTo(other.getClass().getName());
 +    }
 +
 +    int lastComparison = 0;
 +    Key typedOther = (Key)other;
 +
 +    lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetRow()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetColFamily()).compareTo(typedOther.isSetColFamily());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetColFamily()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colFamily, typedOther.colFamily);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetColQualifier()).compareTo(typedOther.isSetColQualifier());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetColQualifier()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colQualifier, typedOther.colQualifier);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetColVisibility()).compareTo(typedOther.isSetColVisibility());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetColVisibility()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colVisibility, typedOther.colVisibility);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetTimestamp()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    return 0;
 +  }
 +
 +  public _Fields fieldForId(int fieldId) {
 +    return _Fields.findByThriftId(fieldId);
 +  }
 +
 +  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
 +    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
 +  }
 +
 +  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
 +    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
 +  }
 +
 +  @Override
 +  public String toString() {
 +    StringBuilder sb = new StringBuilder("Key(");
 +    boolean first = true;
 +
 +    sb.append("row:");
 +    if (this.row == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.row, sb);
 +    }
 +    first = false;
 +    if (!first) sb.append(", ");
 +    sb.append("colFamily:");
 +    if (this.colFamily == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.colFamily, sb);
 +    }
 +    first = false;
 +    if (!first) sb.append(", ");
 +    sb.append("colQualifier:");
 +    if (this.colQualifier == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.colQualifier, sb);
 +    }
 +    first = false;
 +    if (!first) sb.append(", ");
 +    sb.append("colVisibility:");
 +    if (this.colVisibility == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.colVisibility, sb);
 +    }
 +    first = false;
 +    if (isSetTimestamp()) {
 +      if (!first) sb.append(", ");
 +      sb.append("timestamp:");
 +      sb.append(this.timestamp);
 +      first = false;
 +    }
 +    sb.append(")");
 +    return sb.toString();
 +  }
 +
 +  public void validate() throws org.apache.thrift.TException {
 +    // check for required fields
 +    // check for sub-struct validity
 +  }
 +
 +  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
 +    try {
 +      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
 +    } catch (org.apache.thrift.TException te) {
 +      throw new java.io.IOException(te);
 +    }
 +  }
 +
 +  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
 +    try {
 +      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
 +      __isset_bitfield = 0;
 +      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
 +    } catch (org.apache.thrift.TException te) {
 +      throw new java.io.IOException(te);
 +    }
 +  }
 +
 +  private static class KeyStandardSchemeFactory implements SchemeFactory {
 +    public KeyStandardScheme getScheme() {
 +      return new KeyStandardScheme();
 +    }
 +  }
 +
 +  private static class KeyStandardScheme extends StandardScheme<Key> {
 +
 +    public void read(org.apache.thrift.protocol.TProtocol iprot, Key struct) throws org.apache.thrift.TException {
 +      org.apache.thrift.protocol.TField schemeField;
 +      iprot.readStructBegin();
 +      while (true)
 +      {
 +        schemeField = iprot.readFieldBegin();
 +        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
 +          break;
 +        }
 +        switch (schemeField.id) {
 +          case 1: // ROW
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.row = iprot.readBinary();
 +              struct.setRowIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 2: // COL_FAMILY
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.colFamily = iprot.readBinary();
 +              struct.setColFamilyIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 3: // COL_QUALIFIER
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.colQualifier = iprot.readBinary();
 +              struct.setColQualifierIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 4: // COL_VISIBILITY
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.colVisibility = iprot.readBinary();
 +              struct.setColVisibilityIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 5: // TIMESTAMP
 +            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
 +              struct.timestamp = iprot.readI64();
 +              struct.setTimestampIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          default:
 +            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +        }
 +        iprot.readFieldEnd();
 +      }
 +      iprot.readStructEnd();
 +
 +      // check for required fields of primitive type, which can't be checked in the validate method
 +      struct.validate();
 +    }
 +
 +    public void write(org.apache.thrift.protocol.TProtocol oprot, Key struct) throws org.apache.thrift.TException {
 +      struct.validate();
 +
 +      oprot.writeStructBegin(STRUCT_DESC);
 +      if (struct.row != null) {
 +        oprot.writeFieldBegin(ROW_FIELD_DESC);
 +        oprot.writeBinary(struct.row);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.colFamily != null) {
 +        oprot.writeFieldBegin(COL_FAMILY_FIELD_DESC);
 +        oprot.writeBinary(struct.colFamily);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.colQualifier != null) {
 +        oprot.writeFieldBegin(COL_QUALIFIER_FIELD_DESC);
 +        oprot.writeBinary(struct.colQualifier);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.colVisibility != null) {
 +        oprot.writeFieldBegin(COL_VISIBILITY_FIELD_DESC);
 +        oprot.writeBinary(struct.colVisibility);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.isSetTimestamp()) {
 +        oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
 +        oprot.writeI64(struct.timestamp);
 +        oprot.writeFieldEnd();
 +      }
 +      oprot.writeFieldStop();
 +      oprot.writeStructEnd();
 +    }
 +
 +  }
 +
 +  private static class KeyTupleSchemeFactory implements SchemeFactory {
 +    public KeyTupleScheme getScheme() {
 +      return new KeyTupleScheme();
 +    }
 +  }
 +
 +  private static class KeyTupleScheme extends TupleScheme<Key> {
 +
 +    @Override
 +    public void write(org.apache.thrift.protocol.TProtocol prot, Key struct) throws org.apache.thrift.TException {
 +      TTupleProtocol oprot = (TTupleProtocol) prot;
 +      BitSet optionals = new BitSet();
 +      if (struct.isSetRow()) {
 +        optionals.set(0);
 +      }
 +      if (struct.isSetColFamily()) {
 +        optionals.set(1);
 +      }
 +      if (struct.isSetColQualifier()) {
 +        optionals.set(2);
 +      }
 +      if (struct.isSetColVisibility()) {
 +        optionals.set(3);
 +      }
 +      if (struct.isSetTimestamp()) {
 +        optionals.set(4);
 +      }
 +      oprot.writeBitSet(optionals, 5);
 +      if (struct.isSetRow()) {
 +        oprot.writeBinary(struct.row);
 +      }
 +      if (struct.isSetColFamily()) {
 +        oprot.writeBinary(struct.colFamily);
 +      }
 +      if (struct.isSetColQualifier()) {
 +        oprot.writeBinary(struct.colQualifier);
 +      }
 +      if (struct.isSetColVisibility()) {
 +        oprot.writeBinary(struct.colVisibility);
 +      }
 +      if (struct.isSetTimestamp()) {
 +        oprot.writeI64(struct.timestamp);
 +      }
 +    }
 +
 +    @Override
 +    public void read(org.apache.thrift.protocol.TProtocol prot, Key struct) throws org.apache.thrift.TException {
 +      TTupleProtocol iprot = (TTupleProtocol) prot;
 +      BitSet incoming = iprot.readBitSet(5);
 +      if (incoming.get(0)) {
 +        struct.row = iprot.readBinary();
 +        struct.setRowIsSet(true);
 +      }
 +      if (incoming.get(1)) {
 +        struct.colFamily = iprot.readBinary();
 +        struct.setColFamilyIsSet(true);
 +      }
 +      if (incoming.get(2)) {
 +        struct.colQualifier = iprot.readBinary();
 +        struct.setColQualifierIsSet(true);
 +      }
 +      if (incoming.get(3)) {
 +        struct.colVisibility = iprot.readBinary();
 +        struct.setColVisibilityIsSet(true);
 +      }
 +      if (incoming.get(4)) {
 +        struct.timestamp = iprot.readI64();
 +        struct.setTimestampIsSet(true);
 +      }
 +    }
 +  }
 +
 +}
 +

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/main/thrift/proxy.thrift
----------------------------------------------------------------------
diff --cc proxy/src/main/thrift/proxy.thrift
index 8d3c87d,0000000..7fd2c3f
mode 100644,000000..100644
--- a/proxy/src/main/thrift/proxy.thrift
+++ b/proxy/src/main/thrift/proxy.thrift
@@@ -1,342 -1,0 +1,344 @@@
 +/*
 +* 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.
 +*/
 +namespace cpp accumulo
 +namespace java org.apache.accumulo.proxy.thrift
++namespace rb Accumulo
++namespace py accumulo
 +
 +struct Key {
 +  1:binary row;
 +  2:binary colFamily;
 +  3:binary colQualifier;
 +  4:binary colVisibility;
-   5:optional i64 timestamp
++  5:optional i64 timestamp = 0x7FFFFFFFFFFFFFFF
 +}
 +
 +enum PartialKey {
 +  ROW,
 +  ROW_COLFAM,
 +  ROW_COLFAM_COLQUAL,
 +  ROW_COLFAM_COLQUAL_COLVIS,
 +  ROW_COLFAM_COLQUAL_COLVIS_TIME,
 +  ROW_COLFAM_COLQUAL_COLVIS_TIME_DEL
 +}
 +
 +struct ColumnUpdate {
 +  1:binary colFamily,
 +  2:binary colQualifier,
 +  3:optional binary colVisibility,
 +  4:optional i64 timestamp,
 +  5:optional binary value,
 +  6:optional bool deleteCell
 +}
 +
 +struct KeyValue {
 +  1:Key key,
 +  2:binary value
 +}
 +
 +struct ScanResult {
 +  1:list<KeyValue> results,
 +  2:bool more
 +}
 +
 +struct Range {
 +  1:Key start,
 +  2:bool startInclusive
 +  3:Key stop,
 +  4:bool stopInclusive
 +}
 +
 +struct ScanColumn {
 +  1:binary colFamily,
 +  2:optional binary colQualifier
 +}
 +
 +struct IteratorSetting {
 +  1: i32 priority,
 +  2: string name,
 +  3: string iteratorClass,
 +  4: map<string,string> properties
 +}
 +
 +struct ScanOptions {
 +  1:optional set<binary> authorizations;
 +  2:optional Range range,
 +  3:optional list<ScanColumn> columns;
 +  4:optional list<IteratorSetting> iterators;
 +  5:optional i32 bufferSize;
 +} 
 +
 +struct BatchScanOptions {
 +  1:optional set<binary> authorizations;
 +  2:optional list<Range> ranges;
 +  3:optional list<ScanColumn> columns;
 +  4:optional list<IteratorSetting> iterators;
 +  5:optional i32 threads;
 +} 
 +
 +struct KeyValueAndPeek {
 +  1:KeyValue keyValue,
 +  2:bool hasNext
 +}
 +
 +enum TablePermission {
 +  READ = 2,
 +  WRITE = 3,
 +  BULK_IMPORT = 4,
 +  ALTER_TABLE = 5,
 +  GRANT = 6,
 +  DROP_TABLE = 7,
 +}
 +
 +enum SystemPermission {
 +  GRANT = 0,
 +  CREATE_TABLE = 1,
 +  DROP_TABLE = 2,
 +  ALTER_TABLE = 3,
 +  CREATE_USER = 4,
 +  DROP_USER = 5,
 +  ALTER_USER = 6,
 +  SYSTEM = 7,
 +}
 +
 +enum ScanType {
 +    SINGLE,
 +    BATCH
 +}
 +
 +enum ScanState {
 +    IDLE,
 +    RUNNING,
 +    QUEUED
 +}
 +
 +struct KeyExtent {
 +  1:string tableId,
 +  2:binary endRow,
 +  3:binary prevEndRow
 +}
 +
 +struct Column {
 +  1:binary colFamily;
 +  2:binary colQualifier;
 +  3:binary colVisibility;
 +}
 +
 +struct ActiveScan {
 +  1:string client
 +  2:string user
 +  3:string table
 +  4:i64 age
 +  5:i64 idleTime
 +  6:ScanType type
 +  7:ScanState state
 +  8:KeyExtent extent
 +  9:list<Column> columns
 +  10:list<IteratorSetting> iterators
 +  11:list<binary> authorizations
 +}
 +
 +enum CompactionType {
 +   MINOR,
 +   MERGE,
 +   MAJOR,
 +   FULL
 +}
 +
 +enum CompactionReason {
 +   USER,
 +   SYSTEM,
 +   CHOP,
 +   IDLE,
 +   CLOSE
 +}
 +
 +struct ActiveCompaction {
 +  1:KeyExtent extent
 +  2:i64 age
 +  3:list<string> inputFiles
 +  4:string outputFile
 +  5:CompactionType type
 +  6:CompactionReason reason
 +  7:string localityGroup
 +  8:i64 entriesRead
 +  9:i64 entriesWritten
 +  10:list<IteratorSetting> iterators;
 +}
 +
 +struct WriterOptions {
 + 1:i64 maxMemory
 + 2:i64 latencyMs
 + 3:i64 timeoutMs
 + 4:i32 threads
 +}
 +
 +enum IteratorScope {
 +  MINC,
 +  MAJC,
 +  SCAN
 +}
 +
 +enum TimeType {
 +  LOGICAL,
 +  MILLIS
 +}
 +
 +exception UnknownScanner {
 +  1:string msg
 +}
 +
 +exception UnknownWriter {
 +  1:string msg
 +}
 +
 +exception NoMoreEntriesException {
 +  1:string msg
 +}
 +
 +exception AccumuloException {
 +  1:string msg
 +}
 +
 +exception AccumuloSecurityException {
 +  1:string msg
 +}
 +
 +exception TableNotFoundException {
 +  1:string msg
 +}
 +
 +exception TableExistsException {
 +  1:string msg
 +}
 +
 +exception MutationsRejectedException {
 +  1:string msg
 +}
 +
 +service AccumuloProxy
 +{
 +  // get an authentication token
 +  binary login(1:string principal, 2:map<string, string> loginProperties)                              throws (1:AccumuloSecurityException ouch2);
 +
 +  // table operations
 +  i32 addConstraint (1:binary login, 2:string tableName, 3:string constraintClassName)                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void addSplits (1:binary login, 2:string tableName, 3:set<binary> splits)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void attachIterator (1:binary login, 2:string tableName, 3:IteratorSetting setting, 
 +                       4:set<IteratorScope> scopes) 
 +                                                                                                       throws (1:AccumuloSecurityException ouch1, 2:AccumuloException ouch2, 3:TableNotFoundException ouch3);
 +  void checkIteratorConflicts (1:binary login, 2:string tableName, 3:IteratorSetting setting, 
 +                               4:set<IteratorScope> scopes) 
 +                                                                                                       throws (1:AccumuloSecurityException ouch1, 2:AccumuloException ouch2, 3:TableNotFoundException ouch3);
 +  void clearLocatorCache (1:binary login, 2:string tableName)                                          throws (1:TableNotFoundException ouch1);
 +  void cloneTable (1:binary login, 2:string tableName, 3:string newTableName, 4:bool flush, 
 +                   5:map<string,string> propertiesToSet, 6:set<string> propertiesToExclude) 
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:TableExistsException ouch4);
 +  void compactTable (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow, 
 +		     5:list<IteratorSetting> iterators, 6:bool flush, 7:bool wait)                             throws (1:AccumuloSecurityException ouch1, 2:TableNotFoundException ouch2, 3:AccumuloException ouch3);
 +  void cancelCompaction(1:binary login, 2:string tableName)                                            throws (1:AccumuloSecurityException ouch1, 2:TableNotFoundException ouch2, 3:AccumuloException ouch3);
 +                                                                                                            
 +  void createTable (1:binary login, 2:string tableName, 3:bool versioningIter, 4:TimeType type)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableExistsException ouch3);
 +  void deleteTable (1:binary login, 2:string tableName)                                                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void deleteRows (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow)             throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void exportTable (1:binary login, 2:string tableName, 3:string exportDir)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void flushTable (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow, 
 +                   5:bool wait)
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  map<string,set<string>> getLocalityGroups (1:binary login, 2:string tableName)                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  IteratorSetting getIteratorSetting (1:binary login, 2:string tableName, 
 +                                      3:string iteratorName, 4:IteratorScope scope) 
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  binary getMaxRow (1:binary login, 2:string tableName, 3:set<binary> auths, 4:binary startRow, 
 +                    5:bool startInclusive, 6:binary endRow, 7:bool endInclusive) 
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  map<string,string> getTableProperties (1:binary login, 2:string tableName)                           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void importDirectory (1:binary login, 2:string tableName, 3:string importDir, 
 +                        4:string failureDir, 5:bool setTime) 
 +                                                                                                       throws (1:TableNotFoundException ouch1, 2:AccumuloException ouch3, 3:AccumuloSecurityException ouch4);
 +  void importTable (1:binary login, 2:string tableName, 3:string importDir)                            throws (1:TableExistsException ouch1, 2:AccumuloException ouch2, 3:AccumuloSecurityException ouch3);
 +  list<binary> listSplits (1:binary login, 2:string tableName, 3:i32 maxSplits)                        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  set<string> listTables (1:binary login);
 +  map<string,set<IteratorScope>> listIterators (1:binary login, 2:string tableName)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  map<string,i32> listConstraints (1:binary login, 2:string tableName)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void mergeTablets (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow)           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void offlineTable (1:binary login, 2:string tableName)                                               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void onlineTable (1:binary login, 2:string tableName)                                                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void removeConstraint (1:binary login, 2:string tableName, 3:i32 constraint)                         throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void removeIterator (1:binary login, 2:string tableName, 3:string iterName, 
 +                       4:set<IteratorScope> scopes)
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void removeTableProperty (1:binary login, 2:string tableName, 3:string property)                     throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void renameTable (1:binary login, 2:string oldTableName, 3:string newTableName)                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:TableExistsException ouch4);
 +  void setLocalityGroups (1:binary login, 2:string tableName, 3:map<string,set<string>> groups)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void setTableProperty (1:binary login, 2:string tableName, 3:string property, 4:string value)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  set<Range> splitRangeByTablets (1:binary login, 2:string tableName, 3:Range range, 4:i32 maxSplits)  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  bool tableExists (1:binary login, 2:string tableName);
 +  map<string,string> tableIdMap (1:binary login);
 +  bool testTableClassLoad (1:binary login, 2:string tableName, 3:string className                     
 +                           , 4:string asTypeName)                                                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +  // instance operations
 +  void pingTabletServer(1:binary login, 2:string tserver)                                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<ActiveScan> getActiveScans (1:binary login, 2:string tserver)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<ActiveCompaction> getActiveCompactions(1:binary login, 2:string tserver)                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  map<string,string> getSiteConfiguration (1:binary login)                                           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  map<string,string> getSystemConfiguration (1:binary login)                                         throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<string> getTabletServers (1:binary login);
 +  void removeProperty (1:binary login, 2:string property)                                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void setProperty (1:binary login, 2:string property, 3:string value)                               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  bool testClassLoad (1:binary login, 2:string className, 3:string asTypeName)                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +
 +  // security operations
 +  bool authenticateUser (1:binary login, 2:string user, 3:map<string, string> properties)            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void changeUserAuthorizations (1:binary login, 2:string user, 3:set<binary> authorizations)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void changeLocalUserPassword (1:binary login, 2:string user, 3:binary password)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void createLocalUser (1:binary login, 2:string user, 3:binary password)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void dropLocalUser (1:binary login, 2:string user)                                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<binary> getUserAuthorizations (1:binary login, 2:string user)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void grantSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void grantTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm)  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  bool hasSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)                  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  bool hasTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm)    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  set<string> listLocalUsers (1:binary login)                                                        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void revokeSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void revokeTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm) throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +
 +  // scanning
 +  string createBatchScanner(1:binary login, 2:string tableName, 3:BatchScanOptions options)          throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  string createScanner(1:binary login, 2:string tableName, 3:ScanOptions options)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +  // use the scanner
 +  bool hasNext(1:string scanner)                        throws(1:UnknownScanner ouch1);
 +  KeyValueAndPeek nextEntry(1:string scanner)           throws(1:NoMoreEntriesException ouch1, 2:UnknownScanner ouch2, 3:AccumuloSecurityException ouch3);
 +  ScanResult nextK(1:string scanner, 2:i32 k)           throws(1:NoMoreEntriesException ouch1, 2:UnknownScanner ouch2, 3:AccumuloSecurityException ouch3);
 +  void closeScanner(1:string scanner)                   throws(1:UnknownScanner ouch1);
 +
 +  // writing
 +  void updateAndFlush(1:binary login, 2:string tableName, 3:map<binary, list<ColumnUpdate>> cells) throws(1:AccumuloException outch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:MutationsRejectedException ouch4);
 +  string createWriter(1:binary login, 2:string tableName, 3:WriterOptions opts)                    throws(1:AccumuloException outch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +  // use the writer
 +  oneway void update(1:string writer, 2:map<binary, list<ColumnUpdate>> cells);
 +  void flush(1:string writer)                                                                      throws (1:UnknownWriter ouch1, 2:MutationsRejectedException ouch2);
 +  void closeWriter(1:string writer)                                                                throws (1:UnknownWriter ouch1, 2:MutationsRejectedException ouch2);
 +
 +  // utilities
 +  Range getRowRange(1:binary row);
 +  Key getFollowing(1:Key key, 2:PartialKey part);
 +}


[03/10] git commit: ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it)

Posted by ec...@apache.org.
ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it)


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/27ee2367
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/27ee2367
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/27ee2367

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 27ee2367056e5ad0cb6175f91154cd13d49e2c95
Parents: 0b6749a
Author: Eric Newton <er...@gmail.com>
Authored: Thu Jan 2 12:02:00 2014 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Thu Jan 2 12:02:00 2014 -0500

----------------------------------------------------------------------
 src/proxy/examples/python/TestClient.py         |  4 ++--
 src/proxy/examples/ruby/test_client.rb          |  8 ++++----
 .../org/apache/accumulo/proxy/ProxyServer.java  |  6 ++----
 .../org/apache/accumulo/proxy/thrift/Key.java   |  6 ++++--
 src/proxy/src/main/thrift/proxy.thrift          |  4 +++-
 .../org/apache/accumulo/proxy/SimpleTest.java   | 20 ++++++++++++++++++++
 6 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/python/TestClient.py
----------------------------------------------------------------------
diff --git a/src/proxy/examples/python/TestClient.py b/src/proxy/examples/python/TestClient.py
index 7ecf367..5509ded 100644
--- a/src/proxy/examples/python/TestClient.py
+++ b/src/proxy/examples/python/TestClient.py
@@ -21,8 +21,8 @@ from thrift.transport import TSocket
 from thrift.transport import TTransport
 from thrift.protocol import TCompactProtocol
 
-from proxy import AccumuloProxy
-from proxy.ttypes import *
+from accumulo import AccumuloProxy
+from accumulo.ttypes import *
 
 transport = TSocket.TSocket('localhost', 42424)
 transport = TTransport.TFramedTransport(transport)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/ruby/test_client.rb
----------------------------------------------------------------------
diff --git a/src/proxy/examples/ruby/test_client.rb b/src/proxy/examples/ruby/test_client.rb
index d5ee5f5..6310a2f 100644
--- a/src/proxy/examples/ruby/test_client.rb
+++ b/src/proxy/examples/ruby/test_client.rb
@@ -23,7 +23,7 @@ server = ARGV[0] || 'localhost'
 socket = Thrift::Socket.new(server, 42424, 9001)
 transport = Thrift::FramedTransport.new(socket)
 proto = Thrift::CompactProtocol.new(transport)
-proxy = AccumuloProxy::Client.new(proto)
+proxy = Accumulo::AccumuloProxy::Client.new(proto)
 
 # open up the connect
 transport.open()
@@ -35,10 +35,10 @@ login = proxy.login('root', {'password' => 'secret'})
 puts "List of tables: #{proxy.listTables(login).inspect}"
 
 testtable = "rubytest"
-proxy.createTable(login, testtable, true, TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
+proxy.createTable(login, testtable, true, Accumulo::TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
 
-update1 = ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
-update2 = ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
+update1 = Accumulo::ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
+update2 = Accumulo::ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
 proxy.updateAndFlush(login,testtable,{'row1' => [update1,update2]})
 
 cookie = proxy.createScanner(login,testtable,nil)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index d749723..bf050e4 100644
--- a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -1328,6 +1328,7 @@ public class ProxyServer implements AccumuloProxy.Iface {
       return null;
     org.apache.accumulo.proxy.thrift.Key result = new org.apache.accumulo.proxy.thrift.Key(TextUtil.getByteBuffer(k.getRow()), TextUtil.getByteBuffer(k
         .getColumnFamily()), TextUtil.getByteBuffer(k.getColumnQualifier()), TextUtil.getByteBuffer(k.getColumnVisibility()));
+    result.setTimestamp(k.getTimestamp());
     return result;
   }
   
@@ -1346,12 +1347,9 @@ public class ProxyServer implements AccumuloProxy.Iface {
     }
   }
   
-  static private final ByteBuffer EMPTY = ByteBuffer.wrap(new byte[] {});
-  
   @Override
   public org.apache.accumulo.proxy.thrift.Range getRowRange(ByteBuffer row) throws TException {
-    return new org.apache.accumulo.proxy.thrift.Range(new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true,
-        new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true);
+    return getRange(new Range(ByteBufferUtil.toText(row)));
   }
   
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
index 5d8a31c..422149c 100644
--- a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
+++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
@@ -143,6 +143,8 @@ import org.slf4j.LoggerFactory;
   }
 
   public Key() {
+    this.timestamp = 9223372036854775807L;
+
   }
 
   public Key(
@@ -193,8 +195,8 @@ import org.slf4j.LoggerFactory;
     this.colFamily = null;
     this.colQualifier = null;
     this.colVisibility = null;
-    setTimestampIsSet(false);
-    this.timestamp = 0;
+    this.timestamp = 9223372036854775807L;
+
   }
 
   public byte[] getRow() {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/thrift/proxy.thrift
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/thrift/proxy.thrift b/src/proxy/src/main/thrift/proxy.thrift
index 1cebf55..872e253 100644
--- a/src/proxy/src/main/thrift/proxy.thrift
+++ b/src/proxy/src/main/thrift/proxy.thrift
@@ -16,13 +16,15 @@
 */
 namespace cpp accumulo
 namespace java org.apache.accumulo.proxy.thrift
+namespace rb Accumulo
+namespace py accumulo
 
 struct Key {
   1:binary row;
   2:binary colFamily;
   3:binary colQualifier;
   4:binary colVisibility;
-  5:optional i64 timestamp
+  5:optional i64 timestamp = 0x7FFFFFFFFFFFFFFF
 }
 
 enum PartialKey {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index d3b45ae..67b36a6 100644
--- a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@ -798,6 +798,26 @@ public class SimpleTest {
     return toRet;
   }
   
+  static private ByteBuffer t2bb(Text t) {
+    return ByteBuffer.wrap(t.getBytes());
+  }
+  
+  @Test
+  public void testGetRowRange() throws Exception {
+    Range range = client.getRowRange(s2bb("xyzzy"));
+    org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy")); 
+    assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow())));
+    assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow())));
+    assertEquals(range.startInclusive, range2.isStartKeyInclusive());
+    assertEquals(range.stopInclusive, range2.isEndKeyInclusive());
+    assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily())));
+    assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier())));
+    assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily())));
+    assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier())));
+    assertEquals(range.start.timestamp, range.start.timestamp);
+    assertEquals(range.stop.timestamp, range.stop.timestamp);
+  }
+  
   @AfterClass
   public static void tearDownMiniCluster() throws Exception {
     accumulo.stop();


[08/10] Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
----------------------------------------------------------------------
diff --cc proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
index 1a677a1,0000000..80f2ecd
mode 100644,000000..100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
@@@ -1,846 -1,0 +1,848 @@@
 +/*
 + * 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.
 + */
 +/**
 + * Autogenerated by Thrift Compiler (0.9.0)
 + *
 + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 + *  @generated
 + */
 +package org.apache.accumulo.proxy.thrift;
 +
 +import org.apache.thrift.scheme.IScheme;
 +import org.apache.thrift.scheme.SchemeFactory;
 +import org.apache.thrift.scheme.StandardScheme;
 +
 +import org.apache.thrift.scheme.TupleScheme;
 +import org.apache.thrift.protocol.TTupleProtocol;
 +import org.apache.thrift.protocol.TProtocolException;
 +import org.apache.thrift.EncodingUtils;
 +import org.apache.thrift.TException;
 +import java.util.List;
 +import java.util.ArrayList;
 +import java.util.Map;
 +import java.util.HashMap;
 +import java.util.EnumMap;
 +import java.util.Set;
 +import java.util.HashSet;
 +import java.util.EnumSet;
 +import java.util.Collections;
 +import java.util.BitSet;
 +import java.nio.ByteBuffer;
 +import java.util.Arrays;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +@SuppressWarnings("all") public class Key implements org.apache.thrift.TBase<Key, Key._Fields>, java.io.Serializable, Cloneable {
 +  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Key");
 +
 +  private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
 +  private static final org.apache.thrift.protocol.TField COL_FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("colFamily", org.apache.thrift.protocol.TType.STRING, (short)2);
 +  private static final org.apache.thrift.protocol.TField COL_QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("colQualifier", org.apache.thrift.protocol.TType.STRING, (short)3);
 +  private static final org.apache.thrift.protocol.TField COL_VISIBILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("colVisibility", org.apache.thrift.protocol.TType.STRING, (short)4);
 +  private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)5);
 +
 +  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
 +  static {
 +    schemes.put(StandardScheme.class, new KeyStandardSchemeFactory());
 +    schemes.put(TupleScheme.class, new KeyTupleSchemeFactory());
 +  }
 +
 +  public ByteBuffer row; // required
 +  public ByteBuffer colFamily; // required
 +  public ByteBuffer colQualifier; // required
 +  public ByteBuffer colVisibility; // required
 +  public long timestamp; // optional
 +
 +  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
 +  @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
 +    ROW((short)1, "row"),
 +    COL_FAMILY((short)2, "colFamily"),
 +    COL_QUALIFIER((short)3, "colQualifier"),
 +    COL_VISIBILITY((short)4, "colVisibility"),
 +    TIMESTAMP((short)5, "timestamp");
 +
 +    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 +
 +    static {
 +      for (_Fields field : EnumSet.allOf(_Fields.class)) {
 +        byName.put(field.getFieldName(), field);
 +      }
 +    }
 +
 +    /**
 +     * Find the _Fields constant that matches fieldId, or null if its not found.
 +     */
 +    public static _Fields findByThriftId(int fieldId) {
 +      switch(fieldId) {
 +        case 1: // ROW
 +          return ROW;
 +        case 2: // COL_FAMILY
 +          return COL_FAMILY;
 +        case 3: // COL_QUALIFIER
 +          return COL_QUALIFIER;
 +        case 4: // COL_VISIBILITY
 +          return COL_VISIBILITY;
 +        case 5: // TIMESTAMP
 +          return TIMESTAMP;
 +        default:
 +          return null;
 +      }
 +    }
 +
 +    /**
 +     * Find the _Fields constant that matches fieldId, throwing an exception
 +     * if it is not found.
 +     */
 +    public static _Fields findByThriftIdOrThrow(int fieldId) {
 +      _Fields fields = findByThriftId(fieldId);
 +      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
 +      return fields;
 +    }
 +
 +    /**
 +     * Find the _Fields constant that matches name, or null if its not found.
 +     */
 +    public static _Fields findByName(String name) {
 +      return byName.get(name);
 +    }
 +
 +    private final short _thriftId;
 +    private final String _fieldName;
 +
 +    _Fields(short thriftId, String fieldName) {
 +      _thriftId = thriftId;
 +      _fieldName = fieldName;
 +    }
 +
 +    public short getThriftFieldId() {
 +      return _thriftId;
 +    }
 +
 +    public String getFieldName() {
 +      return _fieldName;
 +    }
 +  }
 +
 +  // isset id assignments
 +  private static final int __TIMESTAMP_ISSET_ID = 0;
 +  private byte __isset_bitfield = 0;
 +  private _Fields optionals[] = {_Fields.TIMESTAMP};
 +  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
 +  static {
 +    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
 +    tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.COL_FAMILY, new org.apache.thrift.meta_data.FieldMetaData("colFamily", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.COL_QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("colQualifier", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.COL_VISIBILITY, new org.apache.thrift.meta_data.FieldMetaData("colVisibility", org.apache.thrift.TFieldRequirementType.DEFAULT, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
 +    tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
 +        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
 +    metaDataMap = Collections.unmodifiableMap(tmpMap);
 +    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Key.class, metaDataMap);
 +  }
 +
 +  public Key() {
++    this.timestamp = 9223372036854775807L;
++
 +  }
 +
 +  public Key(
 +    ByteBuffer row,
 +    ByteBuffer colFamily,
 +    ByteBuffer colQualifier,
 +    ByteBuffer colVisibility)
 +  {
 +    this();
 +    this.row = row;
 +    this.colFamily = colFamily;
 +    this.colQualifier = colQualifier;
 +    this.colVisibility = colVisibility;
 +  }
 +
 +  /**
 +   * Performs a deep copy on <i>other</i>.
 +   */
 +  public Key(Key other) {
 +    __isset_bitfield = other.__isset_bitfield;
 +    if (other.isSetRow()) {
 +      this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
 +;
 +    }
 +    if (other.isSetColFamily()) {
 +      this.colFamily = org.apache.thrift.TBaseHelper.copyBinary(other.colFamily);
 +;
 +    }
 +    if (other.isSetColQualifier()) {
 +      this.colQualifier = org.apache.thrift.TBaseHelper.copyBinary(other.colQualifier);
 +;
 +    }
 +    if (other.isSetColVisibility()) {
 +      this.colVisibility = org.apache.thrift.TBaseHelper.copyBinary(other.colVisibility);
 +;
 +    }
 +    this.timestamp = other.timestamp;
 +  }
 +
 +  public Key deepCopy() {
 +    return new Key(this);
 +  }
 +
 +  @Override
 +  public void clear() {
 +    this.row = null;
 +    this.colFamily = null;
 +    this.colQualifier = null;
 +    this.colVisibility = null;
-     setTimestampIsSet(false);
-     this.timestamp = 0;
++    this.timestamp = 9223372036854775807L;
++
 +  }
 +
 +  public byte[] getRow() {
 +    setRow(org.apache.thrift.TBaseHelper.rightSize(row));
 +    return row == null ? null : row.array();
 +  }
 +
 +  public ByteBuffer bufferForRow() {
 +    return row;
 +  }
 +
 +  public Key setRow(byte[] row) {
 +    setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
 +    return this;
 +  }
 +
 +  public Key setRow(ByteBuffer row) {
 +    this.row = row;
 +    return this;
 +  }
 +
 +  public void unsetRow() {
 +    this.row = null;
 +  }
 +
 +  /** Returns true if field row is set (has been assigned a value) and false otherwise */
 +  public boolean isSetRow() {
 +    return this.row != null;
 +  }
 +
 +  public void setRowIsSet(boolean value) {
 +    if (!value) {
 +      this.row = null;
 +    }
 +  }
 +
 +  public byte[] getColFamily() {
 +    setColFamily(org.apache.thrift.TBaseHelper.rightSize(colFamily));
 +    return colFamily == null ? null : colFamily.array();
 +  }
 +
 +  public ByteBuffer bufferForColFamily() {
 +    return colFamily;
 +  }
 +
 +  public Key setColFamily(byte[] colFamily) {
 +    setColFamily(colFamily == null ? (ByteBuffer)null : ByteBuffer.wrap(colFamily));
 +    return this;
 +  }
 +
 +  public Key setColFamily(ByteBuffer colFamily) {
 +    this.colFamily = colFamily;
 +    return this;
 +  }
 +
 +  public void unsetColFamily() {
 +    this.colFamily = null;
 +  }
 +
 +  /** Returns true if field colFamily is set (has been assigned a value) and false otherwise */
 +  public boolean isSetColFamily() {
 +    return this.colFamily != null;
 +  }
 +
 +  public void setColFamilyIsSet(boolean value) {
 +    if (!value) {
 +      this.colFamily = null;
 +    }
 +  }
 +
 +  public byte[] getColQualifier() {
 +    setColQualifier(org.apache.thrift.TBaseHelper.rightSize(colQualifier));
 +    return colQualifier == null ? null : colQualifier.array();
 +  }
 +
 +  public ByteBuffer bufferForColQualifier() {
 +    return colQualifier;
 +  }
 +
 +  public Key setColQualifier(byte[] colQualifier) {
 +    setColQualifier(colQualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(colQualifier));
 +    return this;
 +  }
 +
 +  public Key setColQualifier(ByteBuffer colQualifier) {
 +    this.colQualifier = colQualifier;
 +    return this;
 +  }
 +
 +  public void unsetColQualifier() {
 +    this.colQualifier = null;
 +  }
 +
 +  /** Returns true if field colQualifier is set (has been assigned a value) and false otherwise */
 +  public boolean isSetColQualifier() {
 +    return this.colQualifier != null;
 +  }
 +
 +  public void setColQualifierIsSet(boolean value) {
 +    if (!value) {
 +      this.colQualifier = null;
 +    }
 +  }
 +
 +  public byte[] getColVisibility() {
 +    setColVisibility(org.apache.thrift.TBaseHelper.rightSize(colVisibility));
 +    return colVisibility == null ? null : colVisibility.array();
 +  }
 +
 +  public ByteBuffer bufferForColVisibility() {
 +    return colVisibility;
 +  }
 +
 +  public Key setColVisibility(byte[] colVisibility) {
 +    setColVisibility(colVisibility == null ? (ByteBuffer)null : ByteBuffer.wrap(colVisibility));
 +    return this;
 +  }
 +
 +  public Key setColVisibility(ByteBuffer colVisibility) {
 +    this.colVisibility = colVisibility;
 +    return this;
 +  }
 +
 +  public void unsetColVisibility() {
 +    this.colVisibility = null;
 +  }
 +
 +  /** Returns true if field colVisibility is set (has been assigned a value) and false otherwise */
 +  public boolean isSetColVisibility() {
 +    return this.colVisibility != null;
 +  }
 +
 +  public void setColVisibilityIsSet(boolean value) {
 +    if (!value) {
 +      this.colVisibility = null;
 +    }
 +  }
 +
 +  public long getTimestamp() {
 +    return this.timestamp;
 +  }
 +
 +  public Key setTimestamp(long timestamp) {
 +    this.timestamp = timestamp;
 +    setTimestampIsSet(true);
 +    return this;
 +  }
 +
 +  public void unsetTimestamp() {
 +    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TIMESTAMP_ISSET_ID);
 +  }
 +
 +  /** Returns true if field timestamp is set (has been assigned a value) and false otherwise */
 +  public boolean isSetTimestamp() {
 +    return EncodingUtils.testBit(__isset_bitfield, __TIMESTAMP_ISSET_ID);
 +  }
 +
 +  public void setTimestampIsSet(boolean value) {
 +    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TIMESTAMP_ISSET_ID, value);
 +  }
 +
 +  public void setFieldValue(_Fields field, Object value) {
 +    switch (field) {
 +    case ROW:
 +      if (value == null) {
 +        unsetRow();
 +      } else {
 +        setRow((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case COL_FAMILY:
 +      if (value == null) {
 +        unsetColFamily();
 +      } else {
 +        setColFamily((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case COL_QUALIFIER:
 +      if (value == null) {
 +        unsetColQualifier();
 +      } else {
 +        setColQualifier((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case COL_VISIBILITY:
 +      if (value == null) {
 +        unsetColVisibility();
 +      } else {
 +        setColVisibility((ByteBuffer)value);
 +      }
 +      break;
 +
 +    case TIMESTAMP:
 +      if (value == null) {
 +        unsetTimestamp();
 +      } else {
 +        setTimestamp((Long)value);
 +      }
 +      break;
 +
 +    }
 +  }
 +
 +  public Object getFieldValue(_Fields field) {
 +    switch (field) {
 +    case ROW:
 +      return getRow();
 +
 +    case COL_FAMILY:
 +      return getColFamily();
 +
 +    case COL_QUALIFIER:
 +      return getColQualifier();
 +
 +    case COL_VISIBILITY:
 +      return getColVisibility();
 +
 +    case TIMESTAMP:
 +      return Long.valueOf(getTimestamp());
 +
 +    }
 +    throw new IllegalStateException();
 +  }
 +
 +  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
 +  public boolean isSet(_Fields field) {
 +    if (field == null) {
 +      throw new IllegalArgumentException();
 +    }
 +
 +    switch (field) {
 +    case ROW:
 +      return isSetRow();
 +    case COL_FAMILY:
 +      return isSetColFamily();
 +    case COL_QUALIFIER:
 +      return isSetColQualifier();
 +    case COL_VISIBILITY:
 +      return isSetColVisibility();
 +    case TIMESTAMP:
 +      return isSetTimestamp();
 +    }
 +    throw new IllegalStateException();
 +  }
 +
 +  @Override
 +  public boolean equals(Object that) {
 +    if (that == null)
 +      return false;
 +    if (that instanceof Key)
 +      return this.equals((Key)that);
 +    return false;
 +  }
 +
 +  public boolean equals(Key that) {
 +    if (that == null)
 +      return false;
 +
 +    boolean this_present_row = true && this.isSetRow();
 +    boolean that_present_row = true && that.isSetRow();
 +    if (this_present_row || that_present_row) {
 +      if (!(this_present_row && that_present_row))
 +        return false;
 +      if (!this.row.equals(that.row))
 +        return false;
 +    }
 +
 +    boolean this_present_colFamily = true && this.isSetColFamily();
 +    boolean that_present_colFamily = true && that.isSetColFamily();
 +    if (this_present_colFamily || that_present_colFamily) {
 +      if (!(this_present_colFamily && that_present_colFamily))
 +        return false;
 +      if (!this.colFamily.equals(that.colFamily))
 +        return false;
 +    }
 +
 +    boolean this_present_colQualifier = true && this.isSetColQualifier();
 +    boolean that_present_colQualifier = true && that.isSetColQualifier();
 +    if (this_present_colQualifier || that_present_colQualifier) {
 +      if (!(this_present_colQualifier && that_present_colQualifier))
 +        return false;
 +      if (!this.colQualifier.equals(that.colQualifier))
 +        return false;
 +    }
 +
 +    boolean this_present_colVisibility = true && this.isSetColVisibility();
 +    boolean that_present_colVisibility = true && that.isSetColVisibility();
 +    if (this_present_colVisibility || that_present_colVisibility) {
 +      if (!(this_present_colVisibility && that_present_colVisibility))
 +        return false;
 +      if (!this.colVisibility.equals(that.colVisibility))
 +        return false;
 +    }
 +
 +    boolean this_present_timestamp = true && this.isSetTimestamp();
 +    boolean that_present_timestamp = true && that.isSetTimestamp();
 +    if (this_present_timestamp || that_present_timestamp) {
 +      if (!(this_present_timestamp && that_present_timestamp))
 +        return false;
 +      if (this.timestamp != that.timestamp)
 +        return false;
 +    }
 +
 +    return true;
 +  }
 +
 +  @Override
 +  public int hashCode() {
 +    return 0;
 +  }
 +
 +  public int compareTo(Key other) {
 +    if (!getClass().equals(other.getClass())) {
 +      return getClass().getName().compareTo(other.getClass().getName());
 +    }
 +
 +    int lastComparison = 0;
 +    Key typedOther = (Key)other;
 +
 +    lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetRow()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetColFamily()).compareTo(typedOther.isSetColFamily());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetColFamily()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colFamily, typedOther.colFamily);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetColQualifier()).compareTo(typedOther.isSetColQualifier());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetColQualifier()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colQualifier, typedOther.colQualifier);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetColVisibility()).compareTo(typedOther.isSetColVisibility());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetColVisibility()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colVisibility, typedOther.colVisibility);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
 +    if (lastComparison != 0) {
 +      return lastComparison;
 +    }
 +    if (isSetTimestamp()) {
 +      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
 +      if (lastComparison != 0) {
 +        return lastComparison;
 +      }
 +    }
 +    return 0;
 +  }
 +
 +  public _Fields fieldForId(int fieldId) {
 +    return _Fields.findByThriftId(fieldId);
 +  }
 +
 +  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
 +    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
 +  }
 +
 +  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
 +    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
 +  }
 +
 +  @Override
 +  public String toString() {
 +    StringBuilder sb = new StringBuilder("Key(");
 +    boolean first = true;
 +
 +    sb.append("row:");
 +    if (this.row == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.row, sb);
 +    }
 +    first = false;
 +    if (!first) sb.append(", ");
 +    sb.append("colFamily:");
 +    if (this.colFamily == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.colFamily, sb);
 +    }
 +    first = false;
 +    if (!first) sb.append(", ");
 +    sb.append("colQualifier:");
 +    if (this.colQualifier == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.colQualifier, sb);
 +    }
 +    first = false;
 +    if (!first) sb.append(", ");
 +    sb.append("colVisibility:");
 +    if (this.colVisibility == null) {
 +      sb.append("null");
 +    } else {
 +      org.apache.thrift.TBaseHelper.toString(this.colVisibility, sb);
 +    }
 +    first = false;
 +    if (isSetTimestamp()) {
 +      if (!first) sb.append(", ");
 +      sb.append("timestamp:");
 +      sb.append(this.timestamp);
 +      first = false;
 +    }
 +    sb.append(")");
 +    return sb.toString();
 +  }
 +
 +  public void validate() throws org.apache.thrift.TException {
 +    // check for required fields
 +    // check for sub-struct validity
 +  }
 +
 +  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
 +    try {
 +      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
 +    } catch (org.apache.thrift.TException te) {
 +      throw new java.io.IOException(te);
 +    }
 +  }
 +
 +  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
 +    try {
 +      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
 +      __isset_bitfield = 0;
 +      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
 +    } catch (org.apache.thrift.TException te) {
 +      throw new java.io.IOException(te);
 +    }
 +  }
 +
 +  private static class KeyStandardSchemeFactory implements SchemeFactory {
 +    public KeyStandardScheme getScheme() {
 +      return new KeyStandardScheme();
 +    }
 +  }
 +
 +  private static class KeyStandardScheme extends StandardScheme<Key> {
 +
 +    public void read(org.apache.thrift.protocol.TProtocol iprot, Key struct) throws org.apache.thrift.TException {
 +      org.apache.thrift.protocol.TField schemeField;
 +      iprot.readStructBegin();
 +      while (true)
 +      {
 +        schemeField = iprot.readFieldBegin();
 +        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
 +          break;
 +        }
 +        switch (schemeField.id) {
 +          case 1: // ROW
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.row = iprot.readBinary();
 +              struct.setRowIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 2: // COL_FAMILY
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.colFamily = iprot.readBinary();
 +              struct.setColFamilyIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 3: // COL_QUALIFIER
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.colQualifier = iprot.readBinary();
 +              struct.setColQualifierIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 4: // COL_VISIBILITY
 +            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
 +              struct.colVisibility = iprot.readBinary();
 +              struct.setColVisibilityIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          case 5: // TIMESTAMP
 +            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
 +              struct.timestamp = iprot.readI64();
 +              struct.setTimestampIsSet(true);
 +            } else { 
 +              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +            }
 +            break;
 +          default:
 +            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
 +        }
 +        iprot.readFieldEnd();
 +      }
 +      iprot.readStructEnd();
 +
 +      // check for required fields of primitive type, which can't be checked in the validate method
 +      struct.validate();
 +    }
 +
 +    public void write(org.apache.thrift.protocol.TProtocol oprot, Key struct) throws org.apache.thrift.TException {
 +      struct.validate();
 +
 +      oprot.writeStructBegin(STRUCT_DESC);
 +      if (struct.row != null) {
 +        oprot.writeFieldBegin(ROW_FIELD_DESC);
 +        oprot.writeBinary(struct.row);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.colFamily != null) {
 +        oprot.writeFieldBegin(COL_FAMILY_FIELD_DESC);
 +        oprot.writeBinary(struct.colFamily);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.colQualifier != null) {
 +        oprot.writeFieldBegin(COL_QUALIFIER_FIELD_DESC);
 +        oprot.writeBinary(struct.colQualifier);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.colVisibility != null) {
 +        oprot.writeFieldBegin(COL_VISIBILITY_FIELD_DESC);
 +        oprot.writeBinary(struct.colVisibility);
 +        oprot.writeFieldEnd();
 +      }
 +      if (struct.isSetTimestamp()) {
 +        oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
 +        oprot.writeI64(struct.timestamp);
 +        oprot.writeFieldEnd();
 +      }
 +      oprot.writeFieldStop();
 +      oprot.writeStructEnd();
 +    }
 +
 +  }
 +
 +  private static class KeyTupleSchemeFactory implements SchemeFactory {
 +    public KeyTupleScheme getScheme() {
 +      return new KeyTupleScheme();
 +    }
 +  }
 +
 +  private static class KeyTupleScheme extends TupleScheme<Key> {
 +
 +    @Override
 +    public void write(org.apache.thrift.protocol.TProtocol prot, Key struct) throws org.apache.thrift.TException {
 +      TTupleProtocol oprot = (TTupleProtocol) prot;
 +      BitSet optionals = new BitSet();
 +      if (struct.isSetRow()) {
 +        optionals.set(0);
 +      }
 +      if (struct.isSetColFamily()) {
 +        optionals.set(1);
 +      }
 +      if (struct.isSetColQualifier()) {
 +        optionals.set(2);
 +      }
 +      if (struct.isSetColVisibility()) {
 +        optionals.set(3);
 +      }
 +      if (struct.isSetTimestamp()) {
 +        optionals.set(4);
 +      }
 +      oprot.writeBitSet(optionals, 5);
 +      if (struct.isSetRow()) {
 +        oprot.writeBinary(struct.row);
 +      }
 +      if (struct.isSetColFamily()) {
 +        oprot.writeBinary(struct.colFamily);
 +      }
 +      if (struct.isSetColQualifier()) {
 +        oprot.writeBinary(struct.colQualifier);
 +      }
 +      if (struct.isSetColVisibility()) {
 +        oprot.writeBinary(struct.colVisibility);
 +      }
 +      if (struct.isSetTimestamp()) {
 +        oprot.writeI64(struct.timestamp);
 +      }
 +    }
 +
 +    @Override
 +    public void read(org.apache.thrift.protocol.TProtocol prot, Key struct) throws org.apache.thrift.TException {
 +      TTupleProtocol iprot = (TTupleProtocol) prot;
 +      BitSet incoming = iprot.readBitSet(5);
 +      if (incoming.get(0)) {
 +        struct.row = iprot.readBinary();
 +        struct.setRowIsSet(true);
 +      }
 +      if (incoming.get(1)) {
 +        struct.colFamily = iprot.readBinary();
 +        struct.setColFamilyIsSet(true);
 +      }
 +      if (incoming.get(2)) {
 +        struct.colQualifier = iprot.readBinary();
 +        struct.setColQualifierIsSet(true);
 +      }
 +      if (incoming.get(3)) {
 +        struct.colVisibility = iprot.readBinary();
 +        struct.setColVisibilityIsSet(true);
 +      }
 +      if (incoming.get(4)) {
 +        struct.timestamp = iprot.readI64();
 +        struct.setTimestampIsSet(true);
 +      }
 +    }
 +  }
 +
 +}
 +

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/main/thrift/proxy.thrift
----------------------------------------------------------------------
diff --cc proxy/src/main/thrift/proxy.thrift
index 8d3c87d,0000000..7fd2c3f
mode 100644,000000..100644
--- a/proxy/src/main/thrift/proxy.thrift
+++ b/proxy/src/main/thrift/proxy.thrift
@@@ -1,342 -1,0 +1,344 @@@
 +/*
 +* 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.
 +*/
 +namespace cpp accumulo
 +namespace java org.apache.accumulo.proxy.thrift
++namespace rb Accumulo
++namespace py accumulo
 +
 +struct Key {
 +  1:binary row;
 +  2:binary colFamily;
 +  3:binary colQualifier;
 +  4:binary colVisibility;
-   5:optional i64 timestamp
++  5:optional i64 timestamp = 0x7FFFFFFFFFFFFFFF
 +}
 +
 +enum PartialKey {
 +  ROW,
 +  ROW_COLFAM,
 +  ROW_COLFAM_COLQUAL,
 +  ROW_COLFAM_COLQUAL_COLVIS,
 +  ROW_COLFAM_COLQUAL_COLVIS_TIME,
 +  ROW_COLFAM_COLQUAL_COLVIS_TIME_DEL
 +}
 +
 +struct ColumnUpdate {
 +  1:binary colFamily,
 +  2:binary colQualifier,
 +  3:optional binary colVisibility,
 +  4:optional i64 timestamp,
 +  5:optional binary value,
 +  6:optional bool deleteCell
 +}
 +
 +struct KeyValue {
 +  1:Key key,
 +  2:binary value
 +}
 +
 +struct ScanResult {
 +  1:list<KeyValue> results,
 +  2:bool more
 +}
 +
 +struct Range {
 +  1:Key start,
 +  2:bool startInclusive
 +  3:Key stop,
 +  4:bool stopInclusive
 +}
 +
 +struct ScanColumn {
 +  1:binary colFamily,
 +  2:optional binary colQualifier
 +}
 +
 +struct IteratorSetting {
 +  1: i32 priority,
 +  2: string name,
 +  3: string iteratorClass,
 +  4: map<string,string> properties
 +}
 +
 +struct ScanOptions {
 +  1:optional set<binary> authorizations;
 +  2:optional Range range,
 +  3:optional list<ScanColumn> columns;
 +  4:optional list<IteratorSetting> iterators;
 +  5:optional i32 bufferSize;
 +} 
 +
 +struct BatchScanOptions {
 +  1:optional set<binary> authorizations;
 +  2:optional list<Range> ranges;
 +  3:optional list<ScanColumn> columns;
 +  4:optional list<IteratorSetting> iterators;
 +  5:optional i32 threads;
 +} 
 +
 +struct KeyValueAndPeek {
 +  1:KeyValue keyValue,
 +  2:bool hasNext
 +}
 +
 +enum TablePermission {
 +  READ = 2,
 +  WRITE = 3,
 +  BULK_IMPORT = 4,
 +  ALTER_TABLE = 5,
 +  GRANT = 6,
 +  DROP_TABLE = 7,
 +}
 +
 +enum SystemPermission {
 +  GRANT = 0,
 +  CREATE_TABLE = 1,
 +  DROP_TABLE = 2,
 +  ALTER_TABLE = 3,
 +  CREATE_USER = 4,
 +  DROP_USER = 5,
 +  ALTER_USER = 6,
 +  SYSTEM = 7,
 +}
 +
 +enum ScanType {
 +    SINGLE,
 +    BATCH
 +}
 +
 +enum ScanState {
 +    IDLE,
 +    RUNNING,
 +    QUEUED
 +}
 +
 +struct KeyExtent {
 +  1:string tableId,
 +  2:binary endRow,
 +  3:binary prevEndRow
 +}
 +
 +struct Column {
 +  1:binary colFamily;
 +  2:binary colQualifier;
 +  3:binary colVisibility;
 +}
 +
 +struct ActiveScan {
 +  1:string client
 +  2:string user
 +  3:string table
 +  4:i64 age
 +  5:i64 idleTime
 +  6:ScanType type
 +  7:ScanState state
 +  8:KeyExtent extent
 +  9:list<Column> columns
 +  10:list<IteratorSetting> iterators
 +  11:list<binary> authorizations
 +}
 +
 +enum CompactionType {
 +   MINOR,
 +   MERGE,
 +   MAJOR,
 +   FULL
 +}
 +
 +enum CompactionReason {
 +   USER,
 +   SYSTEM,
 +   CHOP,
 +   IDLE,
 +   CLOSE
 +}
 +
 +struct ActiveCompaction {
 +  1:KeyExtent extent
 +  2:i64 age
 +  3:list<string> inputFiles
 +  4:string outputFile
 +  5:CompactionType type
 +  6:CompactionReason reason
 +  7:string localityGroup
 +  8:i64 entriesRead
 +  9:i64 entriesWritten
 +  10:list<IteratorSetting> iterators;
 +}
 +
 +struct WriterOptions {
 + 1:i64 maxMemory
 + 2:i64 latencyMs
 + 3:i64 timeoutMs
 + 4:i32 threads
 +}
 +
 +enum IteratorScope {
 +  MINC,
 +  MAJC,
 +  SCAN
 +}
 +
 +enum TimeType {
 +  LOGICAL,
 +  MILLIS
 +}
 +
 +exception UnknownScanner {
 +  1:string msg
 +}
 +
 +exception UnknownWriter {
 +  1:string msg
 +}
 +
 +exception NoMoreEntriesException {
 +  1:string msg
 +}
 +
 +exception AccumuloException {
 +  1:string msg
 +}
 +
 +exception AccumuloSecurityException {
 +  1:string msg
 +}
 +
 +exception TableNotFoundException {
 +  1:string msg
 +}
 +
 +exception TableExistsException {
 +  1:string msg
 +}
 +
 +exception MutationsRejectedException {
 +  1:string msg
 +}
 +
 +service AccumuloProxy
 +{
 +  // get an authentication token
 +  binary login(1:string principal, 2:map<string, string> loginProperties)                              throws (1:AccumuloSecurityException ouch2);
 +
 +  // table operations
 +  i32 addConstraint (1:binary login, 2:string tableName, 3:string constraintClassName)                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void addSplits (1:binary login, 2:string tableName, 3:set<binary> splits)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void attachIterator (1:binary login, 2:string tableName, 3:IteratorSetting setting, 
 +                       4:set<IteratorScope> scopes) 
 +                                                                                                       throws (1:AccumuloSecurityException ouch1, 2:AccumuloException ouch2, 3:TableNotFoundException ouch3);
 +  void checkIteratorConflicts (1:binary login, 2:string tableName, 3:IteratorSetting setting, 
 +                               4:set<IteratorScope> scopes) 
 +                                                                                                       throws (1:AccumuloSecurityException ouch1, 2:AccumuloException ouch2, 3:TableNotFoundException ouch3);
 +  void clearLocatorCache (1:binary login, 2:string tableName)                                          throws (1:TableNotFoundException ouch1);
 +  void cloneTable (1:binary login, 2:string tableName, 3:string newTableName, 4:bool flush, 
 +                   5:map<string,string> propertiesToSet, 6:set<string> propertiesToExclude) 
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:TableExistsException ouch4);
 +  void compactTable (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow, 
 +		     5:list<IteratorSetting> iterators, 6:bool flush, 7:bool wait)                             throws (1:AccumuloSecurityException ouch1, 2:TableNotFoundException ouch2, 3:AccumuloException ouch3);
 +  void cancelCompaction(1:binary login, 2:string tableName)                                            throws (1:AccumuloSecurityException ouch1, 2:TableNotFoundException ouch2, 3:AccumuloException ouch3);
 +                                                                                                            
 +  void createTable (1:binary login, 2:string tableName, 3:bool versioningIter, 4:TimeType type)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableExistsException ouch3);
 +  void deleteTable (1:binary login, 2:string tableName)                                                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void deleteRows (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow)             throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void exportTable (1:binary login, 2:string tableName, 3:string exportDir)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void flushTable (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow, 
 +                   5:bool wait)
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  map<string,set<string>> getLocalityGroups (1:binary login, 2:string tableName)                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  IteratorSetting getIteratorSetting (1:binary login, 2:string tableName, 
 +                                      3:string iteratorName, 4:IteratorScope scope) 
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  binary getMaxRow (1:binary login, 2:string tableName, 3:set<binary> auths, 4:binary startRow, 
 +                    5:bool startInclusive, 6:binary endRow, 7:bool endInclusive) 
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  map<string,string> getTableProperties (1:binary login, 2:string tableName)                           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void importDirectory (1:binary login, 2:string tableName, 3:string importDir, 
 +                        4:string failureDir, 5:bool setTime) 
 +                                                                                                       throws (1:TableNotFoundException ouch1, 2:AccumuloException ouch3, 3:AccumuloSecurityException ouch4);
 +  void importTable (1:binary login, 2:string tableName, 3:string importDir)                            throws (1:TableExistsException ouch1, 2:AccumuloException ouch2, 3:AccumuloSecurityException ouch3);
 +  list<binary> listSplits (1:binary login, 2:string tableName, 3:i32 maxSplits)                        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  set<string> listTables (1:binary login);
 +  map<string,set<IteratorScope>> listIterators (1:binary login, 2:string tableName)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  map<string,i32> listConstraints (1:binary login, 2:string tableName)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void mergeTablets (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow)           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void offlineTable (1:binary login, 2:string tableName)                                               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void onlineTable (1:binary login, 2:string tableName)                                                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void removeConstraint (1:binary login, 2:string tableName, 3:i32 constraint)                         throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void removeIterator (1:binary login, 2:string tableName, 3:string iterName, 
 +                       4:set<IteratorScope> scopes)
 +                                                                                                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void removeTableProperty (1:binary login, 2:string tableName, 3:string property)                     throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void renameTable (1:binary login, 2:string oldTableName, 3:string newTableName)                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:TableExistsException ouch4);
 +  void setLocalityGroups (1:binary login, 2:string tableName, 3:map<string,set<string>> groups)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void setTableProperty (1:binary login, 2:string tableName, 3:string property, 4:string value)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  set<Range> splitRangeByTablets (1:binary login, 2:string tableName, 3:Range range, 4:i32 maxSplits)  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  bool tableExists (1:binary login, 2:string tableName);
 +  map<string,string> tableIdMap (1:binary login);
 +  bool testTableClassLoad (1:binary login, 2:string tableName, 3:string className                     
 +                           , 4:string asTypeName)                                                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +  // instance operations
 +  void pingTabletServer(1:binary login, 2:string tserver)                                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<ActiveScan> getActiveScans (1:binary login, 2:string tserver)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<ActiveCompaction> getActiveCompactions(1:binary login, 2:string tserver)                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  map<string,string> getSiteConfiguration (1:binary login)                                           throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  map<string,string> getSystemConfiguration (1:binary login)                                         throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<string> getTabletServers (1:binary login);
 +  void removeProperty (1:binary login, 2:string property)                                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void setProperty (1:binary login, 2:string property, 3:string value)                               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  bool testClassLoad (1:binary login, 2:string className, 3:string asTypeName)                       throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +
 +  // security operations
 +  bool authenticateUser (1:binary login, 2:string user, 3:map<string, string> properties)            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void changeUserAuthorizations (1:binary login, 2:string user, 3:set<binary> authorizations)        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void changeLocalUserPassword (1:binary login, 2:string user, 3:binary password)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void createLocalUser (1:binary login, 2:string user, 3:binary password)                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void dropLocalUser (1:binary login, 2:string user)                                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  list<binary> getUserAuthorizations (1:binary login, 2:string user)                                 throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void grantSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)                throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void grantTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm)  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  bool hasSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)                  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  bool hasTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm)    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  set<string> listLocalUsers (1:binary login)                                                        throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  void revokeSystemPermission (1:binary login, 2:string user, 3:SystemPermission perm)               throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);
 +  void revokeTablePermission (1:binary login, 2:string user, 3:string table, 4:TablePermission perm) throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +
 +  // scanning
 +  string createBatchScanner(1:binary login, 2:string tableName, 3:BatchScanOptions options)          throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +  string createScanner(1:binary login, 2:string tableName, 3:ScanOptions options)                    throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +  // use the scanner
 +  bool hasNext(1:string scanner)                        throws(1:UnknownScanner ouch1);
 +  KeyValueAndPeek nextEntry(1:string scanner)           throws(1:NoMoreEntriesException ouch1, 2:UnknownScanner ouch2, 3:AccumuloSecurityException ouch3);
 +  ScanResult nextK(1:string scanner, 2:i32 k)           throws(1:NoMoreEntriesException ouch1, 2:UnknownScanner ouch2, 3:AccumuloSecurityException ouch3);
 +  void closeScanner(1:string scanner)                   throws(1:UnknownScanner ouch1);
 +
 +  // writing
 +  void updateAndFlush(1:binary login, 2:string tableName, 3:map<binary, list<ColumnUpdate>> cells) throws(1:AccumuloException outch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3, 4:MutationsRejectedException ouch4);
 +  string createWriter(1:binary login, 2:string tableName, 3:WriterOptions opts)                    throws(1:AccumuloException outch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException ouch3);
 +
 +  // use the writer
 +  oneway void update(1:string writer, 2:map<binary, list<ColumnUpdate>> cells);
 +  void flush(1:string writer)                                                                      throws (1:UnknownWriter ouch1, 2:MutationsRejectedException ouch2);
 +  void closeWriter(1:string writer)                                                                throws (1:UnknownWriter ouch1, 2:MutationsRejectedException ouch2);
 +
 +  // utilities
 +  Range getRowRange(1:binary row);
 +  Key getFollowing(1:Key key, 2:PartialKey part);
 +}


[04/10] Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Posted by ec...@apache.org.
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8729dba7/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --cc proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index 3bd552d,0000000..6e591af
mode 100644,000000..100644
--- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@@ -1,1159 -1,0 +1,1179 @@@
 +/*
 + * 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.proxy;
 +
 +import static org.junit.Assert.assertEquals;
 +import static org.junit.Assert.assertFalse;
 +import static org.junit.Assert.assertNotEquals;
 +import static org.junit.Assert.assertTrue;
 +import static org.junit.Assert.fail;
 +
 +import java.io.BufferedReader;
 +import java.io.File;
 +import java.io.InputStreamReader;
 +import java.nio.ByteBuffer;
 +import java.util.ArrayList;
 +import java.util.Arrays;
 +import java.util.Collections;
 +import java.util.EnumSet;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Properties;
 +import java.util.Random;
 +import java.util.Set;
 +import java.util.TreeMap;
 +import java.util.UUID;
 +
 +import org.apache.accumulo.core.Constants;
 +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 +import org.apache.accumulo.core.conf.DefaultConfiguration;
 +import org.apache.accumulo.core.conf.Property;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.core.file.FileOperations;
 +import org.apache.accumulo.core.file.FileSKVWriter;
 +import org.apache.accumulo.core.iterators.DevNull;
 +import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 +import org.apache.accumulo.core.iterators.user.SummingCombiner;
 +import org.apache.accumulo.core.iterators.user.VersioningIterator;
 +import org.apache.accumulo.core.util.UtilWaitThread;
 +import org.apache.accumulo.examples.simple.constraints.NumericValueConstraint;
 +import org.apache.accumulo.minicluster.MiniAccumuloCluster;
 +import org.apache.accumulo.minicluster.MiniAccumuloConfig;
 +import org.apache.accumulo.proxy.thrift.AccumuloProxy.Client;
 +import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
 +import org.apache.accumulo.proxy.thrift.ActiveCompaction;
 +import org.apache.accumulo.proxy.thrift.ActiveScan;
 +import org.apache.accumulo.proxy.thrift.BatchScanOptions;
 +import org.apache.accumulo.proxy.thrift.ColumnUpdate;
 +import org.apache.accumulo.proxy.thrift.CompactionReason;
 +import org.apache.accumulo.proxy.thrift.CompactionType;
 +import org.apache.accumulo.proxy.thrift.IteratorScope;
 +import org.apache.accumulo.proxy.thrift.IteratorSetting;
 +import org.apache.accumulo.proxy.thrift.Key;
 +import org.apache.accumulo.proxy.thrift.MutationsRejectedException;
 +import org.apache.accumulo.proxy.thrift.PartialKey;
 +import org.apache.accumulo.proxy.thrift.Range;
 +import org.apache.accumulo.proxy.thrift.ScanColumn;
 +import org.apache.accumulo.proxy.thrift.ScanOptions;
 +import org.apache.accumulo.proxy.thrift.ScanResult;
 +import org.apache.accumulo.proxy.thrift.ScanState;
 +import org.apache.accumulo.proxy.thrift.ScanType;
 +import org.apache.accumulo.proxy.thrift.SystemPermission;
 +import org.apache.accumulo.proxy.thrift.TableExistsException;
 +import org.apache.accumulo.proxy.thrift.TableNotFoundException;
 +import org.apache.accumulo.proxy.thrift.TablePermission;
 +import org.apache.accumulo.proxy.thrift.TimeType;
 +import org.apache.accumulo.proxy.thrift.UnknownScanner;
 +import org.apache.accumulo.proxy.thrift.UnknownWriter;
 +import org.apache.accumulo.proxy.thrift.WriterOptions;
 +import org.apache.accumulo.server.util.PortUtils;
 +import org.apache.accumulo.test.functional.SlowIterator;
 +import org.apache.commons.io.FileUtils;
 +import org.apache.hadoop.conf.Configuration;
 +import org.apache.hadoop.fs.FSDataInputStream;
 +import org.apache.hadoop.fs.FileSystem;
 +import org.apache.hadoop.fs.Path;
 +import org.apache.hadoop.io.Text;
 +import org.apache.thrift.TException;
 +import org.apache.thrift.protocol.TProtocolFactory;
 +import org.apache.thrift.server.TServer;
 +import org.junit.AfterClass;
 +import org.junit.BeforeClass;
 +import org.junit.Test;
 +import org.junit.rules.TemporaryFolder;
 +
 +/**
 + * Call every method on the proxy and try to verify that it works.
 + */
 +public class SimpleTest {
 +  
 +  public static TemporaryFolder folder = new TemporaryFolder();
 +  
 +  public static final String TABLE_TEST = "test";
 +  
 +  private static MiniAccumuloCluster accumulo;
 +  private static String secret = "superSecret";
 +  private static Random random = new Random();
 +  private static TServer proxyServer;
 +  private static Thread thread;
 +  private static int proxyPort;
 +  private static org.apache.accumulo.proxy.thrift.AccumuloProxy.Client client;
 +  private static String principal = "root";
 +  @SuppressWarnings("serial")
 +  private static Map<String,String> properties = new TreeMap<String,String>() {
 +    {
 +      put("password", secret);
 +    }
 +  };
 +  private static ByteBuffer creds = null;
 +  
 +  private static Class<? extends TProtocolFactory> protocolClass;
 +  
 +  static Class<? extends TProtocolFactory> getRandomProtocol() {
 +    List<Class<? extends TProtocolFactory>> protocolFactories = new ArrayList<Class<? extends TProtocolFactory>>();
 +    protocolFactories.add(org.apache.thrift.protocol.TJSONProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TBinaryProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TTupleProtocol.Factory.class);
 +    protocolFactories.add(org.apache.thrift.protocol.TCompactProtocol.Factory.class);
 +    
 +    return protocolFactories.get(random.nextInt(protocolFactories.size()));
 +  }
 +  
 +  @BeforeClass
 +  public static void setupMiniCluster() throws Exception {
 +    folder.create();
 +    MiniAccumuloConfig config = new MiniAccumuloConfig(folder.getRoot(), secret)
 +            .setNumTservers (1);
 +    accumulo = new MiniAccumuloCluster(config);
 +    accumulo.start();
 +    
 +    Properties props = new Properties();
 +    props.put("instance", accumulo.getInstanceName());
 +    props.put("zookeepers", accumulo.getZooKeepers());
 +    props.put("tokenClass", PasswordToken.class.getName());
 +    
 +    protocolClass = getRandomProtocol();
 +    System.out.println(protocolClass.getName());
 +    
 +    proxyPort = PortUtils.getRandomFreePort();
 +    proxyServer = Proxy.createProxyServer(org.apache.accumulo.proxy.thrift.AccumuloProxy.class, org.apache.accumulo.proxy.ProxyServer.class, proxyPort,
 +        protocolClass, props);
 +    thread = new Thread() {
 +      @Override
 +      public void run() {
 +        proxyServer.serve();
 +      }
 +    };
 +    thread.start();
 +    while (!proxyServer.isServing())
 +      UtilWaitThread.sleep(100);
 +    client = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +    creds = client.login(principal, properties);
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void security() throws Exception {
 +    client.createLocalUser(creds, "user", s2bb(secret));
 +    ByteBuffer badLogin = client.login("user", properties);
 +    client.dropLocalUser(creds, "user");
 +    String table = "test1";
 +    client.createTable(creds, table, false, TimeType.MILLIS);
 +    
 +    final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    
 +    try {
 +      client.addConstraint(badLogin, table, NumericValueConstraint.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.addSplits(badLogin, table, Collections.singleton(s2bb("1")));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.clearLocatorCache(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.compactTable(badLogin, table, null, null, null, true, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.cancelCompaction(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createTable(badLogin, table, false, TimeType.MILLIS);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.deleteTable(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.deleteRows(badLogin, table, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.tableExists(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.flushTable(badLogin, table, null, null, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getLocalityGroups(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getMaxRow(badLogin, table, Collections.<ByteBuffer> emptySet(), null, false, null, false);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getTableProperties(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listSplits(badLogin, table, 10000);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listTables(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.listConstraints(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.mergeTablets(badLogin, table, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.offlineTable(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.onlineTable(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeConstraint(badLogin, table, 0);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeTableProperty(badLogin, table, Property.TABLE_FILE_MAX.getKey());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.renameTable(badLogin, table, "someTableName");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      Map<String,Set<String>> groups = new HashMap<String,Set<String>>();
 +      groups.put("group1", Collections.singleton("cf1"));
 +      groups.put("group2", Collections.singleton("cf2"));
 +      client.setLocalityGroups(badLogin, table, groups);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.setTableProperty(badLogin, table, Property.TABLE_FILE_MAX.getKey(), "0");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.tableIdMap(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.getSiteConfiguration(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getSystemConfiguration(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getTabletServers(badLogin);
 +      fail("exception not thrown");
 +    } catch (TException ex) {}
 +    try {
 +      client.getActiveScans(badLogin, "fake");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getActiveCompactions(badLogin, "fakse");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeProperty(badLogin, "table.split.threshold");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.setProperty(badLogin, "table.split.threshold", "500M");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.testClassLoad(badLogin, DevNull.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.authenticateUser(badLogin, "root", s2pp(secret));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      HashSet<ByteBuffer> auths = new HashSet<ByteBuffer>(Arrays.asList(s2bb("A"), s2bb("B")));
 +      client.changeUserAuthorizations(badLogin, "stooge", auths);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.changeLocalUserPassword(badLogin, "stooge", s2bb(""));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createLocalUser(badLogin, "stooge", s2bb("password"));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.dropLocalUser(badLogin, "stooge");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getUserAuthorizations(badLogin, "stooge");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.grantSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.grantTablePermission(badLogin, "root", table, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.hasSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.hasTablePermission(badLogin, "root", table, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listLocalUsers(badLogin);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.revokeSystemPermission(badLogin, "stooge", SystemPermission.CREATE_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.revokeTablePermission(badLogin, "root", table, TablePermission.ALTER_TABLE);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createScanner(badLogin, table, new ScanOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createBatchScanner(badLogin, table, new BatchScanOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.updateAndFlush(badLogin, table, new HashMap<ByteBuffer,List<ColumnUpdate>>());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.createWriter(badLogin, table, new WriterOptions());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.attachIterator(badLogin, "slow", setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.checkIteratorConflicts(badLogin, table, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.cloneTable(badLogin, table, TABLE_TEST, false, null, null);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.exportTable(badLogin, table, "/tmp");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.importTable(badLogin, "testify", "/tmp");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.getIteratorSetting(badLogin, table, "foo", IteratorScope.SCAN);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.listIterators(badLogin, table);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.removeIterator(badLogin, table, "name", EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.splitRangeByTablets(badLogin, table, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      File newFolder = folder.newFolder();
 +      client.importDirectory(badLogin, table, "/tmp", newFolder.getAbsolutePath(), true);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.pingTabletServer(badLogin, "fake");
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.login("badUser", properties);
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +    try {
 +      client.testTableClassLoad(badLogin, table, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (AccumuloSecurityException ex) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void tableNotFound() throws Exception {
 +    final String doesNotExist = "doesNotExists";
 +    try {
 +      client.addConstraint(creds, doesNotExist, NumericValueConstraint.class.getName());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.addSplits(creds, doesNotExist, Collections.<ByteBuffer> emptySet());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    try {
 +      client.attachIterator(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.cancelCompaction(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.checkIteratorConflicts(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.clearLocatorCache(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.cloneTable(creds, doesNotExist, TABLE_TEST, false, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.compactTable(creds, doesNotExist, null, null, null, true, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createBatchScanner(creds, doesNotExist, new BatchScanOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createScanner(creds, doesNotExist, new ScanOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.createWriter(creds, doesNotExist, new WriterOptions());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.deleteRows(creds, doesNotExist, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.deleteTable(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.exportTable(creds, doesNotExist, "/tmp");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.flushTable(creds, doesNotExist, null, null, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getIteratorSetting(creds, doesNotExist, "foo", IteratorScope.SCAN);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getLocalityGroups(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getMaxRow(creds, doesNotExist, Collections.<ByteBuffer> emptySet(), null, false, null, false);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.getTableProperties(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.grantTablePermission(creds, "root", doesNotExist, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.hasTablePermission(creds, "root", doesNotExist, TablePermission.WRITE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      File newFolder = folder.newFolder();
 +      client.importDirectory(creds, doesNotExist, "/tmp", newFolder.getAbsolutePath(), true);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.listConstraints(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.listSplits(creds, doesNotExist, 10000);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.mergeTablets(creds, doesNotExist, null, null);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.offlineTable(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.onlineTable(creds, doesNotExist);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeConstraint(creds, doesNotExist, 0);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeIterator(creds, doesNotExist, "name", EnumSet.allOf(IteratorScope.class));
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.removeTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.renameTable(creds, doesNotExist, "someTableName");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.revokeTablePermission(creds, "root", doesNotExist, TablePermission.ALTER_TABLE);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.setTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey(), "0");
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.splitRangeByTablets(creds, doesNotExist, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10);
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.updateAndFlush(creds, doesNotExist, new HashMap<ByteBuffer,List<ColumnUpdate>>());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +    try {
 +      client.testTableClassLoad(creds, doesNotExist, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
 +      fail("exception not thrown");
 +    } catch (TableNotFoundException ex) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testExists() throws Exception {
 +    client.createTable(creds, "ett1", false, TimeType.MILLIS);
 +    client.createTable(creds, "ett2", false, TimeType.MILLIS);
 +    try {
 +      client.createTable(creds, "ett1", false, TimeType.MILLIS);
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +    try {
 +      client.renameTable(creds, "ett1", "ett2");
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +    try {
 +      client.cloneTable(creds, "ett1", "ett2", false, new HashMap<String,String>(), new HashSet<String>());
 +      fail("exception not thrown");
 +    } catch (TableExistsException tee) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testUnknownScanner() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    assertFalse(client.hasNext(scanner));
 +    client.closeScanner(scanner);
 +    
 +    try {
 +      client.hasNext(scanner);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    
 +    try {
 +      client.closeScanner(scanner);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    
 +    try {
 +      client.nextEntry("99999999");
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.nextK("99999999", 6);
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.hasNext("99999999");
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +    try {
 +      client.hasNext(UUID.randomUUID().toString());
 +      fail("exception not thrown");
 +    } catch (UnknownScanner us) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testUnknownWriter() throws Exception {
 +    
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    
 +    String writer = client.createWriter(creds, TABLE_TEST, null);
 +    client.update(writer, mutation("row0", "cf", "cq", "value"));
 +    client.flush(writer);
 +    client.update(writer, mutation("row2", "cf", "cq", "value2"));
 +    client.closeWriter(writer);
 +    
 +    // this is a oneway call, so it does not throw exceptions
 +    client.update(writer, mutation("row2", "cf", "cq", "value2"));
 +    
 +    try {
 +      client.flush(writer);
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.flush("99999");
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.flush(UUID.randomUUID().toString());
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +    try {
 +      client.closeWriter("99999");
 +      fail("exception not thrown");
 +    } catch (UnknownWriter uw) {}
 +  }
 +  
 +  @Test(timeout = 10000)
 +  public void testDelete() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row0", "cf", "cq", "value"));
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    ScanResult entries = client.nextK(scanner, 10);
 +    client.closeScanner(scanner);
 +    assertFalse(entries.more);
 +    assertEquals(1, entries.results.size());
 +    
 +    ColumnUpdate upd = new ColumnUpdate(s2bb("cf"), s2bb("cq"));
 +    upd.setDeleteCell(true);
 +    Map<ByteBuffer,List<ColumnUpdate>> delete = Collections.singletonMap(s2bb("row0"), Collections.singletonList(upd));
 +    
 +    client.updateAndFlush(creds, TABLE_TEST, delete);
 +    
 +    scanner = client.createScanner(creds, TABLE_TEST, null);
 +    entries = client.nextK(scanner, 10);
 +    client.closeScanner(scanner);
 +    assertEquals(0, entries.results.size());
 +  }
 +
 +  @Test(timeout = 10000)
 +  public void testInstanceOperations() throws Exception {
 +    int tservers = 0;
 +    for (String tserver : client.getTabletServers(creds)) {
 +      client.pingTabletServer(creds, tserver);
 +      tservers++;
 +    }
 +    assertTrue(tservers > 0);
 +    
 +    // get something we know is in the site config
 +    Map<String,String> cfg = client.getSiteConfiguration(creds);
 +    assertTrue(cfg.get("instance.dfs.dir").startsWith(folder.getRoot().toString()));
 +    
 +    // set a property in zookeeper
 +    client.setProperty(creds, "table.split.threshold", "500M");
 +    
 +    // check that we can read it
 +    for (int i = 0; i < 5; i++) {
 +      cfg = client.getSystemConfiguration(creds);
 +      if ("500M".equals(cfg.get("table.split.threshold")))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertEquals("500M", cfg.get("table.split.threshold"));
 +    
 +    // unset the setting, check that it's not what it was
 +    client.removeProperty(creds, "table.split.threshold");
 +    for (int i = 0; i < 5; i++) {
 +      cfg = client.getSystemConfiguration(creds);
 +      if (!"500M".equals(cfg.get("table.split.threshold")))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertNotEquals("500M", cfg.get("table.split.threshold"));
 +    
 +    // try to load some classes via the proxy
 +    assertTrue(client.testClassLoad(creds, DevNull.class.getName(), SortedKeyValueIterator.class.getName()));
 +    assertFalse(client.testClassLoad(creds, "foo.bar", SortedKeyValueIterator.class.getName()));
 +    
 +    // create a table that's very slow, so we can look for scans/compactions
 +    client.createTable(creds, "slow", true, TimeType.MILLIS);
 +    IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
 +    client.attachIterator(creds, "slow", setting, EnumSet.allOf(IteratorScope.class));
 +    client.updateAndFlush(creds, "slow", mutation("row", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row2", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row3", "cf", "cq", "value"));
 +    client.updateAndFlush(creds, "slow", mutation("row4", "cf", "cq", "value"));
 +    
 +    // scan
 +    Thread t = new Thread() {
 +      @Override
 +      public void run() {
 +        String scanner;
 +        try {
 +          Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +          scanner = client2.createScanner(creds, "slow", null);
 +          client2.nextK(scanner, 10);
 +          client2.closeScanner(scanner);
 +        } catch (Exception e) {
 +          throw new RuntimeException(e);
 +        }
 +      }
 +    };
 +    t.start();
 +    // look for the scan
 +    List<ActiveScan> scans = Collections.emptyList();
 +    loop: for (int i = 0; i < 100; i++) {
 +      for (String tserver : client.getTabletServers(creds)) {
 +        scans = client.getActiveScans(creds, tserver);
 +        if (!scans.isEmpty())
 +          break loop;
 +        UtilWaitThread.sleep(10);
 +      }
 +    }
 +    t.join();
 +    assertFalse(scans.isEmpty());
 +    ActiveScan scan = scans.get(0);
 +    assertEquals("root", scan.getUser());
 +    assertTrue(ScanState.RUNNING.equals(scan.getState()) || ScanState.QUEUED.equals(scan.getState()));
 +    assertEquals(ScanType.SINGLE, scan.getType());
 +    assertEquals("slow", scan.getTable());
 +    Map<String,String> map = client.tableIdMap(creds);
 +    assertEquals(map.get("slow"), scan.getExtent().tableId);
 +    assertTrue(scan.getExtent().endRow == null);
 +    assertTrue(scan.getExtent().prevEndRow == null);
 +    
 +    // start a compaction
 +    t = new Thread() {
 +      @Override
 +      public void run() {
 +        try {
 +          Client client2 = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
 +          client2.compactTable(creds, "slow", null, null, null, true, true);
 +        } catch (Exception e) {
 +          throw new RuntimeException(e);
 +        }
 +      }
 +    };
 +    t.start();
 +    
 +    // try to catch it in the act
 +    List<ActiveCompaction> compactions = Collections.emptyList();
 +    loop2: for (int i = 0; i < 100; i++) {
 +      for (String tserver : client.getTabletServers(creds)) {
 +        compactions = client.getActiveCompactions(creds, tserver);
 +        if (!compactions.isEmpty())
 +          break loop2;
 +      }
 +      UtilWaitThread.sleep(10);
 +    }
 +    t.join();
 +    // verify the compaction information
 +    assertFalse(compactions.isEmpty());
 +    ActiveCompaction c = compactions.get(0);
 +    assertEquals(map.get("slow"), c.getExtent().tableId);
 +    assertTrue(c.inputFiles.isEmpty());
 +    assertEquals(CompactionType.MINOR, c.getType());
 +    assertEquals(CompactionReason.USER, c.getReason());
 +    assertEquals("", c.localityGroup);
 +    assertTrue(c.outputFile.contains("default_tablet"));
 +  }
 +  
 +  @Test
 +  public void testSecurityOperations() throws Exception {
 +    // check password
 +    assertTrue(client.authenticateUser(creds, "root", s2pp(secret)));
 +    assertFalse(client.authenticateUser(creds, "root", s2pp("")));
 +    
 +    // create a user
 +    client.createLocalUser(creds, "stooge", s2bb("password"));
 +    // change auths
 +    Set<String> users = client.listLocalUsers(creds);
 +    assertEquals(new HashSet<String>(Arrays.asList("root", "stooge")), users);
 +    HashSet<ByteBuffer> auths = new HashSet<ByteBuffer>(Arrays.asList(s2bb("A"), s2bb("B")));
 +    client.changeUserAuthorizations(creds, "stooge", auths);
 +    List<ByteBuffer> update = client.getUserAuthorizations(creds, "stooge");
 +    assertEquals(auths, new HashSet<ByteBuffer>(update));
 +    
 +    // change password
 +    client.changeLocalUserPassword(creds, "stooge", s2bb(""));
 +    assertTrue(client.authenticateUser(creds, "stooge", s2pp("")));
 +    
 +    // check permission failure
 +    @SuppressWarnings("serial")
 +    ByteBuffer stooge = client.login("stooge", new TreeMap<String,String>() {
 +      {
 +        put("password", "");
 +      }
 +    });
 +    
 +    try {
 +      client.createTable(stooge, "fail", true, TimeType.MILLIS);
 +      fail("should not create the table");
 +    } catch (AccumuloSecurityException ex) {
 +      assertFalse(client.listTables(creds).contains("fail"));
 +    }
 +    // grant permissions and test
 +    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    client.grantSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
 +    assertTrue(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    client.createTable(stooge, "success", true, TimeType.MILLIS);
 +    client.listTables(creds).contains("succcess");
 +    
 +    // revoke permissions
 +    client.revokeSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
 +    assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
 +    try {
 +      client.createTable(stooge, "fail", true, TimeType.MILLIS);
 +      fail("should not create the table");
 +    } catch (AccumuloSecurityException ex) {
 +      assertFalse(client.listTables(creds).contains("fail"));
 +    }
 +    // create a table to test table permissions
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    // denied!
 +    try {
 +      String scanner = client.createScanner(stooge, TABLE_TEST, null);
 +      client.nextK(scanner, 100);
 +      fail("stooge should not read table test");
 +    } catch (AccumuloSecurityException ex) {}
 +    // grant
 +    assertFalse(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    client.grantTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ);
 +    assertTrue(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    String scanner = client.createScanner(stooge, TABLE_TEST, null);
 +    client.nextK(scanner, 10);
 +    client.closeScanner(scanner);
 +    // revoke
 +    client.revokeTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ);
 +    assertFalse(client.hasTablePermission(creds, "stooge", TABLE_TEST, TablePermission.READ));
 +    try {
 +      scanner = client.createScanner(stooge, TABLE_TEST, null);
 +      client.nextK(scanner, 100);
 +      fail("stooge should not read table test");
 +    } catch (AccumuloSecurityException ex) {}
 +    
 +    // delete user
 +    client.dropLocalUser(creds, "stooge");
 +    users = client.listLocalUsers(creds);
 +    assertEquals(1, users.size());
 +    
 +  }
 +  
 +  @Test
 +  public void testBatchWriter() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
 +    
 +    WriterOptions writerOptions = new WriterOptions();
 +    writerOptions.setLatencyMs(10000);
 +    writerOptions.setMaxMemory(2);
 +    writerOptions.setThreads(1);
 +    writerOptions.setTimeoutMs(100000);
 +    
 +    String batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    try {
 +      client.flush(batchWriter);
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException ex) {}
 +    try {
 +      client.closeWriter(batchWriter);
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException e) {}
 +    
 +    client.removeConstraint(creds, TABLE_TEST, 1);
 +    
 +    writerOptions = new WriterOptions();
 +    writerOptions.setLatencyMs(10000);
 +    writerOptions.setMaxMemory(3000);
 +    writerOptions.setThreads(1);
 +    writerOptions.setTimeoutMs(100000);
 +    
 +    batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
 +    
 +    client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
 +    client.flush(batchWriter);
 +    client.closeWriter(batchWriter);
 +    
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    ScanResult more = client.nextK(scanner, 2);
 +    assertEquals(1, more.getResults().size());
 +    client.closeScanner(scanner);
 +    
 +    client.deleteTable(creds, TABLE_TEST);
 +  }
 +  
 +  @Test
 +  public void testTableOperations() throws Exception {
 +    if (client.tableExists(creds, TABLE_TEST))
 +      client.deleteTable(creds, TABLE_TEST);
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    // constraints
 +    client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "123"));
 +    
 +    try {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
 +      fail("constraint did not fire");
 +    } catch (MutationsRejectedException ex) {}
 +    
 +    client.removeConstraint(creds, TABLE_TEST, 1);
 +    assertEquals(0, client.listConstraints(creds, TABLE_TEST).size());
 +    client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
 +    String scanner = client.createScanner(creds, TABLE_TEST, null);
 +    ScanResult more = client.nextK(scanner, 2);
 +    client.closeScanner(scanner);
 +    assertFalse(more.isMore());
 +    assertEquals(1, more.getResults().size());
 +    assertEquals(s2bb("x"), more.getResults().get(0).value);
 +    // splits, merge
 +    client.addSplits(creds, TABLE_TEST, new HashSet<ByteBuffer>(Arrays.asList(s2bb("a"), s2bb("m"), s2bb("z"))));
 +    List<ByteBuffer> splits = client.listSplits(creds, TABLE_TEST, 1);
 +    assertEquals(Arrays.asList(s2bb("m")), splits);
 +    client.mergeTablets(creds, TABLE_TEST, null, s2bb("m"));
 +    splits = client.listSplits(creds, TABLE_TEST, 10);
 +    assertEquals(Arrays.asList(s2bb("m"), s2bb("z")), splits);
 +    client.mergeTablets(creds, TABLE_TEST, null, null);
 +    splits = client.listSplits(creds, TABLE_TEST, 10);
 +    List<ByteBuffer> empty = Collections.emptyList();
 +    assertEquals(empty, splits);
 +    // iterators
 +    client.deleteTable(creds, TABLE_TEST);
 +    client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
 +    HashMap<String,String> options = new HashMap<String,String>();
 +    options.put("type", "STRING");
 +    options.put("columns", "cf");
 +    IteratorSetting setting = new IteratorSetting(10, TABLE_TEST, SummingCombiner.class.getName(), options);
 +    client.attachIterator(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
 +    for (int i = 0; i < 10; i++) {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "1"));
 +    }
 +    scanner = client.createScanner(creds, TABLE_TEST, null);
 +    more = client.nextK(scanner, 2);
 +    client.closeScanner(scanner);
 +    assertEquals("10", new String(more.getResults().get(0).getValue()));
 +    try {
 +      client.checkIteratorConflicts(creds, TABLE_TEST, setting, EnumSet.allOf(IteratorScope.class));
 +      fail("checkIteratorConflicts did not throw and exception");
 +    } catch (Exception ex) {}
 +    client.deleteRows(creds, TABLE_TEST, null, null);
 +    client.removeIterator(creds, TABLE_TEST, "test", EnumSet.allOf(IteratorScope.class));
 +    for (int i = 0; i < 10; i++) {
 +      client.updateAndFlush(creds, TABLE_TEST, mutation("row" + i, "cf", "cq", "" + i));
 +      client.flushTable(creds, TABLE_TEST, null, null, true);
 +    }
 +    scanner = client.createScanner(creds, TABLE_TEST, null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(10, more.getResults().size());
 +    // clone
 +    client.cloneTable(creds, TABLE_TEST, "test2", true, null, null);
 +    scanner = client.createScanner(creds, "test2", null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(10, more.getResults().size());
 +    client.deleteTable(creds, "test2");
 +    
 +    // don't know how to test this, call it just for fun
 +    client.clearLocatorCache(creds, TABLE_TEST);
 +    
 +    // compact
 +    client.compactTable(creds, TABLE_TEST, null, null, null, true, true);
 +    assertEquals(1, countFiles(TABLE_TEST));
 +    
 +    // export/import
 +    String dir = folder.getRoot() + "/test";
 +    String destDir = folder.getRoot() + "/test_dest";
 +    client.offlineTable(creds, TABLE_TEST);
 +    client.exportTable(creds, TABLE_TEST, dir);
 +    // copy files to a new location
 +    FileSystem fs = FileSystem.get(new Configuration());
 +    FSDataInputStream is = fs.open(new Path(dir + "/distcp.txt"));
 +    BufferedReader r = new BufferedReader(new InputStreamReader(is));
 +    while (true) {
 +      String line = r.readLine();
 +      if (line == null)
 +        break;
 +      Path srcPath = new Path(line);
 +      FileUtils.copyFile(new File(srcPath.toUri().getPath()), new File(destDir, srcPath.getName()));
 +    }
 +    client.deleteTable(creds, TABLE_TEST);
 +    client.importTable(creds, "testify", destDir);
 +    scanner = client.createScanner(creds, "testify", null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(10, more.results.size());
 +    
 +    try {
 +      // ACCUMULO-1558 a second import from the same dir should fail, the first import moved the files
 +      client.importTable(creds, "testify2", destDir);
 +      fail();
 +    } catch (Exception e) {}
 +
 +    assertFalse(client.listTables(creds).contains("testify2"));
 +
 +    // Locality groups
 +    client.createTable(creds, "test", true, TimeType.MILLIS);
 +    Map<String,Set<String>> groups = new HashMap<String,Set<String>>();
 +    groups.put("group1", Collections.singleton("cf1"));
 +    groups.put("group2", Collections.singleton("cf2"));
 +    client.setLocalityGroups(creds, "test", groups);
 +    assertEquals(groups, client.getLocalityGroups(creds, "test"));
 +    // table properties
 +    Map<String,String> orig = client.getTableProperties(creds, "test");
 +    client.setTableProperty(creds, "test", "table.split.threshold", "500M");
 +    Map<String,String> update = client.getTableProperties(creds, "test");
 +    for (int i = 0; i < 5; i++) {
 +      if (update.get("table.split.threshold").equals("500M"))
 +        break;
 +      UtilWaitThread.sleep(200);
 +    }
 +    assertEquals(update.get("table.split.threshold"), "500M");
 +    client.removeTableProperty(creds, "test", "table.split.threshold");
 +    update = client.getTableProperties(creds, "test");
 +    assertEquals(orig, update);
 +    // rename table
 +    Map<String,String> tables = client.tableIdMap(creds);
 +    client.renameTable(creds, "test", "bar");
 +    Map<String,String> tables2 = client.tableIdMap(creds);
 +    assertEquals(tables.get("test"), tables2.get("bar"));
 +    // table exists
 +    assertTrue(client.tableExists(creds, "bar"));
 +    assertFalse(client.tableExists(creds, "test"));
 +    // bulk import
 +    String filename = dir + "/bulk/import/rfile.rf";
 +    FileSKVWriter writer = FileOperations.getInstance().openWriter(filename, fs, fs.getConf(), DefaultConfiguration.getInstance());
 +    writer.startDefaultLocalityGroup();
 +    writer.append(new org.apache.accumulo.core.data.Key(new Text("a"), new Text("b"), new Text("c")), new Value("value".getBytes()));
 +    writer.close();
 +    fs.mkdirs(new Path(dir + "/bulk/fail"));
 +    client.importDirectory(creds, "bar", dir + "/bulk/import", dir + "/bulk/fail", true);
 +    scanner = client.createScanner(creds, "bar", null);
 +    more = client.nextK(scanner, 100);
 +    client.closeScanner(scanner);
 +    assertEquals(1, more.results.size());
 +    ByteBuffer maxRow = client.getMaxRow(creds, "bar", null, null, false, null, false);
 +    assertEquals(s2bb("a"), maxRow);
 +    
 +    assertFalse(client.testTableClassLoad(creds, "bar", "abc123", SortedKeyValueIterator.class.getName()));
 +    assertTrue(client.testTableClassLoad(creds, "bar", VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName()));
 +  }
 +  
 +  // scan !METADATA table for file entries for the given table
 +  private int countFiles(String table) throws Exception {
 +    Map<String,String> tableIdMap = client.tableIdMap(creds);
 +    String tableId = tableIdMap.get(table);
 +    Key start = new Key();
 +    start.row = s2bb(tableId + ";");
 +    Key end = new Key();
 +    end.row = s2bb(tableId + "<");
 +    end = client.getFollowing(end, PartialKey.ROW);
 +    ScanOptions opt = new ScanOptions();
 +    opt.range = new Range(start, true, end, false);
 +    opt.columns = Collections.singletonList(new ScanColumn(s2bb("file")));
 +    String scanner = client.createScanner(creds, Constants.METADATA_TABLE_NAME, opt);
 +    int result = 0;
 +    while (true) {
 +      ScanResult more = client.nextK(scanner, 100);
 +      result += more.getResults().size();
 +      if (!more.more)
 +        break;
 +    }
 +    return result;
 +  }
 +  
 +  private Map<ByteBuffer,List<ColumnUpdate>> mutation(String row, String cf, String cq, String value) {
 +    ColumnUpdate upd = new ColumnUpdate(s2bb(cf), s2bb(cq));
 +    upd.setValue(value.getBytes());
 +    return Collections.singletonMap(s2bb(row), Collections.singletonList(upd));
 +  }
 +  
 +  private ByteBuffer s2bb(String cf) {
 +    return ByteBuffer.wrap(cf.getBytes());
 +  }
 +  
 +  private Map<String,String> s2pp(String cf) {
 +    Map<String,String> toRet = new TreeMap<String,String>();
 +    toRet.put("password", cf);
 +    return toRet;
 +  }
 +  
++  static private ByteBuffer t2bb(Text t) {
++    return ByteBuffer.wrap(t.getBytes());
++  }
++  
++  @Test
++  public void testGetRowRange() throws Exception {
++    Range range = client.getRowRange(s2bb("xyzzy"));
++    org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy")); 
++    assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow())));
++    assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow())));
++    assertEquals(range.startInclusive, range2.isStartKeyInclusive());
++    assertEquals(range.stopInclusive, range2.isEndKeyInclusive());
++    assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily())));
++    assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier())));
++    assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily())));
++    assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier())));
++    assertEquals(range.start.timestamp, range.start.timestamp);
++    assertEquals(range.stop.timestamp, range.stop.timestamp);
++  }
++  
 +  @AfterClass
 +  public static void tearDownMiniCluster() throws Exception {
 +    accumulo.stop();
 +    folder.delete();
 +  }
 +  
 +}


[02/10] git commit: ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it)

Posted by ec...@apache.org.
ACCUMULO-1993 ACCUMULO-1994 make proxy useful for ruby, fix getRowRange (and test it)


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/27ee2367
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/27ee2367
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/27ee2367

Branch: refs/heads/1.5.1-SNAPSHOT
Commit: 27ee2367056e5ad0cb6175f91154cd13d49e2c95
Parents: 0b6749a
Author: Eric Newton <er...@gmail.com>
Authored: Thu Jan 2 12:02:00 2014 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Thu Jan 2 12:02:00 2014 -0500

----------------------------------------------------------------------
 src/proxy/examples/python/TestClient.py         |  4 ++--
 src/proxy/examples/ruby/test_client.rb          |  8 ++++----
 .../org/apache/accumulo/proxy/ProxyServer.java  |  6 ++----
 .../org/apache/accumulo/proxy/thrift/Key.java   |  6 ++++--
 src/proxy/src/main/thrift/proxy.thrift          |  4 +++-
 .../org/apache/accumulo/proxy/SimpleTest.java   | 20 ++++++++++++++++++++
 6 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/python/TestClient.py
----------------------------------------------------------------------
diff --git a/src/proxy/examples/python/TestClient.py b/src/proxy/examples/python/TestClient.py
index 7ecf367..5509ded 100644
--- a/src/proxy/examples/python/TestClient.py
+++ b/src/proxy/examples/python/TestClient.py
@@ -21,8 +21,8 @@ from thrift.transport import TSocket
 from thrift.transport import TTransport
 from thrift.protocol import TCompactProtocol
 
-from proxy import AccumuloProxy
-from proxy.ttypes import *
+from accumulo import AccumuloProxy
+from accumulo.ttypes import *
 
 transport = TSocket.TSocket('localhost', 42424)
 transport = TTransport.TFramedTransport(transport)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/examples/ruby/test_client.rb
----------------------------------------------------------------------
diff --git a/src/proxy/examples/ruby/test_client.rb b/src/proxy/examples/ruby/test_client.rb
index d5ee5f5..6310a2f 100644
--- a/src/proxy/examples/ruby/test_client.rb
+++ b/src/proxy/examples/ruby/test_client.rb
@@ -23,7 +23,7 @@ server = ARGV[0] || 'localhost'
 socket = Thrift::Socket.new(server, 42424, 9001)
 transport = Thrift::FramedTransport.new(socket)
 proto = Thrift::CompactProtocol.new(transport)
-proxy = AccumuloProxy::Client.new(proto)
+proxy = Accumulo::AccumuloProxy::Client.new(proto)
 
 # open up the connect
 transport.open()
@@ -35,10 +35,10 @@ login = proxy.login('root', {'password' => 'secret'})
 puts "List of tables: #{proxy.listTables(login).inspect}"
 
 testtable = "rubytest"
-proxy.createTable(login, testtable, true, TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
+proxy.createTable(login, testtable, true, Accumulo::TimeType::MILLIS) unless proxy.tableExists(login,testtable) 
 
-update1 = ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
-update2 = ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
+update1 = Accumulo::ColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
+update2 = Accumulo::ColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
 proxy.updateAndFlush(login,testtable,{'row1' => [update1,update2]})
 
 cookie = proxy.createScanner(login,testtable,nil)

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index d749723..bf050e4 100644
--- a/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -1328,6 +1328,7 @@ public class ProxyServer implements AccumuloProxy.Iface {
       return null;
     org.apache.accumulo.proxy.thrift.Key result = new org.apache.accumulo.proxy.thrift.Key(TextUtil.getByteBuffer(k.getRow()), TextUtil.getByteBuffer(k
         .getColumnFamily()), TextUtil.getByteBuffer(k.getColumnQualifier()), TextUtil.getByteBuffer(k.getColumnVisibility()));
+    result.setTimestamp(k.getTimestamp());
     return result;
   }
   
@@ -1346,12 +1347,9 @@ public class ProxyServer implements AccumuloProxy.Iface {
     }
   }
   
-  static private final ByteBuffer EMPTY = ByteBuffer.wrap(new byte[] {});
-  
   @Override
   public org.apache.accumulo.proxy.thrift.Range getRowRange(ByteBuffer row) throws TException {
-    return new org.apache.accumulo.proxy.thrift.Range(new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true,
-        new org.apache.accumulo.proxy.thrift.Key(row, EMPTY, EMPTY, EMPTY), true);
+    return getRange(new Range(ByteBufferUtil.toText(row)));
   }
   
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
index 5d8a31c..422149c 100644
--- a/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
+++ b/src/proxy/src/main/java/org/apache/accumulo/proxy/thrift/Key.java
@@ -143,6 +143,8 @@ import org.slf4j.LoggerFactory;
   }
 
   public Key() {
+    this.timestamp = 9223372036854775807L;
+
   }
 
   public Key(
@@ -193,8 +195,8 @@ import org.slf4j.LoggerFactory;
     this.colFamily = null;
     this.colQualifier = null;
     this.colVisibility = null;
-    setTimestampIsSet(false);
-    this.timestamp = 0;
+    this.timestamp = 9223372036854775807L;
+
   }
 
   public byte[] getRow() {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/main/thrift/proxy.thrift
----------------------------------------------------------------------
diff --git a/src/proxy/src/main/thrift/proxy.thrift b/src/proxy/src/main/thrift/proxy.thrift
index 1cebf55..872e253 100644
--- a/src/proxy/src/main/thrift/proxy.thrift
+++ b/src/proxy/src/main/thrift/proxy.thrift
@@ -16,13 +16,15 @@
 */
 namespace cpp accumulo
 namespace java org.apache.accumulo.proxy.thrift
+namespace rb Accumulo
+namespace py accumulo
 
 struct Key {
   1:binary row;
   2:binary colFamily;
   3:binary colQualifier;
   4:binary colVisibility;
-  5:optional i64 timestamp
+  5:optional i64 timestamp = 0x7FFFFFFFFFFFFFFF
 }
 
 enum PartialKey {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/27ee2367/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --git a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index d3b45ae..67b36a6 100644
--- a/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/src/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@ -798,6 +798,26 @@ public class SimpleTest {
     return toRet;
   }
   
+  static private ByteBuffer t2bb(Text t) {
+    return ByteBuffer.wrap(t.getBytes());
+  }
+  
+  @Test
+  public void testGetRowRange() throws Exception {
+    Range range = client.getRowRange(s2bb("xyzzy"));
+    org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy")); 
+    assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow())));
+    assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow())));
+    assertEquals(range.startInclusive, range2.isStartKeyInclusive());
+    assertEquals(range.stopInclusive, range2.isEndKeyInclusive());
+    assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily())));
+    assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier())));
+    assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily())));
+    assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier())));
+    assertEquals(range.start.timestamp, range.start.timestamp);
+    assertEquals(range.stop.timestamp, range.stop.timestamp);
+  }
+  
   @AfterClass
   public static void tearDownMiniCluster() throws Exception {
     accumulo.stop();