accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/3] git commit: Merge branch '1.6.1-SNAPSHOT'
Date Tue, 16 Sep 2014 22:02:47 GMT
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 <elserj@apache.org>
Authored: Tue Sep 16 18:01:02 2014 -0400
Committer: Josh Elser <elserj@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();
 +    }
 +  }
-   
++
 +}


Mime
View raw message