accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1434921 [1/7] - in /accumulo/trunk: ./ conf/examples/1GB/native-standalone/ conf/examples/1GB/standalone/ conf/examples/2GB/native-standalone/ conf/examples/2GB/standalone/ conf/examples/3GB/native-standalone/ conf/examples/3GB/standalone/...
Date Thu, 17 Jan 2013 21:22:36 GMT
Author: ecn
Date: Thu Jan 17 21:22:35 2013
New Revision: 1434921

URL: http://svn.apache.org/viewvc?rev=1434921&view=rev
Log:
First import of the proxy:

Reformated code, added copyrights
Converted command-line parsing to JCommander
Removed warnings
Separated TServer creation from thread creation
Modified update methods to take mutation-like objects
Moved api package to thrift to match the other modules
Added proxy short-hand for accumulo command.
Renamed ProxyHarness to Proxy

Added proxy/target/classes to classpath in all example site files.


Added:
    accumulo/trunk/proxy/   (with props)
    accumulo/trunk/proxy/README   (with props)
    accumulo/trunk/proxy/examples/
    accumulo/trunk/proxy/examples/python/
    accumulo/trunk/proxy/examples/python/README   (with props)
    accumulo/trunk/proxy/examples/python/TestClient.py   (with props)
    accumulo/trunk/proxy/examples/ruby/
    accumulo/trunk/proxy/examples/ruby/README   (with props)
    accumulo/trunk/proxy/examples/ruby/test_client.rb   (with props)
    accumulo/trunk/proxy/pom.xml   (with props)
    accumulo/trunk/proxy/proxy.properties   (with props)
    accumulo/trunk/proxy/src/
    accumulo/trunk/proxy/src/main/
    accumulo/trunk/proxy/src/main/java/
    accumulo/trunk/proxy/src/main/java/org/
    accumulo/trunk/proxy/src/main/java/org/apache/
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Util.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/AccumuloException.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/AccumuloProxy.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/AccumuloSecurityException.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/IOException.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/KeyValueAndPeek.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/NoMoreEntriesException.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PColumn.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PColumnUpdate.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PIteratorSetting.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PKey.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PKeyValue.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PRange.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PScanResult.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PSystemPermission.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/PTablePermission.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/TableExistsException.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/TableNotFoundException.java   (with props)
    accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/UserPass.java   (with props)
    accumulo/trunk/proxy/src/main/scripts/
    accumulo/trunk/proxy/src/main/scripts/generate-thrift.sh   (with props)
    accumulo/trunk/proxy/src/main/thrift/
    accumulo/trunk/proxy/src/main/thrift/proxy.thrift
    accumulo/trunk/proxy/src/test/
    accumulo/trunk/proxy/src/test/java/
    accumulo/trunk/proxy/src/test/java/org/
    accumulo/trunk/proxy/src/test/java/org/apache/
    accumulo/trunk/proxy/src/test/java/org/apache/accumulo/
    accumulo/trunk/proxy/src/test/java/org/apache/accumulo/TestProxyInstanceOperations.java   (with props)
    accumulo/trunk/proxy/src/test/java/org/apache/accumulo/TestProxyReadWrite.java   (with props)
    accumulo/trunk/proxy/src/test/java/org/apache/accumulo/TestProxySecurityOperations.java   (with props)
    accumulo/trunk/proxy/src/test/java/org/apache/accumulo/TestProxyTableOperations.java   (with props)
Modified:
    accumulo/trunk/conf/examples/1GB/native-standalone/accumulo-site.xml
    accumulo/trunk/conf/examples/1GB/standalone/accumulo-site.xml
    accumulo/trunk/conf/examples/2GB/native-standalone/accumulo-site.xml
    accumulo/trunk/conf/examples/2GB/standalone/accumulo-site.xml
    accumulo/trunk/conf/examples/3GB/native-standalone/accumulo-site.xml
    accumulo/trunk/conf/examples/3GB/standalone/accumulo-site.xml
    accumulo/trunk/conf/examples/512MB/native-standalone/accumulo-site.xml
    accumulo/trunk/conf/examples/512MB/standalone/accumulo-site.xml
    accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
    accumulo/trunk/pom.xml
    accumulo/trunk/start/src/main/java/org/apache/accumulo/start/Main.java

Modified: accumulo/trunk/conf/examples/1GB/native-standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/1GB/native-standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/1GB/native-standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/1GB/native-standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -98,6 +98,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/conf/examples/1GB/standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/1GB/standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/1GB/standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/1GB/standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -93,6 +93,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/conf/examples/2GB/native-standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/2GB/native-standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/2GB/native-standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/2GB/native-standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -88,6 +88,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/conf/examples/2GB/standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/2GB/standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/2GB/standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/2GB/standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -88,6 +88,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/conf/examples/3GB/native-standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/3GB/native-standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/3GB/native-standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/3GB/native-standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -83,6 +83,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/conf/examples/3GB/standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/3GB/standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/3GB/standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/3GB/standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -83,6 +83,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/conf/examples/512MB/native-standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/512MB/native-standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/512MB/native-standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/512MB/native-standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -93,6 +93,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/conf/examples/512MB/standalone/accumulo-site.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/conf/examples/512MB/standalone/accumulo-site.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/conf/examples/512MB/standalone/accumulo-site.xml (original)
+++ accumulo/trunk/conf/examples/512MB/standalone/accumulo-site.xml Thu Jan 17 21:22:35 2013
@@ -93,6 +93,8 @@
     $ACCUMULO_HOME/server/target/classes/,
     $ACCUMULO_HOME/core/target/classes/,
     $ACCUMULO_HOME/start/target/classes/,
+    $ACCUMULO_HOME/fate/target/classes/,
+    $ACCUMULO_HOME/proxy/target/classes/,
     $ACCUMULO_HOME/examples/target/classes/,
 	$ACCUMULO_HOME/lib/[^.].$ACCUMULO_VERSION.jar,
 	$ACCUMULO_HOME/lib/[^.].*.jar,

Modified: accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java (original)
+++ accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java Thu Jan 17 21:22:35 2013
@@ -16,13 +16,7 @@
  */
 package org.apache.accumulo.examples.simple.client;
 
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 

Modified: accumulo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/pom.xml?rev=1434921&r1=1434920&r2=1434921&view=diff
==============================================================================
--- accumulo/trunk/pom.xml (original)
+++ accumulo/trunk/pom.xml Thu Jan 17 21:22:35 2013
@@ -53,6 +53,7 @@
     <module>start</module>
     <module>examples</module>
     <module>assemble</module>
+    <module>proxy</module>
     <module>test</module>
   </modules>
 
@@ -144,7 +145,7 @@
             <configuration>
               <outputDirectory>../lib</outputDirectory>
               <!-- just grab the non-provided runtime dependencies -->
-              <includeArtifactIds>commons-collections,commons-configuration,commons-io,commons-lang,jline,log4j,libthrift,commons-logging,commons-logging-api,commons-vfs2,gson,jcommander</includeArtifactIds>
+              <includeArtifactIds>commons-collections,commons-configuration,commons-io,commons-lang,jline,log4j,libthrift,commons-logging,commons-logging-api,commons-vfs2,gson,jcommander,guava</includeArtifactIds>
               <excludeTransitive>true</excludeTransitive>
             </configuration>
           </execution>

Propchange: accumulo/trunk/proxy/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan 17 21:22:35 2013
@@ -0,0 +1,4 @@
+.classpath
+.project
+target
+.settings

Added: accumulo/trunk/proxy/README
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/README?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/README (added)
+++ accumulo/trunk/proxy/README Thu Jan 17 21:22:35 2013
@@ -0,0 +1,48 @@
+Title: Apache Accumulo Proxy
+Notice:    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.
+
+This is a thrift proxy server to interact with the Accumulo database.
+
+1. Building
+
+To compile, you must first install Thrift 0.9.0. 
+
+After thrift is installed, compile the project with:
+mvn clean install
+This will compile the thrift and java files, and will provide C++, python and ruby bindings.
+
+2. Proxy Server Execution
+
+Please note that the proxy can only function correctly when connected to an Accumulo 1.5 instance, or when run standalone in the Mock configuration.
+To run the server, edit the configuration file with parameters suited for your Accumulo installation. If you wish to instead use an in-memory Mock instance, set:
+org.apache.accumulo.proxy.ProxyServer.useMockInstance=true
+This option will override any "real" Accumulo instance information.
+
+Once the properties file is configured correctly, run this command:
+./bin/accumulo proxy -p proxy/proxy.properties
+
+3. Clients
+
+An example java client is incuded with this distribution in the class TestProxyClient. Also the unit tests included show how to use the proxy. Normal Accumulo APIs are emulated whereever possible.
+
+Additional client examples can be found in the examples directory. These clients are tested and function, however, the setup for each language is beyond the scope of this document currently.
+
+In general, to create a client for a new language one must compile the proxy.thrift API (along with the accumulo core data.thrift API) to the language of choice. 
+Then one includes the resulting generated code along with the thrift core library for that language to use the proxy.
+
+As a note, many of the clients here assume "secret" is your root password. Protip: to make the examples work, change this code to your password, do not change your root password to "secret".

Propchange: accumulo/trunk/proxy/README
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/examples/python/README
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/python/README?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/examples/python/README (added)
+++ accumulo/trunk/proxy/examples/python/README Thu Jan 17 21:22:35 2013
@@ -0,0 +1,24 @@
+Title: Apache Accumulo Python Example
+Notice:    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.
+
+This is an example python client for the accumulo proxy. After launching the proxy server, You should be able to run it by typing:
+
+
+PYTHONPATH=path/to/generated/api:path/to/thrift/libs python TestClient.py
+
+As a warning, this script will create a table in your accumulo instance and add a few cells to it.

Propchange: accumulo/trunk/proxy/examples/python/README
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/examples/python/TestClient.py
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/python/TestClient.py?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/examples/python/TestClient.py (added)
+++ accumulo/trunk/proxy/examples/python/TestClient.py Thu Jan 17 21:22:35 2013
@@ -0,0 +1,45 @@
+#!/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 *
+
+transport = TSocket.TSocket('localhost', 42424)
+transport = TTransport.TFramedTransport(transport)
+protocol = TCompactProtocol.TCompactProtocol(transport)
+client = AccumuloProxy.Client(protocol)
+transport.open()
+
+userpass = UserPass("root","secret")
+
+print client.tableOperations_list(userpass)
+
+testtable = "pythontest"
+if not client.tableOperations_exists(userpass,testtable):
+    client.tableOperations_create(userpass,testtable)
+
+row1 = {'a':[PColumnUpdate('a','a',value='value1'), PColumnUpdate('b','b',value='value2')]}
+client.updateAndFlush(userpass,testtable,row1,None)
+
+cookie = client.createBatchScanner(userpass,testtable,"",None,None)
+print client.scanner_next_k(cookie,10)

Propchange: accumulo/trunk/proxy/examples/python/TestClient.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/examples/ruby/README
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/ruby/README?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/examples/ruby/README (added)
+++ accumulo/trunk/proxy/examples/ruby/README Thu Jan 17 21:22:35 2013
@@ -0,0 +1,26 @@
+Title: Apache Accumulo Ruby Example
+Notice:    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.
+
+This directory contains the compiled thrift Accumulo proxy API and an example client for ruby.
+
+To run this script, type the following:
+ruby -I . test_client.rb <host of server>
+
+(the -I option is needed for ruby 1.9.x)
+
+Warning: the script as it is will attempt to connect to your accumulo instance, create a table, and add some rows to it.

Propchange: accumulo/trunk/proxy/examples/ruby/README
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/examples/ruby/test_client.rb
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/ruby/test_client.rb?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/examples/ruby/test_client.rb (added)
+++ accumulo/trunk/proxy/examples/ruby/test_client.rb Thu Jan 17 21:22:35 2013
@@ -0,0 +1,49 @@
+
+# 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)
+us = UserPass.new({'username'=> 'root', 'password' => 'secret'})
+
+# open up the connect
+transport.open()
+
+# Test if the server is up
+puts "Server is up? #{proxy.ping(us)}"
+
+# print out a table list
+puts "List of tables: #{proxy.tableOperations_list(us).inspect}"
+
+testtable = "rubytest"
+proxy.tableOperations_create(us,testtable) unless proxy.tableOperations_exists(us,testtable) 
+
+key1 = PColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 'value'=> "a"})
+key2 = PColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 'value'=> "b"})
+proxy.updateAndFlush(us,testtable,{'row1' => [key1,key2]},nil)
+
+cookie = proxy.createBatchScanner(us,testtable,{},nil,nil)
+result = proxy.scanner_next_k(cookie,10)
+result.results.each{ |keyvalue| puts "Key: #{keyvalue.key.inspect} Value: #{keyvalue.value}" }
+
+transport.close()

Propchange: accumulo/trunk/proxy/examples/ruby/test_client.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/pom.xml?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/pom.xml (added)
+++ accumulo/trunk/proxy/pom.xml Thu Jan 17 21:22:35 2013
@@ -0,0 +1,106 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>accumulo</artifactId>
+		<groupId>org.apache.accumulo</groupId>
+		<version>1.5.0-SNAPSHOT</version>
+	</parent>
+	<artifactId>accumulo-proxy</artifactId>
+	<name>accumulo-proxy</name>
+	<url>http://maven.apache.org</url>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<build>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<artifactId>maven-jar-plugin</artifactId>
+					<configuration>
+						<outputDirectory>../lib</outputDirectory>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>exec-maven-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>generate-core-thrift</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>exec</goal>
+						</goals>
+						<configuration>
+							<executable>${basedir}/src/main/scripts/generate-thrift.sh</executable>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.accumulo</groupId>
+			<artifactId>accumulo-core</artifactId>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.hadoop</groupId>
+			<artifactId>hadoop-core</artifactId>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.zookeeper</groupId>
+			<artifactId>zookeeper</artifactId>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.google.guava</groupId>
+			<artifactId>guava</artifactId>
+			<version>13.0.1</version>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>commons-cli</groupId>
+			<artifactId>commons-cli</artifactId>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.beust</groupId>
+			<artifactId>jcommander</artifactId>
+		</dependency>
+	</dependencies>
+
+</project>

Propchange: accumulo/trunk/proxy/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/proxy.properties
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/proxy.properties?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/proxy.properties (added)
+++ accumulo/trunk/proxy/proxy.properties Thu Jan 17 21:22:35 2013
@@ -0,0 +1,9 @@
+accumulo.proxy.apis=org.apache.accumulo.proxy.api.AccumuloProxy
+
+org.apache.accumulo.proxy.ProxyServer.useMockInstance=false
+org.apache.accumulo.proxy.api.AccumuloProxy.implementor=org.apache.accumulo.proxy.ProxyServer
+org.apache.accumulo.proxy.api.AccumuloProxy.port=42424
+
+org.apache.accumulo.proxy.ProxyServer.instancename=test
+org.apache.accumulo.proxy.ProxyServer.zookeepers=localhost:2181
+

Propchange: accumulo/trunk/proxy/proxy.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java (added)
+++ accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java Thu Jan 17 21:22:35 2013
@@ -0,0 +1,112 @@
+/*
+ * 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.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.util.Properties;
+
+import org.apache.accumulo.core.cli.Help;
+import org.apache.thrift.TProcessor;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.server.THsHaServer;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.transport.TNonblockingServerSocket;
+
+import com.beust.jcommander.IStringConverter;
+import com.beust.jcommander.Parameter;
+
+public class Proxy {
+  
+  public static class PropertiesConverter implements IStringConverter<Properties> {
+    @Override
+    public Properties convert(String fileName) {
+      Properties prop = new Properties();
+      InputStream is;
+      try {
+        is = new FileInputStream(fileName);
+        try {
+          prop.load(is);
+        } finally {
+          is.close();
+        }
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+      return prop;
+    }
+  }
+  
+  public static class Opts extends Help {
+    @Parameter(names = "-p", required = true, description = "properties file name", converter = PropertiesConverter.class)
+    Properties prop;
+  }
+  
+  public static void main(String[] args) throws Exception {
+    Opts opts = new Opts();
+    opts.parseArgs(Proxy.class.getName(), args);
+    
+    String[] apis = opts.prop.getProperty("accumulo.proxy.apis").split(",");
+    if (apis.length == 0) {
+      System.err.println("No apis listed in the accumulo.proxy.apis property");
+      System.exit(1);
+    }
+    for (String api : apis) {
+      // check existence of properties
+      if (!opts.prop.containsKey(api + ".implementor")) {
+        System.err.println("No implementor listed in the " + api + ".implementor property");
+        System.exit(1);
+      }
+      if (!opts.prop.containsKey(api + ".port")) {
+        System.err.println("No port in the " + api + ".port property");
+        System.exit(1);
+      }
+      
+      Class<?> apiclass = Class.forName(api);
+      
+      Class<?> implementor = Class.forName(opts.prop.getProperty(api + ".implementor"));
+      
+      int port = Integer.parseInt(opts.prop.getProperty(api + ".port"));
+      TServer server = createProxyServer(apiclass, implementor, port, opts.prop);
+      server.serve();
+    }
+  }
+  
+  public static TServer createProxyServer(Class<?> api, Class<?> implementor, final int port, Properties properties) throws Exception {
+    final TNonblockingServerSocket socket = new TNonblockingServerSocket(port);
+    
+    // create the implementor
+    Object impl = implementor.getConstructor(Properties.class).newInstance(properties);
+    
+    Class<?> proxyProcClass = Class.forName(api.getName() + "$Processor");
+    Class<?> proxyIfaceClass = Class.forName(api.getName() + "$Iface");
+    @SuppressWarnings("unchecked")
+    Constructor<? extends TProcessor> proxyProcConstructor = (Constructor<? extends TProcessor>) proxyProcClass.getConstructor(proxyIfaceClass);
+    
+    final TProcessor processor = proxyProcConstructor.newInstance(impl);
+    
+    THsHaServer.Args args = new THsHaServer.Args(socket);
+    args.processor(processor);
+    args.transportFactory(new TFramedTransport.Factory());
+    args.protocolFactory(new TCompactProtocol.Factory());
+    return new THsHaServer(args);
+  }
+  
+}

Propchange: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java (added)
+++ accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java Thu Jan 17 21:22:35 2013
@@ -0,0 +1,809 @@
+/*
+ * 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.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+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.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.ZooKeeperInstance;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.core.security.SystemPermission;
+import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.core.util.ByteBufferUtil;
+import org.apache.accumulo.proxy.thrift.AccumuloException;
+import org.apache.accumulo.proxy.thrift.AccumuloProxy;
+import org.apache.accumulo.proxy.thrift.AccumuloSecurityException;
+import org.apache.accumulo.proxy.thrift.KeyValueAndPeek;
+import org.apache.accumulo.proxy.thrift.NoMoreEntriesException;
+import org.apache.accumulo.proxy.thrift.PColumn;
+import org.apache.accumulo.proxy.thrift.PColumnUpdate;
+import org.apache.accumulo.proxy.thrift.PIteratorSetting;
+import org.apache.accumulo.proxy.thrift.PKeyValue;
+import org.apache.accumulo.proxy.thrift.PRange;
+import org.apache.accumulo.proxy.thrift.PScanResult;
+import org.apache.accumulo.proxy.thrift.PSystemPermission;
+import org.apache.accumulo.proxy.thrift.PTablePermission;
+import org.apache.accumulo.proxy.thrift.TableExistsException;
+import org.apache.accumulo.proxy.thrift.TableNotFoundException;
+import org.apache.accumulo.proxy.thrift.UserPass;
+import org.apache.hadoop.io.Text;
+import org.apache.thrift.TException;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
+public class ProxyServer implements AccumuloProxy.Iface {
+  
+  protected Instance instance;
+  
+  protected class ScannerPlusIterator {
+    public ScannerBase scanner;
+    public Iterator<Map.Entry<Key,Value>> iterator;
+  }
+  
+  protected Cache<UUID,ScannerPlusIterator> scannerCache;
+  protected Cache<UUID,BatchWriter> writerCache;
+  
+  public ProxyServer(Properties props) {
+    String useMock = props.getProperty("org.apache.accumulo.proxy.ProxyServer.useMockInstance");
+    if (useMock != null && Boolean.parseBoolean(useMock))
+      instance = new MockInstance();
+    else
+      instance = new ZooKeeperInstance(props.getProperty("org.apache.accumulo.proxy.ProxyServer.instancename"),
+          props.getProperty("org.apache.accumulo.proxy.ProxyServer.zookeepers"));
+    
+    scannerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).build();
+    
+    writerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).build();
+  }
+  
+  protected Connector getConnector(UserPass userpass) throws Exception {
+    Connector connector = instance.getConnector(userpass.getUsername(), userpass.bufferForPassword());
+    return connector;
+  }
+  
+  @Override
+  public boolean ping(UserPass userpass) throws TException {
+    return true;
+  }
+  
+  @Override
+  public int tableOperations_addConstraint(UserPass userpass, String tableName, String constraintClassName) throws AccumuloException,
+      AccumuloSecurityException, TableNotFoundException, TException {
+    try {
+      return getConnector(userpass).tableOperations().addConstraint(tableName, constraintClassName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_addSplits(UserPass userpass, String tableName, Set<String> splits) throws TableNotFoundException, AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      SortedSet<Text> sorted = new TreeSet<Text>();
+      for (String split : splits) {
+        sorted.add(new Text(split));
+      }
+      getConnector(userpass).tableOperations().addSplits(tableName, sorted);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_clearLocatorCache(UserPass userpass, String tableName) throws TableNotFoundException, TException {
+    try {
+      getConnector(userpass).tableOperations().clearLocatorCache(tableName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_compact(UserPass userpass, String tableName, String start, String end, boolean flush, boolean wait)
+      throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TException {
+    try {
+      getConnector(userpass).tableOperations().compact(tableName, new Text(start), new Text(end), flush, wait);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_create(UserPass userpass, String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException, TException {
+    try {
+      getConnector(userpass).tableOperations().create(tableName);
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_delete(UserPass userpass, String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+      TException {
+    try {
+      getConnector(userpass).tableOperations().delete(tableName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_deleteRows(UserPass userpass, String tableName, String start, String end) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException, TException {
+    try {
+      getConnector(userpass).tableOperations().deleteRows(tableName, new Text(start), new Text(end));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public boolean tableOperations_exists(UserPass userpass, String tableName) throws TException {
+    try {
+      return getConnector(userpass).tableOperations().exists(tableName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_flush(UserPass userpass, String tableName) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).tableOperations().flush(tableName, null, null, true);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Map<String,Set<String>> tableOperations_getLocalityGroups(UserPass userpass, String tableName) throws AccumuloException, TableNotFoundException,
+      TException {
+    try {
+      Map<String,Set<Text>> groups = getConnector(userpass).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) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public String tableOperations_getMaxRow(UserPass userpass, String tableName, List<ByteBuffer> auths, String start, boolean startinclusive, String end,
+      boolean endinclusive) throws TableNotFoundException, AccumuloException, AccumuloSecurityException, TException {
+    try {
+      
+      Text startText = start == null ? null : new Text(start);
+      Text endText = end == null ? null : new Text(end);
+      return getConnector(userpass).tableOperations().getMaxRow(tableName, new Authorizations(auths), startText, startinclusive, endText, endinclusive)
+          .toString();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Map<String,String> tableOperations_getProperties(UserPass userpass, String tableName) throws AccumuloException, TableNotFoundException, TException {
+    try {
+      Map<String,String> ret = new HashMap<String,String>();
+      
+      for (Map.Entry<String,String> entry : getConnector(userpass).tableOperations().getProperties(tableName)) {
+        ret.put(entry.getKey(), entry.getValue());
+      }
+      return ret;
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public List<String> tableOperations_getSplits(UserPass userpass, String tableName, int maxSplits) throws TableNotFoundException, TException {
+    try {
+      Collection<Text> splits = getConnector(userpass).tableOperations().getSplits(tableName, maxSplits);
+      List<String> ret = new ArrayList<String>();
+      for (Text split : splits) {
+        ret.add(split.toString());
+      }
+      return ret;
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Set<String> tableOperations_list(UserPass userpass) throws TException {
+    try {
+      return getConnector(userpass).tableOperations().list();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Map<String,Integer> tableOperations_listConstraints(UserPass userpass, String arg2) throws AccumuloException, TableNotFoundException, TException {
+    try {
+      return getConnector(userpass).tableOperations().listConstraints(arg2);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_merge(UserPass userpass, String tableName, String start, String end) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException, TException {
+    try {
+      getConnector(userpass).tableOperations().merge(tableName, new Text(start), new Text(end));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_offline(UserPass userpass, String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException,
+      TException {
+    try {
+      getConnector(userpass).tableOperations().offline(tableName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_online(UserPass userpass, String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException,
+      TException {
+    try {
+      getConnector(userpass).tableOperations().online(tableName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_removeConstraint(UserPass userpass, String tableName, int number) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).tableOperations().removeConstraint(tableName, number);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_removeProperty(UserPass userpass, String tableName, String property) throws AccumuloException, AccumuloSecurityException,
+      TException {
+    try {
+      getConnector(userpass).tableOperations().removeProperty(tableName, property);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_rename(UserPass userpass, String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException,
+      AccumuloException, TableExistsException, TException {
+    try {
+      getConnector(userpass).tableOperations().rename(oldTableName, newTableName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_setLocalityGroups(UserPass userpass, String tableName, Map<String,Set<String>> groupStrings) throws AccumuloException,
+      AccumuloSecurityException, 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(userpass).tableOperations().setLocalityGroups(tableName, groups);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void tableOperations_setProperty(UserPass userpass, String tableName, String property, String value) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).tableOperations().setProperty(tableName, property, value);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Map<String,String> tableOperations_tableIdMap(UserPass userpass) throws TException {
+    try {
+      return getConnector(userpass).tableOperations().tableIdMap();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Map<String,String> instanceOperations_getSiteConfiguration(UserPass userpass) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      return getConnector(userpass).instanceOperations().getSiteConfiguration();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Map<String,String> instanceOperations_getSystemConfiguration(UserPass userpass) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      return getConnector(userpass).instanceOperations().getSystemConfiguration();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public List<String> instanceOperations_getTabletServers(UserPass userpass) throws TException {
+    try {
+      return getConnector(userpass).instanceOperations().getTabletServers();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void instanceOperations_removeProperty(UserPass userpass, String property) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).instanceOperations().removeProperty(property);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void instanceOperations_setProperty(UserPass userpass, String property, String value) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).instanceOperations().setProperty(property, value);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public boolean instanceOperations_testClassLoad(UserPass userpass, String className, String asTypeName) throws AccumuloException, AccumuloSecurityException,
+      TException {
+    try {
+      return getConnector(userpass).instanceOperations().testClassLoad(className, asTypeName);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public boolean securityOperations_authenticateUser(UserPass userpass, String user, ByteBuffer password) throws AccumuloException, AccumuloSecurityException,
+      TException {
+    try {
+      return getConnector(userpass).securityOperations().authenticateUser(user, password.array());
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_changeUserAuthorizations(UserPass userpass, String user, Set<String> authorizations) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).securityOperations().changeUserAuthorizations(user, new Authorizations(authorizations.toArray(new String[0])));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_changeUserPassword(UserPass userpass, String user, ByteBuffer password) throws AccumuloException, AccumuloSecurityException,
+      TException {
+    try {
+      getConnector(userpass).securityOperations().changeUserPassword(user, password.array());
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_createUser(UserPass userpass, String user, ByteBuffer password, Set<String> authorizations) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).securityOperations().createUser(user, password.array());
+      getConnector(userpass).securityOperations().changeUserAuthorizations(user, new Authorizations(authorizations.toArray(new String[] {})));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_dropUser(UserPass userpass, String user) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).securityOperations().dropUser(user);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public List<ByteBuffer> securityOperations_getUserAuthorizations(UserPass userpass, String user) throws AccumuloException, AccumuloSecurityException,
+      TException {
+    try {
+      return getConnector(userpass).securityOperations().getUserAuthorizations(user).getAuthorizationsBB();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_grantSystemPermission(UserPass userpass, String user, PSystemPermission perm) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).securityOperations().grantSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_grantTablePermission(UserPass userpass, String user, String table, PTablePermission perm) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).securityOperations().grantTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public boolean securityOperations_hasSystemPermission(UserPass userpass, String user, PSystemPermission perm) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      return getConnector(userpass).securityOperations().hasSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public boolean securityOperations_hasTablePermission(UserPass userpass, String user, String table, PTablePermission perm) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      return getConnector(userpass).securityOperations().hasTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public Set<String> securityOperations_listUsers(UserPass userpass) throws AccumuloException, AccumuloSecurityException, TException {
+    try {
+      return getConnector(userpass).securityOperations().listUsers();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_revokeSystemPermission(UserPass userpass, String user, PSystemPermission perm) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).securityOperations().revokeSystemPermission(user, SystemPermission.getPermissionById((byte) perm.getValue()));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void securityOperations_revokeTablePermission(UserPass userpass, String user, String table, PTablePermission perm) throws AccumuloException,
+      AccumuloSecurityException, TException {
+    try {
+      getConnector(userpass).securityOperations().revokeTablePermission(user, table, TablePermission.getPermissionById((byte) perm.getValue()));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public String createScanner(UserPass userpass, String tableName, Set<String> authorizations, PIteratorSetting in_is, PRange prange) throws TException {
+    try {
+      Connector connector = getConnector(userpass);
+      
+      Authorizations auth;
+      if (authorizations != null)
+        auth = new Authorizations(authorizations.toArray(new String[0]));
+      else
+        auth = connector.securityOperations().getUserAuthorizations(userpass.getUsername());
+      
+      Scanner scanner = connector.createScanner(tableName, auth);
+      
+      if (in_is != null) {
+        IteratorSetting is = new IteratorSetting(in_is.getPriority(), in_is.getName(), in_is.getIteratorClass(), in_is.getProperties());
+        scanner.addScanIterator(is);
+      }
+      
+      Range range = prange == null ? new Range() : (new Range(prange.getStart() == null ? null : Util.fromThrift(prange.getStart()), true,
+          prange.getStop() == null ? null : Util.fromThrift(prange.getStop()), false));
+      
+      scanner.setRange(range);
+      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) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public String createBatchScanner(UserPass userpass, String tableName, Set<String> authorizations, PIteratorSetting in_is, List<PRange> pranges)
+      throws TException {
+    try {
+      Connector connector = getConnector(userpass);
+      
+      Authorizations auth;
+      if (authorizations != null)
+        auth = new Authorizations(authorizations.toArray(new String[0]));
+      else
+        auth = connector.securityOperations().getUserAuthorizations(userpass.getUsername());
+      
+      BatchScanner scanner = connector.createBatchScanner(tableName, auth, 10);
+      
+      if (in_is != null) {
+        IteratorSetting is = new IteratorSetting(in_is.getPriority(), in_is.getName(), in_is.getIteratorClass(), in_is.getProperties());
+        scanner.addScanIterator(is);
+      }
+      
+      ArrayList<Range> ranges = new ArrayList<Range>();
+      
+      if (pranges == null) {
+        ranges.add(new Range());
+      } else {
+        for (PRange range : pranges) {
+          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);
+      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) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public boolean scanner_hasnext(String scanner) throws TException {
+    ScannerPlusIterator spi = scannerCache.getIfPresent(UUID.fromString(scanner));
+    if (spi == null) {
+      throw new TException("Scanner never existed or no longer exists");
+    }
+    
+    return (spi.iterator.hasNext());
+  }
+  
+  @Override
+  public KeyValueAndPeek scanner_next(String scanner) throws TException, NoMoreEntriesException {
+    
+    PScanResult scanResult = scanner_next_k(scanner, 1);
+    if (scanResult.results.size() > 0) {
+      return new KeyValueAndPeek(scanResult.results.get(0), scanResult.isMore());
+    } else {
+      throw new NoMoreEntriesException();
+    }
+    
+  }
+  
+  @Override
+  public PScanResult scanner_next_k(String scanner, int k) throws TException {
+    
+    // fetch the scanner
+    ScannerPlusIterator spi = scannerCache.getIfPresent(UUID.fromString(scanner));
+    if (spi == null) {
+      throw new TException("Scanner never existed or no longer exists");
+    }
+    Iterator<Map.Entry<Key,Value>> batchScanner = spi.iterator;
+    // synchronized to prevent race conditions
+    synchronized (batchScanner) {
+      PScanResult ret = new PScanResult();
+      ret.setResults(new ArrayList<PKeyValue>());
+      int numRead = 0;
+      while (batchScanner.hasNext() && numRead < k) {
+        Map.Entry<Key,Value> next = batchScanner.next();
+        ret.addToResults(new PKeyValue(Util.toThrift(next.getKey()), ByteBuffer.wrap(next.getValue().get())));
+        numRead++;
+      }
+      ret.setMore(numRead == k);
+      return ret;
+    }
+  }
+  
+  @Override
+  public void close_scanner(String uuid) throws TException {
+    scannerCache.invalidate(uuid);
+  }
+  
+  @Override
+  public void updateAndFlush(UserPass userpass, String tableName, Map<ByteBuffer,List<PColumnUpdate>> cells, Map<ByteBuffer,List<PColumn>> deletedCells)
+      throws TException {
+    try {
+      BatchWriter writer = getWriter(userpass, tableName);
+      addCellsToWriter(cells, deletedCells, writer);
+      writer.flush();
+      writer.close();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  private static final ColumnVisibility EMPTY_VIS = new ColumnVisibility();
+  
+  private void addCellsToWriter(Map<ByteBuffer,List<PColumnUpdate>> cells, Map<ByteBuffer,List<PColumn>> deletedCells, BatchWriter writer)
+      throws MutationsRejectedException {
+    HashMap<Text,ColumnVisibility> vizMap = new HashMap<Text,ColumnVisibility>();
+    if (cells != null) {
+      for (Entry<ByteBuffer,List<PColumnUpdate>> entry : cells.entrySet()) {
+        Mutation m = new Mutation(ByteBufferUtil.toBytes(entry.getKey()));
+        
+        for (PColumnUpdate 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())
+            m.put(update.getColFamily(), update.getColQualifier(), viz, update.getTimestamp(), value);
+          else
+            m.put(update.getColFamily(), update.getColQualifier(), viz, value);
+        }
+        writer.addMutation(m);
+      }
+    }
+    
+    if (deletedCells != null) {
+      for (Entry<ByteBuffer,List<PColumn>> entry : deletedCells.entrySet()) {
+        Mutation m = new Mutation(ByteBufferUtil.toBytes(entry.getKey()));
+        for (PColumn col : entry.getValue()) {
+          ColumnVisibility viz = EMPTY_VIS;
+          long timestamp = 0;
+          if (col.isSetColVisibility()) {
+            Text vizText = new Text(col.getColVisibility());
+            viz = vizMap.get(vizText);
+            if (viz == null) {
+              vizMap.put(vizText, viz = new ColumnVisibility(vizText));
+            }
+          }
+          if (col.isSetTimestamp())
+            timestamp = col.getTimestamp();
+          m.putDelete(col.getColFamily(), col.getColQualifier(), viz, timestamp);
+        }
+        writer.addMutation(m);
+      }
+    }
+  }
+  
+  @Override
+  public String createWriter(UserPass userpass, String tableName) throws TException {
+    try {
+      BatchWriter writer = getWriter(userpass, tableName);
+      UUID uuid = UUID.randomUUID();
+      writerCache.put(uuid, writer);
+      return uuid.toString();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void writer_update(String writer, Map<ByteBuffer,List<PColumnUpdate>> cells, Map<ByteBuffer,List<PColumn>> deletedCells) throws TException {
+    try {
+      BatchWriter batchwriter = writerCache.getIfPresent(UUID.fromString(writer));
+      if (batchwriter == null) {
+        throw new TException("Writer never existed or no longer exists");
+      }
+      addCellsToWriter(cells, deletedCells, batchwriter);
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void writer_flush(String writer) throws TException {
+    try {
+      BatchWriter batchwriter = writerCache.getIfPresent(UUID.fromString(writer));
+      if (batchwriter == null) {
+        throw new TException("Writer never existed or no longer exists");
+      }
+      batchwriter.flush();
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  @Override
+  public void writer_close(String writer) throws TException {
+    try {
+      BatchWriter batchwriter = writerCache.getIfPresent(UUID.fromString(writer));
+      if (batchwriter == null) {
+        throw new TException("Writer never existed or no longer exists");
+      }
+      batchwriter.close();
+      writerCache.invalidate(UUID.fromString(writer));
+    } catch (Exception e) {
+      throw new TException(e);
+    }
+  }
+  
+  private BatchWriter getWriter(UserPass userpass, String tableName) throws Exception {
+    return getConnector(userpass).createBatchWriter(tableName, new BatchWriterConfig());
+  }
+  
+}

Propchange: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java (added)
+++ accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java Thu Jan 17 21:22:35 2013
@@ -0,0 +1,168 @@
+/*
+ * 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.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.iterators.user.RegExFilter;
+import org.apache.accumulo.proxy.thrift.AccumuloProxy;
+import org.apache.accumulo.proxy.thrift.PColumnUpdate;
+import org.apache.accumulo.proxy.thrift.PKey;
+import org.apache.accumulo.proxy.thrift.PScanResult;
+import org.apache.accumulo.proxy.thrift.UserPass;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+public class TestProxyClient {
+  
+  protected AccumuloProxy.Client proxy;
+  protected TTransport transport;
+  
+  public TestProxyClient(String host, int port) throws TTransportException {
+    final TSocket socket = new TSocket(host, port);
+    socket.setTimeout(600000);
+    transport = new TFramedTransport(socket);
+    final TProtocol protocol = new TCompactProtocol(transport);
+    proxy = new AccumuloProxy.Client(protocol);
+    transport.open();
+  }
+  
+  public AccumuloProxy.Client proxy() {
+    return proxy;
+  }
+  
+  public static void main(String[] args) throws Exception {
+    
+    TestProxyClient tpc = new TestProxyClient("localhost", 42424);
+    UserPass userpass = new UserPass();
+    userpass.setUsername("root");
+    userpass.setPassword("secret".getBytes());
+    
+    System.out.println("Creating user: ");
+    if (!tpc.proxy().securityOperations_listUsers(userpass).contains("testuser")) {
+      Set<String> auths = new HashSet<String>();
+      tpc.proxy().securityOperations_createUser(userpass, "testuser", ByteBuffer.wrap("testpass".getBytes()), auths);
+    }
+    System.out.println("UserList: " + tpc.proxy().securityOperations_listUsers(userpass));
+    
+    System.out.println("Pinging: " + tpc.proxy().ping(userpass));
+    System.out.println("Listing: " + tpc.proxy().tableOperations_list(userpass));
+    
+    System.out.println("Deleting: ");
+    String testTable = "testtableOMGOMGOMG";
+    
+    System.out.println("Creating: ");
+    
+    if (tpc.proxy().tableOperations_exists(userpass, testTable))
+      tpc.proxy().tableOperations_delete(userpass, testTable);
+    
+    tpc.proxy().tableOperations_create(userpass, testTable);
+    
+    System.out.println("Listing: " + tpc.proxy().tableOperations_list(userpass));
+    
+    System.out.println("Writing: ");
+    Date start = new Date();
+    Date then = new Date();
+    int maxInserts = 1000000;
+    String format = "%1$05d";
+    Map<ByteBuffer,List<PColumnUpdate>> mutations = new HashMap<ByteBuffer,List<PColumnUpdate>>();
+    for (int i = 0; i < maxInserts; i++) {
+      String result = String.format(format, i);
+      PColumnUpdate update = new PColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes()), ByteBuffer.wrap(("cq" + i).getBytes()), Util.randStringBuffer(10));
+      mutations.put(ByteBuffer.wrap(result.getBytes()), Collections.singletonList(update));
+      
+      if (i % 1000 == 0) {
+        tpc.proxy().updateAndFlush(userpass, testTable, mutations, null);
+        mutations.clear();
+      }
+    }
+    tpc.proxy().updateAndFlush(userpass, testTable, mutations, null);
+    Date end = new Date();
+    System.out.println(" End of writing: " + (end.getTime() - start.getTime()));
+    
+    tpc.proxy().tableOperations_delete(userpass, testTable);
+    tpc.proxy().tableOperations_create(userpass, testTable);
+    
+    // Thread.sleep(1000);
+    
+    System.out.println("Writing async: ");
+    start = new Date();
+    then = new Date();
+    mutations.clear();
+    String writer = tpc.proxy().createWriter(userpass, testTable);
+    for (int i = 0; i < maxInserts; i++) {
+      String result = String.format(format, i);
+      PKey pkey = new PKey();
+      pkey.setRow(result.getBytes());
+      PColumnUpdate update = new PColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes()), ByteBuffer.wrap(("cq" + i).getBytes()), Util.randStringBuffer(10));
+      mutations.put(ByteBuffer.wrap(result.getBytes()), Collections.singletonList(update));
+      tpc.proxy().writer_update(writer, mutations, null);
+      mutations.clear();
+    }
+    
+    end = new Date();
+    System.out.println(" End of writing: " + (end.getTime() - start.getTime()));
+    start = end;
+    System.out.println("Closing...");
+    tpc.proxy().writer_close(writer);
+    end = new Date();
+    System.out.println(" End of closing: " + (end.getTime() - start.getTime()));
+    
+    System.out.println("Reading: ");
+    
+    String regex = "cf1.*";
+    
+    IteratorSetting is = new IteratorSetting(50, regex, RegExFilter.class);
+    RegExFilter.setRegexs(is, null, regex, null, null, false);
+    
+    PKey stop = new PKey();
+    stop.setRow("5".getBytes());
+    String cookie = tpc.proxy().createBatchScanner(userpass, testTable, null, null, null);
+    
+    int i = 0;
+    start = new Date();
+    then = new Date();
+    boolean hasNext = true;
+    
+    int k = 1000;
+    while (hasNext) {
+      PScanResult kvList = tpc.proxy().scanner_next_k(cookie, k);
+      
+      Date now = new Date();
+      System.out.println(i + " " + (now.getTime() - then.getTime()));
+      then = now;
+      
+      i += kvList.getResultsSize();
+      // for (TKeyValue kv:kvList.getResults()) System.out.println(new Key(kv.getKey()));
+      hasNext = kvList.isMore();
+    }
+    end = new Date();
+    System.out.println("Total entries: " + i + " total time " + (end.getTime() - start.getTime()));
+  }
+}

Propchange: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Util.java?rev=1434921&view=auto
==============================================================================
--- accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Util.java (added)
+++ accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Util.java Thu Jan 17 21:22:35 2013
@@ -0,0 +1,62 @@
+/*
+ * 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 org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.proxy.thrift.PIteratorSetting;
+import org.apache.accumulo.proxy.thrift.PKey;
+
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.util.Random;
+
+public class Util {
+  
+  private static Random random = new Random(0);
+  
+  public static String randString(int numbytes) {
+    return new BigInteger(numbytes * 5, random).toString(32);
+  }
+  
+  public static ByteBuffer randStringBuffer(int numbytes) {
+    return ByteBuffer.wrap(new BigInteger(numbytes * 5, random).toString(32).getBytes());
+  }
+  
+  public static PIteratorSetting iteratorSetting2ProxyIteratorSetting(IteratorSetting is) {
+    return new PIteratorSetting(is.getPriority(), is.getName(), is.getIteratorClass(), is.getOptions());
+  }
+  
+  public static PKey toThrift(Key key) {
+    PKey pkey = new PKey(ByteBuffer.wrap(key.getRow().getBytes()), ByteBuffer.wrap(key.getColumnFamily().getBytes()), ByteBuffer.wrap(key.getColumnQualifier()
+        .getBytes()), ByteBuffer.wrap(key.getColumnVisibility().getBytes()));
+    pkey.setTimestamp(key.getTimestamp());
+    return pkey;
+  }
+  
+  public static Key fromThrift(PKey pkey) {
+    return new Key(deNullify(pkey.getRow()), deNullify(pkey.getColFamily()), deNullify(pkey.getColQualifier()), deNullify(pkey.getColVisibility()),
+        pkey.getTimestamp());
+  }
+  
+  protected static byte[] deNullify(byte[] in) {
+    if (in == null)
+      return new byte[0];
+    else
+      return in;
+  }
+}

Propchange: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message