Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-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 1E601175C9 for ; Wed, 3 Jun 2015 21:58:48 +0000 (UTC) Received: (qmail 1290 invoked by uid 500); 3 Jun 2015 21:58:47 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 1202 invoked by uid 500); 3 Jun 2015 21:58:47 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 947 invoked by uid 99); 3 Jun 2015 21:58:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jun 2015 21:58:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 86ED8E3028; Wed, 3 Jun 2015 21:58:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: benedict@apache.org To: commits@cassandra.apache.org Date: Wed, 03 Jun 2015 21:58:49 -0000 Message-Id: <9380aa962d034ebda3f6afe6eea2015d@git.apache.org> In-Reply-To: <9efbb97a3ff94178bb085a3da898e932@git.apache.org> References: <9efbb97a3ff94178bb085a3da898e932@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/6] cassandra git commit: Replace IndexSummaryManagerTest.testCompactionRace with DataTrackerTest.testCompactOnlyCorrectInstance Replace IndexSummaryManagerTest.testCompactionRace with DataTrackerTest.testCompactOnlyCorrectInstance patch by benedict; reviewed by ariel for CASSANDRA-9271 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/be3e3895 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/be3e3895 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/be3e3895 Branch: refs/heads/trunk Commit: be3e3895863211fa79556170be1a584db71f8543 Parents: 80ef282 Author: Benedict Elliott Smith Authored: Wed Jun 3 22:47:32 2015 +0100 Committer: Benedict Elliott Smith Committed: Wed Jun 3 22:47:32 2015 +0100 ---------------------------------------------------------------------- .../apache/cassandra/db/DataTrackerTest.java | 65 ++++++++++++++++++ .../io/sstable/IndexSummaryManagerTest.java | 72 -------------------- 2 files changed, 65 insertions(+), 72 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/be3e3895/test/unit/org/apache/cassandra/db/DataTrackerTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/DataTrackerTest.java b/test/unit/org/apache/cassandra/db/DataTrackerTest.java new file mode 100644 index 0000000..b557ee3 --- /dev/null +++ b/test/unit/org/apache/cassandra/db/DataTrackerTest.java @@ -0,0 +1,65 @@ +/* +* 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.cassandra.db; + +import java.nio.ByteBuffer; +import java.util.HashSet; +import java.util.Set; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import org.junit.Test; + +import junit.framework.Assert; +import org.apache.cassandra.SchemaLoader; +import org.apache.cassandra.Util; +import org.apache.cassandra.io.sstable.SSTableReader; +import org.apache.cassandra.utils.ByteBufferUtil; + +public class DataTrackerTest extends SchemaLoader +{ + private static final String KEYSPACE = "Keyspace1"; + private static final String CF = "Standard1"; + + @Test + public void testCompactOnlyCorrectInstance() + { + Keyspace keyspace = Keyspace.open(KEYSPACE); + ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF); + cfs.truncateBlocking(); + for (int j = 0; j < 100; j ++) + { + ByteBuffer key = ByteBufferUtil.bytes(String.valueOf(j)); + Mutation rm = new Mutation(KEYSPACE, key); + rm.add(CF, Util.cellname("0"), ByteBufferUtil.EMPTY_BYTE_BUFFER, j); + rm.apply(); + } + cfs.forceBlockingFlush(); + Set sstables = new HashSet<>(cfs.getSSTables()); + assert sstables.size() == 1; + SSTableReader reader = Iterables.getFirst(sstables, null); + SSTableReader reader2 = reader.cloneAsShadowed(new Runnable() { public void run() { } }); + Assert.assertFalse(cfs.getDataTracker().markCompacting(ImmutableList.of(reader2))); + Assert.assertTrue(cfs.getDataTracker().markCompacting(ImmutableList.of(reader))); + cfs.getDataTracker().replaceWithNewInstances(ImmutableList.of(reader), ImmutableList.of(reader2)); + cfs.getDataTracker().unmarkCompacting(ImmutableList.of(reader)); + cfs.truncateBlocking(); + } + +} http://git-wip-us.apache.org/repos/asf/cassandra/blob/be3e3895/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java index 877b6e6..64d3354 100644 --- a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java +++ b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java @@ -499,76 +499,4 @@ public class IndexSummaryManagerTest extends SchemaLoader assertTrue(entry.getValue() >= cfs.metadata.getMinIndexInterval()); } } - - //This test runs last, since cleaning up compactions and tp is a pain - @Test - public void testCompactionRace() throws InterruptedException, ExecutionException - { - String ksname = "Keyspace1"; - String cfname = "StandardRace"; // index interval of 8, no key caching - Keyspace keyspace = Keyspace.open(ksname); - ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname); - int numSSTables = 50; - int numRows = 1 << 10; - createSSTables(ksname, cfname, numSSTables, numRows); - - List sstables = new ArrayList<>(cfs.getSSTables()); - - ExecutorService tp = Executors.newFixedThreadPool(2); - - final AtomicBoolean failed = new AtomicBoolean(false); - - for (int i = 0; i < 2; i++) - { - tp.submit(new Runnable() - { - @Override - public void run() - { - while(!failed.get()) - { - try - { - IndexSummaryManager.instance.redistributeSummaries(); - } - catch (Throwable e) - { - failed.set(true); - } - } - } - }); - } - - while ( cfs.getSSTables().size() != 1 ) - cfs.forceMajorCompaction(); - - try - { - Assert.assertFalse(failed.getAndSet(true)); - - for (SSTableReader sstable : sstables) - { - Assert.assertEquals(true, sstable.isMarkedCompacted()); - } - - Assert.assertEquals(numSSTables, sstables.size()); - - try - { - totalOffHeapSize(sstables); - Assert.fail("This should have failed"); - } catch (AssertionError e) - { - - } - } - finally - { - tp.shutdownNow(); - CompactionManager.instance.finishCompactionsAndShutdown(10, TimeUnit.SECONDS); - } - - cfs.truncateBlocking(); - } }