Only return cache information on the cache requested.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5877 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -57,18 +57,10 @@ public class EHCachePeerCoordinator extends CacheManagerPeerProviderFactory
|
|||||||
/** Must correspond to what's provided to the PeerManagerCacheListener in ehcache.xml. */
|
/** Must correspond to what's provided to the PeerManagerCacheListener in ehcache.xml. */
|
||||||
public static final int RMI_PORT = 40001;
|
public static final int RMI_PORT = 40001;
|
||||||
|
|
||||||
/** Caches we boldly assume exist on each peer. */
|
|
||||||
public static final String[] EHCACHES = {
|
|
||||||
EHCacheAdapter.EHCACHE_RECORD_CACHE,
|
|
||||||
EHCacheAdapter.EHCACHE_SHORT_KEYSET_CACHE,
|
|
||||||
EHCacheAdapter.EHCACHE_LONG_KEYSET_CACHE,
|
|
||||||
EHCacheAdapter.EHCACHE_RESULT_CACHE
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void initWithPeers (PeerManager peerMan)
|
public static void initWithPeers (PeerManager peerMan)
|
||||||
{
|
{
|
||||||
if (_instance == null) {
|
if (_instance == null) {
|
||||||
log.warning("No provider initialized -- not coordinating Whirled and EHCache peers.");
|
log.warning("No provider initialized -- not coordinating Presents and EHCache peers.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_instance.initWithPeers(peerMan);
|
_instance.initWithPeers(peerMan);
|
||||||
@@ -105,17 +97,17 @@ public class EHCachePeerCoordinator extends CacheManagerPeerProviderFactory
|
|||||||
throws CacheException
|
throws CacheException
|
||||||
{
|
{
|
||||||
if (_peerMan == null) {
|
if (_peerMan == null) {
|
||||||
// the ehcache subsystem has fired up but Whirled is still booting;
|
// the ehcache subsystem has fired up but the server is still booting; we return
|
||||||
// we return null here and ehcache will try again
|
// null here and ehcache will try again
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// list the current whirled peers
|
// list the current peers
|
||||||
final List<CachePeer> result = Lists.newArrayList();
|
final List<CachePeer> result = Lists.newArrayList();
|
||||||
final Set<String> nodes = Sets.newHashSet();
|
final Set<String> nodes = Sets.newHashSet();
|
||||||
for (NodeObject node : _peerMan.getNodeObjects()) {
|
for (NodeObject node : _peerMan.getNodeObjects()) {
|
||||||
if (node != _peerMan.getNodeObject()) {
|
if (node != _peerMan.getNodeObject()) {
|
||||||
addCachesForNode(result, node.nodeName);
|
addCacheForNode(result, node.nodeName, cache.getName());
|
||||||
nodes.add(node.nodeName);
|
nodes.add(node.nodeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,23 +149,19 @@ public class EHCachePeerCoordinator extends CacheManagerPeerProviderFactory
|
|||||||
return "presents_peer";
|
return "presents_peer";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addCachesForNode (List<CachePeer> result, String nodeName)
|
protected void addCacheForNode (List<CachePeer> result, String nodeName, String cacheName)
|
||||||
{
|
{
|
||||||
String nodeHost = _peerMan.getPeerInternalHostName(nodeName);
|
String nodeHost = _peerMan.getPeerInternalHostName(nodeName);
|
||||||
if (nodeHost == null) {
|
if (nodeHost == null) {
|
||||||
log.warning("Eek, couldn't find the public host name of peer", "node", nodeName);
|
log.warning("Eek, couldn't find the public host name of peer", "node", nodeName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String rmiBase = "//" + nodeHost + ":" + RMI_PORT + "/";
|
try {
|
||||||
|
String rmiBase = "//" + nodeHost + ":" + RMI_PORT + "/";
|
||||||
// for the given node, acquire a RMI handle for each known Depot cache
|
result.add(getCache(nodeName, rmiBase + cacheName));
|
||||||
for (String cacheName : EHCACHES) {
|
} catch (Exception e) {
|
||||||
try {
|
log.warning("Could not resolve remote peer", "host", nodeHost,
|
||||||
result.add(getCache(nodeName, rmiBase + cacheName));
|
"cache", cacheName, e);
|
||||||
} catch (Exception e) {
|
|
||||||
log.warning("Could not resolve remote peer", "host", nodeHost,
|
|
||||||
"cache", cacheName, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user