Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correction of some bugs and performance enhancement.
[jaceP2P.git] / src / jaceP2P / JaceP2P.java
1 // Primary class to launch JaceP2P
2
3 // jaceP2P.JaceP2P -[Daemon|Spawner|SNode] <Option>
4
5 package jaceP2P;
6
7 public class JaceP2P {
8
9         static String[] param;
10
11         public static void main(String[] args) {
12
13                 if (args.length < 4) {
14                         usage();
15                 } else {
16                         String entity = args[0]; // entity : "-Daemon" or "-Spawner" or
17                                                                                 // "-SNode"
18                         int port = -1;
19
20                         String superNodeName = args[1];
21                         String comProtocol = args[3];
22                         try {
23                                 port = new Integer(args[2]).intValue();
24
25                         } catch (NumberFormatException e) {
26                                 System.out.println("the port must be an integer: " + e);
27                                 System.exit(0);
28                         }
29                         if (entity.equals("-Daemon")) {
30                                 System.out
31                                                 .println("\n*************** LAUNCHING ---- DAEMON *****");
32                                 JaceDaemon daemon = new JaceDaemon( superNodeName, port,
33                                                 comProtocol ) ;
34                                 daemon.initialize();
35                         } else if (entity.equals("-Spawner")) {
36                                 if (args.length > 9) {
37                                         System.out
38                                                         .println("\n*************** LAUNCHING ---- SPAWNER *******************");
39                                         int nbDaemonPerSpawner = -1;
40                                         int nbDaemonPerThread = -1;
41                                         int nbSavingNodes = -1;
42                                         int algoMapping = -1;
43                                         int test = -1 ;
44                                         double paramAlgo = 0.5 ;
45                                         int nbFault = 0 ;
46                                         int faultTime = 0 ;
47
48                                         try {
49                                                 nbDaemonPerSpawner = new Integer(args[4]).intValue();
50                                                 nbDaemonPerThread = new Integer(args[5]).intValue();
51                                                 nbSavingNodes = new Integer(args[6]).intValue();
52                                                 test = new Integer(args[7]).intValue();
53                                                 nbFault = new Integer(args[8]).intValue();
54                                                 faultTime = new Integer(args[9]).intValue();
55                                                 algoMapping = new Integer(args[10]).intValue();
56                                                 paramAlgo = new Double(args[11]).doubleValue();
57                                         } catch (NumberFormatException e) {
58                                                 System.err.println("The number of Daemons per spawner and the number of daemons per thread must be integers: "
59                                                                                 + e);
60                                                 System.exit(1);
61                                         }
62                                         //System.out.println("=====> " + algoMapping);
63                                         param = new String[args.length - 12];
64                                         for (int i = 12; i < args.length; i++) {
65                                                 param[i - 12] = args[i];
66                                                 System.out.println("=> " + args[i]);
67                                         }
68                                         JaceSpawner spawner = new JaceSpawner(superNodeName, port,
69                                                         comProtocol, param, nbDaemonPerSpawner,
70                                                         nbDaemonPerThread, nbSavingNodes, algoMapping, paramAlgo, test, nbFault, faultTime);
71                                         spawner.initialize();
72                                 }
73
74                                 else
75                                         usage();
76
77                         } else if (entity.equals("-SNode"))
78                                 if (args.length > 4) {
79                                         System.out
80                                                         .println("\n*************** LAUNCHING ---- SUPER-NODE *******************");
81                                         int beat = -1;
82                                         try {
83                                                 beat = new Integer(args[4]).intValue();
84                                         } catch (NumberFormatException e) {
85                                                 System.err
86                                                                 .println("The beat number must be an integer: "
87                                                                                 + e);
88                                                 System.exit(0);
89                                         }
90                                         JaceSuperNode superNode = new JaceSuperNode(superNodeName,
91                                                         port, comProtocol, beat);
92                                         superNode.initialize();
93                                 } else
94                                         usage();
95
96                         else
97                                 usage();
98
99                 }
100         }
101
102         public static void usage() {
103                 System.out
104                                 .println("Usage: java jaceP2P.JaceP2P -[Daemon|Spawner|SNode]  <Option> ");
105                 System.out.println("");
106                 System.out
107                                 .println("-Daemon : <option> = [superNodeName] [daemonPort] [protocol]");
108                 System.out
109                                 .println("ex : java jaceP2P.JaceP2P -Daemon cluster1 1098 rmi");
110                 System.out.println("");
111                 System.out
112                                 .println("-SNode : <option> = [superNodeName] [superNodePort] [protocol] [timeHeartBeat]");
113                 System.out
114                                 .println("ex : java jaceP2P.JaceP2P -SNode cluster1 1098 rmi 500");
115                 System.out.println("");
116                 System.out
117                                 .println("-Spawner : <option> = [superNodeName] [SpawnerPort] [protocol] nbDaemonPerSpawner nbDaemonPerThread nbresave nbTask URLToTaskName <TaskParam>");
118                 System.out
119                                 .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1098 rmi 8 4 3 16 http://bilbo/staff/vuillemi/java/LinSolv2 1000 0 20000 5");
120                 System.out
121                                 .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1098 rmi 8 4 3 16 file:/home/vuillemi/java/LinSolv2 1000 0 20000 5");
122                 System.exit(0);
123         }
124 }