Package org.deepsymmetry.cratedigger
Class FileFetcher
- java.lang.Object
-
- org.deepsymmetry.cratedigger.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 Summary
Fields Modifier and Type Field Description static Charset
CHARSET
The character set with which paths are sent to the NFS servers running on players.static int
DEFAULT_READ_SIZE
The default number of bytes to read from the player in each request for file data.static int
DEFAULT_RPC_RETRANSMIT_TIMEOUT
How long to wait for a response to our UDP RPC calls before retransmitting.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fetch(InetAddress player, String mountPath, String sourcePath, File destination)
Download a file from a player, storing it locally.static FileFetcher
getInstance()
Look up the singleton instance of this class.int
getReadSize()
Check the number of bytes to read from the player in each request for file data.int
getRetransmitTimeout()
Check how long to wait for a response to our UDP RPC calls before retransmitting.void
removePlayer(InetAddress player)
Clear any cached mount points for the player with the specified address.void
setReadSize(int readSize)
Set the number of bytes to read from the player in each request for file data.void
setRetransmitTimeout(int retransmitTimeout)
Set how long to wait for a response to our UDP RPC calls before retransmitting.
-
-
-
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
- ifreadSize
is less than 1024 or greater thannfs.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 filemountPath
- the mount path of the filesystem from which the file is to be retrievedsourcePath
- the path to the file itself within the exported filesystemdestination
- the local file to which the remote contents should be saved- Throws:
IOException
- if there is a problem retrieving the file
-
-