1 31 package org.objectweb.proactive.ext.locationserver; 32 33 import org.apache.log4j.Logger; 34 35 import org.objectweb.proactive.Body; 36 import org.objectweb.proactive.core.body.UniversalBody; 37 import org.objectweb.proactive.core.body.migration.MigrationException; 38 import org.objectweb.proactive.core.body.migration.MigrationManagerImpl; 39 import org.objectweb.proactive.core.body.reply.ReplyReceiver; 40 import org.objectweb.proactive.core.body.request.RequestReceiver; 41 import org.objectweb.proactive.core.node.Node; 42 43 import java.io.IOException ; 44 import java.io.ObjectInputStream ; 45 46 47 public class MigrationManagerWithLocationServer extends MigrationManagerImpl { 48 static Logger logger = Logger.getLogger(MigrationManagerWithLocationServer.class.getName()); 49 transient private LocationServer locationServer; 50 protected Body myBody; 51 52 public MigrationManagerWithLocationServer() { 56 } 57 58 public MigrationManagerWithLocationServer(LocationServer locationServer) { 59 this.locationServer = locationServer; 60 } 61 62 66 69 public void updateLocation(Body body) { 70 if (locationServer == null) { 71 this.locationServer = LocationServerFactory.getLocationServer(); 72 } 73 74 if (logger.isDebugEnabled()) { 76 logger.debug("Updating location with this stub " + 77 body.getRemoteAdapter()); 78 } 79 locationServer.updateLocation(body.getID(), body.getRemoteAdapter()); 80 } 82 83 public UniversalBody migrateTo(Node node, Body body) 87 throws MigrationException { 88 locationServer = null; 89 if (myBody == null) { 90 this.myBody = body; 91 } 92 93 UniversalBody remoteBody = super.migrateTo(node, body); 95 96 return remoteBody; 97 } 98 99 106 public RequestReceiver createRequestReceiver(UniversalBody remoteBody, 107 RequestReceiver currentRequestReceiver) { 108 return new BouncingRequestReceiver(); 109 } 110 111 public ReplyReceiver createReplyReceiver(UniversalBody remoteBody, 112 ReplyReceiver currentReplyReceiver) { 113 return currentReplyReceiver; 114 } 115 116 private void readObject(ObjectInputStream in) 117 throws IOException , ClassNotFoundException { 118 in.defaultReadObject(); 119 this.updateLocation(myBody); 120 } 122 } 123 | Popular Tags |