3 import java.net.MalformedURLException;
4 import java.rmi.Naming;
5 import java.rmi.NotBoundException;
6 import java.rmi.RemoteException;
7 import java.util.ArrayList;
12 private ServicesServer ss ;
14 public User( String _serverIP, int _serverPort )
16 System.out.println( "Connecting to server ..." ) ;
17 /** Connection to server **/
19 ss = (ServicesServer) Naming.lookup( "rmi://"
20 + _serverIP + ":" + _serverPort + "/Server" ) ;
21 } catch( MalformedURLException e ) {
23 } catch( RemoteException e ) {
25 } catch( NotBoundException e ) {
31 System.err.println( "Unable to connect to server!!" ) ;
32 System.err.println( "Server IP: " + _serverIP + " -- server port: " + _serverPort ) ;
37 System.out.println( "Connected to server " + _serverIP + " on port " + _serverPort + "." ) ;
40 public void reserveMachines( int _nb )
42 ArrayList<ServicesClient> sc = null ;
45 sc = ss.startApplication( _nb ) ;
46 } catch( RemoteException e ) {
47 System.err.println( "Unable to retrieve VMs!!" ) ;
53 System.err.println( "There are not enough ressources!!" ) ;
57 System.out.println( "List of VMs: " ) ;
58 for( int i = 0 ; i < sc.size() ; i++ )
61 System.out.println( " " + sc.get( i ).getName() + " (" + sc.get( i ).getIPVM() + ")" ) ;
62 } catch( RemoteException e ) {
63 System.err.println( "Unable to retrieve VM informations!" ) ;
70 public void stopMachines()
74 } catch( RemoteException e ) {
84 } catch (RemoteException e) {
90 public void deploy( String _name, String _archive, String _directory )
94 nb = ss.deployVM( _name, _archive, _directory ) ;
95 } catch (RemoteException e) {
102 System.out.println( "There is only 1 machine available." ) ;
104 System.out.println( "There are " + nb + " machines available." ) ;
111 /** La programmation est un art, respectons ceux qui la pratiquent !! **/