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 7FA131033D for ; Mon, 10 Mar 2014 03:51:00 +0000 (UTC) Received: (qmail 72352 invoked by uid 500); 10 Mar 2014 03:50:59 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 72243 invoked by uid 500); 10 Mar 2014 03:50:51 -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 71645 invoked by uid 99); 10 Mar 2014 03:50:27 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Mar 2014 03:50:27 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2903293BCB1; Mon, 10 Mar 2014 03:50:26 +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: Mon, 10 Mar 2014 03:50:28 -0000 Message-Id: In-Reply-To: <2f1b48abd8824b52a3df62f19fdf584a@git.apache.org> References: <2f1b48abd8824b52a3df62f19fdf584a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/6] git commit: ACCUMULO-2438 Backport the changes to ensure that we watch separate sets of tables for merges ACCUMULO-2438 Backport the changes to ensure that we watch separate sets of tables for merges Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/12b53b04 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/12b53b04 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/12b53b04 Branch: refs/heads/master Commit: 12b53b043b60368fb647db9c0a15916171d4504b Parents: 18006d2 Author: Josh Elser Authored: Sun Mar 9 23:34:18 2014 -0400 Committer: Josh Elser Committed: Sun Mar 9 23:48:44 2014 -0400 ---------------------------------------------------------------------- .../apache/accumulo/server/master/Master.java | 9 ++- .../apache/accumulo/test/DeleteRowsTest.java | 78 ++++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/12b53b04/server/src/main/java/org/apache/accumulo/server/master/Master.java ---------------------------------------------------------------------- diff --git a/server/src/main/java/org/apache/accumulo/server/master/Master.java b/server/src/main/java/org/apache/accumulo/server/master/Master.java index e72fe3f..8c4c864 100644 --- a/server/src/main/java/org/apache/accumulo/server/master/Master.java +++ b/server/src/main/java/org/apache/accumulo/server/master/Master.java @@ -1288,9 +1288,10 @@ public class Master implements LiveTServerSet.Listener, TableObserver, CurrentSt int unloaded = 0; try { Map mergeStatsCache = new HashMap(); + Map currentMerges = new HashMap(); for (MergeInfo merge : merges()) { if (merge.getRange() != null) { - mergeStatsCache.put(merge.getRange().getTableId(), new MergeStats(merge)); + currentMerges.put(merge.getRange().getTableId(), new MergeStats(merge)); } } @@ -1339,7 +1340,11 @@ public class Master implements LiveTServerSet.Listener, TableObserver, CurrentSt Text tableId = tls.extent.getTableId(); MergeStats mergeStats = mergeStatsCache.get(tableId); if (mergeStats == null) { - mergeStatsCache.put(tableId, mergeStats = new MergeStats(new MergeInfo())); + mergeStats = currentMerges.get(tableId); + if (mergeStats == null) { + mergeStats = new MergeStats(new MergeInfo()); + } + mergeStatsCache.put(tableId, mergeStats); } TabletGoalState goal = getGoalState(tls, mergeStats.getMergeInfo()); TServerInstance server = tls.getServer(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/12b53b04/test/src/test/java/org/apache/accumulo/test/DeleteRowsTest.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/DeleteRowsTest.java b/test/src/test/java/org/apache/accumulo/test/DeleteRowsTest.java new file mode 100644 index 0000000..a627dc1 --- /dev/null +++ b/test/src/test/java/org/apache/accumulo/test/DeleteRowsTest.java @@ -0,0 +1,78 @@ +/* + * 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 static org.junit.Assert.assertEquals; + +import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.ZooKeeperInstance; +import org.apache.accumulo.core.client.security.tokens.PasswordToken; +import org.apache.accumulo.core.security.Authorizations; +import org.apache.accumulo.minicluster.MiniAccumuloCluster; +import org.apache.accumulo.minicluster.MiniAccumuloConfig; +import org.apache.log4j.Logger; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.junit.rules.TestName; + +import com.google.common.collect.Iterables; + +public class DeleteRowsTest { + private static final Logger log = Logger.getLogger(DeleteRowsTest.class); + + @Rule + public TestName testName = new TestName(); + + private static String secret = "superSecret"; + public static TemporaryFolder folder = new TemporaryFolder(); + public static MiniAccumuloCluster cluster; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + folder.create(); + MiniAccumuloConfig cfg = new MiniAccumuloConfig(folder.newFolder("miniAccumulo"), secret); + cfg.setNumTservers(1); + cluster = new MiniAccumuloCluster(cfg); + cluster.start(); + + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + cluster.stop(); + folder.delete(); + } + + @Test(timeout = 120 * 1000) + public void test() throws Exception { + ZooKeeperInstance zk = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers()); + Connector c = zk.getConnector("root", new PasswordToken(secret)); + for (int i = 0; i < 20; i++) { + final String tableName = testName.getMethodName() + i; + log.debug("Creating " + tableName); + c.tableOperations().create(tableName); + log.debug("Deleting rows from " + tableName); + c.tableOperations().deleteRows(tableName, null, null); + log.debug("Verifying no rows were found"); + Scanner scanner = c.createScanner(tableName, new Authorizations()); + assertEquals(0, Iterables.size(scanner)); + } + } +}