navigators.smart.tom
Class ServiceProxy

java.lang.Object
  extended by navigators.smart.tom.TOMSender
      extended by navigators.smart.tom.ServiceProxy
All Implemented Interfaces:
ReplyReceiver

public class ServiceProxy
extends TOMSender

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


Field Summary
private  int f
           
private  java.util.concurrent.Semaphore mutex
           
private  int n
           
private  TOMMessage[] replies
           
private  int reqId
           
private  byte[] response
           
private  java.util.concurrent.Semaphore sm
           
 
Constructor Summary
ServiceProxy(int id)
          Constructor
ServiceProxy(int id, java.lang.String configHome)
          Constructor
 
Method Summary
private  void init(TOMConfiguration conf)
           
 byte[] invoke(byte[] request)
          This method sends a request to the replicas, and returns the related reply.
 byte[] invoke(byte[] request, boolean readOnly)
          This method sends a request to the replicas, and returns the related reply.
 void replyReceived(TOMMessage reply)
          This is the method invoked by the client side comunication system.
 
Methods inherited from class navigators.smart.tom.TOMSender
getLastSequenceNumber, init, init, sign, TOMulticast, TOMulticast, TOMulticast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

n

private int n

f

private int f

mutex

private java.util.concurrent.Semaphore mutex

sm

private java.util.concurrent.Semaphore sm

reqId

private int reqId

replies

private TOMMessage[] replies

response

private byte[] response
Constructor Detail

ServiceProxy

public ServiceProxy(int id)
Constructor

Parameters:
id - Process id for this client

ServiceProxy

public ServiceProxy(int id,
                    java.lang.String configHome)
Constructor

Parameters:
id - Process id for this client
configHome - Configuration directory for JBP TODO: E mesmo a directoria do JBP, ou de alguma biblioteca de terceiros?
Method Detail

init

private void init(TOMConfiguration conf)

invoke

public byte[] invoke(byte[] request)
This method sends a request to the replicas, and returns the related reply. This method is thread-safe.

Parameters:
request - Request to be sent
Returns:
The reply from the replicas related to request

invoke

public byte[] invoke(byte[] request,
                     boolean readOnly)
This method sends a request to the replicas, and returns the related reply. This method is thread-safe.

Parameters:
request - Request to be sent
readOnly - it is a read only request (will not be ordered)
Returns:
The reply from the replicas related to request

replyReceived

public void replyReceived(TOMMessage reply)
This is the method invoked by the client side comunication system.

Parameters:
reply - The reply delivered by the client side comunication system