// -*- IDL -*-

//=============================================================================
/**
 *  @file    FTRT.idl
 *
 *  @author Huang-Ming Huang
 */
//=============================================================================

#ifndef FTRT_H
#define FTRT_H

#include "tao/IOP.pidl"

module FTRT
{

  typedef long TransactionDepth;
  typedef unsigned long SequenceNumber;

  const IOP::ServiceId FT_TRANSACTION_DEPTH = 30;
  const IOP::ServiceId FT_SEQUENCE_NUMBER = 31;
  const IOP::ServiceId FT_FORWARD = 32;

  /// this service context is used by FTRT client
  /// to information the server the depth of replication
  /// which has to be complete before the request returns.
  struct FTTransactionDepthServiceContext {
    TransactionDepth transaction_depth;
  };

  /// this service context is used by replicas for detecting
  /// the loss of replication messages in soft-replication.
  struct FTSequenceNumberServiceContext {
    SequenceNumber sequence_number;
  };

  /// In the FTCORBA standard, if the server receive a request
  /// from a client with an object_group_ref_version less than
  /// the one known to the server. The server should reply a
  /// LOCATION_FORARD_PERM exception. However, if the server is
  /// also the primary, the server have to wait until the client
  /// issue a new request with the new object_group_ref_version
  /// before it can return the result. This will cause unnecessary
  /// delay for processing the request. The service context is used
  /// by the primary to inform the client the lastest version of
  /// IOGR known to the primary in the reply. The client can thus
  /// upates the object reference in the next method invocation without
  /// extra round trip delay.
  struct FTForwardServiceContext {
    Object forward;
  };

  exception OutOfSequence
  {
    SequenceNumber current;
  };

  exception TransactionDepthTooHigh
  {
  };

  typedef sequence<octet> State;

  exception InvalidUpdate {};

  interface Updateable
  {
    /// used for assured replication
    void set_update(in State s)
      raises(InvalidUpdate, OutOfSequence, TransactionDepthTooHigh);

    /// used for soft replication
    oneway void oneway_set_update(in State s);
  };
};

#endif

