org/objectweb/proactive/core/body/ft/protocols/pmlrb/servers/CheckpointServerPMLRB.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.body.ft.protocols.pmlrb.servers;
00032 
00033 import java.rmi.RemoteException;
00034 
00035 import org.apache.log4j.Logger;
00036 import org.objectweb.proactive.core.UniqueID;
00037 import org.objectweb.proactive.core.body.ft.checkpointing.Checkpoint;
00038 import org.objectweb.proactive.core.body.ft.checkpointing.CheckpointInfo;
00039 import org.objectweb.proactive.core.body.ft.exception.NotImplementedException;
00040 import org.objectweb.proactive.core.body.ft.message.HistoryUpdater;
00041 import org.objectweb.proactive.core.body.ft.message.MessageInfo;
00042 import org.objectweb.proactive.core.body.ft.protocols.pmlrb.infos.CheckpointInfoPMLRB;
00043 import org.objectweb.proactive.core.body.ft.servers.FTServer;
00044 import org.objectweb.proactive.core.body.ft.servers.storage.CheckpointServerImpl;
00045 import org.objectweb.proactive.core.body.reply.Reply;
00046 import org.objectweb.proactive.core.body.request.Request;
00047 import org.objectweb.proactive.core.util.log.Loggers;
00048 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00049 
00050 
00056 public class CheckpointServerPMLRB extends CheckpointServerImpl {
00057     //logger
00058     protected static Logger logger = ProActiveLogger.getLogger(Loggers.FAULT_TOLERANCE_PML);
00059 
00064     public CheckpointServerPMLRB(FTServer server) {
00065         super(server);
00066     }
00067 
00071     public int storeCheckpoint(Checkpoint c, int incarnation)
00072         throws RemoteException {
00073         logger.info("[STORAGE] " + c.getBodyID() + " is checkpointing..." +
00074             " (used memory = " + this.getUsedMem() + " Kb)");
00075         UniqueID caller = c.getBodyID();
00076         Object already = this.checkpointStorage.get(caller);
00077 
00078         // delete old checkpoint if any
00079         if (already != null) {
00080             this.checkpointStorage.remove(caller);
00081         }
00082 
00083         // store new checkpoint
00084         this.checkpointStorage.put(c.getBodyID(), c);
00085         // delete message logs if any
00086         return 0;
00087     }
00088 
00093     public Checkpoint getCheckpoint(UniqueID id, int sequenceNumber)
00094         throws RemoteException {
00095         throw new NotImplementedException();
00096     }
00097 
00101     public Checkpoint getLastCheckpoint(UniqueID id) throws RemoteException {
00102         return (Checkpoint) this.checkpointStorage.get(id);
00103     }
00104 
00109     public void addInfoToCheckpoint(CheckpointInfo ci, UniqueID id,
00110         int sequenceNumber, int incarnation) throws RemoteException {
00111         throw new NotImplementedException();
00112     }
00113 
00118     public CheckpointInfo getInfoFromCheckpoint(UniqueID id, int sequenceNumber)
00119         throws RemoteException {
00120         throw new NotImplementedException();
00121     }
00122 
00126     public void storeRequest(UniqueID receiverId, Request request)
00127         throws RemoteException {
00128         Checkpoint c = (Checkpoint) (this.checkpointStorage.get(receiverId));
00129         if (c != null) {
00130             CheckpointInfoPMLRB ci = (CheckpointInfoPMLRB) (c.getCheckpointInfo());
00131             ci.addRequest(request);
00132         }
00133 
00134         //else {
00135         //System.out.println(" ****** NOT LOGGED REQUEST ****** ");
00136         //}
00137     }
00138 
00142     public void storeReply(UniqueID receiverID, Reply reply)
00143         throws RemoteException {
00144         // checkpoint could not be null : if this oa receive a repy, it thus has already
00145         // served a request, and has checkpointed before.
00146         CheckpointInfoPMLRB ci = (CheckpointInfoPMLRB) ((Checkpoint) (this.checkpointStorage.get(receiverID))).getCheckpointInfo();
00147         ci.addReply(reply);
00148     }
00149 
00153     public void outputCommit(MessageInfo mi) throws RemoteException {
00154         throw new NotImplementedException("outputCommit(MessageInfo mi)");
00155     }
00156 
00160     public void commitHistory(HistoryUpdater rh) throws RemoteException {
00161         // nothing to do         
00162     }
00163 }

Generated on Mon Jan 22 15:16:05 2007 for ProActive by  doxygen 1.5.1