Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'cassandra-2.1' into trunk

  • Loading branch information...
commit 2766711cb6a159a34b6da1572752535c9fcbb7a5 2 parents 3315e68 + d55e191
@yukim yukim authored
View
21 src/java/org/apache/cassandra/repair/RepairJob.java
@@ -19,14 +19,13 @@
import java.net.InetAddress;
import java.util.*;
-import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import com.google.common.util.concurrent.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.cassandra.concurrent.NamedThreadFactory;
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.dht.Range;
import org.apache.cassandra.dht.Token;
@@ -51,12 +50,13 @@
private final List<TreeResponse> trees = new ArrayList<>();
// once all responses are received, each tree is compared with each other, and differencer tasks
// are submitted. the job is done when all differencers are complete.
- private final Set<Differencer> differencers = new HashSet<>();
private final ListeningExecutorService taskExecutor;
private final Condition requestsSent = new SimpleCondition();
private int gcBefore = -1;
private volatile boolean failed = false;
+ /* Count down as sync completes */
+ private AtomicInteger waitForSync;
/**
* Create repair job to run on specific columnfamily
@@ -172,7 +172,7 @@ public synchronized int addTree(InetAddress endpoint, MerkleTree tree)
public void submitDifferencers()
{
assert !failed;
-
+ List<Differencer> differencers = new ArrayList<>();
// We need to difference all trees one against another
for (int i = 0; i < trees.size() - 1; ++i)
{
@@ -183,21 +183,20 @@ public void submitDifferencers()
Differencer differencer = new Differencer(desc, r1, r2);
differencers.add(differencer);
logger.debug("Queueing comparison {}", differencer);
- taskExecutor.submit(differencer);
}
}
+ waitForSync = new AtomicInteger(differencers.size());
+ for (Differencer differencer : differencers)
+ taskExecutor.submit(differencer);
+
trees.clear(); // allows gc to do its thing
}
/**
* @return true if the given node pair was the last remaining
*/
- synchronized boolean completedSynchronization(NodePair nodes, boolean success)
+ boolean completedSynchronization()
{
- if (!success)
- failed = true;
- Differencer completed = new Differencer(desc, new TreeResponse(nodes.endpoint1, null), new TreeResponse(nodes.endpoint2, null));
- differencers.remove(completed);
- return differencers.size() == 0;
+ return waitForSync.decrementAndGet() == 0;
}
}
View
2  src/java/org/apache/cassandra/repair/RepairSession.java
@@ -213,7 +213,7 @@ public void syncComplete(RepairJobDesc desc, NodePair nodes, boolean success)
logger.debug(String.format("[repair #%s] Repair completed between %s and %s on %s", getId(), nodes.endpoint1, nodes.endpoint2, desc.columnFamily));
- if (job.completedSynchronization(nodes, success))
+ if (job.completedSynchronization())
{
RepairJob completedJob = syncingJobs.remove(job.desc.columnFamily);
String remaining = syncingJobs.size() == 0 ? "" : String.format(" (%d remaining column family to sync for this session)", syncingJobs.size());
Please sign in to comment.
Something went wrong with that request. Please try again.