Class FileFetcher


  • public class FileFetcher
    extends Object

    Retrieves data files from a Pioneer player over NFS to enable use of track metadata even when four players are using the same media.

    The primary purpose of this class is provided through the fetch(InetAddress, String, String, File) method.

    This is a singleton, so the single instance is obtained through the getInstance() method.

    • Field Detail

      • CHARSET

        public static final Charset CHARSET
        The character set with which paths are sent to the NFS servers running on players.
      • DEFAULT_READ_SIZE

        public static final int DEFAULT_READ_SIZE
        The default number of bytes to read from the player in each request for file data. This is a trade-off between reducing the number of requests and reducing IP fragmentation and expensive retransmissions of already-sent fragments whenever one is lost.
        See Also:
        Constant Field Values
      • DEFAULT_RPC_RETRANSMIT_TIMEOUT

        public static final int DEFAULT_RPC_RETRANSMIT_TIMEOUT
        How long to wait for a response to our UDP RPC calls before retransmitting. The players respond within a few milliseconds if they are going to at all.
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static FileFetcher getInstance()
        Look up the singleton instance of this class.
        Returns:
        the only instance that exists
      • getReadSize

        public int getReadSize()
        Check the number of bytes to read from the player in each request for file data. This is a trade-off between reducing the number of requests and reducing IP fragmentation and expensive retransmissions of already-sent fragments whenever one is lost.
        Returns:
        the current read size
      • setReadSize

        public void setReadSize​(int readSize)
        Set the number of bytes to read from the player in each request for file data. This is a trade-off between reducing the number of requests and reducing IP fragmentation and expensive retransmissions of already-sent fragments whenever one is lost. Changes do not affect operations already in progress.
        Parameters:
        readSize - the new read size, must be between 1024 and the largest value supported by NFS, inclusive
        Throws:
        IllegalArgumentException - if readSize is less than 1024 or greater than nfs.MAXDATA
      • getRetransmitTimeout

        public int getRetransmitTimeout()
        Check how long to wait for a response to our UDP RPC calls before retransmitting. The players respond within a few milliseconds if they are going to at all.
        Returns:
        the current retransmit timeout
      • setRetransmitTimeout

        public void setRetransmitTimeout​(int retransmitTimeout)
        Set how long to wait for a response to our UDP RPC calls before retransmitting. The players respond within a few milliseconds if they are going to at all. Changes do not affect operations already in progress.
        Parameters:
        retransmitTimeout - the new retransmit timeout, must be between 1 an 30000, inclusive
      • removePlayer

        public void removePlayer​(InetAddress player)
        Clear any cached mount points for the player with the specified address. This should be called when the player drops off the network, in case a different player later appears on the same address, or if one of the media slots in the player unmounts, because that file handle will no longer be valid. Also clears our cached NFS client for the player.
        Parameters:
        player - the player that has disappeared or unmounted a filesystem
      • fetch

        public void fetch​(InetAddress player,
                          String mountPath,
                          String sourcePath,
                          File destination)
                   throws IOException
        Download a file from a player, storing it locally.
        Parameters:
        player - the address of the player from which we are to retrieve a file
        mountPath - the mount path of the filesystem from which the file is to be retrieved
        sourcePath - the path to the file itself within the exported filesystem
        destination - the local file to which the remote contents should be saved
        Throws:
        IOException - if there is a problem retrieving the file