public class CacheServerListBarrierListener extends Object implements BarrierListener
BarrierListener implementation for synchronizing the cache server list among all clients which have joined the same zookeeper server| Modifier and Type | Field and Description |
|---|---|
protected MemcachedCache |
cache |
protected String |
cacheName |
static String |
DEFAULT_SERVER_LIST_CHARSET |
protected Set<SocketAddress> |
localCacheServerSet |
| Constructor and Description |
|---|
CacheServerListBarrierListener(MemcachedCache cache,
Set<SocketAddress> cacheServerSet) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCustomListener(BarrierListener listener) |
static Set<SocketAddress> |
getAddressesFromStringList(String serverList)
Split a string in the form of "host:port, host2:port" into a Set of
SocketAddress instances. |
static String |
getStringListFromAddressSet(Set<SocketAddress> servers)
Convert server set into server list like "host:port,host2:port"
|
void |
onCommit(String regionName,
String path,
byte[] remoteBytes)
Called by zookeeper clients at the same time when all are prepared for commiting something
|
void |
onDestroy(String regionName)
Called when the barrier is unregistered
|
void |
onInit(String regionName,
String path,
byte[] remoteBytes)
Called when the barrier is registered
|
void |
removeCustomListener(BarrierListener listener) |
String |
toString() |
public static final String DEFAULT_SERVER_LIST_CHARSET
protected final MemcachedCache cache
protected final String cacheName
protected final Set<SocketAddress> localCacheServerSet
public CacheServerListBarrierListener(MemcachedCache cache, Set<SocketAddress> cacheServerSet)
public void onInit(String regionName, String path, byte[] remoteBytes)
BarrierListeneronInit in interface BarrierListenerregionName - current region namepath - current data pathremoteBytes - the data of the zookeeper server. This could be null.public void onCommit(String regionName, String path, byte[] remoteBytes)
BarrierListeneronCommit in interface BarrierListenerregionName - current region namepath - current data pathremoteBytes - the changed data of the zookeeper serverpublic void onDestroy(String regionName)
BarrierListeneronDestroy in interface BarrierListenerregionName - current region namepublic void addCustomListener(BarrierListener listener)
public void removeCustomListener(BarrierListener listener)
public static Set<SocketAddress> getAddressesFromStringList(String serverList)
SocketAddress instances.
Note that colon-delimited IPv6 is also supported. For example: ::1:11211serverList - server list in the form of "host:port,host2:port"public static String getStringListFromAddressSet(Set<SocketAddress> servers)
servers - InetSocketAddress setCopyright © 2015 Project Grizzly. All Rights Reserved.