1 31 package org.objectweb.proactive.core.runtime.rmi; 32 33 import org.objectweb.proactive.Body; 34 import org.objectweb.proactive.core.ProActiveException; 35 import org.objectweb.proactive.core.body.UniversalBody; 36 import org.objectweb.proactive.core.descriptor.data.VirtualNode; 37 import org.objectweb.proactive.core.mop.ConstructorCall; 38 import org.objectweb.proactive.core.mop.ConstructorCallExecutionFailedException; 39 import org.objectweb.proactive.core.node.NodeException; 40 import org.objectweb.proactive.core.process.UniversalProcess; 41 import org.objectweb.proactive.core.runtime.ProActiveRuntime; 42 import org.objectweb.proactive.core.runtime.VMInformation; 43 import org.objectweb.proactive.ext.security.PolicyServer; 44 import org.objectweb.proactive.ext.security.ProActiveSecurityManager; 45 46 import java.io.IOException ; 47 import java.io.Serializable ; 48 49 import java.lang.reflect.InvocationTargetException ; 50 51 import java.rmi.UnmarshalException ; 52 53 import java.security.cert.X509Certificate ; 54 55 import java.util.ArrayList ; 56 57 58 64 public class RemoteProActiveRuntimeAdapter implements ProActiveRuntime, 65 Serializable { 66 protected RemoteProActiveRuntime remoteProActiveRuntime; 68 protected VMInformation vmInformation; 69 protected String proActiveRuntimeURL; 70 71 protected boolean alreadykilled = false; 74 75 public RemoteProActiveRuntimeAdapter() throws ProActiveException { 79 try { 80 this.remoteProActiveRuntime = createRemoteProActiveRuntime(); 81 82 this.vmInformation = remoteProActiveRuntime.getVMInformation(); 84 this.proActiveRuntimeURL = remoteProActiveRuntime.getURL(); 85 } catch (java.rmi.RemoteException e) { 86 throw new ProActiveException("Cannot create the remoteProactiveRuntime or get the VMInformation from the RemoteProActiveRuntime", 87 e); 88 } catch (java.rmi.AlreadyBoundException e) { 89 throw new ProActiveException( 90 "Cannot bind remoteProactiveRuntime to" + proActiveRuntimeURL, e); 91 } 92 } 93 94 public RemoteProActiveRuntimeAdapter( 95 RemoteProActiveRuntime remoteProActiveRuntime) 96 throws ProActiveException { 97 this.remoteProActiveRuntime = remoteProActiveRuntime; 98 99 try { 100 this.vmInformation = remoteProActiveRuntime.getVMInformation(); 101 this.proActiveRuntimeURL = remoteProActiveRuntime.getURL(); 102 } catch (java.rmi.RemoteException re) { 103 throw new ProActiveException(re); 104 } 105 } 106 107 public boolean equals(Object o) { 111 if (!(o instanceof RemoteProActiveRuntimeAdapter)) { 112 return false; 113 } 114 RemoteProActiveRuntimeAdapter runtime = (RemoteProActiveRuntimeAdapter) o; 115 return remoteProActiveRuntime.equals(runtime.remoteProActiveRuntime); 116 } 117 118 public int hashCode() { 119 return remoteProActiveRuntime.hashCode(); 120 } 121 122 public String createLocalNode(String nodeName, 126 boolean replacePreviousBinding, PolicyServer ps, String vname, String jobId) 127 throws NodeException { 128 try { 129 return remoteProActiveRuntime.createLocalNode(nodeName, 130 replacePreviousBinding, ps, vname, jobId); 131 } catch (java.rmi.RemoteException e) { 132 throw new NodeException(e); 133 } 134 } 135 136 public void killAllNodes() throws ProActiveException { 137 try { 138 remoteProActiveRuntime.killAllNodes(); 139 } catch (java.rmi.RemoteException re) { 140 throw new ProActiveException(re); 141 } 143 } 144 145 public void killNode(String nodeName) throws ProActiveException { 146 try { 147 remoteProActiveRuntime.killNode(nodeName); 148 } catch (java.rmi.RemoteException re) { 149 throw new ProActiveException(re); 150 } 151 } 152 153 public void createVM(UniversalProcess remoteProcess) 163 throws IOException , ProActiveException { 164 try { 165 remoteProActiveRuntime.createVM(remoteProcess); 166 } catch (java.rmi.RemoteException re) { 167 throw new ProActiveException(re); 168 } 169 } 170 171 public String [] getLocalNodeNames() throws ProActiveException { 181 try { 182 return remoteProActiveRuntime.getLocalNodeNames(); 183 } catch (java.rmi.RemoteException re) { 184 throw new ProActiveException(re); 185 } 187 } 188 189 public VMInformation getVMInformation() { 218 return vmInformation; 219 } 220 221 public void register(ProActiveRuntime proActiveRuntimeDist, 222 String proActiveRuntimeName, String creatorID, String creationProtocol, 223 String vmName) { 224 try { 225 remoteProActiveRuntime.register(proActiveRuntimeDist, 227 proActiveRuntimeName, creatorID, creationProtocol, vmName); 228 } catch (java.rmi.RemoteException re) { 229 re.printStackTrace(); 230 } 232 } 233 234 public ProActiveRuntime[] getProActiveRuntimes() throws ProActiveException { 235 try { 236 return remoteProActiveRuntime.getProActiveRuntimes(); 237 } catch (java.rmi.RemoteException re) { 238 throw new ProActiveException(re); 239 } 241 } 242 243 public ProActiveRuntime getProActiveRuntime(String proActiveRuntimeName) 244 throws ProActiveException { 245 try { 246 return remoteProActiveRuntime.getProActiveRuntime(proActiveRuntimeName); 247 } catch (java.rmi.RemoteException re) { 248 throw new ProActiveException(re); 249 } 251 } 252 253 public void killRT(boolean softly) throws Exception { 254 try { 255 if (!alreadykilled) { 256 remoteProActiveRuntime.killRT(softly); 257 } 258 alreadykilled = true; 259 } catch (UnmarshalException e) { 260 alreadykilled = true; 262 throw e; 263 } catch (java.rmi.RemoteException re) { 264 throw new ProActiveException(re); 265 } 266 } 267 268 public String getURL() throws ProActiveException { 269 return proActiveRuntimeURL; 270 } 277 278 public ArrayList getActiveObjects(String nodeName) 279 throws ProActiveException { 280 try { 281 return remoteProActiveRuntime.getActiveObjects(nodeName); 282 } catch (java.rmi.RemoteException re) { 283 throw new ProActiveException(re); 284 } 285 } 286 287 public ArrayList getActiveObjects(String nodeName, String objectName) 288 throws ProActiveException { 289 try { 290 return remoteProActiveRuntime.getActiveObjects(nodeName, objectName); 291 } catch (java.rmi.RemoteException re) { 292 throw new ProActiveException(re); 293 } 294 } 295 296 public VirtualNode getVirtualNode(String virtualNodeName) 297 throws ProActiveException { 298 try { 299 return remoteProActiveRuntime.getVirtualNode(virtualNodeName); 300 } catch (java.rmi.RemoteException re) { 301 throw new ProActiveException(re); 302 } 303 } 304 305 public void registerVirtualNode(String virtualNodeName, 306 boolean replacePreviousBinding) throws ProActiveException { 307 try { 308 remoteProActiveRuntime.registerVirtualNode(virtualNodeName, 309 replacePreviousBinding); 310 } catch (java.rmi.RemoteException re) { 311 throw new ProActiveException(re); 312 } 313 } 314 315 public void unregisterVirtualNode(String virtualNodeName) 316 throws ProActiveException { 317 try { 318 remoteProActiveRuntime.unregisterVirtualNode(virtualNodeName); 319 } catch (java.rmi.RemoteException re) { 320 throw new ProActiveException(re); 321 } 322 } 323 324 public void unregisterAllVirtualNodes() throws ProActiveException { 325 try { 326 remoteProActiveRuntime.unregisterAllVirtualNodes(); 327 } catch (java.rmi.RemoteException re) { 328 throw new ProActiveException(re); 329 } 330 } 331 332 public UniversalBody createBody(String nodeName, 333 ConstructorCall bodyConstructorCall, boolean isNodeLocal) 334 throws ProActiveException, ConstructorCallExecutionFailedException, 335 InvocationTargetException { 336 try { 337 return remoteProActiveRuntime.createBody(nodeName, 338 bodyConstructorCall, isNodeLocal); 339 } catch (java.rmi.RemoteException re) { 340 throw new ProActiveException(re); 341 } 342 } 343 344 public UniversalBody receiveBody(String nodeName, Body body) 345 throws ProActiveException { 346 try { 347 return remoteProActiveRuntime.receiveBody(nodeName, body); 348 } catch (java.rmi.RemoteException re) { 349 throw new ProActiveException(re); 350 } 351 } 352 353 355 356 public PolicyServer getPolicyServer() throws ProActiveException { 357 try { 358 return remoteProActiveRuntime.getPolicyServer(); 359 } catch (java.rmi.RemoteException re) { 360 throw new ProActiveException(re); 361 } 362 } 363 364 public void setProActiveSecurityManager(ProActiveSecurityManager ps) 365 throws ProActiveException { 366 try { 367 remoteProActiveRuntime.setProActiveSecurityManager(ps); 368 } catch (java.rmi.RemoteException re) { 369 throw new ProActiveException(re); 370 } 371 } 372 373 376 public X509Certificate getCreatorCertificate() throws ProActiveException { 377 try { 378 return remoteProActiveRuntime.getCreatorCertificate(); 379 } catch (java.rmi.RemoteException re) { 380 throw new ProActiveException(re); 381 } 382 } 383 384 public String getVNName(String nodename) throws ProActiveException { 385 try { 386 return remoteProActiveRuntime.getVNName(nodename); 387 } catch (java.rmi.RemoteException re) { 388 throw new ProActiveException(re); 389 } 390 } 391 392 395 public void setDefaultNodeVirtualNodeName(String s) 396 throws ProActiveException { 397 try { 398 remoteProActiveRuntime.setDefaultNodeVirtualNodeNAme(s); 399 } catch (java.rmi.RemoteException re) { 400 throw new ProActiveException(re); 401 } 402 } 403 404 407 public void listVirtualNodes() throws ProActiveException { 408 try { 409 remoteProActiveRuntime.updateLocalNodeVirtualName(); 410 } catch (java.rmi.RemoteException re) { 411 throw new ProActiveException(re); 412 } 413 } 414 415 418 public PolicyServer getNodePolicyServer(String nodeName) 419 throws ProActiveException { 420 try { 421 return remoteProActiveRuntime.getNodePolicyServer(nodeName); 422 } catch (java.rmi.RemoteException re) { 423 throw new ProActiveException(re); 424 } 425 } 426 427 430 public void enableSecurityIfNeeded() throws ProActiveException { 431 try { 432 remoteProActiveRuntime.enableSecurityIfNeeded(); 433 } catch (java.rmi.RemoteException re) { 434 throw new ProActiveException(re); 435 } 436 } 437 438 441 public X509Certificate getNodeCertificate(String nodeName) 442 throws ProActiveException { 443 try { 444 return remoteProActiveRuntime.getNodeCertificate(nodeName); 445 } catch (java.rmi.RemoteException re) { 446 throw new ProActiveException(re); 447 } 448 } 449 450 454 public ArrayList getEntities(String nodeName) throws ProActiveException { 455 try { 456 return remoteProActiveRuntime.getEntities(nodeName); 457 } catch (java.rmi.RemoteException re) { 458 throw new ProActiveException(re); 459 } 460 } 461 462 466 public ArrayList getEntities(UniversalBody uBody) throws ProActiveException { 467 try { 468 return remoteProActiveRuntime.getEntities(uBody); 469 } catch (java.rmi.RemoteException re) { 470 throw new ProActiveException(re); 471 } 472 } 473 474 477 public ArrayList getEntities() throws ProActiveException { 478 try { 479 return remoteProActiveRuntime.getEntities(); 480 } catch (java.rmi.RemoteException re) { 481 throw new ProActiveException(re); 482 } 483 } 484 485 488 public String getJobID() { 489 return vmInformation.getJobID(); 490 } 491 492 495 public String getJobID(String nodeUrl) throws ProActiveException { 496 try { 497 return remoteProActiveRuntime.getJobID(nodeUrl); 498 } catch (java.rmi.RemoteException re) { 499 throw new ProActiveException(re); 500 } 501 } 502 503 protected RemoteProActiveRuntime createRemoteProActiveRuntime() 507 throws java.rmi.RemoteException , java.rmi.AlreadyBoundException { 508 return new RemoteProActiveRuntimeImpl(); 509 } 510 } 511 | Popular Tags |