-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added memberUnreachable() to RouteStatusListener
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
src/org/jgroups/protocols/relay/DefaultRouteStatusListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.jgroups.protocols.relay; | ||
|
||
import org.jgroups.Address; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* The default implementation of {@link RouteStatusListener} | ||
* @author Bela Ban | ||
* @since 5.3.1 | ||
*/ | ||
public class DefaultRouteStatusListener implements RouteStatusListener { | ||
protected final Supplier<Address> addr_getter; | ||
protected final List<String> up=new ArrayList<>(), down=new ArrayList<>(); | ||
protected boolean verbose; | ||
|
||
public DefaultRouteStatusListener(Supplier<Address> s) { | ||
this.addr_getter=s; | ||
} | ||
|
||
public List<String> up() {return up;} | ||
public List<String> down() {return down;} | ||
public DefaultRouteStatusListener verbose(boolean b) {this.verbose=b; return this;} | ||
public boolean verbose() {return verbose;} | ||
public Address addr() {return addr_getter != null? addr_getter.get() : null;} | ||
|
||
@Override public synchronized void sitesUp(String... sites) { | ||
if(verbose) | ||
System.out.printf("%s: UP(%s)\n", addr(), String.join(",", sites)); | ||
up.addAll(Arrays.asList(sites)); | ||
} | ||
|
||
@Override public synchronized void sitesDown(String... sites) { | ||
if(verbose) | ||
System.out.printf("%s: DOWN(%s)\n", addr(), String.join(",", sites)); | ||
down.addAll(Arrays.asList(sites)); | ||
} | ||
|
||
@Override public void sitesUnreachable(String... sites) { | ||
if(verbose) | ||
System.out.printf("%s: SITE-UNREACHABLE(%s)\n", addr(), String.join(",", sites)); | ||
} | ||
|
||
@Override | ||
public void memberUnreachable(Address member) { | ||
if(verbose) | ||
System.out.printf("%s: MEMBER-UNREACHABLE: %s\n", addr(), member); | ||
} | ||
|
||
protected synchronized DefaultRouteStatusListener clear() {up.clear(); down.clear(); return this;} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("down: %s, up: %s", down, up); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters