-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNodeClient.java
More file actions
34 lines (28 loc) · 850 Bytes
/
NodeClient.java
File metadata and controls
34 lines (28 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Eleccion.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import java.io.*;
/**
*
* @author Miguel Alejandro
*/
public class NodeClient {
public static void main (String args []) {
try{
//crea e inicializa el orb
ORB orb = ORB.init (args, null);
org.omg.CORBA.Object objRef = orb.resolve_initial_references ("NameService");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
NameComponent nc1 = new NameComponent("node0", "");
NameComponent path[] = {nc1};
Node n1 = NodeHelper.narrow(ncRef.resolve(path));
n1.election();
int leader = n1.getLeader();
System.out.println("El lider fue: "+leader);
}catch (Exception e) {
System.out.println("ERROR:"+ e);
e.printStackTrace(System.out);
}
}
}