Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correction of some messages and comments.
[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                                         double paramAlgo = 0.5 ;
44
45                                         try {
46                                                 nbDaemonPerSpawner = new Integer(args[4]).intValue();
47                                                 nbDaemonPerThread = new Integer(args[5]).intValue();
48                                                 nbSavingNodes = new Integer(args[6]).intValue();
49                                                 algoMapping = new Integer(args[7]).intValue();
50                                                 paramAlgo = new Double(args[8]).doubleValue();
51                                         } catch (NumberFormatException e) {
52                                                 System.err.println("The number of Daemons per spawner and the number of daemons per thread must be integers: "
53                                                                                 + e);
54                                                 System.exit(0);
55                                         }
56                                         //System.out.println("=====> " + algoMapping);
57                                         param = new String[args.length - 9];
58                                         for (int i = 9; i < args.length; i++) {
59                                                 param[i - 9] = args[i];
60                                                 System.out.println("=> " + args[i]);
61                                         }
62                                         JaceSpawner spawner = new JaceSpawner(superNodeName, port,
63                                                         comProtocol, param, nbDaemonPerSpawner,
64                                                         nbDaemonPerThread, nbSavingNodes, algoMapping, paramAlgo);
65                                         spawner.initialize();
66                                 }
67
68                                 else
69                                         usage();
70
71                         } else if (entity.equals("-SNode"))
72                                 if (args.length > 4) {
73                                         System.out
74                                                         .println("\n*************** LAUNCHING ---- SUPER-NODE *******************");
75                                         int beat = -1;
76                                         try {
77                                                 beat = new Integer(args[4]).intValue();
78                                         } catch (NumberFormatException e) {
79                                                 System.err
80                                                                 .println("The beat number must be an integer: "
81                                                                                 + e);
82                                                 System.exit(0);
83                                         }
84                                         JaceSuperNode superNode = new JaceSuperNode(superNodeName,
85                                                         port, comProtocol, beat);
86                                         superNode.initialize();
87                                 } else
88                                         usage();
89
90                         else
91                                 usage();
92
93                 }
94         }
95
96         public static void usage() {
97                 System.out
98                                 .println("Usage: java jaceP2P.JaceP2P -[Daemon|Spawner|SNode]  <Option> ");
99                 System.out.println("");
100                 System.out
101                                 .println("-Daemon : <option> = [superNodeName] [daemonPort] [protocol]");
102                 System.out
103                                 .println("ex : java jaceP2P.JaceP2P -Daemon cluster1 1098 rmi");
104                 System.out.println("");
105                 System.out
106                                 .println("-SNode : <option> = [superNodeName] [superNodePort] [protocol] [timeHeartBeat]");
107                 System.out
108                                 .println("ex : java jaceP2P.JaceP2P -SNode cluster1 1098 rmi 500");
109                 System.out.println("");
110                 System.out
111                                 .println("-Spawner : <option> = [superNodeName] [SpawnerPort] [protocol] nbDaemonPerSpawner nbDaemonPerThread nbresave nbTask URLToTaskName <TaskParam>");
112                 System.out
113                                 .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1098 rmi 8 4 3 16 http://bilbo/staff/vuillemi/java/LinSolv2 1000 0 20000 5");
114                 System.out
115                                 .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1098 rmi 8 4 3 16 file:/home/vuillemi/java/LinSolv2 1000 0 20000 5");
116                 System.exit(0);
117         }
118 }