Some widening & logening

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@768 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Dave Hoover
2008-10-27 23:52:47 +00:00
parent c26ffc6958
commit 387eb32349
3 changed files with 42 additions and 47 deletions
@@ -27,8 +27,6 @@ import java.io.IOException;
import com.samskivert.util.LRUHashMap; import com.samskivert.util.LRUHashMap;
import com.samskivert.util.ResultListener; import com.samskivert.util.ResultListener;
import com.samskivert.util.StringUtil;
import com.threerings.presents.client.BasicDirector; import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
@@ -147,7 +145,7 @@ public class SceneDirector extends BasicDirector
// sanity-check the destination scene id // sanity-check the destination scene id
if (sceneId == _sceneId) { if (sceneId == _sceneId) {
log.warning("Refusing request to move to the same scene [sceneId=" + sceneId + "]."); log.warning("Refusing request to move to the same scene", "sceneId", sceneId);
return false; return false;
} }
@@ -180,12 +178,12 @@ public class SceneDirector extends BasicDirector
// complain if we're over-writing a pending request // complain if we're over-writing a pending request
if (movePending()) { if (movePending()) {
if (refuse) { if (refuse) {
log.warning("Refusing moveTo; We have a request outstanding " + log.warning("Refusing moveTo; We have a request outstanding",
"[psid=" + _pendingSceneId + ", nsid=" + sceneId + "]."); "psid", _pendingSceneId, "nsid", sceneId);
return false; return false;
} else { } else {
log.warning("Overriding stale moveTo request [psid=" + _pendingSceneId + log.warning("Overriding stale moveTo request",
", nsid=" + sceneId + "]."); "psid", _pendingSceneId, "nsid", sceneId);
} }
} }
@@ -246,27 +244,26 @@ public class SceneDirector extends BasicDirector
// from interface SceneService.SceneMoveListener // from interface SceneService.SceneMoveListener
public void moveSucceededWithUpdates (int placeId, PlaceConfig config, SceneUpdate[] updates) public void moveSucceededWithUpdates (int placeId, PlaceConfig config, SceneUpdate[] updates)
{ {
log.info("Got updates [placeId=" + placeId + ", config=" + config + log.info("Got updates", "placeId", placeId, "config", config, "updates", updates);
", updates=" + StringUtil.toString(updates) + "].");
// apply the updates to our cached scene // apply the updates to our cached scene
SceneModel model = loadSceneModel(_pendingSceneId); SceneModel model = loadSceneModel(_pendingSceneId);
boolean failure = false; boolean failure = false;
for (int ii = 0; ii < updates.length; ii++) { for (SceneUpdate element : updates) {
try { try {
updates[ii].validate(model); element.validate(model);
} catch (IllegalStateException ise) { } catch (IllegalStateException ise) {
log.warning("Scene update failed validation [model=" + model + log.warning("Scene update failed validation",
", update=" + updates[ii] + ", error=" + ise.getMessage() + "]."); "model", model, "update", element, "error", ise.getMessage());
failure = true; failure = true;
break; break;
} }
try { try {
updates[ii].apply(model); element.apply(model);
} catch (Exception e) { } catch (Exception e) {
log.warning("Failure applying scene update [model=" + model + log.warning("Failure applying scene update",
", update=" + updates[ii] + "].", e); "model", model, "update", element, e);
failure = true; failure = true;
break; break;
} }
@@ -277,8 +274,8 @@ public class SceneDirector extends BasicDirector
try { try {
_screp.deleteSceneModel(_pendingSceneId); _screp.deleteSceneModel(_pendingSceneId);
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failure removing booched scene model " + log.warning("Failure removing booched scene model",
"[sceneId=" + _pendingSceneId + "].", ioe); "sceneId", _pendingSceneId, ioe);
} }
// act as if the scene move failed; we'll be in a funny state because the server thinks // act as if the scene move failed; we'll be in a funny state because the server thinks
@@ -297,8 +294,9 @@ public class SceneDirector extends BasicDirector
// from interface SceneService.SceneMoveListener // from interface SceneService.SceneMoveListener
public void moveSucceededWithScene (int placeId, PlaceConfig config, SceneModel model) public void moveSucceededWithScene (int placeId, PlaceConfig config, SceneModel model)
{ {
log.info("Got updated scene model [placeId=" + placeId + ", config=" + config + log.info("Got updated scene model",
", scene=" + model.sceneId + "/" + model.name + "/" + model.version + "]."); "placeId", placeId, "config", config,
"scene", (model.sceneId + "/" + model.name + "/" + model.version));
// update the model in the repository // update the model in the repository
persistSceneModel(model); persistSceneModel(model);
@@ -361,8 +359,8 @@ public class SceneDirector extends BasicDirector
if (_moveHandler != null) { if (_moveHandler != null) {
log.warning("Requested to set move handler, but we've already got one. The " + log.warning("Requested to set move handler, but we've already got one. The " +
"conflicting entities will likely need to perform more sophisticated " + "conflicting entities will likely need to perform more sophisticated " +
"coordination to deal with failures. [old=" + _moveHandler + "coordination to deal with failures.",
", new=" + handler + "]."); "old", _moveHandler, "new", handler);
} else { } else {
_moveHandler = handler; _moveHandler = handler;
@@ -376,12 +374,12 @@ public class SceneDirector extends BasicDirector
// just finish up what we're doing and assume that the repeated move request was the // just finish up what we're doing and assume that the repeated move request was the
// spurious one as it would be in the case of lag causing rapid-fire repeat requests // spurious one as it would be in the case of lag causing rapid-fire repeat requests
if (movePending()) { if (movePending()) {
log.info("Dropping forced move because we have a move pending " + log.info("Dropping forced move because we have a move pending",
"[pendId=" + _pendingSceneId + ", reqId=" + sceneId + "]."); "pendId", _pendingSceneId, "reqId", sceneId);
return; return;
} }
log.info("Moving at request of server [sceneId=" + sceneId + "]."); log.info("Moving at request of server", "sceneId", sceneId);
// clear out our old scene and place data // clear out our old scene and place data
didLeaveScene(); didLeaveScene();
// move to the new scene // move to the new scene
@@ -464,7 +462,7 @@ public class SceneDirector extends BasicDirector
} catch (IOException ioe) { } catch (IOException ioe) {
// complain first, then return null // complain first, then return null
log.warning("Error loading scene [scid=" + sceneId + ", error=" + ioe + "]."); log.warning("Error loading scene", "scid", sceneId, "error", ioe);
} }
} }
@@ -480,8 +478,8 @@ public class SceneDirector extends BasicDirector
try { try {
_screp.storeSceneModel(model); _screp.storeSceneModel(model);
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failed to update repository with updated scene [sceneId=" + model.sceneId + log.warning("Failed to update repository with updated scene",
", nvers=" + model.version + "].", ioe); "sceneId", model.sceneId, "nvers", model.version, ioe);
} }
} }
@@ -47,8 +47,7 @@ import static com.threerings.whirled.zone.Log.log;
* which provides information on the zone which can be used to generate an overview map or similar. * which provides information on the zone which can be used to generate an overview map or similar.
*/ */
public class ZoneDirector extends BasicDirector public class ZoneDirector extends BasicDirector
implements ZoneReceiver, ZoneService.ZoneMoveListener, implements ZoneReceiver, ZoneService.ZoneMoveListener, SceneDirector.MoveHandler
SceneDirector.MoveHandler
{ {
/** /**
* Constructs a zone director with the supplied context, and delegate scene director (which the * Constructs a zone director with the supplied context, and delegate scene director (which the
@@ -63,8 +62,7 @@ public class ZoneDirector extends BasicDirector
_scdir.setMoveHandler(this); _scdir.setMoveHandler(this);
// register for zone notifications // register for zone notifications
_ctx.getClient().getInvocationDirector().registerReceiver( _ctx.getClient().getInvocationDirector().registerReceiver(new ZoneDecoder(this));
new ZoneDecoder(this));
} }
/** /**
@@ -112,8 +110,8 @@ public class ZoneDirector extends BasicDirector
{ {
// make sure the zoneId and sceneId are valid // make sure the zoneId and sceneId are valid
if (zoneId < 0 || sceneId < 0) { if (zoneId < 0 || sceneId < 0) {
log.warning("Refusing moveTo(): invalid sceneId or zoneId " + log.warning("Refusing moveTo(): invalid sceneId or zoneId",
"[zoneId=" + zoneId + ", sceneId=" + sceneId + "]."); "zoneId", zoneId, "sceneId", sceneId);
return false; return false;
} }
@@ -227,13 +225,13 @@ public class ZoneDirector extends BasicDirector
// just finish up what we're doing and assume that the repeated move request was the // just finish up what we're doing and assume that the repeated move request was the
// spurious one as it would be in the case of lag causing rapid-fire repeat requests // spurious one as it would be in the case of lag causing rapid-fire repeat requests
if (_scdir.movePending()) { if (_scdir.movePending()) {
log.info("Dropping forced move because we have a move pending " + log.info("Dropping forced move because we have a move pending",
"[pend=" + _scdir.getPendingModel() + ", rzId=" + zoneId + "pend", _scdir.getPendingModel(), "rzId", zoneId, "rsId", sceneId);
", rsId=" + sceneId + "].");
return; return;
} }
log.info("Moving at request of server [zoneId=" + zoneId + ", sceneId=" + sceneId + "]."); log.info("Moving at request of server",
"zoneId", zoneId, "sceneId", sceneId);
// clear out our old scene and place data // clear out our old scene and place data
_scdir.didLeaveScene(); _scdir.didLeaveScene();
// move to the new zone and scene // move to the new zone and scene
@@ -272,8 +270,8 @@ public class ZoneDirector extends BasicDirector
} }
} catch (Throwable t) { } catch (Throwable t) {
log.warning("Zone observer choked during notification [data=" + data + log.warning("Zone observer choked during notification",
", obs=" + obs + "].", t); "data", data, "obs", obs, t);
} }
} }
} }
@@ -24,17 +24,16 @@ package com.threerings.whirled.zone.client;
import com.threerings.presents.client.InvocationReceiver; import com.threerings.presents.client.InvocationReceiver;
/** /**
* Defines, for the zone services, a set of notifications delivered * Defines, for the zone services, a set of notifications delivered asynchronously by the server
* asynchronously by the server to the client. * to the client.
*/ */
public interface ZoneReceiver extends InvocationReceiver public interface ZoneReceiver extends InvocationReceiver
{ {
/** /**
* Used to communicate a required move notification to the client. The * Used to communicate a required move notification to the client. The server will have
* server will have removed the client from their existing scene and * removed the client from their existing scene and the client is then responsible for
* the client is then responsible for generating a {@link * generating a {@link ZoneService#moveTo} request to move to the new scene in the specified
* ZoneService#moveTo} request to move to the new scene in the * zone.
* specified zone.
*/ */
public void forcedMove (int zoneId, int sceneId); public void forcedMove (int zoneId, int sceneId);
} }