00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.body.ft.servers;
00032
00033 import java.rmi.RemoteException;
00034 import java.rmi.server.UnicastRemoteObject;
00035 import java.util.ArrayList;
00036
00037 import org.apache.log4j.Logger;
00038 import org.objectweb.proactive.core.UniqueID;
00039 import org.objectweb.proactive.core.body.UniversalBody;
00040 import org.objectweb.proactive.core.body.ft.checkpointing.Checkpoint;
00041 import org.objectweb.proactive.core.body.ft.checkpointing.CheckpointInfo;
00042 import org.objectweb.proactive.core.body.ft.message.HistoryUpdater;
00043 import org.objectweb.proactive.core.body.ft.message.MessageInfo;
00044 import org.objectweb.proactive.core.body.ft.servers.faultdetection.FaultDetector;
00045 import org.objectweb.proactive.core.body.ft.servers.location.LocationServer;
00046 import org.objectweb.proactive.core.body.ft.servers.recovery.RecoveryProcess;
00047 import org.objectweb.proactive.core.body.ft.servers.resource.ResourceServer;
00048 import org.objectweb.proactive.core.body.ft.servers.storage.CheckpointServer;
00049 import org.objectweb.proactive.core.body.ft.servers.util.ActiveQueueJob;
00050 import org.objectweb.proactive.core.body.ft.servers.util.JobBarrier;
00051 import org.objectweb.proactive.core.body.reply.Reply;
00052 import org.objectweb.proactive.core.body.request.Request;
00053 import org.objectweb.proactive.core.node.Node;
00054 import org.objectweb.proactive.core.util.log.Loggers;
00055 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00056
00057
00064 public class FTServer extends UnicastRemoteObject implements FaultDetector,
00065 LocationServer, RecoveryProcess, ResourceServer, CheckpointServer {
00066
00067 protected static Logger logger = ProActiveLogger.getLogger(Loggers.FAULT_TOLERANCE);
00068
00070 public static final int DEFAULT_PORT = 1100;
00071
00073 public static final int DEFAULT_FDETECT_SCAN_PERIOD = 10000;
00074
00076 public static final String DEFAULT_SERVER_NAME = "FTServer";
00077
00078
00079 private FaultDetector faultDetector;
00080 private LocationServer locationServer;
00081 private RecoveryProcess recoveryProcess;
00082 private ResourceServer resourceServer;
00083 private CheckpointServer checkpointServer;
00084
00088 public FTServer() throws RemoteException {
00089 super();
00090
00091 }
00092
00097 public void init(FaultDetector fd, LocationServer ls, RecoveryProcess rp,
00098 ResourceServer rs, CheckpointServer cs) {
00099 this.faultDetector = fd;
00100 this.locationServer = ls;
00101 this.recoveryProcess = rp;
00102 this.resourceServer = rs;
00103 this.checkpointServer = cs;
00104 }
00105
00109
00113 public boolean isUnreachable(UniversalBody body) throws RemoteException {
00114 return this.faultDetector.isUnreachable(body);
00115 }
00116
00120 public void startFailureDetector() throws RemoteException {
00121 this.faultDetector.startFailureDetector();
00122 }
00123
00127 public void suspendFailureDetector() throws RemoteException {
00128 this.faultDetector.suspendFailureDetector();
00129 }
00130
00134 public void stopFailureDetector() throws RemoteException {
00135 this.faultDetector.stopFailureDetector();
00136 }
00137
00141 public void forceDetection() throws RemoteException {
00142 this.faultDetector.forceDetection();
00143 }
00144
00148 public UniversalBody searchObject(UniqueID id, UniversalBody oldLocation,
00149 UniqueID caller) throws RemoteException {
00150 return this.locationServer.searchObject(id, oldLocation, caller);
00151 }
00152
00156 public void updateLocation(UniqueID id, UniversalBody newLocation)
00157 throws RemoteException {
00158 this.locationServer.updateLocation(id, newLocation);
00159 }
00160
00164 public ArrayList getAllLocations() throws RemoteException {
00165 return this.locationServer.getAllLocations();
00166 }
00167
00171 public UniversalBody getLocation(UniqueID id) throws RemoteException {
00172 return this.locationServer.getLocation(id);
00173 }
00174
00178 public void register(UniqueID id) throws RemoteException {
00179 this.recoveryProcess.register(id);
00180 }
00181
00185 public void unregister(UniqueID id) throws RemoteException {
00186 this.recoveryProcess.unregister(id);
00187 }
00188
00192 public void failureDetected(UniqueID id) throws RemoteException {
00193 this.recoveryProcess.failureDetected(id);
00194 }
00195
00199 public void updateState(UniqueID id, int state) throws RemoteException {
00200 this.recoveryProcess.updateState(id, state);
00201 }
00202
00206 public int getSystemSize() throws RemoteException {
00207 return this.recoveryProcess.getSystemSize();
00208 }
00209
00213 public void submitJob(ActiveQueueJob job) throws RemoteException {
00214 this.recoveryProcess.submitJob(job);
00215 }
00216
00220 public JobBarrier submitJobWithBarrier(ActiveQueueJob job)
00221 throws RemoteException {
00222 return this.recoveryProcess.submitJobWithBarrier(job);
00223 }
00224
00228 public void addFreeNode(Node n) throws RemoteException {
00229 this.resourceServer.addFreeNode(n);
00230 }
00231
00235 public Node getFreeNode() throws RemoteException {
00236 return this.resourceServer.getFreeNode();
00237 }
00238
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 public int storeCheckpoint(Checkpoint c, int incarnation)
00254 throws RemoteException {
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 return this.checkpointServer.storeCheckpoint(c, incarnation);
00267 }
00268
00272 public Checkpoint getCheckpoint(UniqueID id, int sequenceNumber)
00273 throws RemoteException {
00274 return this.checkpointServer.getCheckpoint(id, sequenceNumber);
00275 }
00276
00280 public Checkpoint getLastCheckpoint(UniqueID id) throws RemoteException {
00281 return this.checkpointServer.getLastCheckpoint(id);
00282 }
00283
00287 public void addInfoToCheckpoint(CheckpointInfo ci, UniqueID id,
00288 int sequenceNumber, int incarnation) throws RemoteException {
00289 this.checkpointServer.addInfoToCheckpoint(ci, id, sequenceNumber,
00290 incarnation);
00291 }
00292
00296 public CheckpointInfo getInfoFromCheckpoint(UniqueID id, int sequenceNumber)
00297 throws RemoteException {
00298 return this.checkpointServer.getInfoFromCheckpoint(id, sequenceNumber);
00299 }
00300
00304 public void commitHistory(HistoryUpdater rh) throws RemoteException {
00305 this.checkpointServer.commitHistory(rh);
00306 }
00307
00311 public void outputCommit(MessageInfo mi) throws RemoteException {
00312 this.checkpointServer.outputCommit(mi);
00313 }
00314
00318 public String getServerCodebase() throws RemoteException {
00319 return this.checkpointServer.getServerCodebase();
00320 }
00321
00325 public void storeRequest(UniqueID receiverId, Request request)
00326 throws RemoteException {
00327 this.checkpointServer.storeRequest(receiverId, request);
00328 }
00329
00333 public void storeReply(UniqueID receiverID, Reply reply)
00334 throws RemoteException {
00335 this.checkpointServer.storeReply(receiverID, reply);
00336 }
00337
00341
00345 public CheckpointServer getCheckpointServer() {
00346 return checkpointServer;
00347 }
00348
00352 public void setCheckpointServer(CheckpointServer checkpointServer) {
00353 this.checkpointServer = checkpointServer;
00354 }
00355
00359 public FaultDetector getFaultDetector() {
00360 return faultDetector;
00361 }
00362
00366 public void setFaultDetector(FaultDetector faultDetector) {
00367 this.faultDetector = faultDetector;
00368 }
00369
00373 public LocationServer getLocationServer() {
00374 return locationServer;
00375 }
00376
00380 public void setLocationServer(LocationServer locationServer) {
00381 this.locationServer = locationServer;
00382 }
00383
00387 public RecoveryProcess getRecoveryProcess() {
00388 return recoveryProcess;
00389 }
00390
00394 public void setRecoveryProcess(RecoveryProcess recoveryProcess) {
00395 this.recoveryProcess = recoveryProcess;
00396 }
00397
00401 public ResourceServer getResourceServer() {
00402 return resourceServer;
00403 }
00404
00408 public void setResourceServer(ResourceServer resourceServer) {
00409 this.resourceServer = resourceServer;
00410 }
00411
00415 public void initialize() throws RemoteException {
00416 logger.info("[GLOBAL] Reinitializing server ...");
00417 this.checkpointServer.initialize();
00418 this.locationServer.initialize();
00419 this.recoveryProcess.initialize();
00420 this.resourceServer.initialize();
00421 logger.info("[GLOBAL] Server reinitialized");
00422 }
00423 }