root / src / testapp / TestApp.java
History | View | Annotate | Download (1.63 KB)
1 | 1 | up20150524 | package testapp; |
---|---|---|---|
2 | |||
3 | import peer.RMIStub; |
||
4 | |||
5 | import java.rmi.NotBoundException; |
||
6 | import java.rmi.RemoteException; |
||
7 | import java.rmi.registry.LocateRegistry; |
||
8 | import java.rmi.registry.Registry; |
||
9 | |||
10 | public class TestApp { |
||
11 | |||
12 | public static void main(String args[]) throws RemoteException, NotBoundException { |
||
13 | |||
14 | String peerAcessPoint = args[0]; |
||
15 | String protocol = args[1]; |
||
16 | |||
17 | String operand1 = null; |
||
18 | int operand2 = 1; |
||
19 | long aux = 100; |
||
20 | |||
21 | Registry registry = LocateRegistry.getRegistry("localhost"); |
||
22 | RMIStub stub = (RMIStub) registry.lookup(peerAcessPoint); |
||
23 | |||
24 | System.out.println("Initiation Peer : " + peerAcessPoint + "\n" + "Protocol : " + protocol); |
||
25 | |||
26 | switch (protocol){
|
||
27 | case "BACKUP": |
||
28 | operand1 = args[2];
|
||
29 | try {
|
||
30 | operand2 = Integer.parseInt(args[3]); |
||
31 | if(operand2 <= 0 || operand2 >= 10) |
||
32 | throw new Exception("rd amount"); |
||
33 | } catch (Exception e) { |
||
34 | System.err.println("rd must be an integer from 1 to 9"); |
||
35 | System.exit(-1); |
||
36 | } |
||
37 | stub.backupProtocol(operand1, operand2); |
||
38 | break;
|
||
39 | case "RESTORE": |
||
40 | operand1 = args[2];
|
||
41 | stub.restoreProtocol(operand1); |
||
42 | break;
|
||
43 | case "DELETE": |
||
44 | operand1 = args[2];
|
||
45 | stub.deleteProtocol(operand1); |
||
46 | break;
|
||
47 | case "RECLAIM": |
||
48 | operand1 = args[2];
|
||
49 | stub.reclaimProtocol(Integer.parseInt(operand1));
|
||
50 | break;
|
||
51 | } |
||
52 | } |
||
53 | |||
54 | } |