Click here to Skip to main content
Click here to Skip to main content

Tagged as

Managing server failover in WCF

, 4 Mar 2013
Rate this:
Please Sign up or sign in to vote.
In this article I will talk about server failover and how to manage it.

Sample Image

Introduction

In this article I will talk about server failover and how to manage it.

Solution Summary

Here is the message sequence diagram for a vanilla case.

Sample Image - maximum width is 600 pixels

Here is the problematic scenario that we are going to solve:

  • Concurrency problem. In our case it could happen that some services send messages at the same time. This problem will be solved with the Vector Clock algorithm.
  • Critical section - System activation should be performed in the critical section.

Pseudo code

procedure OnMessageArrived(msg)
    isGreater = msg.VectorClockTimeStamp > currentVectorClockTimeStamp
    isLess = msg.VectorClockTimeStamp < currentVectorClockTimeStamp

    if ( isGreater ) then
        currentClockTimeStamp = msg.VectorClockTimeStamp
    else if ( isLess == false )
         concurrency error 
    end if    
    ...
    call appropriate message handler
    
    
    
procedure Activate(msg)
    if ( AcquireLockFromAllServicesApproved() ) then
        isActivated = true
        SendHeartBeat()
        ReleaseLock()
    End if

procedure Deactivate(msg)
    isActivated = false
    SendHeartBeat()

//message handlers     

procedure HandleHeartBeatFromOther(msg)
    //do something

procedure HandleOtherSystemAcquiredLock(msg)
    if (CurrentSystemInLock)
        return LockNotAprooved;
    Else
        return LockAprooved;
    End if
procedure HandleOtherSystemReleasedLock(msg)
    //do something

Demo

  • Download demo and runner.bat.
  • Three applications will be created, just press Start.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Dima Zevelev
Software Developer (Senior) Better Place
Israel Israel
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 4 Mar 2013
Article Copyright 2013 by Dima Zevelev
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid