1 31 package org.objectweb.proactive.core.runtime.ibis; 32 33 import ibis.rmi.AlreadyBoundException; 34 import ibis.rmi.RemoteException; 35 import ibis.rmi.UnmarshalException; 36 37 import org.objectweb.proactive.Body; 38 import org.objectweb.proactive.core.ProActiveException; 39 import org.objectweb.proactive.core.body.UniversalBody; 40 import org.objectweb.proactive.core.descriptor.data.VirtualNode; 41 import org.objectweb.proactive.core.mop.ConstructorCall; 42 import org.objectweb.proactive.core.mop.ConstructorCallExecutionFailedException; 43 import org.objectweb.proactive.core.node.NodeException; 44 import org.objectweb.proactive.core.process.UniversalProcess; 45 import org.objectweb.proactive.core.runtime.ProActiveRuntime; 46 import org.objectweb.proactive.core.runtime.VMInformation; 47 import org.objectweb.proactive.ext.security.PolicyServer; 48 import org.objectweb.proactive.ext.security.ProActiveSecurityManager; 49 50 import java.io.IOException ; 51 import java.io.Serializable ; 52 53 import java.lang.reflect.InvocationTargetException ; 54 55 import java.security.cert.X509Certificate ; 56 57 import java.util.ArrayList ; 58 59 60 66 public class RemoteProActiveRuntimeAdapter implements ProActiveRuntime, 67 Serializable { 68 protected RemoteProActiveRuntime remoteProActiveRuntime; 70 protected VMInformation vmInformation; 71 protected String proActiveRuntimeURL; 72 protected boolean alreadykilled = false; 73 74 public RemoteProActiveRuntimeAdapter() throws ProActiveException { 78 try { 79 this.remoteProActiveRuntime = createRemoteProActiveRuntime(); 80 this.vmInformation = remoteProActiveRuntime.getVMInformation(); 82 this.proActiveRuntimeURL = remoteProActiveRuntime.getURL(); 83 } catch (RemoteException e) { 84 throw new ProActiveException("Cannot create the remoteProactiveRuntime or get the VMInformation from the RemoteProActiveRuntime", 85 e); 86 } catch (AlreadyBoundException e) { 87 throw new ProActiveException( 88 "Cannot bind remoteProactiveRuntime to" + proActiveRuntimeURL, e); 89 } 90 } 91 92 public RemoteProActiveRuntimeAdapter( 93 RemoteProActiveRuntime remoteProActiveRuntime) 94 throws ProActiveException { 95 this.remoteProActiveRuntime = remoteProActiveRuntime; 96 try { 97 this.vmInformation = remoteProActiveRuntime.getVMInformation(); 98 this.proActiveRuntimeURL = remoteProActiveRuntime.getURL(); 99 } catch (RemoteException re) { 100 throw new ProActiveException(re); 101 } 102 } 103 104 public boolean equals(Object o) { 108 if (!(o instanceof RemoteProActiveRuntimeAdapter)) { 109 return false; 110 } 111 RemoteProActiveRuntimeAdapter runtime = (RemoteProActiveRuntimeAdapter) o; 112 return remoteProActiveRuntime.equals(runtime.remoteProActiveRuntime); 113 } 114 115 public int hashCode() { 116 return remoteProActiveRuntime.hashCode(); 117 } 118 119 public String createLocalNode(String nodeName, 123 boolean replacePreviousBinding, PolicyServer ps, String vname, String jobId) 124 throws NodeException { 125 try { 126 return remoteProActiveRuntime.createLocalNode(nodeName, 127 replacePreviousBinding, ps, vname, jobId); 128 } catch (RemoteException e) { 129 throw new NodeException(e); 130 } 131 } 132 133 public void killAllNodes() throws ProActiveException { 134 try { 135 remoteProActiveRuntime.killAllNodes(); 136 } catch (RemoteException re) { 137 throw new ProActiveException(re); 138 } 140 } 141 142 public void killNode(String nodeName) throws ProActiveException { 143 try { 144 remoteProActiveRuntime.killNode(nodeName); 145 } catch (RemoteException re) { 146 throw new ProActiveException(re); 147 } 148 } 149 150 public void createVM(UniversalProcess remoteProcess) 160 throws IOException , ProActiveException { 161 try { 162 remoteProActiveRuntime.createVM(remoteProcess); 163 } catch (RemoteException re) { 164 throw new ProActiveException(re); 165 } 166 } 167 168 public String [] getLocalNodeNames() throws ProActiveException { 178 try { 179 return remoteProActiveRuntime.getLocalNodeNames(); 180 } catch (RemoteException re) { 181 throw new ProActiveException(re); 182 } 184 } 185 186 public VMInformation getVMInformation() { 215 return vmInformation; 216 } 217 218 public void register(ProActiveRuntime proActiveRuntimeDist, 219 String proActiveRuntimeName, String creatorID, String creationProtocol, 220 String vmName) { 221 try { 222 remoteProActiveRuntime.register(proActiveRuntimeDist, 224 proActiveRuntimeName, creatorID, creationProtocol, vmName); 225 } catch (RemoteException re) { 226 re.printStackTrace(); 227 } 229 } 230 231 public ProActiveRuntime[] getProActiveRuntimes() throws ProActiveException { 232 try { 233 return remoteProActiveRuntime.getProActiveRuntimes(); 234 } catch (RemoteException re) { 235 throw new ProActiveException(re); 236 } 237 } 238 239 public ProActiveRuntime getProActiveRuntime(String proActiveRuntimeName) 240 throws ProActiveException { 241 try { 242 return remoteProActiveRuntime.getProActiveRuntime(proActiveRuntimeName); 243 } catch (RemoteException re) { 244 throw new ProActiveException(re); 245 } 247 } 248 249 public void killRT(boolean softly) throws Exception { 250 try { 251 if (!alreadykilled) { 252 remoteProActiveRuntime.killRT(softly); 253 } 254 alreadykilled = true; 255 } catch (UnmarshalException e) { 256 alreadykilled = true; 258 throw e; 259 } catch (RemoteException re) { 260 throw new ProActiveException(re); 261 } 262 } 263 264 public String getURL() throws ProActiveException { 265 return proActiveRuntimeURL; 266 } 273 274 public ArrayList getActiveObjects(String nodeName) 275 throws ProActiveException { 276 try { 277 return remoteProActiveRuntime.getActiveObjects(nodeName); 278 } catch (RemoteException re) { 279 throw new ProActiveException(re); 280 } 281 } 282 283 public ArrayList getActiveObjects(String nodeName, String objectName) 284 throws ProActiveException { 285 try { 286 return remoteProActiveRuntime.getActiveObjects(nodeName, objectName); 287 } catch (RemoteException re) { 288 throw new ProActiveException(re); 289 } 290 } 291 292 public VirtualNode getVirtualNode(String virtualNodeName) 293 throws ProActiveException { 294 try { 295 return remoteProActiveRuntime.getVirtualNode(virtualNodeName); 296 } catch (RemoteException re) { 297 throw new ProActiveException(re); 298 } 299 } 300 301 public void registerVirtualNode(String virtualNodeName, 302 boolean replacePreviousBinding) throws ProActiveException { 303 try { 304 remoteProActiveRuntime.registerVirtualNode(virtualNodeName, 305 replacePreviousBinding); 306 } catch (RemoteException re) { 307 throw new ProActiveException(re); 308 } 309 } 310 311 public void unregisterVirtualNode(String virtualNodeName) 312 throws ProActiveException { 313 try { 314 remoteProActiveRuntime.unregisterVirtualNode(virtualNodeName); 315 } catch (RemoteException re) { 316 throw new ProActiveException(re); 317 } 318 } 319 320 public void unregisterAllVirtualNodes() throws ProActiveException { 321 try { 322 remoteProActiveRuntime.unregisterAllVirtualNodes(); 323 } catch (RemoteException re) { 324 throw new ProActiveException(re); 325 } 326 } 327 328 public UniversalBody createBody(String nodeName, 329 ConstructorCall bodyConstructorCall, boolean isNodeLocal) 330 throws ProActiveException, ConstructorCallExecutionFailedException, 331 InvocationTargetException { 332 try { 333 return remoteProActiveRuntime.createBody(nodeName, 334 bodyConstructorCall, isNodeLocal); 335 } catch (RemoteException re) { 336 throw new ProActiveException(re); 337 } 338 } 339 340 public UniversalBody receiveBody(String nodeName, Body body) 341 throws ProActiveException { 342 try { 343 return remoteProActiveRuntime.receiveBody(nodeName, body); 344 } catch (RemoteException re) { 345 throw new ProActiveException(re); 346 } 347 } 348 349 351 352 public PolicyServer getPolicyServer() throws ProActiveException { 353 try { 354 return remoteProActiveRuntime.getPolicyServer(); 355 } catch (RemoteException re) { 356 throw new ProActiveException(re); 357 } 358 } 359 360 public void setProActiveSecurityManager(ProActiveSecurityManager ps) 361 throws ProActiveException { 362 try { 363 remoteProActiveRuntime.setProActiveSecurityManager(ps); 364 } catch (RemoteException re) { 365 throw new ProActiveException(re); 366 } 367 } 368 369 372 public X509Certificate getCreatorCertificate() throws ProActiveException { 373 try { 374 return remoteProActiveRuntime.getCreatorCertificate(); 375 } catch (RemoteException re) { 376 throw new ProActiveException(re); 377 } 378 } 379 380 public String getVNName(String nodename) throws ProActiveException { 381 try { 382 return remoteProActiveRuntime.getVNName(nodename); 383 } catch (RemoteException re) { 384 throw new ProActiveException(re); 385 } 386 } 387 388 391 public void setDefaultNodeVirtualNodeName(String s) 392 throws ProActiveException { 393 try { 394 remoteProActiveRuntime.setDefaultNodeVirtualNodeName(s); 395 } catch (RemoteException re) { 396 throw new ProActiveException(re); 397 } 398 } 399 400 403 public void updateLocalNodeVirtualName() throws ProActiveException { 404 try { 405 remoteProActiveRuntime.updateLocalNodeVirtualName(); 406 } catch (RemoteException re) { 407 throw new ProActiveException(re); 408 } 409 } 410 411 414 public void listVirtualNodes() throws ProActiveException { 415 try { 416 remoteProActiveRuntime.listVirtualNodes(); 417 } catch (RemoteException re) { 418 throw new ProActiveException(re); 419 } 420 } 421 422 425 public PolicyServer getNodePolicyServer(String nodeName) 426 throws ProActiveException { 427 try { 428 return remoteProActiveRuntime.getNodePolicyServer(nodeName); 429 } catch (RemoteException re) { 430 throw new ProActiveException(re); 431 } 432 } 433 434 437 public void enableSecurityIfNeeded() throws ProActiveException { 438 try { 439 remoteProActiveRuntime.enableSecurityIfNeeded(); 440 } catch (RemoteException re) { 441 throw new ProActiveException(re); 442 } 443 } 444 445 448 public X509Certificate getNodeCertificate(String nodeName) 449 throws ProActiveException { 450 try { 451 return remoteProActiveRuntime.getNodeCertificate(nodeName); 452 } catch (RemoteException re) { 453 throw new ProActiveException(re); 454 } 455 } 456 457 461 public ArrayList getEntities(String nodeName) throws ProActiveException { 462 try { 463 return remoteProActiveRuntime.getEntities(nodeName); 464 } catch (RemoteException re) { 465 throw new ProActiveException(re); 466 } 467 } 468 469 473 public ArrayList getEntities(UniversalBody uBody) throws ProActiveException { 474 try { 475 return remoteProActiveRuntime.getEntities(uBody); 476 } catch (RemoteException re) { 477 throw new ProActiveException(re); 478 } 479 } 480 481 484 public ArrayList getEntities() throws ProActiveException { 485 try { 486 return remoteProActiveRuntime.getEntities(); 487 } catch (RemoteException re) { 488 throw new ProActiveException(re); 489 } 490 } 491 492 495 public String getJobID() { 496 return vmInformation.getJobID(); 497 } 498 499 500 public String getJobID(String nodeUrl) throws ProActiveException{ 501 try { 502 return remoteProActiveRuntime.getJobID(nodeUrl); 503 } catch (RemoteException re) { 504 throw new ProActiveException(re); 505 } 506 } 507 508 protected RemoteProActiveRuntime createRemoteProActiveRuntime() 512 throws RemoteException, AlreadyBoundException { 513 return new RemoteProActiveRuntimeImpl(); 514 } 515 516 517 } 518 | Popular Tags |