bftsmart.tom

## Class ServiceProxy

- java.lang.Object
- - bftsmart.tom.TOMSender
  - - bftsmart.tom.ServiceProxy

All Implemented Interfaces:
  bftsmart.communication.client.ReplyReceiver

Direct Known Subclasses:
  AsynchServiceProxy

    public class ServiceProxy
    extends TOMSender

This class implements a TOMSender and represents a proxy to be used on the client side of the replicated system. It sends a request to the replicas, receives the reply, and delivers it to the application.

### Field Summary

Fields
`protected java.util.concurrent.locks.ReentrantLock` `canReceiveLock`
`protected java.util.concurrent.locks.ReentrantLock` `canSendLock`

### Constructor Summary

Constructors
Constructor and Description
`ServiceProxy(int processId)` Constructor
`ServiceProxy(int processId, java.lang.String configHome)` Constructor
`ServiceProxy(int processId, java.lang.String configHome, java.util.Comparator<byte[]> replyComparator, Extractor replyExtractor)` Constructor

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `getInvokeTimeout()` Get the amount of time (in seconds) that this proxy will wait for servers replies before returning null.
`int` `getInvokeUnorderedHashedTimeout()`
`byte[]` `invoke(byte[] request, bftsmart.tom.core.messages.TOMMessageType reqType)` This method sends a request to the replicas, and returns the related reply.
`byte[]` `invokeOrdered(byte[] request)`
`byte[]` `invokeUnordered(byte[] request)`
`byte[]` `invokeUnorderedHashed(byte[] request)`
`void` `replyReceived(bftsmart.tom.core.messages.TOMMessage reply)` This is the method invoked by the client side communication system.
`void` `setInvokeTimeout(int invokeTimeout)` Set the amount of time (in seconds) that this proxy will wait for servers replies before returning null.
`void` `setInvokeUnorderedHashedTimeout(int timeout)`

### Methods inherited from class bftsmart.tom.TOMSender

`close, generateOperationId, generateRequestId, getCommunicationSystem, getProcessId, getSession, getViewManager, init, init, sendMessageToTargets, sendMessageToTargets, TOMulticast, TOMulticast, TOMulticast`

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

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

### Field Detail

#### canReceiveLock

    protected java.util.concurrent.locks.ReentrantLock canReceiveLock

#### canSendLock

    protected java.util.concurrent.locks.ReentrantLock canSendLock

### Constructor Detail

#### ServiceProxy

    public ServiceProxy(int processId)

Constructor

See Also:
  `bellow`

#### ServiceProxy

    public ServiceProxy(int processId,
                        java.lang.String configHome)

Constructor

See Also:
  `bellow`

#### ServiceProxy

    public ServiceProxy(int processId,
                        java.lang.String configHome,
                        java.util.Comparator<byte[]> replyComparator,
                        Extractor replyExtractor)

Constructor

Parameters:
  `processId` - Process id for this client (should be different from replicas)
  `configHome` - Configuration directory for BFT-SMART
  `replyComparator` - used for comparing replies from different servers to extract one returned by f+1
  `replyExtractor` - used for extracting the response from the matching quorum of replies

### Method Detail

#### getInvokeTimeout

    public int getInvokeTimeout()

Get the amount of time (in seconds) that this proxy will wait for servers replies before returning null.

Returns:
  the invokeTimeout

#### getInvokeUnorderedHashedTimeout

    public int getInvokeUnorderedHashedTimeout()

#### setInvokeTimeout

    public void setInvokeTimeout(int invokeTimeout)

Set the amount of time (in seconds) that this proxy will wait for servers replies before returning null.

Parameters:
  `invokeTimeout` - the invokeTimeout to set

#### setInvokeUnorderedHashedTimeout

    public void setInvokeUnorderedHashedTimeout(int timeout)

#### invokeOrdered

    public byte[] invokeOrdered(byte[] request)

#### invokeUnordered

    public byte[] invokeUnordered(byte[] request)

#### invokeUnorderedHashed

    public byte[] invokeUnorderedHashed(byte[] request)

#### invoke

    public byte[] invoke(byte[] request,
                         bftsmart.tom.core.messages.TOMMessageType reqType)

This method sends a request to the replicas, and returns the related reply. If the servers take more than invokeTimeout seconds the method returns null. This method is thread-safe.

Parameters:
  `request` - Request to be sent
  `reqType` - TOM_NORMAL_REQUESTS for service requests, and other for reconfig requests.
Returns:
  The reply from the replicas related to request

#### replyReceived

    public void replyReceived(bftsmart.tom.core.messages.TOMMessage reply)

This is the method invoked by the client side communication system.

Parameters:
  `reply` - The reply delivered by the client side communication system