1 31 package org.objectweb.proactive.core.runtime.jini; 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 48 import java.lang.reflect.InvocationTargetException ; 49 50 import java.rmi.RemoteException ; 51 52 import java.security.cert.X509Certificate ; 53 54 import java.util.ArrayList ; 55 56 57 63 public class JiniRuntimeAdapter implements ProActiveRuntime, 64 java.io.Serializable { 65 protected JiniRuntime jiniRuntime; 66 protected VMInformation vmInformation; 67 protected String proActiveRuntimeURL; 68 69 protected JiniRuntimeAdapter() throws ProActiveException { 73 try { 74 this.jiniRuntime = createJiniRuntime(); 75 this.vmInformation = jiniRuntime.getVMInformation(); 76 this.proActiveRuntimeURL = jiniRuntime.getURL(); 77 } catch (java.rmi.RemoteException e) { 78 throw new ProActiveException("Cannot create the jiniRuntime or get the VMInformation from the JiniRuntime", 79 e); 80 } 81 } 82 83 public JiniRuntimeAdapter(JiniRuntime r) throws ProActiveException { 84 this.jiniRuntime = r; 85 try { 86 this.vmInformation = jiniRuntime.getVMInformation(); 87 this.proActiveRuntimeURL = jiniRuntime.getURL(); 88 } catch (java.rmi.RemoteException e) { 89 throw new ProActiveException("Cannot get the NodeInformation of the node", 90 e); 91 } 92 } 93 94 public boolean equals(Object o) { 98 if (!(o instanceof JiniRuntimeAdapter)) { 99 return false; 100 } 101 JiniRuntimeAdapter runtime = (JiniRuntimeAdapter) o; 102 return jiniRuntime.equals(runtime.jiniRuntime); 103 } 104 105 public int hashCode() { 106 return jiniRuntime.hashCode(); 107 } 108 109 public String createLocalNode(String nodeName, 113 boolean replacePreviousBinding, PolicyServer ps, String vnname, String jobId) 114 throws NodeException { 115 try { 116 return jiniRuntime.createLocalNode(nodeName, 117 replacePreviousBinding, ps, vnname, jobId); 118 } catch (java.rmi.RemoteException e) { 119 throw new NodeException(e); 120 } 121 } 122 123 public void killAllNodes() throws ProActiveException { 124 try { 125 jiniRuntime.killAllNodes(); 126 } catch (java.rmi.RemoteException re) { 127 throw new ProActiveException(re); 128 } 129 } 130 131 public void killNode(String nodeName) throws ProActiveException { 132 try { 133 jiniRuntime.killNode(nodeName); 134 } catch (java.rmi.RemoteException re) { 135 throw new ProActiveException(re); 136 } 137 } 138 139 public void createVM(UniversalProcess remoteProcess) 149 throws IOException , ProActiveException { 150 try { 151 jiniRuntime.createVM(remoteProcess); 152 } catch (java.rmi.RemoteException re) { 153 throw new ProActiveException(re); 154 } 155 } 156 157 public String [] getLocalNodeNames() throws ProActiveException { 167 try { 168 return jiniRuntime.getLocalNodeNames(); 169 } catch (java.rmi.RemoteException re) { 170 throw new ProActiveException(re); 171 } 173 } 174 175 public VMInformation getVMInformation() { 204 return vmInformation; 205 } 206 207 public void register(ProActiveRuntime proActiveRuntimeDist, 208 String proActiveRuntimeName, String creatorID, String creationProtocol, 209 String vmName) { 210 try { 211 jiniRuntime.register(proActiveRuntimeDist, proActiveRuntimeName, 213 creatorID, creationProtocol, vmName); 214 } catch (java.rmi.RemoteException re) { 215 re.printStackTrace(); 216 } 218 } 219 220 public ProActiveRuntime[] getProActiveRuntimes() throws ProActiveException { 221 try { 222 return jiniRuntime.getProActiveRuntimes(); 223 } catch (java.rmi.RemoteException re) { 224 throw new ProActiveException(re); 225 } 227 } 228 229 public ProActiveRuntime getProActiveRuntime(String proActiveRuntimeName) 230 throws ProActiveException { 231 try { 232 return jiniRuntime.getProActiveRuntime(proActiveRuntimeName); 233 } catch (java.rmi.RemoteException re) { 234 throw new ProActiveException(re); 235 } 237 } 238 239 public void killRT(boolean softly) throws Exception { 240 try { 241 jiniRuntime.killRT(softly); 242 } catch (java.rmi.RemoteException re) { 243 throw new ProActiveException(re); 244 } 247 } 248 249 public String getURL() throws ProActiveException { 250 return proActiveRuntimeURL; 251 } 258 259 public ArrayList getActiveObjects(String nodeName) 260 throws ProActiveException { 261 try { 262 return jiniRuntime.getActiveObjects(nodeName); 263 } catch (java.rmi.RemoteException re) { 264 throw new ProActiveException(re); 265 } 266 } 267 268 public ArrayList getActiveObjects(String nodeName, String objectName) 269 throws ProActiveException { 270 try { 271 return jiniRuntime.getActiveObjects(nodeName, objectName); 272 } catch (java.rmi.RemoteException re) { 273 throw new ProActiveException(re); 274 } 275 } 276 277 public VirtualNode getVirtualNode(String virtualNodeName) 278 throws ProActiveException { 279 try { 280 return jiniRuntime.getVirtualNode(virtualNodeName); 281 } catch (java.rmi.RemoteException re) { 282 throw new ProActiveException(re); 283 } 284 } 285 286 public void registerVirtualNode(String virtualNodeName, 287 boolean replacePreviousBinding) throws ProActiveException { 288 try { 289 jiniRuntime.registerVirtualNode(virtualNodeName, 290 replacePreviousBinding); 291 } catch (java.rmi.RemoteException re) { 292 throw new ProActiveException(re); 293 } 294 } 295 296 public void unregisterVirtualNode(String virtualNodeName) 297 throws ProActiveException { 298 try { 299 jiniRuntime.unregisterVirtualNode(virtualNodeName); 300 } catch (java.rmi.RemoteException re) { 301 throw new ProActiveException(re); 302 } 303 } 304 305 public void unregisterAllVirtualNodes() throws ProActiveException { 306 try { 307 jiniRuntime.unregisterAllVirtualNodes(); 308 } catch (java.rmi.RemoteException re) { 309 throw new ProActiveException(re); 310 } 311 } 312 313 public UniversalBody createBody(String nodeName, 314 ConstructorCall bodyConstructorCall, boolean isNodeLocal) 315 throws ProActiveException, ConstructorCallExecutionFailedException, 316 InvocationTargetException { 317 try { 318 return jiniRuntime.createBody(nodeName, bodyConstructorCall, 319 isNodeLocal); 320 } catch (java.rmi.RemoteException re) { 321 throw new ProActiveException(re); 322 } 323 } 324 325 public UniversalBody receiveBody(String nodeName, Body body) 326 throws ProActiveException { 327 try { 328 return jiniRuntime.receiveBody(nodeName, body); 329 } catch (java.rmi.RemoteException re) { 330 throw new ProActiveException(re); 331 } 332 } 333 334 336 339 public X509Certificate getCreatorCertificate() throws ProActiveException { 340 try { 341 return jiniRuntime.getCreatorCertificate(); 342 } catch (RemoteException e) { 343 throw new ProActiveException(e); 344 } 345 } 346 347 350 public PolicyServer getPolicyServer() throws ProActiveException { 351 try { 352 return jiniRuntime.getPolicyServer(); 353 } catch (RemoteException e) { 354 throw new ProActiveException(e); 355 } 356 } 357 358 public String getVNName(String Nodename) throws ProActiveException { 359 try { 360 return jiniRuntime.getVNName(Nodename); 361 } catch (java.rmi.RemoteException re) { 362 throw new ProActiveException(re); 363 } 364 } 365 366 public void setProActiveSecurityManager(ProActiveSecurityManager ps) 367 throws ProActiveException { 368 try { 369 jiniRuntime.setProActiveSecurityManager(ps); 370 } catch (RemoteException e) { 371 throw new ProActiveException(e); 372 } 373 } 374 375 378 public void setDefaultNodeVirtualNodeName(String s) 379 throws ProActiveException { 380 try { 381 jiniRuntime.setDefaultNodeVirtualNodeName(s); 382 } catch (RemoteException e) { 383 throw new ProActiveException(e); 384 } 385 } 386 387 390 public void listVirtualNodes() throws ProActiveException { 391 try { 392 jiniRuntime.updateLocalNodeVirtualName(); 393 } catch (RemoteException e) { 394 throw new ProActiveException(e); 395 } 396 } 397 398 401 public PolicyServer getNodePolicyServer(String nodeName) 402 throws ProActiveException { 403 try { 404 return jiniRuntime.getNodePolicyServer(nodeName); 405 } catch (RemoteException e) { 406 throw new ProActiveException(e); 407 } 408 } 409 410 413 public void enableSecurityIfNeeded() throws ProActiveException { 414 try { 415 jiniRuntime.enableSecurityIfNeeded(); 416 } catch (RemoteException e) { 417 throw new ProActiveException(e); 418 } 419 } 420 421 424 public X509Certificate getNodeCertificate(String nodeName) 425 throws ProActiveException { 426 try { 427 return jiniRuntime.getNodeCertificate(nodeName); 428 } catch (RemoteException e) { 429 throw new ProActiveException(e); 430 } 431 } 432 433 437 public ArrayList getEntities(String nodeName) throws ProActiveException { 438 try { 439 return jiniRuntime.getEntities(nodeName); 440 } catch (java.rmi.RemoteException re) { 441 throw new ProActiveException(re); 442 } 443 } 444 445 449 public ArrayList getEntities(UniversalBody uBody) throws ProActiveException { 450 try { 451 return jiniRuntime.getEntities(uBody); 452 } catch (java.rmi.RemoteException re) { 453 throw new ProActiveException(re); 454 } 455 } 456 457 460 public ArrayList getEntities() throws ProActiveException { 461 try { 462 return jiniRuntime.getEntities(); 463 } catch (java.rmi.RemoteException re) { 464 throw new ProActiveException(re); 465 } 466 } 467 468 471 public String getJobID() { 472 return vmInformation.getJobID(); 473 } 474 475 478 public String getJobID(String nodeUrl) throws ProActiveException { 479 try { 480 return jiniRuntime.getJobID(nodeUrl); 481 } catch (java.rmi.RemoteException re) { 482 throw new ProActiveException(re); 483 } 484 } 485 486 protected JiniRuntime createJiniRuntime() throws java.rmi.RemoteException { 490 return new JiniRuntimeImpl(); 491 } 492 } 493 | Popular Tags |