Revision 2
Final delivery
TestApp.java | ||
---|---|---|
1 | 1 |
|
2 |
import java.io.File; |
|
2 | 3 |
import java.io.IOException; |
3 | 4 |
import java.net.DatagramPacket; |
4 | 5 |
import java.net.InetAddress; |
... | ... | |
40 | 41 |
|
41 | 42 |
if(args.length != 4) { |
42 | 43 |
System.out.println("Invalid arguments for Backup protocol"); |
43 |
System.out.println("TestApp BACKUP <file_path> <replication_degree>");
|
|
44 |
System.out.println("java TestApp <peer_ap> BACKUP <file_path> <replication_degree>");
|
|
44 | 45 |
return; |
45 | 46 |
} |
46 | 47 |
ReplicationDeg = Integer.parseInt(args[3]); |
47 | 48 |
file_path = args[2]; |
48 | 49 |
|
50 |
File f = new File(file_path); |
|
51 |
if(!f.exists()) { |
|
52 |
System.out.println("ERROR: File path specified doesn't lead to a file."); |
|
53 |
|
|
54 |
return; |
|
55 |
} |
|
56 |
|
|
49 | 57 |
stub.operation(sub_protocol, file_path, ReplicationDeg, disk_space); |
50 | 58 |
} |
51 | 59 |
else if(sub_protocol.equals("RESTORE")) |
52 | 60 |
{ |
53 | 61 |
if(args.length != 3) { |
54 | 62 |
System.out.println("Invalid arguments for Restore protocol"); |
55 |
System.out.println("TestApp RESTORE <file_path>");
|
|
63 |
System.out.println("java TestApp <peer_ap> RESTORE <file_path>");
|
|
56 | 64 |
return; |
57 | 65 |
} |
58 | 66 |
|
... | ... | |
64 | 72 |
{ |
65 | 73 |
if(args.length != 3) { |
66 | 74 |
System.out.println("Invalid arguments for Delete protocol"); |
67 |
System.out.println("TestApp DELETE <file_path> ");
|
|
75 |
System.out.println("java TestApp <peer_ap> DELETE <file_path> ");
|
|
68 | 76 |
return; |
69 | 77 |
} |
70 | 78 |
|
79 |
|
|
80 |
|
|
71 | 81 |
file_path = args[2]; |
72 | 82 |
|
83 |
|
|
84 |
|
|
85 |
|
|
73 | 86 |
stub.operation(sub_protocol, file_path, ReplicationDeg, disk_space); |
74 | 87 |
} |
75 | 88 |
else if(sub_protocol.equals("RECLAIM")) |
76 | 89 |
{ |
77 | 90 |
if(args.length != 3) { |
78 | 91 |
System.out.println("Invalid arguments for Reclaim protocol"); |
79 |
System.out.println("TestApp RECLAIM <space>");
|
|
92 |
System.out.println("java TestApp <peer_ap> RECLAIM <space>");
|
|
80 | 93 |
return; |
81 | 94 |
} |
82 | 95 |
|
... | ... | |
85 | 98 |
stub.operation(sub_protocol, file_path, ReplicationDeg, disk_space); |
86 | 99 |
} |
87 | 100 |
|
101 |
else if(sub_protocol.equals("STATE")) |
|
102 |
{ |
|
103 |
if(args.length != 2) { |
|
104 |
System.out.println("Invalid arguments for State protocol"); |
|
105 |
System.out.println("java TestApp <peer_ap> STATE"); |
|
106 |
return; |
|
107 |
} |
|
108 |
|
|
109 |
stub.operation(sub_protocol, file_path, ReplicationDeg, disk_space); |
|
110 |
|
|
111 |
} |
|
88 | 112 |
|
113 |
|
|
89 | 114 |
|
90 | 115 |
} catch (Exception e) { |
91 | 116 |
System.err.println("TestApp Exception: " + e.toString()); |
92 | 117 |
e.printStackTrace(); |
93 | 118 |
} |
119 |
|
|
120 |
System.out.println("PROTOCOL EXECUTED"); |
|
94 | 121 |
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 | 122 |
} |
123 |
|
|
124 |
|
|
102 | 125 |
} |
Also available in: Unified diff