Drive by de-whitespace-excessificiation.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5469 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -158,16 +158,13 @@ public class BureauRegistry
|
|||||||
if (bureau == null) {
|
if (bureau == null) {
|
||||||
return "Bureau " + creds.bureauId + " not found";
|
return "Bureau " + creds.bureauId + " not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bureau.clientObj != null) {
|
if (bureau.clientObj != null) {
|
||||||
return "Bureau " + creds.bureauId + " already logged in";
|
return "Bureau " + creds.bureauId + " already logged in";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bureau.token.equals(creds.sessionToken)) {
|
if (!bureau.token.equals(creds.sessionToken)) {
|
||||||
return "Bureau " + creds.bureauId +
|
return "Bureau " + creds.bureauId +
|
||||||
" does not match credentials token";
|
" does not match credentials token";
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,21 +251,16 @@ public class BureauRegistry
|
|||||||
{
|
{
|
||||||
Bureau bureau = _bureaus.get(agent.bureauId);
|
Bureau bureau = _bureaus.get(agent.bureauId);
|
||||||
if (bureau != null && bureau.ready()) {
|
if (bureau != null && bureau.ready()) {
|
||||||
|
|
||||||
_omgr.registerObject(agent);
|
_omgr.registerObject(agent);
|
||||||
|
|
||||||
log.info("Bureau ready, sending createAgent", "agent", agent.which());
|
log.info("Bureau ready, sending createAgent", "agent", agent.which());
|
||||||
|
|
||||||
BureauSender.createAgent(bureau.clientObj, agent.getOid());
|
BureauSender.createAgent(bureau.clientObj, agent.getOid());
|
||||||
bureau.agentStates.put(agent, AgentState.STARTED);
|
bureau.agentStates.put(agent, AgentState.STARTED);
|
||||||
|
|
||||||
bureau.summarize();
|
bureau.summarize();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bureau == null) {
|
if (bureau == null) {
|
||||||
|
|
||||||
LauncherEntry launcherEntry = _launchers.get(agent.bureauType);
|
LauncherEntry launcherEntry = _launchers.get(agent.bureauType);
|
||||||
if (launcherEntry == null) {
|
if (launcherEntry == null) {
|
||||||
log.warning("Launcher not found", "agent", agent.which());
|
log.warning("Launcher not found", "agent", agent.which());
|
||||||
@@ -276,14 +268,11 @@ public class BureauRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("Creating new bureau", "bureauId", agent.bureauId, "launcher", launcherEntry);
|
log.info("Creating new bureau", "bureauId", agent.bureauId, "launcher", launcherEntry);
|
||||||
|
|
||||||
bureau = new Bureau();
|
bureau = new Bureau();
|
||||||
bureau.bureauId = agent.bureauId;
|
bureau.bureauId = agent.bureauId;
|
||||||
bureau.token = generateToken(bureau.bureauId);
|
bureau.token = generateToken(bureau.bureauId);
|
||||||
bureau.launcherEntry = launcherEntry;
|
bureau.launcherEntry = launcherEntry;
|
||||||
|
|
||||||
_invoker.postUnit(new LauncherUnit(bureau, _omgr));
|
_invoker.postUnit(new LauncherUnit(bureau, _omgr));
|
||||||
|
|
||||||
_bureaus.put(agent.bureauId, bureau);
|
_bureaus.put(agent.bureauId, bureau);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +280,6 @@ public class BureauRegistry
|
|||||||
bureau.agentStates.put(agent, AgentState.PENDING);
|
bureau.agentStates.put(agent, AgentState.PENDING);
|
||||||
|
|
||||||
log.info("Bureau not ready, pending agent", "agent", agent.which());
|
log.info("Bureau not ready, pending agent", "agent", agent.which());
|
||||||
|
|
||||||
bureau.summarize();
|
bureau.summarize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +289,6 @@ public class BureauRegistry
|
|||||||
public void destroyAgent (AgentObject agent)
|
public void destroyAgent (AgentObject agent)
|
||||||
{
|
{
|
||||||
FoundAgent found = resolve(null, agent.getOid(), "destroyAgent");
|
FoundAgent found = resolve(null, agent.getOid(), "destroyAgent");
|
||||||
|
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -552,8 +539,7 @@ public class BureauRegistry
|
|||||||
*/
|
*/
|
||||||
protected String generateToken (String bureauId)
|
protected String generateToken (String bureauId)
|
||||||
{
|
{
|
||||||
String tokenSource = bureauId + "@" +
|
String tokenSource = bureauId + "@" + System.currentTimeMillis() + "r" + Math.random();
|
||||||
System.currentTimeMillis() + "r" + Math.random();
|
|
||||||
return StringUtil.md5hex(tokenSource);
|
return StringUtil.md5hex(tokenSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,8 +550,7 @@ public class BureauRegistry
|
|||||||
protected void launchTimeoutExpired (Bureau bureau)
|
protected void launchTimeoutExpired (Bureau bureau)
|
||||||
{
|
{
|
||||||
if (bureau.clientObj != null) {
|
if (bureau.clientObj != null) {
|
||||||
// all's well, ignore
|
return; // all's well, ignore
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_bureaus.containsKey(bureau.bureauId)) {
|
if (!_bureaus.containsKey(bureau.bureauId)) {
|
||||||
@@ -582,19 +567,14 @@ public class BureauRegistry
|
|||||||
*/
|
*/
|
||||||
protected class LauncherUnit extends Invoker.Unit
|
protected class LauncherUnit extends Invoker.Unit
|
||||||
{
|
{
|
||||||
LauncherUnit (Bureau bureau, RunQueue runQueue)
|
LauncherUnit (Bureau bureau, RunQueue runQueue) {
|
||||||
{
|
super("LauncherUnit for " + bureau + ": " + StringUtil.toString(bureau.launcherEntry));
|
||||||
super("LauncherUnit for " + bureau + ": " +
|
|
||||||
StringUtil.toString(bureau.launcherEntry));
|
|
||||||
_bureau = bureau;
|
_bureau = bureau;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public boolean invoke () {
|
||||||
public boolean invoke ()
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
_bureau.launch();
|
_bureau.launch();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Could not launch bureau", e);
|
log.warning("Could not launch bureau", e);
|
||||||
}
|
}
|
||||||
@@ -602,8 +582,7 @@ public class BureauRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleResult ()
|
public void handleResult () {
|
||||||
{
|
|
||||||
int timeout = _bureau.launcherEntry.timeout;
|
int timeout = _bureau.launcherEntry.timeout;
|
||||||
if (timeout != 0) {
|
if (timeout != 0) {
|
||||||
new Interval(_runQueue) {
|
new Interval(_runQueue) {
|
||||||
@@ -627,15 +606,13 @@ public class BureauRegistry
|
|||||||
public Launcher launcher;
|
public Launcher launcher;
|
||||||
public int timeout;
|
public int timeout;
|
||||||
|
|
||||||
public LauncherEntry (Launcher launcher, int timeout)
|
public LauncherEntry (Launcher launcher, int timeout) {
|
||||||
{
|
|
||||||
this.launcher = launcher;
|
this.launcher = launcher;
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString () {
|
||||||
{
|
|
||||||
return StringUtil.fieldsToString(this);
|
return StringUtil.fieldsToString(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -701,8 +678,7 @@ public class BureauRegistry
|
|||||||
Map<AgentObject, AgentState> agentStates = Maps.newHashMap();
|
Map<AgentObject, AgentState> agentStates = Maps.newHashMap();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString () {
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("[Bureau id=").append(bureauId).append(", client=");
|
builder.append("[Bureau id=").append(bureauId).append(", client=");
|
||||||
if (clientObj == null) {
|
if (clientObj == null) {
|
||||||
@@ -717,13 +693,11 @@ public class BureauRegistry
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ready ()
|
boolean ready () {
|
||||||
{
|
|
||||||
return clientObj != null;
|
return clientObj != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder agentSummary (StringBuilder str)
|
StringBuilder agentSummary (StringBuilder str) {
|
||||||
{
|
|
||||||
int[] counts = new int[AgentState.values().length];
|
int[] counts = new int[AgentState.values().length];
|
||||||
for (Map.Entry<AgentObject, AgentState> me : agentStates.entrySet()) {
|
for (Map.Entry<AgentObject, AgentState> me : agentStates.entrySet()) {
|
||||||
counts[me.getValue().ordinal()]++;
|
counts[me.getValue().ordinal()]++;
|
||||||
@@ -737,17 +711,14 @@ public class BureauRegistry
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void summarize ()
|
void summarize () {
|
||||||
{
|
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
str.append("Bureau ").append(bureauId).append(" [");
|
str.append("Bureau ").append(bureauId).append(" [");
|
||||||
agentSummary(str).append("]");
|
agentSummary(str).append("]");
|
||||||
log.info(str.toString());
|
log.info(str.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void launch ()
|
void launch () throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
launcherEntry.launcher.launchBureau(bureauId, token);
|
launcherEntry.launcher.launchBureau(bureauId, token);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user