Fault Tolerance Tutorial

In this tutorial, you will create and start two contexts in two VMs that will behave as a single fault tolerant context; the two contexts will be members of the same FT cluster. A third context will subscribe for a record from the fault tolerant context and then the active context in the FT cluster will be stopped.

  • Run the FTListener example using the source file here. The following will appear in the console.
    Constructed LogTaskHandler
    Starting logging executor
    Started logging executor
    
  • Run the FT1 example that starts a single FT context using the source file here. The following will be displayed in the console.
    Constructed LogTaskHandler
    Starting logging executor
    Started logging executor
    FT1 start
    

    After 30 seconds the following should be appear in the console for the FT1 program

    FT1 willActivate
    FT1 didActivate
    

    This means this FT context is the active context in its cluster. At the same time, the following should appear in the FTListener console

    received Record(helloWorld:Type(10,Record):Domain(1,null))=[nativeContext=FTPublisher, state=STALE]
    received Record(helloWorld:Type(10,Record):Domain(1,null))=[nativeContext=FTPublisher, state=LIVE, active context is=FT1!]
    
  • Run the FT2 example using the source file here. After 30 seconds the console should display the following
    Constructed LogTaskHandler
    Starting logging executor
    Started logging executor
    FT2 start
    FT2 willStandby
    FT2 didStandby
    

    There are now two FT Fulmine contexts running. Both are hosting a Fulmine context called 'FTPublisher'; the code for each FT instance has the following:

        final IFrameworkContext appContext = new FulmineContext("FTPublisher");
    

    This is the application context that is being made fault tolerant. Even though both FT contexts are running the same application context, only one of these application contexts is actually active; the one hosted by the FT1 context.

  • Stop the FT1 program. FT2 should now detect this and become active. The following should appear in the FT2 console output
    FT2 willActivate
    FT2 didActivate
    

    The application context hosted in FT2 will now be active. The FTListener console output should also contain the following new lines

    received Record(helloWorld:Type(10,Record):Domain(1,null))=[nativeContext=FTPublisher, state=STALE]
    received Record(helloWorld:Type(10,Record):Domain(1,null))=[nativeContext=FTPublisher, state=STALE]
    received Record(helloWorld:Type(10,Record):Domain(1,null))=[nativeContext=FTPublisher, state=LIVE, active context is=FT2!]
    

    The FTListener program has simply seen a change in state of the 'helloWorld' record and a change in a field.