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.runtime;
00032
00033 import java.io.IOException;
00034 import java.io.Serializable;
00035 import java.lang.reflect.InvocationTargetException;
00036 import java.rmi.AlreadyBoundException;
00037 import java.rmi.UnmarshalException;
00038 import java.security.PublicKey;
00039 import java.security.cert.X509Certificate;
00040 import java.util.ArrayList;
00041
00042 import org.objectweb.proactive.Body;
00043 import org.objectweb.proactive.core.ProActiveException;
00044 import org.objectweb.proactive.core.UniqueRuntimeID;
00045 import org.objectweb.proactive.core.body.UniversalBody;
00046 import org.objectweb.proactive.core.body.ft.checkpointing.Checkpoint;
00047 import org.objectweb.proactive.core.config.ProActiveConfiguration;
00048 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor;
00049 import org.objectweb.proactive.core.descriptor.data.VirtualNode;
00050 import org.objectweb.proactive.core.mop.ConstructorCall;
00051 import org.objectweb.proactive.core.mop.ConstructorCallExecutionFailedException;
00052 import org.objectweb.proactive.core.node.NodeException;
00053 import org.objectweb.proactive.core.process.ExternalProcess;
00054 import org.objectweb.proactive.core.process.UniversalProcess;
00055 import org.objectweb.proactive.ext.security.Communication;
00056 import org.objectweb.proactive.ext.security.ProActiveSecurityManager;
00057 import org.objectweb.proactive.ext.security.SecurityContext;
00058 import org.objectweb.proactive.ext.security.crypto.KeyExchangeException;
00059 import org.objectweb.proactive.ext.security.exceptions.RenegotiateSessionException;
00060 import org.objectweb.proactive.ext.security.exceptions.SecurityNotAvailableException;
00061 import org.objectweb.proactive.ext.security.securityentity.Entity;
00062
00063
00076 public class ProActiveRuntimeAdapterForwarderImpl
00077 extends ProActiveRuntimeAdapter implements Serializable, Cloneable {
00078 private UniqueRuntimeID urid;
00079 protected RemoteProActiveRuntimeForwarder proActiveRuntime;
00080 protected String proActiveRuntimeURL;
00081
00082
00083
00084 protected boolean alreadykilled = false;
00085
00086
00087
00088
00089 public ProActiveRuntimeAdapterForwarderImpl() {
00090 }
00091
00092 public ProActiveRuntimeAdapterForwarderImpl(
00093 RemoteProActiveRuntimeForwarder proActiveRuntime)
00094 throws ProActiveException {
00095 this.proActiveRuntime = proActiveRuntime;
00096
00097 try {
00098 this.vmInformation = proActiveRuntime.getVMInformation();
00099 this.proActiveRuntimeURL = proActiveRuntime.getURL();
00100 } catch (IOException e) {
00101 throw new ProActiveException(e);
00102 }
00103 }
00104
00105 public ProActiveRuntimeAdapterForwarderImpl(
00106 ProActiveRuntimeAdapterForwarderImpl localAdapter,
00107 ProActiveRuntime remoteAdapter) throws ProActiveException {
00108 this.proActiveRuntime = (RemoteProActiveRuntimeForwarder) localAdapter.proActiveRuntime;
00109 this.vmInformation = remoteAdapter.getVMInformation();
00110 this.proActiveRuntimeURL = remoteAdapter.getURL();
00111 this.urid = new UniqueRuntimeID(remoteAdapter.getVMInformation()
00112 .getName(),
00113 remoteAdapter.getVMInformation().getVMID());
00114 }
00115
00116 private void readObject(java.io.ObjectInputStream in)
00117 throws java.io.IOException, ClassNotFoundException {
00118 in.defaultReadObject();
00119
00120 if (ProActiveConfiguration.isForwarder()) {
00121
00122 ProActiveRuntimeForwarderImpl partf = (ProActiveRuntimeForwarderImpl) ProActiveRuntimeImpl.getProActiveRuntime();
00123
00124 if (!partf.registeredRuntimes.containsKey(urid)) {
00125 try {
00126
00127 partf.registeredRuntimes.put(urid, (ProActiveRuntime)this.clone());
00128 } catch (CloneNotSupportedException e) {
00129 runtimeLogger.warn(e);
00130 }
00131 }
00132
00133 try {
00134
00135 proActiveRuntime = ((ProActiveRuntimeAdapterForwarderImpl) RuntimeFactory.getDefaultRuntime()).proActiveRuntime;
00136 } catch (ProActiveException e) {
00137 runtimeLogger.warn(e);
00138 }
00139 }
00140 }
00141
00142
00143
00144
00145 public boolean equals(Object o) {
00146 if (!(o instanceof ProActiveRuntimeAdapterForwarderImpl)) {
00147 return false;
00148 }
00149
00150 ProActiveRuntimeAdapterForwarderImpl runtime = (ProActiveRuntimeAdapterForwarderImpl) o;
00151
00152 return this.urid.equals(runtime.urid);
00153 }
00154
00155 public int hashCode() {
00156 return urid.hashCode();
00157 }
00158
00159
00160
00161
00162
00167 public String createLocalNode(String nodeName,
00168 boolean replacePreviousBinding, ProActiveSecurityManager psm,
00169 String vnName, String jobId) throws NodeException {
00170 try {
00171 return proActiveRuntime.createLocalNode(urid, nodeName,
00172 replacePreviousBinding, psm, vnName, jobId);
00173 } catch (Exception e) {
00174 throw new NodeException(e);
00175 }
00176 }
00177
00182 public void killAllNodes() throws ProActiveException {
00183 try {
00184 proActiveRuntime.killAllNodes(urid);
00185 } catch (IOException e) {
00186 throw new ProActiveException(e);
00187 }
00188 }
00189
00194 public void killNode(String nodeName) throws ProActiveException {
00195 try {
00196 proActiveRuntime.killNode(urid, nodeName);
00197 } catch (IOException e) {
00198 throw new ProActiveException(e);
00199 }
00200 }
00201
00207 public void createVM(UniversalProcess remoteProcess)
00208 throws IOException, ProActiveException {
00209 proActiveRuntime.createVM(urid, remoteProcess);
00210 }
00211
00216 public String[] getLocalNodeNames() throws ProActiveException {
00217 try {
00218 return proActiveRuntime.getLocalNodeNames(urid);
00219 } catch (IOException e) {
00220 throw new ProActiveException(e);
00221 }
00222 }
00223
00227 public VMInformation getVMInformation() {
00228 return vmInformation;
00229 }
00230
00235 public void register(ProActiveRuntime proActiveRuntimeDist,
00236 String proActiveRuntimeUrl, String creatorID, String creationProtocol,
00237 String vmName) throws ProActiveException {
00238 try {
00239 proActiveRuntime.register(urid, proActiveRuntimeDist,
00240 proActiveRuntimeUrl, creatorID, creationProtocol, vmName);
00241 } catch (IOException e) {
00242 throw new ProActiveException(e);
00243 }
00244 }
00245
00250 public void unregister(ProActiveRuntime proActiveRuntimeDist,
00251 String proActiveRuntimeUrl, String creatorID, String creationProtocol,
00252 String vmName) throws ProActiveException {
00253 try {
00254 this.proActiveRuntime.unregister(urid, proActiveRuntimeDist,
00255 proActiveRuntimeUrl, creatorID, creationProtocol, vmName);
00256 } catch (IOException e) {
00257 throw new ProActiveException(e);
00258 }
00259 }
00260
00265 public ProActiveRuntime[] getProActiveRuntimes() throws ProActiveException {
00266 try {
00267 return proActiveRuntime.getProActiveRuntimes(urid);
00268 } catch (IOException e) {
00269 throw new ProActiveException(e);
00270 }
00271 }
00272
00277 public ProActiveRuntime getProActiveRuntime(String proActiveRuntimeName)
00278 throws ProActiveException {
00279 try {
00280 return proActiveRuntime.getProActiveRuntime(urid,
00281 proActiveRuntimeName);
00282 } catch (IOException e) {
00283 throw new ProActiveException(e);
00284 }
00285 }
00286
00291 public void addAcquaintance(String proActiveRuntimeName)
00292 throws ProActiveException {
00293 try {
00294 proActiveRuntime.addAcquaintance(urid, proActiveRuntimeName);
00295 } catch (IOException e) {
00296 throw new ProActiveException(e);
00297 }
00298 }
00299
00304 public String[] getAcquaintances() throws ProActiveException {
00305 try {
00306 return proActiveRuntime.getAcquaintances(urid);
00307 } catch (IOException e) {
00308 throw new ProActiveException(e);
00309 }
00310 }
00311
00316 public void rmAcquaintance(String proActiveRuntimeName)
00317 throws ProActiveException {
00318 try {
00319 proActiveRuntime.rmAcquaintance(urid, proActiveRuntimeName);
00320 } catch (IOException e) {
00321 throw new ProActiveException(e);
00322 }
00323 }
00324
00328 public void killRT(boolean softly) throws Exception {
00329 try {
00330 if (!alreadykilled) {
00331 proActiveRuntime.killRT(urid, softly);
00332 }
00333
00334 alreadykilled = true;
00335 } catch (UnmarshalException e) {
00336
00337 alreadykilled = true;
00338 throw e;
00339 }
00340 }
00341
00345 public String getURL() {
00346 return proActiveRuntimeURL;
00347 }
00348
00353 public ArrayList getActiveObjects(String nodeName)
00354 throws ProActiveException {
00355 try {
00356 return proActiveRuntime.getActiveObjects(urid, nodeName);
00357 } catch (IOException e) {
00358 throw new ProActiveException(e);
00359 }
00360 }
00361
00366 public ArrayList getActiveObjects(String nodeName, String className)
00367 throws ProActiveException {
00368 try {
00369 return proActiveRuntime.getActiveObjects(urid, nodeName, className);
00370 } catch (IOException e) {
00371 throw new ProActiveException(e);
00372 }
00373 }
00374
00379 public VirtualNode getVirtualNode(String virtualNodeName)
00380 throws ProActiveException {
00381 try {
00382 return proActiveRuntime.getVirtualNode(urid, virtualNodeName);
00383 } catch (IOException e) {
00384 throw new ProActiveException(e);
00385 }
00386 }
00387
00392 public void registerVirtualNode(String virtualNodeName,
00393 boolean replacePreviousBinding)
00394 throws ProActiveException, AlreadyBoundException {
00395 try {
00396 proActiveRuntime.registerVirtualNode(urid, virtualNodeName,
00397 replacePreviousBinding);
00398 } catch (IOException e) {
00399 throw new ProActiveException(e);
00400 }
00401 }
00402
00407 public void unregisterVirtualNode(String virtualNodeName)
00408 throws ProActiveException {
00409 try {
00410 proActiveRuntime.unregisterVirtualNode(urid, virtualNodeName);
00411 } catch (IOException e) {
00412 throw new ProActiveException(e);
00413 }
00414 }
00415
00420 public void unregisterAllVirtualNodes() throws ProActiveException {
00421 try {
00422 proActiveRuntime.unregisterAllVirtualNodes(urid);
00423 } catch (IOException e) {
00424 throw new ProActiveException(e);
00425 }
00426 }
00427
00432 public String getJobID(String nodeUrl) throws ProActiveException {
00433 try {
00434 return proActiveRuntime.getJobID(urid, nodeUrl);
00435 } catch (IOException e) {
00436 throw new ProActiveException(e);
00437 }
00438 }
00439
00444 public UniversalBody createBody(String nodeName,
00445 ConstructorCall bodyConstructorCall, boolean isNodeLocal)
00446 throws ConstructorCallExecutionFailedException,
00447 InvocationTargetException, ProActiveException {
00448 try {
00449 return proActiveRuntime.createBody(urid, nodeName,
00450 bodyConstructorCall, isNodeLocal);
00451 } catch (IOException e) {
00452 throw new ProActiveException(e);
00453 }
00454 }
00455
00460 public UniversalBody receiveBody(String nodeName, Body body)
00461 throws ProActiveException {
00462 try {
00463 return proActiveRuntime.receiveBody(urid, nodeName, body);
00464 } catch (IOException e) {
00465 throw new ProActiveException(e);
00466 }
00467 }
00468
00473 public UniversalBody receiveCheckpoint(String nodeName, Checkpoint ckpt,
00474 int inc) throws ProActiveException {
00475 try {
00476 return proActiveRuntime.receiveCheckpoint(urid, nodeName, ckpt, inc);
00477 } catch (IOException e) {
00478 throw new ProActiveException(e);
00479 }
00480 }
00481
00486 public String getVNName(String Nodename) throws ProActiveException {
00487 try {
00488 return proActiveRuntime.getVNName(urid, Nodename);
00489 } catch (IOException e) {
00490 throw new ProActiveException(e);
00491 }
00492 }
00493
00498 public byte[] getClassDataFromThisRuntime(String className)
00499 throws ProActiveException {
00500 try {
00501 return proActiveRuntime.getClassDataFromThisRuntime(urid, className);
00502 } catch (IOException e) {
00503 throw new ProActiveException(e);
00504 }
00505 }
00506
00511 public byte[] getClassDataFromParentRuntime(String className)
00512 throws ProActiveException {
00513 try {
00514 return proActiveRuntime.getClassDataFromParentRuntime(urid,
00515 className);
00516 } catch (IOException e) {
00517 throw new ProActiveException(e);
00518 }
00519 }
00520
00521 public ExternalProcess getProcessToDeploy(
00522 ProActiveRuntime proActiveRuntimeDist, String creatorID, String vmName,
00523 String padURL) throws ProActiveException {
00524 try {
00525 return proActiveRuntime.getProcessToDeploy(urid,
00526 proActiveRuntimeDist, creatorID, vmName, padURL);
00527 } catch (IOException e) {
00528 throw new ProActiveException(e);
00529 }
00530 }
00531
00532
00533
00534
00535
00539 public String getJobID() {
00540 return vmInformation.getJobID();
00541 }
00542
00543 public ProActiveDescriptor getDescriptor(String url,
00544 boolean isHierarchicalSearch) throws IOException, ProActiveException {
00545 try {
00546 return proActiveRuntime.getDescriptor(urid, url,
00547 isHierarchicalSearch);
00548 } catch (IOException e) {
00549 throw new ProActiveException(e);
00550 }
00551 }
00552
00553 public void launchMain(String className, String[] parameters)
00554 throws ClassNotFoundException, NoSuchMethodException, ProActiveException {
00555 try {
00556 proActiveRuntime.launchMain(urid, className, parameters);
00557 } catch (IOException e) {
00558 throw new ProActiveException(e);
00559 }
00560 }
00561
00562 public void newRemote(String className)
00563 throws ClassNotFoundException, ProActiveException {
00564 try {
00565 proActiveRuntime.newRemote(urid, className);
00566 } catch (IOException e) {
00567 throw new ProActiveException(e);
00568 }
00569 }
00570
00571 public X509Certificate getCertificate()
00572 throws SecurityNotAvailableException, IOException {
00573 return proActiveRuntime.getCertificate(urid);
00574 }
00575
00576 public byte[] getCertificateEncoded()
00577 throws SecurityNotAvailableException, IOException {
00578 return proActiveRuntime.getCertificateEncoded(urid);
00579 }
00580
00581 public ArrayList<Entity> getEntities()
00582 throws SecurityNotAvailableException, IOException {
00583 return proActiveRuntime.getEntities(urid);
00584 }
00585
00586 public PublicKey getPublicKey()
00587 throws SecurityNotAvailableException, IOException {
00588 return proActiveRuntime.getPublicKey(urid);
00589 }
00590
00591 public byte[][] publicKeyExchange(long sessionID, byte[] myPublicKey,
00592 byte[] myCertificate, byte[] signature)
00593 throws SecurityNotAvailableException, RenegotiateSessionException,
00594 KeyExchangeException, IOException {
00595 return proActiveRuntime.publicKeyExchange(urid, sessionID, myPublicKey,
00596 myCertificate, signature);
00597 }
00598
00599 public byte[] randomValue(long sessionID, byte[] clientRandomValue)
00600 throws SecurityNotAvailableException, RenegotiateSessionException,
00601 IOException {
00602 return proActiveRuntime.randomValue(urid, sessionID, clientRandomValue);
00603 }
00604
00605 public byte[][] secretKeyExchange(long sessionID, byte[] encodedAESKey,
00606 byte[] encodedIVParameters, byte[] encodedClientMacKey,
00607 byte[] encodedLockData, byte[] parametersSignature)
00608 throws SecurityNotAvailableException, RenegotiateSessionException,
00609 IOException {
00610 return proActiveRuntime.secretKeyExchange(urid, sessionID,
00611 encodedAESKey, encodedIVParameters, encodedClientMacKey,
00612 encodedLockData, parametersSignature);
00613 }
00614
00615 public long startNewSession(Communication policy)
00616 throws SecurityNotAvailableException, RenegotiateSessionException,
00617 IOException {
00618 return proActiveRuntime.startNewSession(urid, policy);
00619 }
00620
00621 public void terminateSession(long sessionID)
00622 throws SecurityNotAvailableException, IOException {
00623 proActiveRuntime.terminateSession(urid, sessionID);
00624 }
00625
00626 public SecurityContext getPolicy(SecurityContext securityContext)
00627 throws SecurityNotAvailableException, IOException {
00628 return proActiveRuntime.getPolicy(urid, securityContext);
00629 }
00630
00631 public Object setLocalNodeProperty(String nodeName, String key, String value)
00632 throws ProActiveException {
00633 try {
00634 return this.proActiveRuntime.setLocalNodeProperty(this.urid,
00635 nodeName, key, value);
00636 } catch (IOException e) {
00637 throw new ProActiveException(e);
00638 }
00639 }
00640
00641 public String getLocalNodeProperty(String nodeName, String key)
00642 throws ProActiveException {
00643 try {
00644 return this.proActiveRuntime.getLocalNodeProperty(this.urid,
00645 nodeName, key);
00646 } catch (IOException e) {
00647 throw new ProActiveException(e);
00648 }
00649 }
00650 }