org/objectweb/proactive/core/descriptor/services/FaultToleranceService.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.descriptor.services;
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.body.ft.servers.resource.ResourceServer;
00041 import org.objectweb.proactive.core.node.Node;
00042 import org.objectweb.proactive.core.runtime.ProActiveRuntime;
00043 import org.objectweb.proactive.core.util.log.Loggers;
00044 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00045 
00046 
00054 public class FaultToleranceService implements UniversalService {
00055     public static final String FT_SERVICE_NAME = "Fault-Tolerance Service";
00056     public static final String DEFAULT_PARAM_LINE = "-Dproactive.ft=disable";
00057 
00058     // logger
00059     protected static Logger logger = ProActiveLogger.getLogger(Loggers.FAULT_TOLERANCE);
00060 
00061     // protocol Type
00062     private String protocolType;
00063 
00064     // fault tolerance servers
00065     private String recoveryProcessURL;
00066     private String checkpointServerURL;
00067     private String locationServerURL;
00068     private String globalServerURL; // priority on the 3 upper values
00069 
00070     // fault tolerance values
00071     private String ttcValue;
00072 
00073     // attached ressource server
00074     private String attachedResourceServer; // null if not registred has a ressource node
00075 
00076     public FaultToleranceService() {
00077         super();
00078     }
00079 
00084     public ProActiveRuntime[] startService() throws ProActiveException {
00085         return null;
00086     }
00087 
00091     public String getServiceName() {
00092         return FaultToleranceService.FT_SERVICE_NAME;
00093     }
00094 
00099     public String buildParamsLine() {
00100         StringBuffer line = new StringBuffer("-Dproactive.ft=enable");
00101         if (this.getGlobalServerURL() != null) {
00102             if ((this.getCheckpointServerURL() != null) ||
00103                     (this.getLocationServerURL() != null) ||
00104                     (this.getRecoveryProcessURL() != null)) {
00105                 logger.warn(
00106                     "A global server is set : other servers are ignored !!");
00107             }
00108             line.append(" -Dproactive.ft.server.global=" +
00109                 this.getGlobalServerURL());
00110         } else {
00111             line.append(" -Dproactive.ft.server.checkpoint=" +
00112                 this.getCheckpointServerURL());
00113             line.append(" -Dproactive.ft.server.recovery=" +
00114                 this.getRecoveryProcessURL());
00115             line.append(" -Dproactive.ft.server.location=" +
00116                 this.getLocationServerURL());
00117         }
00118 
00119         if (this.getTtcValue() != null) {
00120             line.append(" -Dproactive.ft.ttc=" + this.getTtcValue());
00121         }
00122         if (this.getAttachedResourceServer() != null) {
00123             line.append(" -Dproactive.ft.server.resource=" +
00124                 this.getAttachedResourceServer());
00125         }
00126         if (this.getProtocolType() != null) {
00127             line.append(" -Dproactive.ft.protocol=" + this.getProtocolType());
00128         }
00129         if (logger.isDebugEnabled()) {
00130             logger.debug("FT config is : " + line);
00131         }
00132         return line.toString();
00133     }
00134 
00140     public boolean registerRessources(Node[] nodes) {
00141         if (this.getAttachedResourceServer() != null) {
00142             try {
00143                 ResourceServer rs = (ResourceServer) (Naming.lookup(this.getAttachedResourceServer()));
00144                 for (int i = 0; i < nodes.length; i++) {
00145                     rs.addFreeNode(nodes[i]);
00146                 }
00147                 return true;
00148             } catch (MalformedURLException e) {
00149                 logger.error(
00150                     "**ERROR** RessourceServer unreachable : ressource is not registred." +
00151                     e);
00152             } catch (RemoteException e) {
00153                 logger.error(
00154                     "**ERROR** RessourceServer unreachable : ressource is not registred" +
00155                     e);
00156             } catch (NotBoundException e) {
00157                 logger.error(
00158                     "**ERROR** RessourceServer unreachable : ressource is not registred" +
00159                     e);
00160             }
00161             return false;
00162         } else {
00163             return false;
00164         }
00165     }
00166 
00167     // Getters and setters
00168     public String getAttachedResourceServer() {
00169         return attachedResourceServer;
00170     }
00171 
00172     public void setAttachedResourceServer(String attachedRessourceServer) {
00173         this.attachedResourceServer = attachedRessourceServer;
00174     }
00175 
00176     public String getCheckpointServerURL() {
00177         return checkpointServerURL;
00178     }
00179 
00180     public void setCheckpointServerURL(String checkpointServerURL) {
00181         this.checkpointServerURL = checkpointServerURL;
00182     }
00183 
00184     public String getGlobalServerURL() {
00185         return globalServerURL;
00186     }
00187 
00188     public void setGlobalServerURL(String globalServerURL) {
00189         this.globalServerURL = globalServerURL;
00190     }
00191 
00192     public String getLocationServerURL() {
00193         return locationServerURL;
00194     }
00195 
00196     public void setLocationServerURL(String locationServerURL) {
00197         this.locationServerURL = locationServerURL;
00198     }
00199 
00200     public String getRecoveryProcessURL() {
00201         return recoveryProcessURL;
00202     }
00203 
00204     public void setRecoveryProcessURL(String recoveryProcessURL) {
00205         this.recoveryProcessURL = recoveryProcessURL;
00206     }
00207 
00208     public String getTtcValue() {
00209         return ttcValue;
00210     }
00211 
00212     public void setTtcValue(String ttcValue) {
00213         this.ttcValue = ttcValue;
00214     }
00215 
00216     public String getProtocolType() {
00217         return protocolType;
00218     }
00219 
00220     public void setProtocolType(String protocolType) {
00221         this.protocolType = protocolType;
00222     }
00223 }

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