Split up some of the calls involved in resolving peered zones to make them easier to override.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@919 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -131,12 +131,36 @@ public abstract class PeeredZoneRegistry extends ZoneRegistry
|
||||
listener.zoneOnNode(nodeInfo); // somewhere else, pass the buck
|
||||
}
|
||||
return;
|
||||
|
||||
} else {
|
||||
resolveNewZone(zoneId, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a zone that's not yet hosted.
|
||||
*/
|
||||
protected void resolveNewZone (final int zoneId, final PeerZoneResolutionListener listener)
|
||||
{
|
||||
// otherwise the zone is not resolved here nor there; so we claim the zone by acquiring a
|
||||
// distributed lock and then resolve it locally
|
||||
_peerMgr.acquireLock(ZonePeerManager.getZoneLock(zoneId), new ResultListener<String>() {
|
||||
public void requestCompleted (String nodeName) {
|
||||
resolveZoneForNode(zoneId, nodeName, listener);
|
||||
}
|
||||
public void requestFailed (Exception cause) {
|
||||
log.warning("Failed to acquire zone resolution lock", "id", zoneId, cause);
|
||||
listener.zoneFailedToResolve(zoneId, cause);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a zone that's hosted or to-be-hosted on a zone.
|
||||
*/
|
||||
protected void resolveZoneForNode (final int zoneId, String nodeName,
|
||||
final PeerZoneResolutionListener listener)
|
||||
{
|
||||
if (_peerMgr.getNodeObject().nodeName.equals(nodeName)) {
|
||||
log.debug("Got lock, resolving zone", "zoneId", zoneId);
|
||||
resolveZone(zoneId, new ResolutionListener() {
|
||||
@@ -175,12 +199,6 @@ public abstract class PeeredZoneRegistry extends ZoneRegistry
|
||||
}
|
||||
}
|
||||
}
|
||||
public void requestFailed (Exception cause) {
|
||||
log.warning("Failed to acquire zone resolution lock", "id", zoneId, cause);
|
||||
listener.zoneFailedToResolve(zoneId, cause);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass on that the zone has shutdown.
|
||||
|
||||
Reference in New Issue
Block a user