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.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
00059 protected static Logger logger = ProActiveLogger.getLogger(Loggers.FAULT_TOLERANCE);
00060
00061
00062 private String protocolType;
00063
00064
00065 private String recoveryProcessURL;
00066 private String checkpointServerURL;
00067 private String locationServerURL;
00068 private String globalServerURL;
00069
00070
00071 private String ttcValue;
00072
00073
00074 private String attachedResourceServer;
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
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 }