+
+
+ public class FaultMake extends Thread {
+
+ public FaultMake(){}
+
+ public void run()
+ {
+ ListeTask t = null ;
+ Random r = null ;
+ int next, old = -1 ;
+
+ System.out.println( "Starting fault tolerance !" ) ;
+
+ while( ! RunningApplication.Instance().isRunning() )
+ {
+ /** Waiting some time the beginning of the computation **/
+ try {
+ sleep( 1000 ) ;
+ } catch (InterruptedException e) {
+ }
+ }
+
+ while( RunningApplication.Instance().isRunning() )
+ {
+ /** Waiting some time ... **/
+ try {
+ sleep( faultTime * 1000 ) ;
+ } catch (InterruptedException e) {
+ }
+
+ /** ... and kill some daemons ! **/
+ t = Register.Instance().getListeOfTasks();
+ r = new Random() ;
+
+ for( int i = 0 ; i < nbFault ; i++ )
+ {
+ next = r.nextInt( t.getSize() ) ;
+
+ while( next == old )
+ {
+ next = r.nextInt( t.getSize() ) ;
+ }
+ old = next ;
+
+ Node noeud = null;
+ try {
+ TaskId recev = null;
+ System.out.println("Making fault on Task" + next);
+
+ recev = t.getTaskIdOfRank( next );
+
+ JaceInterface stub = recev.getHostStub();
+ System.out.println("name = " + recev.getHostName());
+ noeud = Register.Instance().getNodeOfStub( stub ) ;
+
+ stub.suicide2( "Test fault tolerance" ) ;
+
+ } catch (UnmarshalException ue ){
+ } catch (Exception e) {
+ try {
+ System.err.println("Error in FaultMake on node: "
+ + noeud.getName() + ". " + e);
+ } catch (Exception e2) {
+ System.err.println("(Fault)Error in error:" + e2);
+ }
+ }
+
+ try {
+ sleep( 500 ) ;
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ }
+ }
+
+