Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E68311425 for ; Tue, 16 Sep 2014 22:02:46 +0000 (UTC) Received: (qmail 42551 invoked by uid 500); 16 Sep 2014 22:02:45 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 42512 invoked by uid 500); 16 Sep 2014 22:02:45 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 42503 invoked by uid 99); 16 Sep 2014 22:02:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2014 22:02:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8DE0DA172C0; Tue, 16 Sep 2014 22:02:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Tue, 16 Sep 2014 22:02:47 -0000 Message-Id: <27d3b99f2f1340b1a18461a06150d60f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/3] git commit: Merge branch '1.6.1-SNAPSHOT' 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 Authored: Tue Sep 16 18:01:02 2014 -0400 Committer: Josh Elser 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 scans = new ArrayList(conn.instanceOperations().getActiveScans(tserver)); ++ Iterator 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 entry : scanner) { + } + Assert.fail("Scan should not succeed"); + } catch (Exception ex) { + } finally { + thread.join(); + } + } - ++ +}