Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Release of threads, and adding error messages.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 25 Jul 2011 08:34:56 +0000 (10:34 +0200)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 25 Jul 2011 08:34:56 +0000 (10:34 +0200)
src/and/hpcvm/Client.java
src/and/hpcvm/Server.java

index 06bb4e7..662944e 100644 (file)
@@ -1328,12 +1328,14 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                } catch( RemoteException e1 ) {
                                        System.err.println( "Unable to ping the server!" ) ;
                                        e1.printStackTrace() ;
+                                       yield() ;
                                }
                                
                                try {
                                        sleep( 2000 ) ;
                                } catch( InterruptedException e ) {
                                        e.printStackTrace() ;
+                                       yield() ;
                                }
                        }
                }
@@ -1361,6 +1363,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        serverSocket.close() ;                                  
                                } catch( IOException e ) {
                                        e.printStackTrace() ;
+                                       yield() ;
                                }
                        }                       
                }
@@ -1377,8 +1380,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        } catch( IOException e ) {
                                System.err.println( "Unable to launch the SocketServer on port " + dialog_port + "!" ) ;
                                e.printStackTrace() ;
-                               
-                               go = false ;
+                               System.exit( 1 ) ;
                        }       
                        
                        while( go )
@@ -1391,6 +1393,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                } catch( IOException e ) {
                                        System.err.println( "Problem with the accept function!" ) ;
                                        e.printStackTrace() ;
+                                       yield() ;
                                }
                        }
                }
@@ -1412,7 +1415,8 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                reader = new BufferedReader( new InputStreamReader( socket.getInputStream() ) ) ;
                        } catch( IOException e ) {
                                System.err.println( "Unable to open a dialog socket with the VM!" ) ;
-                               e.printStackTrace();
+                               e.printStackTrace() ;
+                               yield() ;
                        }
 
                        try {
@@ -1526,6 +1530,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
 
                        } catch( IOException e ) {
                                e.printStackTrace() ;
+                               yield() ;
                        }
                }
        }
index a822cf7..b703aa7 100644 (file)
@@ -263,7 +263,8 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                clients.get( i ).getStub().emergencyStop() ;
                                clients.get( i ).getStub().stop() ;
                        } catch (RemoteException e) {
-                               e.printStackTrace();
+                               System.err.println( "Unable to send stop signal to " + clients.get( i ).getName() ) ;
+                               e.printStackTrace() ;
                        }
                }
                
@@ -398,6 +399,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                        } catch( RemoteException e ) {
                                                                System.err.println( "Unable to indicate to client to retrieve last save!" ) ;
                                                                e.printStackTrace() ;
+                                                               yield() ;
                                                        }
                                                                
                                                        if( res == 0 )
@@ -425,6 +427,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                                                } catch( RemoteException e ) {
                                                                                        System.err.println( "Unable to set the new VM IP on the replacing client!" ) ;
                                                                                        e.printStackTrace() ;
+                                                                                       yield() ;
                                                                                }
                                                                                
                                                                                if( ok_new && ok_old )
@@ -527,10 +530,11 @@ public class Server extends UnicastRemoteObject implements ServicesServer
 //                                                                     break ;
 //                                                             }
 //                                                     }
-                                                       synchronized( counter ){
-                                                               counter.inc() ;}
+                                                       synchronized( counter )
+                                                       {
+                                                               counter.inc() ;
+                                                       }
                                                                
-                                                       
                                                        new Server.FaultManager( cl ).start() ;
                                                        nb_disconnections_computing++ ;
                                                } else {
@@ -577,6 +581,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                        } catch( RemoteException e ) {
                                                                System.err.println( "Unable to invoke emergency stop signal on " + clients.get( i ).getName() ) ;
                                                                e.printStackTrace() ;
+                                                               yield() ;
                                                        }
                                                }
                                        }
@@ -596,16 +601,17 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                                counter.wait() ;
                                                        } catch( InterruptedException e ) {
                                                                e.printStackTrace() ;
+                                                               yield() ;
                                                        }
                                                }
                                        }
                                        
                                        for( int i = 0 ; i < applications.get( ind ).getComputingClients().size() ; i++ )
                                        {
-                                               final ServicesClient sc = applications.get( ind ).getComputingClients().get( i ).getClient().getStub() ;
-                                               
                                                applications.get( ind ).getComputingClients().get( i ).setRestartOk( false ) ;
                                                
+                                               final ServicesClient sc = applications.get( ind ).getComputingClients().get( i ).getClient().getStub() ;
+                                               
                                                new Thread( new Runnable() {
                                                        
                                                        @Override
@@ -615,6 +621,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                                        sc.restartVMAfterCrash() ;
                                                                } catch( RemoteException e ) {
                                                                        e.printStackTrace() ;
+                                                                       yield() ;
                                                                }
                                                        }
                                                } ).start() ;
@@ -626,6 +633,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                        Thread.sleep( 2000 ) ;
                                } catch( InterruptedException e ) {
                                        e.printStackTrace() ;
+                                       yield() ;
                                }
                        }
                }
@@ -662,7 +670,8 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                try {
                                        computingClients.get( i ).getClient().getStub().saveOk() ;
                                } catch (RemoteException e) {
-                                       e.printStackTrace();
+                                       System.err.println( "Unable to invoke the saveOk method on " + computingClients.get( i ).getClient().getName() ) ;
+                                       e.printStackTrace() ;
                                }
                                computingClients.get( i ).setSaveStatus( false ) ;
                        }
@@ -697,6 +706,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                return 1 ;
        }
 
+       
        @Override
        public ArrayList<ServicesClient> startApplication( int _nb ) 
        {
@@ -727,8 +737,8 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                        
                                                        try {
                                                                startingClients.wait() ;
-                                                       } catch (InterruptedException e) {
-                                                               e.printStackTrace();
+                                                       } catch( InterruptedException e ) {
+                                                               e.printStackTrace() ;
                                                        }
                                                }
                                                
@@ -756,8 +766,8 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                }
                                                
                                                final int indice = i ;
-                                               new Thread( new Runnable(){
-                                                       
+                                               new Thread( new Runnable()
+                                               {       
                                                        @Override
                                                        public void run() 
                                                        {
@@ -765,7 +775,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                                try {
                                                                        res = clients.get( indice ).getStub().startVM( 0 ) ;
                                                                } catch( RemoteException e ) {
-                                                                       e.printStackTrace();
+                                                                       e.printStackTrace() ;
                                                                }
                                                                
                                                                if( res == 0 )