Action Tracking Service update

Keep a record of which machine an action is currently running on, so for a cluster situation you know where you actions are


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21482 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-07-29 11:10:41 +00:00
parent 44e18c2d81
commit 77967ef61b
2 changed files with 21 additions and 4 deletions

View File

@@ -18,6 +18,8 @@
*/
package org.alfresco.repo.action;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -409,16 +411,25 @@ public class ActionTrackingServiceImpl implements ActionTrackingService
*/
protected static ExecutionDetails buildExecutionDetails(Action action)
{
// TODO Where are we?
String machine = "TODO";
// Where are we running?
if(machineName == null) {
try {
InetAddress localhost = InetAddress.getLocalHost();
machineName = localhost.getHostAddress() + " : " +
localhost.getHostName();
} catch(UnknownHostException e) {
machineName = "(machine details unavailable - server IP not known)";
}
}
// Generate
return new ExecutionDetails(
buildExecutionSummary(action),
action.getNodeRef(), machine,
action.getNodeRef(), machineName,
action.getExecutionStartDate(), false
);
}
private static String machineName = null;
/**
* Turns a cache key back into its constituent

View File

@@ -20,6 +20,7 @@ package org.alfresco.repo.action;
import static org.alfresco.repo.action.ActionServiceImplTest.assertBefore;
import java.net.InetAddress;
import java.util.Date;
import javax.transaction.UserTransaction;
@@ -171,7 +172,12 @@ public class ActionTrackingServiceImplTest extends TestCase
assertEquals(null, d.getPersistedActionRef());
assertEquals(null, d.getStartedAt());
// TODO Check machine details
// Check the machine details
// Should be "IP : Name"
InetAddress localhost = InetAddress.getLocalHost();
String machineName = localhost.getHostAddress() + " : " +
localhost.getHostName();
assertEquals(machineName, d.getRunningOn());
}
/** Running an action gives it an execution ID */