You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2015/07/17 15:40:06 UTC
[1/5] cassandra git commit: Fix comparison contract violation in the
dynamic snitch sorting
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.2 f74419cd2 -> f60e4ad42
Fix comparison contract violation in the dynamic snitch sorting
patch by slebresne; reviewed by benedict for CASSANDRA-9519
Conflicts:
CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a9b9e627
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a9b9e627
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a9b9e627
Branch: refs/heads/cassandra-2.2
Commit: a9b9e627b0256a7b55dbfefa6960e1e5b8379e64
Parents: 1d54fc3
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Thu Jul 9 13:28:38 2015 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Jul 17 15:35:07 2015 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../locator/DynamicEndpointSnitch.java | 34 ++++++++--
.../locator/DynamicEndpointSnitchTest.java | 69 +++++++++++++++++++-
3 files changed, 95 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a9b9e627/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a755cb9..f20fad8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.0.17
+ * Complete CASSANDRA-8448 fix (CASSANDRA-9519)
* Don't include auth credentials in debug log (CASSANDRA-9682)
* Can't transition from write survey to normal mode (CASSANDRA-9740)
* Avoid NPE in AuthSuccess#decode (CASSANDRA-9727)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a9b9e627/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
index 3469847..f226989 100644
--- a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
+++ b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
@@ -42,9 +42,9 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
private static final double ALPHA = 0.75; // set to 0.75 to make EDS more biased to towards the newer values
private static final int WINDOW_SIZE = 100;
- private int UPDATE_INTERVAL_IN_MS = DatabaseDescriptor.getDynamicUpdateInterval();
- private int RESET_INTERVAL_IN_MS = DatabaseDescriptor.getDynamicResetInterval();
- private double BADNESS_THRESHOLD = DatabaseDescriptor.getDynamicBadnessThreshold();
+ private final int UPDATE_INTERVAL_IN_MS = DatabaseDescriptor.getDynamicUpdateInterval();
+ private final int RESET_INTERVAL_IN_MS = DatabaseDescriptor.getDynamicResetInterval();
+ private final double BADNESS_THRESHOLD = DatabaseDescriptor.getDynamicBadnessThreshold();
// the score for a merged set of endpoints must be this much worse than the score for separate endpoints to
// warrant not merging two ranges into a single range
@@ -154,7 +154,18 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
private void sortByProximityWithScore(final InetAddress address, List<InetAddress> addresses)
{
- super.sortByProximity(address, addresses);
+ // Scores can change concurrently from a call to this method. But Collections.sort() expects
+ // its comparator to be "stable", that is 2 endpoint should compare the same way for the duration
+ // of the sort() call. As we copy the scores map on write, it is thus enough to alias the current
+ // version of it during this call.
+ final HashMap<InetAddress, Double> scores = this.scores;
+ Collections.sort(addresses, new Comparator<InetAddress>()
+ {
+ public int compare(InetAddress a1, InetAddress a2)
+ {
+ return compareEndpoints(address, a1, a2, scores);
+ }
+ });
}
private void sortByProximityWithBadness(final InetAddress address, List<InetAddress> addresses)
@@ -163,6 +174,8 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
return;
subsnitch.sortByProximity(address, addresses);
+ HashMap<InetAddress, Double> scores = this.scores; // Make sure the score don't change in the middle of the loop below
+ // (which wouldn't really matter here but its cleaner that way).
ArrayList<Double> subsnitchOrderedScores = new ArrayList<>(addresses.size());
for (InetAddress inet : addresses)
{
@@ -189,7 +202,8 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
}
}
- public int compareEndpoints(InetAddress target, InetAddress a1, InetAddress a2)
+ // Compare endpoints given an immutable snapshot of the scores
+ private int compareEndpoints(InetAddress target, InetAddress a1, InetAddress a2, Map<InetAddress, Double> scores)
{
Double scored1 = scores.get(a1);
Double scored2 = scores.get(a2);
@@ -214,6 +228,14 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
return 1;
}
+ public int compareEndpoints(InetAddress target, InetAddress a1, InetAddress a2)
+ {
+ // That function is fundamentally unsafe because the scores can change at any time and so the result of that
+ // method is not stable for identical arguments. This is why we don't rely on super.sortByProximity() in
+ // sortByProximityWithScore().
+ throw new UnsupportedOperationException("You shouldn't wrap the DynamicEndpointSnitch (within itself or otherwise)");
+ }
+
public void receiveTiming(InetAddress host, long latency) // this is cheap
{
ExponentiallyDecayingSample sample = samples.get(host);
@@ -263,7 +285,6 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
scores = newScores;
}
-
private void reset()
{
for (ExponentiallyDecayingSample sample : samples.values())
@@ -287,6 +308,7 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
{
return BADNESS_THRESHOLD;
}
+
public String getSubsnitchClassName()
{
return subsnitch.getClass().getName();
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a9b9e627/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java b/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
index e23bcfa..3f90532 100644
--- a/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
+++ b/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
@@ -21,9 +21,9 @@ package org.apache.cassandra.locator;
import java.io.IOException;
import java.net.InetAddress;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
+import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.service.StorageService;
import org.junit.Test;
@@ -90,4 +90,67 @@ public class DynamicEndpointSnitchTest
order = Arrays.asList(host1, host3, host2);
assertEquals(order, dsnitch.getSortedListByProximity(self, Arrays.asList(host1, host2, host3)));
}
-}
\ No newline at end of file
+
+ @Test
+ public void testConcurrency() throws InterruptedException, IOException, ConfigurationException
+ {
+ // The goal of this test is to check for CASSANDRA-8448/CASSANDRA-9519
+ double badness = DatabaseDescriptor.getDynamicBadnessThreshold();
+ DatabaseDescriptor.setDynamicBadnessThreshold(0.0);
+
+ final int ITERATIONS = 10;
+
+ // do this because SS needs to be initialized before DES can work properly.
+ StorageService.instance.initClient(0);
+ SimpleSnitch ss = new SimpleSnitch();
+ DynamicEndpointSnitch dsnitch = new DynamicEndpointSnitch(ss, String.valueOf(ss.hashCode()));
+ InetAddress self = FBUtilities.getBroadcastAddress();
+
+ List<InetAddress> hosts = new ArrayList<>();
+ // We want a giant list of hosts so that sorting it takes time, making it much more likely to reproduce the
+ // problem we're looking for.
+ for (int i = 0; i < 10; i++)
+ for (int j = 0; j < 256; j++)
+ for (int k = 0; k < 256; k++)
+ hosts.add(InetAddress.getByAddress(new byte[]{127, (byte)i, (byte)j, (byte)k}));
+
+ ScoreUpdater updater = new ScoreUpdater(dsnitch, hosts);
+ updater.start();
+
+ List<InetAddress> result = null;
+ for (int i = 0; i < ITERATIONS; i++)
+ result = dsnitch.getSortedListByProximity(self, hosts);
+
+ updater.stopped = true;
+ updater.join();
+
+ DatabaseDescriptor.setDynamicBadnessThreshold(badness);
+ }
+
+ public static class ScoreUpdater extends Thread
+ {
+ private static final int SCORE_RANGE = 100;
+
+ public volatile boolean stopped;
+
+ private final DynamicEndpointSnitch dsnitch;
+ private final List<InetAddress> hosts;
+ private final Random random = new Random();
+
+ public ScoreUpdater(DynamicEndpointSnitch dsnitch, List<InetAddress> hosts)
+ {
+ this.dsnitch = dsnitch;
+ this.hosts = hosts;
+ }
+
+ public void run()
+ {
+ while (!stopped)
+ {
+ InetAddress host = hosts.get(random.nextInt(hosts.size()));
+ int score = random.nextInt(SCORE_RANGE);
+ dsnitch.receiveTiming(host, score);
+ }
+ }
+ }
+}
[5/5] cassandra git commit: Don't wrap byte arrays in SequentialWriter
Posted by sl...@apache.org.
Don't wrap byte arrays in SequentialWriter
patch by slebresne; reviewed by snazy & benedict for CASSANDRA-9797
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f60e4ad4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f60e4ad4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f60e4ad4
Branch: refs/heads/cassandra-2.2
Commit: f60e4ad4298725dac57c36da8427d992be19eb8a
Parents: 22c97bc
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Fri Jul 17 15:39:32 2015 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Jul 17 15:39:32 2015 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../cassandra/io/util/SequentialWriter.java | 22 ++++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f60e4ad4/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9a262dc..47d1db5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.2.0-rc3
+ * Don't wrap byte arrays in SequentialWriter (CASSANDRA-9797)
* sum() and avg() functions missing for smallint and tinyint types (CASSANDRA-9671)
* Revert CASSANDRA-9542 (allow native functions in UDA) (CASSANDRA-9771)
Merged from 2.1:
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f60e4ad4/src/java/org/apache/cassandra/io/util/SequentialWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/SequentialWriter.java b/src/java/org/apache/cassandra/io/util/SequentialWriter.java
index f3268a2..915133f 100644
--- a/src/java/org/apache/cassandra/io/util/SequentialWriter.java
+++ b/src/java/org/apache/cassandra/io/util/SequentialWriter.java
@@ -185,12 +185,30 @@ public class SequentialWriter extends OutputStream implements WritableByteChanne
public void write(byte[] buffer) throws IOException
{
- write(ByteBuffer.wrap(buffer, 0, buffer.length));
+ write(buffer, 0, buffer.length);
}
public void write(byte[] data, int offset, int length) throws IOException
{
- write(ByteBuffer.wrap(data, offset, length));
+ if (buffer == null)
+ throw new ClosedChannelException();
+
+ int position = offset;
+ int remaining = length;
+ while (remaining > 0)
+ {
+ if (!buffer.hasRemaining())
+ reBuffer();
+
+ int toCopy = Math.min(remaining, buffer.remaining());
+ buffer.put(data, position, toCopy);
+
+ remaining -= toCopy;
+ position += toCopy;
+
+ isDirty = true;
+ syncNeeded = true;
+ }
}
public int write(ByteBuffer src) throws IOException
[3/5] cassandra git commit: Merge branch 'cassandra-2.0' into
cassandra-2.1
Posted by sl...@apache.org.
Merge branch 'cassandra-2.0' into cassandra-2.1
Conflicts:
CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2d462c04
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2d462c04
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2d462c04
Branch: refs/heads/cassandra-2.2
Commit: 2d462c04973a15e84ca550ce3913d08d7c5ee8c8
Parents: 1eda7cb 0ef1888
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Fri Jul 17 15:36:24 2015 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Jul 17 15:36:24 2015 +0200
----------------------------------------------------------------------
CHANGES.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d462c04/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 49cc850,f20fad8..c6774c2
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,32 -1,7 +1,32 @@@
-2.0.17
+2.1.9
+ * Fix broken logging for "empty" flushes in Memtable (CASSANDRA-9837)
- * Complete CASSANDRA-8448 fix (CASSANDRA-9519)
+ * Handle corrupt files on startup (CASSANDRA-9686)
+ * Fix clientutil jar and tests (CASSANDRA-9760)
+ * (cqlsh) Allow the SSL protocol version to be specified through the
+ config file or environment variables (CASSANDRA-9544)
+Merged from 2.0:
+ * Complete CASSANDRA-8448 fix (CASSANDRA-9519)
* Don't include auth credentials in debug log (CASSANDRA-9682)
* Can't transition from write survey to normal mode (CASSANDRA-9740)
+ * Scrub (recover) sstables even when -Index.db is missing, (CASSANDRA-9591)
+ * Fix growing pending background compaction (CASSANDRA-9662)
+
+
+2.1.8
+ * (cqlsh) Fix bad check for CQL compatibility when DESCRIBE'ing
+ COMPACT STORAGE tables with no clustering columns
+ * Warn when an extra-large partition is compacted (CASSANDRA-9643)
+ * Eliminate strong self-reference chains in sstable ref tidiers (CASSANDRA-9656)
+ * Ensure StreamSession uses canonical sstable reader instances (CASSANDRA-9700)
+ * Ensure memtable book keeping is not corrupted in the event we shrink usage (CASSANDRA-9681)
+ * Update internal python driver for cqlsh (CASSANDRA-9064)
+ * Fix IndexOutOfBoundsException when inserting tuple with too many
+ elements using the string literal notation (CASSANDRA-9559)
+ * Allow JMX over SSL directly from nodetool (CASSANDRA-9090)
+ * Fix incorrect result for IN queries where column not found (CASSANDRA-9540)
+ * Enable describe on indices (CASSANDRA-7814)
+ * ColumnFamilyStore.selectAndReference may block during compaction (CASSANDRA-9637)
+Merged from 2.0:
* Avoid NPE in AuthSuccess#decode (CASSANDRA-9727)
* Add listen_address to system.local (CASSANDRA-9603)
* Bug fixes to resultset metadata construction (CASSANDRA-9636)
[4/5] cassandra git commit: Merge branch 'cassandra-2.1' into
cassandra-2.2
Posted by sl...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/22c97bc5
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/22c97bc5
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/22c97bc5
Branch: refs/heads/cassandra-2.2
Commit: 22c97bc5ef5017663a40d25bd5b7283c09e25dd5
Parents: f74419c 2d462c0
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Fri Jul 17 15:36:49 2015 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Jul 17 15:36:49 2015 +0200
----------------------------------------------------------------------
CHANGES.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/22c97bc5/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index e6c093d,c6774c2..9a262dc
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,17 -1,14 +1,17 @@@
-2.1.9
+2.2.0-rc3
+ * sum() and avg() functions missing for smallint and tinyint types (CASSANDRA-9671)
+ * Revert CASSANDRA-9542 (allow native functions in UDA) (CASSANDRA-9771)
+Merged from 2.1:
* Fix broken logging for "empty" flushes in Memtable (CASSANDRA-9837)
- * Complete CASSANDRA-8448 fix (CASSANDRA-9519)
* Handle corrupt files on startup (CASSANDRA-9686)
* Fix clientutil jar and tests (CASSANDRA-9760)
* (cqlsh) Allow the SSL protocol version to be specified through the
config file or environment variables (CASSANDRA-9544)
Merged from 2.0:
+ * Complete CASSANDRA-8448 fix (CASSANDRA-9519)
* Don't include auth credentials in debug log (CASSANDRA-9682)
* Can't transition from write survey to normal mode (CASSANDRA-9740)
- * Scrub (recover) sstables even when -Index.db is missing, (CASSANDRA-9591)
+ * Scrub (recover) sstables even when -Index.db is missing (CASSANDRA-9591)
* Fix growing pending background compaction (CASSANDRA-9662)
[2/5] cassandra git commit: Move CASSANDRA-9519 test in long tests
(and reduce the size of the list used)
Posted by sl...@apache.org.
Move CASSANDRA-9519 test in long tests (and reduce the size of the list used)
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0ef18886
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0ef18886
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0ef18886
Branch: refs/heads/cassandra-2.2
Commit: 0ef188869049ec6233d115f7a46c25f492e8fa42
Parents: a9b9e62
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Thu Jul 16 15:14:54 2015 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Jul 17 15:35:24 2015 +0200
----------------------------------------------------------------------
.../locator/DynamicEndpointSnitchLongTest.java | 104 +++++++++++++++++++
.../locator/DynamicEndpointSnitchTest.java | 64 ------------
2 files changed, 104 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ef18886/test/long/org/apache/cassandra/locator/DynamicEndpointSnitchLongTest.java
----------------------------------------------------------------------
diff --git a/test/long/org/apache/cassandra/locator/DynamicEndpointSnitchLongTest.java b/test/long/org/apache/cassandra/locator/DynamicEndpointSnitchLongTest.java
new file mode 100644
index 0000000..1c628fa
--- /dev/null
+++ b/test/long/org/apache/cassandra/locator/DynamicEndpointSnitchLongTest.java
@@ -0,0 +1,104 @@
+/*
+* 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.locator;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.*;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.service.StorageService;
+import org.junit.Test;
+
+import org.apache.cassandra.utils.FBUtilities;
+
+import static org.junit.Assert.assertEquals;
+
+public class DynamicEndpointSnitchLongTest
+{
+ @Test
+ public void testConcurrency() throws InterruptedException, IOException, ConfigurationException
+ {
+ // The goal of this test is to check for CASSANDRA-8448/CASSANDRA-9519
+ double badness = DatabaseDescriptor.getDynamicBadnessThreshold();
+ DatabaseDescriptor.setDynamicBadnessThreshold(0.0);
+
+ try
+ {
+ final int ITERATIONS = 10000;
+
+ // do this because SS needs to be initialized before DES can work properly.
+ StorageService.instance.initClient(0);
+ SimpleSnitch ss = new SimpleSnitch();
+ DynamicEndpointSnitch dsnitch = new DynamicEndpointSnitch(ss, String.valueOf(ss.hashCode()));
+ InetAddress self = FBUtilities.getBroadcastAddress();
+
+ List<InetAddress> hosts = new ArrayList<>();
+ // We want a big list of hosts so sorting takes time, making it much more likely to reproduce the
+ // problem we're looking for.
+ for (int i = 0; i < 100; i++)
+ for (int j = 0; j < 256; j++)
+ hosts.add(InetAddress.getByAddress(new byte[]{127, 0, (byte)i, (byte)j}));
+
+ ScoreUpdater updater = new ScoreUpdater(dsnitch, hosts);
+ updater.start();
+
+ List<InetAddress> result = null;
+ for (int i = 0; i < ITERATIONS; i++)
+ result = dsnitch.getSortedListByProximity(self, hosts);
+
+ updater.stopped = true;
+ updater.join();
+ }
+ finally
+ {
+ DatabaseDescriptor.setDynamicBadnessThreshold(badness);
+ }
+ }
+
+ public static class ScoreUpdater extends Thread
+ {
+ private static final int SCORE_RANGE = 100;
+
+ public volatile boolean stopped;
+
+ private final DynamicEndpointSnitch dsnitch;
+ private final List<InetAddress> hosts;
+ private final Random random = new Random();
+
+ public ScoreUpdater(DynamicEndpointSnitch dsnitch, List<InetAddress> hosts)
+ {
+ this.dsnitch = dsnitch;
+ this.hosts = hosts;
+ }
+
+ public void run()
+ {
+ while (!stopped)
+ {
+ InetAddress host = hosts.get(random.nextInt(hosts.size()));
+ int score = random.nextInt(SCORE_RANGE);
+ dsnitch.receiveTiming(host, score);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ef18886/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java b/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
index 3f90532..c1928d8 100644
--- a/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
+++ b/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.net.InetAddress;
import java.util.*;
-import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.service.StorageService;
import org.junit.Test;
@@ -90,67 +89,4 @@ public class DynamicEndpointSnitchTest
order = Arrays.asList(host1, host3, host2);
assertEquals(order, dsnitch.getSortedListByProximity(self, Arrays.asList(host1, host2, host3)));
}
-
- @Test
- public void testConcurrency() throws InterruptedException, IOException, ConfigurationException
- {
- // The goal of this test is to check for CASSANDRA-8448/CASSANDRA-9519
- double badness = DatabaseDescriptor.getDynamicBadnessThreshold();
- DatabaseDescriptor.setDynamicBadnessThreshold(0.0);
-
- final int ITERATIONS = 10;
-
- // do this because SS needs to be initialized before DES can work properly.
- StorageService.instance.initClient(0);
- SimpleSnitch ss = new SimpleSnitch();
- DynamicEndpointSnitch dsnitch = new DynamicEndpointSnitch(ss, String.valueOf(ss.hashCode()));
- InetAddress self = FBUtilities.getBroadcastAddress();
-
- List<InetAddress> hosts = new ArrayList<>();
- // We want a giant list of hosts so that sorting it takes time, making it much more likely to reproduce the
- // problem we're looking for.
- for (int i = 0; i < 10; i++)
- for (int j = 0; j < 256; j++)
- for (int k = 0; k < 256; k++)
- hosts.add(InetAddress.getByAddress(new byte[]{127, (byte)i, (byte)j, (byte)k}));
-
- ScoreUpdater updater = new ScoreUpdater(dsnitch, hosts);
- updater.start();
-
- List<InetAddress> result = null;
- for (int i = 0; i < ITERATIONS; i++)
- result = dsnitch.getSortedListByProximity(self, hosts);
-
- updater.stopped = true;
- updater.join();
-
- DatabaseDescriptor.setDynamicBadnessThreshold(badness);
- }
-
- public static class ScoreUpdater extends Thread
- {
- private static final int SCORE_RANGE = 100;
-
- public volatile boolean stopped;
-
- private final DynamicEndpointSnitch dsnitch;
- private final List<InetAddress> hosts;
- private final Random random = new Random();
-
- public ScoreUpdater(DynamicEndpointSnitch dsnitch, List<InetAddress> hosts)
- {
- this.dsnitch = dsnitch;
- this.hosts = hosts;
- }
-
- public void run()
- {
- while (!stopped)
- {
- InetAddress host = hosts.get(random.nextInt(hosts.size()));
- int score = random.nextInt(SCORE_RANGE);
- dsnitch.receiveTiming(host, score);
- }
- }
- }
}