Project

General

Profile

Revision 2

Fixed many bugs

View differences:

Client.java
4 4

  
5 5
public class Client {
6 6

  
7
    private Client() {
8

  
9
    }
10

  
11 7
    public static void main(String[] args) {
12 8

  
13 9
        // Command parameters
......
52 48
        }
53 49
        // Any more arguments are invalid too
54 50
        else {
55
            System.out.println("Invalid number of arguments");
51
            System.out.println("java Client <peer_ap> <protocol> <opnd_1> <opnd_2");
56 52
            return;
57 53
        }
58 54

  
59
        // Peer Id to takeover
60
        String idPeer = args[0];
55
        // Host id
56
        String[] host = new String(args[0]).split("/");
61 57

  
62 58
        try {
63 59

  
60
            PeerInterface stub;
61

  
64 62
            // Lookup for RMI
65
            Registry registry = LocateRegistry.getRegistry();
63
            if(host.length > 2){
64
                Registry registry = LocateRegistry.getRegistry(host[2]);
65
                stub = (PeerInterface) registry.lookup(host[3]);
66
            }else{
67
                Registry registry = LocateRegistry.getRegistry();
68
                stub = (PeerInterface) registry.lookup(args[0]);
69
            }                     
66 70

  
67
            // Lookup for peer access point
68
            PeerInterface stub = (PeerInterface) registry.lookup(idPeer);
69

  
70 71
            // Identify action
71 72
            switch (opnd[0]) {
72 73
            case "BACKUP":

Also available in: Unified diff