Package bftsmart.tom

Class 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 Detail

      • canReceiveLock

        protected java.util.concurrent.locks.ReentrantLock canReceiveLock
      • canSendLock

        protected java.util.concurrent.locks.ReentrantLock canSendLock
    • Constructor Detail

      • 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-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
        loader - 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 sent
        reqType - 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