KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > ic2d > util > CreateJiniNodeTask


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.ic2d.util;
32
33 import org.objectweb.proactive.core.node.Node;
34 import org.objectweb.proactive.ic2d.data.*;
35
36
37 public class CreateJiniNodeTask implements Runnable JavaDoc {
38     private WorldObject worldObject;
39     private String JavaDoc host;
40
41     public CreateJiniNodeTask() {
42     }
43
44     public CreateJiniNodeTask(WorldObject worldObject) {
45         this.worldObject = worldObject;
46         this.host = null;
47     }
48
49     public CreateJiniNodeTask(WorldObject worldObject, String JavaDoc host) {
50         this.worldObject = worldObject;
51         this.host = host;
52     }
53
54     public void run() {
55         System.out.println("CreateJininodeTask: lancement de la recherche");
56
57         Node[] nodes;
58         JiniNodeFinder finder = new JiniNodeFinder();
59         nodes = finder.findNodes(host);
60
61         //System.out.println("fin de la recherche NB de noeud: "+nodes.length);
62
for (int i = 0; i < nodes.length; i++) {
63             Node node = nodes[i];
64             String JavaDoc nodeName = node.getNodeInformation().getName();
65             String JavaDoc hostname = node.getNodeInformation().getInetAddress()
66                                   .getCanonicalHostName();
67             HostObject hostObject = worldObject.getHostObject(hostname);
68
69             //System.out.println("hostObject: "+hostObject.getHostName());
70
if (hostObject == null) {
71                 //System.out.println("CreateJiniNodeTask: creation d'un nouvel host");
72
hostObject = new HostObject(worldObject, hostname, null);
73                 worldObject.addHostsObject(hostObject);
74                 worldObject.putChild(hostname, hostObject);
75             }
76
77             VMObject vmObject = hostObject.findVMObjectHavingExistingNode(nodeName);
78
79             if (vmObject == null) {
80                 // new NodeObject
81
//System.out.println("CreateJiniNodeTask: creation d'une nouvelle VM ");
82
hostObject.addVMObject(node);
83             } else {
84                 //System.out.println("CreateJiniNodeTask: creation d'un node dans une VM ");
85
vmObject.addNodeObject(node);
86                 vmObject.sendEventsForAllActiveObjects();
87             }
88         }
89     }
90 }
91
Popular Tags