Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using a ConcurrentSkipListSet rather than a HashSet in views, to prev…

…ent CCMEs
  • Loading branch information...
commit 70172ee4b898fd0d0703fdb5e1db5e6eb301abac 1 parent 170591b
@belaban authored
Showing with 9 additions and 12 deletions.
  1. +9 −12 src/org/jgroups/protocols/MERGE3.java
View
21 src/org/jgroups/protocols/MERGE3.java
@@ -15,6 +15,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.Future;
@@ -63,7 +64,7 @@
protected Future<?> view_consistency_checker;
// hashmap to keep track of view-id sent in INFO messages
- protected final ConcurrentMap<ViewId,Set<Address>> views=new ConcurrentHashMap<ViewId,Set<Address>>(view != null? view.size() : 16);
+ protected final ConcurrentMap<ViewId,SortedSet<Address>> views=new ConcurrentHashMap<ViewId,SortedSet<Address>>(view != null? view.size() : 16);
protected final ResponseCollector<View> view_rsps=new ResponseCollector<View>();
@@ -93,7 +94,7 @@ public synchronized boolean isInfoSenderRunning() {
@ManagedOperation(description="Lists the contents of the cached views")
public String dumpViews() {
StringBuilder sb=new StringBuilder();
- for(Map.Entry<ViewId,Set<Address>> entry: views.entrySet())
+ for(Map.Entry<ViewId,SortedSet<Address>> entry: views.entrySet())
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
return sb.toString();
}
@@ -255,10 +256,10 @@ public Object up(Event evt) {
down(new Event(Event.SET_PHYSICAL_ADDRESS,
new Tuple<Address,PhysicalAddress>(sender, physical_addr)));
}
- Set<Address> existing=views.get(hdr.view_id);
+ SortedSet<Address> existing=views.get(hdr.view_id);
if(existing == null) {
- existing=new HashSet<Address>();
- Set<Address> tmp=views.putIfAbsent(hdr.view_id, existing);
+ existing=new ConcurrentSkipListSet<Address>();
+ SortedSet<Address> tmp=views.putIfAbsent(hdr.view_id, existing);
if(tmp != null)
existing=tmp;
}
@@ -362,10 +363,9 @@ protected void _run() {
log.debug("I (" + local_addr + ") will be the merge leader");
// add merge participants
- for(Set<Address> set: views.values()) {
- SortedSet<Address> addrs=new TreeSet<Address>(set);
- if(!addrs.isEmpty())
- coords.add(addrs.first());
+ for(SortedSet<Address> set: views.values()) {
+ if(!set.isEmpty())
+ coords.add(set.first());
}
if(log.isTraceEnabled())
@@ -390,9 +390,6 @@ protected void _run() {
+ max_participants_in_merge + " coords");
}
-
-
-
// grab views from all members in coords
view_rsps.reset(coords);
for(Address target: coords) {
Please sign in to comment.
Something went wrong with that request. Please try again.