You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/09/17 00:02:45 UTC

[1/3] git commit: ACCUMULO-3136 Be a little more rigid on the ActiveScans we observe.

Repository: accumulo
Updated Branches:
  refs/heads/1.6.1-SNAPSHOT 0055bab8b -> 2e273505d
  refs/heads/master 498f32bdf -> 503f10465


ACCUMULO-3136 Be a little more rigid on the ActiveScans we observe.

We might get scans by the system to the metadata table instead of
the scan we run in the test case. When this happens, the test will
timeout because the interrupt happens before the scan is running, and then
the scan just sits on the SlowIterator.


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

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: 2e273505d9ca2d32db48d2052f38be2625119bec
Parents: 0055bab
Author: Josh Elser <el...@apache.org>
Authored: Tue Sep 16 17:54:42 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Sep 16 18:00:17 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/test/Accumulo3030IT.java    | 27 +++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e273505/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java b/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
index bc56346..91674a5 100644
--- a/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
+++ b/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
@@ -16,15 +16,17 @@
  */
 package org.apache.accumulo.test;
 
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.Map.Entry;
 
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.admin.ActiveScan;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 import org.apache.accumulo.test.functional.ConfigurableMacIT;
 import org.apache.accumulo.test.functional.SlowIterator;
@@ -33,7 +35,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 public class Accumulo3030IT extends ConfigurableMacIT {
-  
+
   @Override
   public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
     cfg.setNumTservers(1);
@@ -58,9 +60,22 @@ public class Accumulo3030IT extends ConfigurableMacIT {
         try {
           // ensure the scan is running: not perfect, the metadata tables could be scanned, too.
           String tserver = conn.instanceOperations().getTabletServers().iterator().next();
-          while (conn.instanceOperations().getActiveScans(tserver).size() < 1) {
-            UtilWaitThread.sleep(1000);
-          }
+          do {
+            ArrayList<ActiveScan> scans = new ArrayList<ActiveScan>(conn.instanceOperations().getActiveScans(tserver));
+            Iterator<ActiveScan> iter = scans.iterator();
+            while (iter.hasNext()) {
+              ActiveScan scan = iter.next();
+              // Remove scans not against our table and not owned by us
+              if (!"root".equals(scan.getUser()) || !tableName.equals(scan.getTable())) {
+                iter.remove();
+              }
+            }
+
+            if (!scans.isEmpty()) {
+              // We found our scan
+              break;
+            }
+          } while (true);
         } catch (Exception e) {
           e.printStackTrace();
         }
@@ -79,5 +94,5 @@ public class Accumulo3030IT extends ConfigurableMacIT {
       thread.join();
     }
   }
-  
+
 }


[2/3] git commit: ACCUMULO-3136 Be a little more rigid on the ActiveScans we observe.

Posted by el...@apache.org.
ACCUMULO-3136 Be a little more rigid on the ActiveScans we observe.

We might get scans by the system to the metadata table instead of
the scan we run in the test case. When this happens, the test will
timeout because the interrupt happens before the scan is running, and then
the scan just sits on the SlowIterator.


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

Branch: refs/heads/master
Commit: 2e273505d9ca2d32db48d2052f38be2625119bec
Parents: 0055bab
Author: Josh Elser <el...@apache.org>
Authored: Tue Sep 16 17:54:42 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Sep 16 18:00:17 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/test/Accumulo3030IT.java    | 27 +++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e273505/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java b/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
index bc56346..91674a5 100644
--- a/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
+++ b/test/src/test/java/org/apache/accumulo/test/Accumulo3030IT.java
@@ -16,15 +16,17 @@
  */
 package org.apache.accumulo.test;
 
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.Map.Entry;
 
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.admin.ActiveScan;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 import org.apache.accumulo.test.functional.ConfigurableMacIT;
 import org.apache.accumulo.test.functional.SlowIterator;
@@ -33,7 +35,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 public class Accumulo3030IT extends ConfigurableMacIT {
-  
+
   @Override
   public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
     cfg.setNumTservers(1);
@@ -58,9 +60,22 @@ public class Accumulo3030IT extends ConfigurableMacIT {
         try {
           // ensure the scan is running: not perfect, the metadata tables could be scanned, too.
           String tserver = conn.instanceOperations().getTabletServers().iterator().next();
-          while (conn.instanceOperations().getActiveScans(tserver).size() < 1) {
-            UtilWaitThread.sleep(1000);
-          }
+          do {
+            ArrayList<ActiveScan> scans = new ArrayList<ActiveScan>(conn.instanceOperations().getActiveScans(tserver));
+            Iterator<ActiveScan> iter = scans.iterator();
+            while (iter.hasNext()) {
+              ActiveScan scan = iter.next();
+              // Remove scans not against our table and not owned by us
+              if (!"root".equals(scan.getUser()) || !tableName.equals(scan.getTable())) {
+                iter.remove();
+              }
+            }
+
+            if (!scans.isEmpty()) {
+              // We found our scan
+              break;
+            }
+          } while (true);
         } catch (Exception e) {
           e.printStackTrace();
         }
@@ -79,5 +94,5 @@ public class Accumulo3030IT extends ConfigurableMacIT {
       thread.join();
     }
   }
-  
+
 }


[3/3] git commit: Merge branch '1.6.1-SNAPSHOT'

Posted by el...@apache.org.
Merge branch '1.6.1-SNAPSHOT'

Conflicts:
	test/src/test/java/org/apache/accumulo/test/AllowScansToBeInterruptedIT.java


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

Branch: refs/heads/master
Commit: 503f104657afdfd0ab98674262590c4977e0754e
Parents: 498f32b 2e27350
Author: Josh Elser <el...@apache.org>
Authored: Tue Sep 16 18:01:02 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Sep 16 18:01:02 2014 -0400

----------------------------------------------------------------------
 .../test/AllowScansToBeInterruptedIT.java       | 27 +++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/503f1046/test/src/test/java/org/apache/accumulo/test/AllowScansToBeInterruptedIT.java
----------------------------------------------------------------------
diff --cc test/src/test/java/org/apache/accumulo/test/AllowScansToBeInterruptedIT.java
index 6354dcc,0000000..2f28920
mode 100644,000000..100644
--- a/test/src/test/java/org/apache/accumulo/test/AllowScansToBeInterruptedIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/AllowScansToBeInterruptedIT.java
@@@ -1,84 -1,0 +1,99 @@@
 +/*
 + * 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.test;
 +
++import java.util.ArrayList;
++import java.util.Iterator;
 +import java.util.Map.Entry;
 +
 +import org.apache.accumulo.core.client.Connector;
 +import org.apache.accumulo.core.client.IteratorSetting;
 +import org.apache.accumulo.core.client.Scanner;
++import org.apache.accumulo.core.client.admin.ActiveScan;
 +import org.apache.accumulo.core.data.Key;
 +import org.apache.accumulo.core.data.Value;
 +import org.apache.accumulo.core.security.Authorizations;
- import org.apache.accumulo.core.util.UtilWaitThread;
 +import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 +import org.apache.accumulo.test.functional.ConfigurableMacIT;
 +import org.apache.accumulo.test.functional.SlowIterator;
 +import org.apache.hadoop.conf.Configuration;
 +import org.junit.Assert;
 +import org.junit.Test;
 +
 +// Accumulo3030
 +public class AllowScansToBeInterruptedIT extends ConfigurableMacIT {
-   
++
 +  @Override
 +  public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
 +    cfg.setNumTservers(1);
 +  }
 +
 +  @Test(timeout = 60 * 1000)
 +  public void test() throws Exception {
 +    // make a table
 +    final String tableName = getUniqueNames(1)[0];
 +    final Connector conn = getConnector();
 +    conn.tableOperations().create(tableName);
 +    // make the world's slowest scanner
 +    final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
 +    final IteratorSetting cfg = new IteratorSetting(100, SlowIterator.class);
 +    SlowIterator.setSeekSleepTime(cfg, 99999*1000);
 +    scanner.addScanIterator(cfg);
 +    // create a thread to interrupt the slow scan
 +    final Thread scanThread = Thread.currentThread();
 +    Thread thread = new Thread() {
 +      @Override
 +      public void run() {
 +        try {
 +          // ensure the scan is running: not perfect, the metadata tables could be scanned, too.
 +          String tserver = conn.instanceOperations().getTabletServers().iterator().next();
-           while (conn.instanceOperations().getActiveScans(tserver).size() < 1) {
-             UtilWaitThread.sleep(1000);
-           }
++          do {
++            ArrayList<ActiveScan> scans = new ArrayList<ActiveScan>(conn.instanceOperations().getActiveScans(tserver));
++            Iterator<ActiveScan> iter = scans.iterator();
++            while (iter.hasNext()) {
++              ActiveScan scan = iter.next();
++              // Remove scans not against our table and not owned by us
++              if (!"root".equals(scan.getUser()) || !tableName.equals(scan.getTable())) {
++                iter.remove();
++              }
++            }
++
++            if (!scans.isEmpty()) {
++              // We found our scan
++              break;
++            }
++          } while (true);
 +        } catch (Exception e) {
 +          e.printStackTrace();
 +        }
 +        // BAM!
 +        scanThread.interrupt();
 +      }
 +    };
 +    thread.start();
 +    try {
 +      // Use the scanner, expect problems
 +      for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) {
 +      }
 +      Assert.fail("Scan should not succeed");
 +    } catch (Exception ex) {
 +    } finally {
 +      thread.join();
 +    }
 +  }
-   
++
 +}