Field mapServer =
NodeMappingServiceImpl.class.getDeclaredField("serverImpl");
mapServer.setAccessible(true);
final NodeMappingService nodeMappingService =
serverNode.getNodeMappingService();
NodeMappingServerImpl nodeMappingServer =
(NodeMappingServerImpl) mapServer.get(nodeMappingService);
// Create a new identity and assign it to a node
// Since there is only 1 app node, it will be assigned to that one
final Identity id = new IdentityImpl(appName + "_identity");
nodeMappingService.assignNode(NodeMappingService.class, id);
System.err.println("AppNode id: "+appNode.getNodeId());
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() throws Exception {
// See if the right node has the identity
long nodeid = nodeMappingService.getNode(id).getId();
System.err.println("Identity is on node: "+nodeid);
if (nodeid != appNode.getNodeId())
fail("Identity is on the wrong node");
}
}, taskOwner);
// Convince the Node Mapping server that the identity
// has been removed. This ensures that rtask.isDead() is true
appNode.getNodeMappingService().setStatus(
NodeMappingService.class, id, false);
// Unexport the NodeMappingService on the appNode to shutdown the
// service without removing the node listener. This should
// cause an IOException in the RemoveTask of the server when
// removing the identity.
Field privateField =
NodeMappingServiceImpl.class.getDeclaredField("exporter");
privateField.setAccessible(true);
Exporter<?> exporter = (Exporter<?>) privateField.get(
appNode.getNodeMappingService());
exporter.unexport();
Thread.sleep(renewTime); // Let it shutdown
nodeMappingServer.canRemove(id); // Remove the identity
Thread.sleep(renewTime); // Wait for RemoveThread to run on server
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() throws Exception {
try {