More unit cleanup.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5109 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -24,6 +24,7 @@ package com.threerings.admin.server;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.samskivert.io.PersistenceException;
|
import com.samskivert.io.PersistenceException;
|
||||||
|
import com.samskivert.jdbc.WriteOnlyUnit;
|
||||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||||
import com.samskivert.util.Invoker;
|
import com.samskivert.util.Invoker;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
@@ -288,16 +289,10 @@ public class DatabaseConfigRegistry extends ConfigRegistry
|
|||||||
|
|
||||||
protected void setAndFlush (final String field, final String value) {
|
protected void setAndFlush (final String field, final String value) {
|
||||||
_data.put(field, value);
|
_data.put(field, value);
|
||||||
_invoker.postUnit(new Invoker.Unit() {
|
String iname = "updateConfig(" + _path + ", " + field + ", value=" + value + ")";
|
||||||
public boolean invoke () {
|
_invoker.postUnit(new WriteOnlyUnit(iname) {
|
||||||
try {
|
public void invokePersist () throws Exception {
|
||||||
_repo.updateConfig(_node, _path, field, value);
|
_repo.updateConfig(_node, _path, field, value);
|
||||||
} catch (PersistenceException pe) {
|
|
||||||
Log.warning("Failed to update object configuration [path=" + _path +
|
|
||||||
", field=" + field + ", value=" + value + "].");
|
|
||||||
Log.logStackTrace(pe);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import com.samskivert.io.PersistenceException;
|
import com.samskivert.jdbc.RepositoryUnit;
|
||||||
|
import com.samskivert.jdbc.WriteOnlyUnit;
|
||||||
import com.samskivert.jdbc.depot.PersistenceContext;
|
import com.samskivert.jdbc.depot.PersistenceContext;
|
||||||
import com.samskivert.util.ArrayIntSet;
|
import com.samskivert.util.ArrayIntSet;
|
||||||
import com.samskivert.util.ChainedResultListener;
|
import com.samskivert.util.ChainedResultListener;
|
||||||
@@ -215,15 +216,9 @@ public class PeerManager
|
|||||||
// register ourselves with the node table
|
// register ourselves with the node table
|
||||||
_self = new NodeRecord(
|
_self = new NodeRecord(
|
||||||
_nodeName, hostName, (publicHostName == null) ? hostName : publicHostName, port);
|
_nodeName, hostName, (publicHostName == null) ? hostName : publicHostName, port);
|
||||||
_invoker.postUnit(new Invoker.Unit("registerNode") {
|
_invoker.postUnit(new WriteOnlyUnit("registerNode(" + _self + ")") {
|
||||||
public boolean invoke () {
|
public void invokePersist () throws Exception {
|
||||||
try {
|
_noderepo.updateNode(_self);
|
||||||
_noderepo.updateNode(_self);
|
|
||||||
} catch (PersistenceException pe) {
|
|
||||||
log.warning("Failed to register node record [rec=" + _self +
|
|
||||||
", error=" + pe + "].");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -702,15 +697,9 @@ public class PeerManager
|
|||||||
PresentsServer.clmgr.removeClientObserver(this);
|
PresentsServer.clmgr.removeClientObserver(this);
|
||||||
|
|
||||||
// clear our record from the node table
|
// clear our record from the node table
|
||||||
_invoker.postUnit(new Invoker.Unit("deleteNode") {
|
_invoker.postUnit(new WriteOnlyUnit("deleteNode(" + _nodeName + ")") {
|
||||||
public boolean invoke () {
|
public void invokePersist () throws Exception {
|
||||||
try {
|
_noderepo.deleteNode(_nodeName);
|
||||||
_noderepo.deleteNode(_nodeName);
|
|
||||||
} catch (PersistenceException pe) {
|
|
||||||
log.warning("Failed to delete node record [nodeName=" + _nodeName +
|
|
||||||
", error=" + pe + "].");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -803,21 +792,14 @@ public class PeerManager
|
|||||||
protected void refreshPeers ()
|
protected void refreshPeers ()
|
||||||
{
|
{
|
||||||
// load up information on our nodes
|
// load up information on our nodes
|
||||||
_invoker.postUnit(new Invoker.Unit("refreshPeers") {
|
_invoker.postUnit(new RepositoryUnit("refreshPeers") {
|
||||||
public boolean invoke () {
|
public void invokePersist () throws Exception {
|
||||||
try {
|
// let the world know that we're alive
|
||||||
// let the world know that we're alive
|
_noderepo.heartbeatNode(_nodeName);
|
||||||
_noderepo.heartbeatNode(_nodeName);
|
// then load up all the peer records
|
||||||
// then load up all the peer records
|
_nodes = _noderepo.loadNodes();
|
||||||
_nodes = _noderepo.loadNodes();
|
|
||||||
return true;
|
|
||||||
} catch (PersistenceException pe) {
|
|
||||||
log.warning("Failed to load node records: " + pe + ".");
|
|
||||||
// we'll just try again next time
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void handleResult () {
|
public void handleSuccess() {
|
||||||
for (NodeRecord record : _nodes) {
|
for (NodeRecord record : _nodes) {
|
||||||
if (record.nodeName.equals(_nodeName)) {
|
if (record.nodeName.equals(_nodeName)) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user