Package bftsmart.tom
Class ServiceProxy
- java.lang.Object
-
- bftsmart.tom.core.TOMSender
-
- bftsmart.tom.ServiceProxy
-
- All Implemented Interfaces:
ReplyReceiver
,java.io.Closeable
,java.lang.AutoCloseable
- 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 Modifier and Type Field Description protected java.util.concurrent.locks.ReentrantLock
canReceiveLock
protected java.util.concurrent.locks.ReentrantLock
canSendLock
-
Constructor Summary
Constructors Constructor Description ServiceProxy(int processId)
ConstructorServiceProxy(int processId, java.lang.String configHome)
ConstructorServiceProxy(int processId, java.lang.String configHome, KeyLoader loader)
ConstructorServiceProxy(int processId, java.lang.String configHome, java.util.Comparator<byte[]> replyComparator, Extractor replyExtractor, KeyLoader loader)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getInvokeTimeout()
Get the amount of time (in seconds) that this proxy will wait for servers replies before returning null.int
getInvokeUnorderedHashedTimeout()
Get the amount of time (in seconds) that this proxy will wait for servers unordered hashed replies before returning null.byte[]
invoke(byte[] request, TOMMessageType reqType)
This method sends a request to the replicas, and returns the related reply.byte[]
invokeOrdered(byte[] request)
This method sends an ordered request to the replicas, and returns the related reply.byte[]
invokeOrderedHashed(byte[] request)
byte[]
invokeUnordered(byte[] request)
This method sends an unordered request to the replicas, and returns the related reply.byte[]
invokeUnorderedHashed(byte[] request)
This method sends an unordered request to the replicas, and returns the related reply.protected void
reconfigureTo(View v)
void
replyReceived(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)
Set the amount of time (in seconds) that this proxy will wait for servers unordered hashed replies before returning null.-
Methods inherited from class bftsmart.tom.core.TOMSender
close, generateOperationId, generateRequestId, getCommunicationSystem, getProcessId, getReplyQuorum, getSession, getViewManager, sendMessageToTargets, TOMulticast, TOMulticast
-
-
-
-
Constructor Detail
-
ServiceProxy
public ServiceProxy(int processId)
Constructor
-
ServiceProxy
public ServiceProxy(int processId, java.lang.String configHome)
Constructor
-
ServiceProxy
public ServiceProxy(int processId, java.lang.String configHome, KeyLoader loader)
Constructor
-
ServiceProxy
public ServiceProxy(int processId, java.lang.String configHome, java.util.Comparator<byte[]> replyComparator, Extractor replyExtractor, KeyLoader loader)
Constructor- Parameters:
processId
- Process id for this client (should be different from replicas)configHome
- Configuration directory for BFT-SMARTreplyComparator
- Used for comparing replies from different servers to extract one returned by f+1replyExtractor
- Used for extracting the response from the matching quorum of repliesloader
- Used to load signature keys from disk
-
-
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 timeout value in seconds
-
getInvokeUnorderedHashedTimeout
public int getInvokeUnorderedHashedTimeout()
Get the amount of time (in seconds) that this proxy will wait for servers unordered hashed replies before returning null.- Returns:
- the timeout value in seconds
-
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 timeout value to set
-
setInvokeUnorderedHashedTimeout
public void setInvokeUnorderedHashedTimeout(int timeout)
Set the amount of time (in seconds) that this proxy will wait for servers unordered hashed replies before returning null.- Parameters:
timeout
- the timeout value to set
-
invokeOrdered
public byte[] invokeOrdered(byte[] request)
This method sends an ordered 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
- to be sent- Returns:
- The reply from the replicas related to request
-
invokeOrderedHashed
public byte[] invokeOrderedHashed(byte[] request)
-
invokeUnordered
public byte[] invokeUnordered(byte[] request)
This method sends an unordered 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
- to be sent- Returns:
- The reply from the replicas related to request
-
invokeUnorderedHashed
public byte[] invokeUnorderedHashed(byte[] request)
This method sends an unordered request to the replicas, and returns the related reply. This method chooses randomly one replica to send the complete response, while the others only send a hash of that response. If the servers take more than invokeTimeout seconds the method returns null. This method is thread-safe.- Parameters:
request
- to be sent- Returns:
- The reply from the replicas related to request
-
invoke
public byte[] invoke(byte[] request, 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 sentreqType
- ORDERED_REQUEST/ORDERED_HASHED_REQUEST/UNORDERED_REQUEST/UNORDERED_HASHED_REQUEST for normal requests, and RECONFIG for reconfiguration requests.- Returns:
- The reply from the replicas related to request
-
reconfigureTo
protected void reconfigureTo(View v)
-
replyReceived
public void replyReceived(TOMMessage reply)
This is the method invoked by the client side communication system.- Parameters:
reply
- The reply delivered by the client side communication system
-
-