SRV_MIGRATE_STATE

SRV_MIGRATE_STATE is an event that is triggered whenever the migration state has transitioned to SRV_MIG_READY or SRV_MIG_FAILED, the transition being a result of a migration message from a client. The SRV_MIGRATE_STATE event handler is invoked in these situations:

SRV_T_MIGRATE_ STATE

Situation

Possible application action

SRV_MIG_READY

The client has sent a message to the server indicating that it has detected the request and is ready to migrate. The server determines whether to continue the migration or not.

One of the following:

  • Make the context available for the other servers.

  • Cancel the migration if the application decides that migration is no longer needed.

  • Request another migration if a new migration target has been selected.

SRV_MIG_FAILED

The client has sent a message to the server indicating that the migration failed.

One of the following:

  • Access the client context and continue serving the connection.

  • Request another migration.

This is an example of a SRV_MIGRATE_STATE event handler:

/*
** Simple migrate-state event handler
*/
CS_RETCODE CS_PUBLIC
migrate_state_handler(SRV_PROC *sp)
{
   SRV_MIG_STATE migration_state;
   ret = srv_thread_props(sp, CS_GET,
      SRV_T_MIGRATE_STATE, &migration_state, 
      sizeof (migration_state), NULL);

   ...

   switch(migration_state)
   {
      case SRV_MIG_READY:
           ...
      case SRV_MIG_FAILED:
           ...
   }
}

...

/*
** Install the migrate-state change event handler
*/
srv_handle(server, SRV_MIGRATE_STATE, migrate_state_handler);
...

When working with the SRV_MIGRATE_STATE event handler: