Permalink
Browse files

Removed num_initial_srv_mbrs and wait for responses including the coo…

…rd if break_on_coord_rsp=true (https://issues.jboss.org/browse/JGRP-1422)
  • Loading branch information...
1 parent cf7f4e1 commit bc3dacb1b352a05e840a639441d7414e94bb478d Bela Ban committed Feb 3, 2012
Showing with 5 additions and 21 deletions.
  1. +5 −21 src/org/jgroups/protocols/Discovery.java
@@ -38,8 +38,9 @@
@Property(description="Minimum number of initial members to get a response from")
protected int num_initial_members=10;
+ @Deprecated
@Property(description="Minimum number of server responses (PingData.isServer()=true). If this value is " +
- "greater than 0, we'll ignore num_initial_members")
+ "greater than 0, we'll ignore num_initial_members",deprecatedMessage="not used anymore")
protected int num_initial_srv_members=0;
@Property(description="Return from the discovery phase as soon as we have 1 coordinator response")
@@ -202,7 +203,7 @@ public void stop() {
boolean break_on_coord, ViewId view_id) {
num_discovery_requests++;
- final Responses rsps=new Responses(num_expected_rsps, num_initial_srv_members, break_on_coord, promise);
+ final Responses rsps=new Responses(num_expected_rsps, break_on_coord, promise);
synchronized(ping_responses) {
ping_responses.add(rsps);
}
@@ -631,12 +632,10 @@ public void run() {
final Promise<JoinRsp> promise;
final List<PingData> ping_rsps=new ArrayList<PingData>();
final int num_expected_rsps;
- final int num_expected_srv_rsps;
final boolean break_on_coord_rsp;
- protected Responses(int num_expected_rsps, int num_expected_srv_rsps, boolean break_on_coord_rsp, Promise<JoinRsp> promise) {
+ protected Responses(int num_expected_rsps, boolean break_on_coord_rsp, Promise<JoinRsp> promise) {
this.num_expected_rsps=num_expected_rsps;
- this.num_expected_srv_rsps=num_expected_srv_rsps;
this.break_on_coord_rsp=break_on_coord_rsp;
this.promise=promise != null? promise : new Promise<JoinRsp>();
}
@@ -680,15 +679,8 @@ else if(rsp.isCoord()) {
promise.getLock().lock();
try {
while(time_to_wait > 0 && !promise.hasResult()) {
- // if num_expected_srv_rsps > 0, then it overrides num_expected_rsps
- if(num_expected_srv_rsps > 0) {
- int received_srv_rsps=getNumServerResponses(ping_rsps);
- if(received_srv_rsps >= num_expected_srv_rsps)
- return new LinkedList<PingData>(ping_rsps);
- }
- else if(ping_rsps.size() >= num_expected_rsps) {
+ if(ping_rsps.size() >= num_expected_rsps && (break_on_coord_rsp && containsCoordinatorResponse(ping_rsps)))
return new LinkedList<PingData>(ping_rsps);
- }
if(break_on_coord_rsp && containsCoordinatorResponse(ping_rsps))
return new LinkedList<PingData>(ping_rsps);
@@ -703,14 +695,6 @@ else if(ping_rsps.size() >= num_expected_rsps) {
}
}
- private static int getNumServerResponses(Collection<PingData> rsps) {
- int cnt=0;
- for(PingData rsp: rsps) {
- if(rsp.isServer())
- cnt++;
- }
- return cnt;
- }
private static boolean containsCoordinatorResponse(Collection<PingData> rsps) {
if(rsps == null || rsps.isEmpty())

0 comments on commit bc3dacb

Please sign in to comment.