bftsmart.tom

## Class ServiceReplica

- java.lang.Object
- - bftsmart.tom.ServiceReplica

    public class ServiceReplica
    extends java.lang.Object

This class receives messages from DeliveryThread and manages the execution from the application and reply to the clients. For applications where the ordered messages are executed one by one, ServiceReplica receives the batch decided in a consensus, deliver one by one and reply with the batch of replies. In cases where the application executes the messages in batches, the batch of messages is delivered to the application and ServiceReplica doesn't need to organize the replies in batches.

### Constructor Summary

Constructors
Constructor and Description
`ServiceReplica(int id, boolean isToJoin, Executable executor, Recoverable recoverer)` Constructor
`ServiceReplica(int id, Executable executor, Recoverable recoverer)` Constructor
`ServiceReplica(int id, Executable executor, Recoverable recoverer, RequestVerifier verifier)` Constructor
`ServiceReplica(int id, java.lang.String configHome, boolean isToJoin, Executable executor, Recoverable recoverer, RequestVerifier verifier)`
`ServiceReplica(int id, java.lang.String configHome, Executable executor, Recoverable recoverer, RequestVerifier verifier)` Constructor

### Method Summary

All Methods Instance Methods Concrete Methods
`ReplicaContext` `getReplicaContext()` Obtains the current replica context (getting access to several information and capabilities of the replication engine).
`void` `joinMsgReceived(bftsmart.reconfiguration.VMMessage msg)`
`void` `leave()` This method makes the replica leave the group
`void` `receiveMessages(int[] consId, int[] regencies, int[] leaders, bftsmart.tom.leaderchange.CertifiedDecision[] cDecs, bftsmart.tom.core.messages.TOMMessage[][] requests)`
`void` `receiveReadonlyMessage(bftsmart.tom.core.messages.TOMMessage message, MessageContext msgCtx)` This message delivers a readonly message, i.e., a message that was not ordered to the replica and gather the reply to forward to the client
`void` `setReplyController(Replier replier)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ServiceReplica

    public ServiceReplica(int id,
                          Executable executor,
                          Recoverable recoverer)

Constructor

Parameters:
  `id` - Replica ID
  `executor` - Executor
  `recoverer` - Recoverer

#### ServiceReplica

    public ServiceReplica(int id,
                          Executable executor,
                          Recoverable recoverer,
                          RequestVerifier verifier)

Constructor

Parameters:
  `id` - Replica ID
  `executor` - Executor
  `recoverer` - Recoverer
  `verifier` - Requests verifier

#### ServiceReplica

    public ServiceReplica(int id,
                          java.lang.String configHome,
                          Executable executor,
                          Recoverable recoverer,
                          RequestVerifier verifier)

Constructor

Parameters:
  `id` - Process ID
  `configHome` - Configuration directory for JBP
  `executor` - Executor
  `recoverer` - Recoverer
  `verifier` - Requests verifier

#### ServiceReplica

    public ServiceReplica(int id,
                          boolean isToJoin,
                          Executable executor,
                          Recoverable recoverer)

Constructor

Parameters:
  `id` - Replica ID
  `isToJoin:` - if true, the replica tries to join the system, otherwise it waits for TTP message informing its join
  `executor` - Executor
  `recoverer` - Recoverer

#### ServiceReplica

    public ServiceReplica(int id,
                          java.lang.String configHome,
                          boolean isToJoin,
                          Executable executor,
                          Recoverable recoverer,
                          RequestVerifier verifier)

### Method Detail

#### setReplyController

    public void setReplyController(Replier replier)

#### joinMsgReceived

    public void joinMsgReceived(bftsmart.reconfiguration.VMMessage msg)

#### receiveReadonlyMessage

    public final void receiveReadonlyMessage(bftsmart.tom.core.messages.TOMMessage message,
                                             MessageContext msgCtx)

This message delivers a readonly message, i.e., a message that was not ordered to the replica and gather the reply to forward to the client

Parameters:
  `message` - the request received from the delivery thread

#### receiveMessages

    public void receiveMessages(int[] consId,
                                int[] regencies,
                                int[] leaders,
                                bftsmart.tom.leaderchange.CertifiedDecision[] cDecs,
                                bftsmart.tom.core.messages.TOMMessage[][] requests)

#### leave

    public void leave()

This method makes the replica leave the group

#### getReplicaContext

    public final ReplicaContext getReplicaContext()

Obtains the current replica context (getting access to several information and capabilities of the replication engine).

Returns:
  this replica context