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.managers; 00032 00033 import java.net.MalformedURLException; 00034 import java.rmi.Naming; 00035 import java.rmi.NotBoundException; 00036 import java.rmi.RemoteException; 00037 00038 import org.apache.log4j.Logger; 00039 import org.objectweb.proactive.core.ProActiveException; 00040 import org.objectweb.proactive.core.ProActiveRuntimeException; 00041 import org.objectweb.proactive.core.body.AbstractBody; 00042 import org.objectweb.proactive.core.body.UniversalBody; 00043 import org.objectweb.proactive.core.body.ft.checkpointing.CheckpointInfo; 00044 import org.objectweb.proactive.core.body.ft.internalmsg.FTMessage; 00045 import org.objectweb.proactive.core.body.ft.protocols.FTManager; 00046 import org.objectweb.proactive.core.body.ft.protocols.pmlrb.infos.MessageInfoPMLRB; 00047 import org.objectweb.proactive.core.body.ft.servers.location.LocationServer; 00048 import org.objectweb.proactive.core.body.reply.Reply; 00049 import org.objectweb.proactive.core.body.request.Request; 00050 import org.objectweb.proactive.core.config.ProActiveConfiguration; 00051 import org.objectweb.proactive.core.util.log.Loggers; 00052 import org.objectweb.proactive.core.util.log.ProActiveLogger; 00053 import org.objectweb.proactive.ext.security.exceptions.RenegotiateSessionException; 00054 00055 00062 public class HalfFTManagerPMLRB extends FTManager { 00063 //logger 00064 protected static Logger logger = ProActiveLogger.getLogger(Loggers.FAULT_TOLERANCE_PML); 00065 00066 //sequence number of sending for any messages 00067 private char sendNumber; 00068 private MessageInfoPMLRB requestInfos; 00069 00074 public int init(AbstractBody owner) throws ProActiveException { 00075 //super.init(owner); 00076 try { 00077 String urlGlobal = ProActiveConfiguration.getGlobalFTServer(); 00078 if (urlGlobal != null) { 00079 this.location = (LocationServer) (Naming.lookup(urlGlobal)); 00080 } else { 00081 String urlLocation = ProActiveConfiguration.getLocationServer(); 00082 if (urlLocation != null) { 00083 this.location = (LocationServer) (Naming.lookup(urlLocation)); 00084 } else { 00085 throw new ProActiveException( 00086 "Unable to init HalfFTManager : servers are not correctly set"); 00087 } 00088 } 00089 this.storage = null; 00090 this.recovery = null; 00091 } catch (MalformedURLException e) { 00092 throw new ProActiveException("Unable to init HalfFTManager : FT is disable.", 00093 e); 00094 } catch (RemoteException e) { 00095 throw new ProActiveException("Unable to init HalfFTManager : FT is disable.", 00096 e); 00097 } catch (NotBoundException e) { 00098 throw new ProActiveException("Unable to init HalfFTManager : FT is disable.", 00099 e); 00100 } 00101 this.sendNumber = 0; 00102 this.requestInfos = new MessageInfoPMLRB(); 00103 logger.info(" PML fault-tolerance is enabled for half body " + 00104 this.ownerID); 00105 return 0; 00106 } 00107 00111 public int onReceiveReply(Reply reply) { 00112 reply.setFTManager(this); 00113 return 0; 00114 } 00115 00119 public int onDeliverReply(Reply reply) { 00120 return FTManager.NON_FT; 00121 } 00122 00126 public int onSendReplyBefore(Reply reply) { 00127 return 0; 00128 } 00129 00133 public int onSendReplyAfter(Reply reply, int rdvValue, 00134 UniversalBody destination) { 00135 return 0; 00136 } 00137 00141 public int onSendRequestBefore(Request request) { 00142 this.requestInfos.sentSequenceNumber = this.getNextSendNumber(); 00143 request.setMessageInfo(this.requestInfos); 00144 return 0; 00145 } 00146 00150 public int onSendRequestAfter(Request request, int rdvValue, 00151 UniversalBody destination) throws RenegotiateSessionException { 00152 return 0; 00153 } 00154 00155 private synchronized char getNextSendNumber() { 00156 return ++sendNumber; 00157 } 00158 00160 // UNCALLABLE METHODS // 00162 public int onReceiveRequest(Request request) { 00163 throw new ProActiveRuntimeException(HALF_BODY_EXCEPTION_MESSAGE); 00164 } 00165 00166 public int onDeliverRequest(Request request) { 00167 throw new ProActiveRuntimeException(HALF_BODY_EXCEPTION_MESSAGE); 00168 } 00169 00170 public int onServeRequestBefore(Request request) { 00171 throw new ProActiveRuntimeException(HALF_BODY_EXCEPTION_MESSAGE); 00172 } 00173 00174 public int onServeRequestAfter(Request request) { 00175 throw new ProActiveRuntimeException(HALF_BODY_EXCEPTION_MESSAGE); 00176 } 00177 00178 public int beforeRestartAfterRecovery(CheckpointInfo ci, int inc) { 00179 throw new ProActiveRuntimeException(HALF_BODY_EXCEPTION_MESSAGE); 00180 } 00181 00182 public int getIncarnation() { 00183 throw new ProActiveRuntimeException(HALF_BODY_EXCEPTION_MESSAGE); 00184 } 00185 00186 public Object handleFTMessage(FTMessage fte) { 00187 throw new ProActiveRuntimeException(HALF_BODY_EXCEPTION_MESSAGE); 00188 } 00189 }