Author: ecn
Date: Thu Jan 24 20:16:57 2013
New Revision: 1438157

URL: http://svn.apache.org/viewvc?rev=1438157&view=rev
Log:
ACCUMULO-969 final cleanup of scanner api

Modified:
    
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
    
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
    accumulo/trunk/proxy/examples/python/TestClient.py
    accumulo/trunk/proxy/examples/ruby/test_client.rb
    
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
    
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
    
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/AccumuloProxy.java
    
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/ActiveCompaction.java
    
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/ActiveScan.java
    
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/thrift/BatchScanOptions.java
    accumulo/trunk/proxy/src/main/thrift/proxy.thrift
    accumulo/trunk/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
    
accumulo/trunk/proxy/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java

Modified: 
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java?rev=1438157&r1=1438156&r2=1438157&view=diff
==============================================================================
--- 
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
 (original)
+++ 
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
 Thu Jan 24 20:16:57 2013
@@ -243,18 +243,18 @@ public class TableOperationsHelperTest {
     try {
       t.attachIterator("table", setting);
       Assert.fail();
-    } catch (IllegalArgumentException e) {}
+    } catch (AccumuloException e) {}
     setting.setName("thirdName");
     try {
       t.attachIterator("table", setting);
       Assert.fail();
-    } catch (IllegalArgumentException e) {}
+    } catch (AccumuloException e) {}
     setting.setPriority(10);
     t.setProperty("table", "table.iterator.minc.thirdName.opt.key", "value");
     try {
       t.attachIterator("table", setting);
       Assert.fail();
-    } catch (IllegalArgumentException e) {}
+    } catch (AccumuloException e) {}
     t.removeProperty("table", "table.iterator.minc.thirdName.opt.key");
     t.attachIterator("table", setting);
   }

Modified: 
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java?rev=1438157&r1=1438156&r2=1438157&view=diff
==============================================================================
--- 
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
 (original)
+++ 
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
 Thu Jan 24 20:16:57 2013
@@ -92,7 +92,7 @@ public class MockTableOperationsTest {
                 conn.tableOperations().attachIterator(t, settings);
                 Assert.fail();
             }
-            catch (IllegalArgumentException ex) {}
+            catch (AccumuloException ex) {}
             
             writeVersionable(conn, t, 3);
             assertVersionable(conn, t, 1);

Modified: accumulo/trunk/proxy/examples/python/TestClient.py
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/python/TestClient.py?rev=1438157&r1=1438156&r2=1438157&view=diff
==============================================================================
--- accumulo/trunk/proxy/examples/python/TestClient.py (original)
+++ accumulo/trunk/proxy/examples/python/TestClient.py Thu Jan 24 20:16:57 2013
@@ -41,5 +41,6 @@ if not client.tableExists(userpass, test
 row1 = {'a':[ColumnUpdate('a','a',value='value1'), 
ColumnUpdate('b','b',value='value2')]}
 client.updateAndFlush(userpass, testtable, row1)
 
-cookie = client.createBatchScanner(userpass, testtable, "", None, None)
-print client.scanner_next_k(cookie, 10)
+cookie = client.createScanner(userpass, testtable, None)
+for entry in client.nextK(cookie, 10).results:
+   print entry

Modified: accumulo/trunk/proxy/examples/ruby/test_client.rb
URL: 
http://svn.apache.org/viewvc/accumulo/trunk/proxy/examples/ruby/test_client.rb?rev=1438157&r1=1438156&r2=1438157&view=diff
==============================================================================
--- accumulo/trunk/proxy/examples/ruby/test_client.rb (original)
+++ accumulo/trunk/proxy/examples/ruby/test_client.rb Thu Jan 24 20:16:57 2013
@@ -38,12 +38,12 @@ puts "List of tables: #{proxy.listTables
 testtable = "rubytest"
 proxy.createTable(us,testtable) unless proxy.tableExists(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)
+update1 = PColumnUpdate.new({'colFamily' => "cf1", 'colQualifier' => "cq1", 
'value'=> "a"})
+update2 = PColumnUpdate.new({'colFamily' => "cf2", 'colQualifier' => "cq2", 
'value'=> "b"})
+proxy.updateAndFlush(us,testtable,{'row1' => [update1,update2]},nil)
 
-cookie = proxy.createBatchScanner(us,testtable,{},nil,nil)
-result = proxy.scanner_next_k(cookie,10)
+cookie = proxy.createScanner(us,testtable,nil)
+result = proxy.nextK(cookie,10)
 result.results.each{ |keyvalue| puts "Key: #{keyvalue.key.inspect} Value: 
#{keyvalue.value}" }
 
 transport.close()

Modified: 
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=1438157&r1=1438156&r2=1438157&view=diff
==============================================================================
--- 
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java 
(original)
+++ 
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java 
Thu Jan 24 20:16:57 2013
@@ -200,6 +200,9 @@ public class ProxyServer implements Accu
   @Override
   public void createTable(UserPass userpass, String tableName, boolean 
versioningIter, org.apache.accumulo.proxy.thrift.TimeType timeType) throws 
TException {
     try {
+      if (timeType == null)
+        timeType = org.apache.accumulo.proxy.thrift.TimeType.MILLIS;
+      
       getConnector(userpass).tableOperations().create(tableName, 
versioningIter, TimeType.valueOf(timeType.toString()));
     } catch (Exception e) {
       throw translateException(e);
@@ -729,7 +732,7 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public String createBatchScanner(UserPass userpass, String tableName, 
BatchScanOptions opts)
+  public String createBatchScanner(UserPass userpass, String tableName, 
List<org.apache.accumulo.proxy.thrift.Range> pranges, BatchScanOptions opts)
       throws TException {
     try {
       Connector connector = getConnector(userpass);
@@ -756,10 +759,10 @@ public class ProxyServer implements Accu
         
         ArrayList<Range> ranges = new ArrayList<Range>();
         
-        if (opts.ranges == null) {
+        if (pranges == null) {
           ranges.add(new Range());
         } else {
-          for (org.apache.accumulo.proxy.thrift.Range range : opts.ranges) {
+          for (org.apache.accumulo.proxy.thrift.Range 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);
@@ -780,7 +783,7 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public boolean scanner_hasnext(String scanner) throws TException {
+  public boolean 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");
@@ -790,9 +793,9 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public KeyValueAndPeek scanner_next(String scanner) throws TException {
+  public KeyValueAndPeek nextEntry(String scanner) throws TException {
     
-    ScanResult scanResult = scanner_next_k(scanner, 1);
+    ScanResult scanResult = nextK(scanner, 1);
     if (scanResult.results.size() > 0) {
       return new KeyValueAndPeek(scanResult.results.get(0), 
scanResult.isMore());
     } else {
@@ -802,7 +805,7 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public ScanResult scanner_next_k(String scanner, int k) throws TException {
+  public ScanResult nextK(String scanner, int k) throws TException {
     
     // fetch the scanner
     ScannerPlusIterator spi = 
scannerCache.getIfPresent(UUID.fromString(scanner));
@@ -823,7 +826,7 @@ public class ProxyServer implements Accu
         }
         ret.setMore(numRead == k);
       } catch (Exception ex) {
-        close_scanner(scanner);
+        closeScanner(scanner);
         throw translateException(ex);
       }
       return ret;
@@ -831,7 +834,7 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public void close_scanner(String uuid) throws TException {
+  public void closeScanner(String uuid) throws TException {
     scannerCache.invalidate(uuid);
   }
   
@@ -898,7 +901,7 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public void writer_update(String writer, Map<ByteBuffer,List<ColumnUpdate>> 
cells) throws TException {
+  public void update(String writer, Map<ByteBuffer,List<ColumnUpdate>> cells) 
throws TException {
     try {
       BatchWriter batchwriter = 
writerCache.getIfPresent(UUID.fromString(writer));
       if (batchwriter == null) {
@@ -911,7 +914,7 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public void writer_flush(String writer) throws TException {
+  public void flush(String writer) throws TException {
     try {
       BatchWriter batchwriter = 
writerCache.getIfPresent(UUID.fromString(writer));
       if (batchwriter == null) {
@@ -924,7 +927,7 @@ public class ProxyServer implements Accu
   }
   
   @Override
-  public void writer_close(String writer) throws TException {
+  public void closeWriter(String writer) throws TException {
     try {
       BatchWriter batchwriter = 
writerCache.getIfPresent(UUID.fromString(writer));
       if (batchwriter == null) {

Modified: 
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=1438157&r1=1438156&r2=1438157&view=diff
==============================================================================
--- 
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
 (original)
+++ 
accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
 Thu Jan 24 20:16:57 2013
@@ -122,7 +122,7 @@ public class TestProxyClient {
       ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + 
i).getBytes()), ByteBuffer.wrap(("cq" + i).getBytes()));
       update.setValue(Util.randStringBuffer(10));
       mutations.put(ByteBuffer.wrap(result.getBytes()), 
Collections.singletonList(update));
-      tpc.proxy().writer_update(writer, mutations);
+      tpc.proxy().update(writer, mutations);
       mutations.clear();
     }
     
@@ -130,7 +130,7 @@ public class TestProxyClient {
     System.out.println(" End of writing: " + (end.getTime() - 
start.getTime()));
     start = end;
     System.out.println("Closing...");
-    tpc.proxy().writer_close(writer);
+    tpc.proxy().closeWriter(writer);
     end = new Date();
     System.out.println(" End of closing: " + (end.getTime() - 
start.getTime()));
     
@@ -141,9 +141,7 @@ public class TestProxyClient {
     IteratorSetting is = new IteratorSetting(50, regex, RegExFilter.class);
     RegExFilter.setRegexs(is, null, regex, null, null, false);
     
-    Key stop = new Key();
-    stop.setRow("5".getBytes());
-    String cookie = tpc.proxy().createBatchScanner(userpass, testTable, null);
+    String cookie = tpc.proxy().createScanner(userpass, testTable, null);
     
     int i = 0;
     start = new Date();
@@ -152,7 +150,7 @@ public class TestProxyClient {
     
     int k = 1000;
     while (hasNext) {
-      ScanResult kvList = tpc.proxy().scanner_next_k(cookie, k);
+      ScanResult kvList = tpc.proxy().nextK(cookie, k);
       
       Date now = new Date();
       System.out.println(i + " " + (now.getTime() - then.getTime()));


Reply via email to