You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2013/04/24 21:40:16 UTC

svn commit: r1471607 - in /accumulo/branches/1.5/proxy/src: main/java/org/apache/accumulo/proxy/ProxyServer.java test/java/org/apache/accumulo/proxy/SimpleTest.java

Author: kturner
Date: Wed Apr 24 19:40:15 2013
New Revision: 1471607

URL: http://svn.apache.org/r1471607
Log:
ACCUMULO-1338 fixed issue w/ closeScanner() in proxy

Modified:
    accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
    accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java

Modified: accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java?rev=1471607&r1=1471606&r2=1471607&view=diff
==============================================================================
--- accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java (original)
+++ accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java Wed Apr 24 19:40:15 2013
@@ -1065,8 +1065,19 @@ public class ProxyServer implements Accu
 
   @Override
   public void closeScanner(String scanner) throws UnknownScanner, TException {
+    UUID uuid = null;
     try {
-      scannerCache.invalidate(scanner);
+      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());
     }

Modified: accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java?rev=1471607&r1=1471606&r2=1471607&view=diff
==============================================================================
--- accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java (original)
+++ accumulo/branches/1.5/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java Wed Apr 24 19:40:15 2013
@@ -329,6 +329,25 @@ public class SimpleTest {
   
   @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");
@@ -349,6 +368,22 @@ public class SimpleTest {
   
   @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);
+    
+    try {
+      client.flush(writer);
+      fail("exception not thrown");
+    } catch (UnknownWriter uw) {}
     try {
       client.flush("99999");
       fail("exception not thrown");