public class GPUdbFileHandler extends Object
upload(String, String, UploadOptions, FileUploadListener)
,
upload(List, String, UploadOptions, FileUploadListener)
)
and similarly for download.
The entire filesystem
API is exposed through this class and an
instance of this class is enough to consume all functionalities provided by
the KIFS.
Apart from this class the other classes which could be used by the users of
this API are:
UploadOptions
DownloadOptions
FileUploadListener
FileDownloadListener
Modifier and Type | Class and Description |
---|---|
static class |
GPUdbFileHandler.Options
This class models the options available for modifying some behaviors
of the
GPUdbFileHandler class. |
Modifier and Type | Field and Description |
---|---|
static String |
KIFS_PATH_PREFIX
Prefix to use when referencing KiFS files; e.g., for purposes for file
ingest.
|
static String |
KIFS_PATH_SEPARATOR
Separator character between a KiFS directory and KiFS file name.
|
static String |
REMOTE_USER_HOME_DIR_PREFIX
Alias for a user's home directory.
|
Constructor and Description |
---|
GPUdbFileHandler(GPUdb db)
Constructs a
GPUdbFileHandler object that allows the user to
upload and download files using default GPUdbFileHandler.Options . |
GPUdbFileHandler(GPUdb db,
GPUdbFileHandler.Options options)
Constructs a
GPUdbFileHandler object that allows the user to
upload and download files. |
Modifier and Type | Method and Description |
---|---|
void |
createDirectory(String remoteDirName)
This method will create a KIFS directory with default options.
|
void |
createDirectory(String remoteDirName,
boolean noErrorIfExists)
This method will create a KIFS directory with options as explained
below.
|
void |
deleteDirectory(String remoteDirName)
This method deletes a KIFS directory.
|
void |
deleteDirectory(String remoteDirName,
boolean recursive,
boolean noErrorIfNotExists)
This method deletes a KIFS directory.
|
void |
deleteFiles(List<String> fileNames)
This method takes a list of fully qualified KIFS file paths and deletes
the files in one go.
|
void |
deleteFiles(List<String> fileNames,
boolean noErrorIfNotExists)
This method takes a list of fully qualified KIFS file paths and deletes
the files in one go.
|
void |
deleteFilesInDir(String remoteDirName)
This method deletes files in the KIFS directory whose name is passed in
using
remoteDirName . |
void |
deleteFilesInDir(String remoteDirName,
boolean noErrorIfNotExists)
This method deletes files in the KIFS directory whose name is passes in
using
remoteDirName . |
void |
download(List<String> fileNames,
String localDirName)
This method downloads files from a KIFS
directory to a local directory.
|
void |
download(List<String> fileNames,
String localDirName,
DownloadOptions downloadOptions,
FileDownloadListener callback)
This method downloads files from a KIFS
directory to a local directory.
|
void |
download(String fileName,
String localDirName)
This method downloads a single file from a KIFS
directory to a local directory.
|
void |
download(String fileName,
String localDirName,
DownloadOptions downloadOptions,
FileDownloadListener callback)
This method downloads a single file from a KIFS
directory to a local directory.
|
void |
downloadDir(String remoteDirName,
String localDirName,
DownloadOptions downloadOptions,
FileDownloadListener callback)
This method will download all files in a KIFS directory to a directory on
the local file system.
|
static int |
getDefaultFullFileDispatcherThreadpoolSize() |
static int |
getDefaultThreadPoolTerminationTimeout() |
GPUdbFileHandler.Options |
getOptions()
Returns the
GPUdbFileHandler.Options instance |
void |
ingest(List<String> fileNames,
String tableName,
IngestOptions ingestOptions,
TableCreationOptions createTableOptions)
This method will ingest several files in one go.
|
boolean |
kifsDirectoriesExist(Set<String> dirNames)
This method checks whether the given KIFS directories exist or not.
|
boolean |
kifsDirectoryExists(String dirName)
This method checks whether the given KIFS directory exists or not.
|
boolean |
kifsFileExists(String fileName)
This method checks whether the given KIFS file exists or not.
|
List<KifsDirectoryInfo> |
showAllDirectories()
This method retrieves the directory information all KIFS
directories and returns the information as a list of
KifsDirectoryInfo
objects. |
List<KifsDirectoryInfo> |
showAllDirectories(Map<String,String> showDirectoryOptions)
This method retrieves the directory information all KIFS
directories and returns the information as a list of
KifsDirectoryInfo
objects. |
List<KifsDirectoryInfo> |
showDirectories(List<String> remoteDirNames)
This method retrieves the directory information for a given list of KIFS
directories and returns the information as a list of
KifsDirectoryInfo
objects. |
List<KifsDirectoryInfo> |
showDirectories(List<String> remoteDirNames,
Map<String,String> showDirectoryOptions)
This method retrieves the directory information for a given list of KIFS
directories and returns the information as a list of
KifsDirectoryInfo
objects. |
List<KifsDirectoryInfo> |
showDirectories(Set<String> remoteDirNames)
Deprecated.
|
List<KifsDirectoryInfo> |
showDirectories(Set<String> remoteDirNames,
Map<String,String> showDirectoryOptions)
Deprecated.
|
List<KifsDirectoryInfo> |
showDirectory(String remoteDirName)
This method retrieves the directory information for a given KIFS
directory and returns the information as a list of
KifsDirectoryInfo
objects. |
List<KifsDirectoryInfo> |
showDirectory(String remoteDirName,
Map<String,String> showDirectoryOptions)
This method retrieves the directory information for a given KIFS
directory and returns the information as a list of
KifsDirectoryInfo
objects. |
List<KifsFileInfo> |
showFiles(List<String> remotePaths)
This method returns statistics about the given files and/or directories.
|
void |
upload(List<String> fileNames,
String remoteDirName)
This method facilitates uploading of multiple files from the same
local directory to a given remote directory.
|
void |
upload(List<String> fileNames,
String remoteDirName,
UploadOptions uploadOptions,
FileUploadListener callback)
This method facilitates uploading of multiple files from the same
local directory to a given remote directory.
|
void |
upload(String fileName,
String remoteDirName)
This method facilitates the upload of a single file from a given
local directory to a given remote directory.
|
void |
upload(String fileName,
String remoteDirName,
UploadOptions uploadOptions,
FileUploadListener callback)
This method facilitates the upload of a single file from a given
local directory to a given remote directory.
|
public static final String KIFS_PATH_SEPARATOR
public static final String KIFS_PATH_PREFIX
public static final String REMOTE_USER_HOME_DIR_PREFIX
public GPUdbFileHandler(GPUdb db, GPUdbFileHandler.Options options)
GPUdbFileHandler
object that allows the user to
upload and download files.db
- The GPUdb
instance used to access KiFS.options
- Options for setting up the files for transfer.public GPUdbFileHandler(GPUdb db)
GPUdbFileHandler
object that allows the user to
upload and download files using default GPUdbFileHandler.Options
.db
- The GPUdb
instance used to access KiFS.public static int getDefaultThreadPoolTerminationTimeout()
public static int getDefaultFullFileDispatcherThreadpoolSize()
public GPUdbFileHandler.Options getOptions()
GPUdbFileHandler.Options
instancepublic void upload(String fileName, String remoteDirName) throws GPUdbException
fileName
- Name of the file along with the full path
e.g., "/home/user1/dir1/dir2/a.txt".remoteDirName
- Name of KiFS directory to upload to.GPUdbException
- If an error occurs uploading any of the files to
the server.FileUploadListener
,
UploadOptions
,
UploadOptions.defaultOptions()
,
upload(String, String, UploadOptions, FileUploadListener)
public void upload(String fileName, String remoteDirName, UploadOptions uploadOptions, FileUploadListener callback) throws GPUdbException
fileName
- Name of the file along with the full path
e.g., "/home/user1/dir1/dir2/a.txt".remoteDirName
- Name of KiFS directory to upload to.uploadOptions
- Various options to be used for
uploading a file. If the value passed is null then
default values would be used. The default values for
the options can also be set explicitly using the method
UploadOptions.defaultOptions()
.callback
- An instance of FileUploadListener
class which
is used to report status of an ongoing/completed upload
to the caller of the method.GPUdbException
- If an error occurs uploading any of the files to
the server.FileUploadListener
,
UploadOptions
public void upload(List<String> fileNames, String remoteDirName) throws GPUdbException
fileNames
- Names of the files along with the full path
e.g., "/home/user1/dir1/dir2/a.txt".remoteDirName
- Name of KiFS directory to upload to.GPUdbException
- If an error occurs uploading any of the files to
the server.FileUploadListener
,
UploadOptions
,
UploadOptions.defaultOptions()
,
upload(List, String, UploadOptions, FileUploadListener)
public void upload(List<String> fileNames, String remoteDirName, UploadOptions uploadOptions, FileUploadListener callback) throws GPUdbException
fileNames
- Names of the files along with the full path
e.g., "/home/user1/dir1/dir2/a.txt".remoteDirName
- Name of KiFS directory to upload to.uploadOptions
- Various uploadOptions to be used for
uploading a file. If the value passed is null then
default values would be used. The default values for
the uploadOptions can also be set explicitly using the method
UploadOptions.defaultOptions()
.callback
- An instance of FileUploadListener
class which
is used to report status of an ongoing/completed upload
to the caller of the method.GPUdbException
- If an error occurs uploading any of the files to
the server.FileUploadListener
,
UploadOptions
public void download(List<String> fileNames, String localDirName) throws GPUdbException
fileNames
- Names of the KiFS files to download
e.g., 'a/b/c/d.txt'.localDirName
- Name of local directory to download to. This
directory must exist on the local file system.GPUdbException
DownloadOptions
,
DownloadOptions.defaultOptions()
,
FileDownloadListener
public void download(List<String> fileNames, String localDirName, DownloadOptions downloadOptions, FileDownloadListener callback) throws GPUdbException
fileNames
- Names of the KiFS files to download
e.g., 'a/b/c/d.txt'.localDirName
- Name of local directory to download to. This
directory must exist on the local file system.downloadOptions
- Options to be used for
downloading files from KIFS to the local directory.
if the value passed is null then default values
would be used. The default values for the options
can also be set explicitly using the method
DownloadOptions.defaultOptions()
.callback
- An instance of FileDownloadListener
class which
is used to report status of an ongoing/completed download
to the caller of the method.GPUdbException
public void download(String fileName, String localDirName) throws GPUdbException
fileName
- Name of the KiFS file to download
e.g., 'a/b/c/d.txt'.localDirName
- Name of local directory to download to. This
directory must exist on the local file system.GPUdbException
public void download(String fileName, String localDirName, DownloadOptions downloadOptions, FileDownloadListener callback) throws GPUdbException
fileName
- Name of the KiFS file to download
e.g., 'a/b/c/d.txt'.localDirName
- Name of local directory to download to. This
directory must exist on the local file system.downloadOptions
- Options to be used for
downloading files from KIFS to the local directory.
if the value passed is null then default values
would be used. The default values for the options
can also be set explicitly using the method
DownloadOptions.defaultOptions()
.GPUdbException
public void downloadDir(String remoteDirName, String localDirName, DownloadOptions downloadOptions, FileDownloadListener callback) throws GPUdbException
remoteDirName
- - Name of the KIFS directory to download.localDirName
- - Name of the local directory.downloadOptions
- Options to be used for
downloading files from KIFS to the local directory.
if the value passed is null then default values
would be used. The default values for the options
can also be set explicitly using the method
DownloadOptions.defaultOptions()
.GPUdbException
- If:
1. the remoteDirName is not existing
2. the localDirName is not existing
3. something goes wrong with the downloadDownloadOptions
public void ingest(List<String> fileNames, String tableName, IngestOptions ingestOptions, TableCreationOptions createTableOptions) throws GPUdbException
upload(List, String, UploadOptions, FileUploadListener)
to
upload the files to the directory 'sys_temp' on the KIFS and use the
method GPUdb.insertRecordsFromFiles(String, List, Map, Map, Map)
to update the table data.fileNames
- Names of the local files to be ingested.tableName
- Name of the table to ingest into.ingestOptions
- Options for ingestion.createTableOptions
- Options for table creation.If
- the ingestion or the underlying upload fails.GPUdbException
IngestOptions
,
TableCreationOptions
public void deleteFiles(List<String> fileNames) throws GPUdbException
fileNames
- List of files in KIFS to delete.GPUdbException
public void deleteFiles(List<String> fileNames, boolean noErrorIfNotExists) throws GPUdbException
fileNames
- List of files in KIFS to delete.noErrorIfNotExists
- True indicates not to throw an error if the
files are not found on KIFS and false otherwise.GPUdbException
public void deleteFilesInDir(String remoteDirName) throws GPUdbException
remoteDirName
. This method uses default options.remoteDirName
- Name of the KIFS directory containing files to
delete.GPUdbException
- If an error occurs deleting the files.public void deleteFilesInDir(String remoteDirName, boolean noErrorIfNotExists) throws GPUdbException
remoteDirName
.remoteDirName
- Name of the KIFS directory containing files to
delete.noErrorIfNotExists
- Indicates whether to allow deletion of files
in non-existent KIFS directory or not.GPUdbException
- If an error occurs deleting the files.public List<KifsFileInfo> showFiles(List<String> remotePaths) throws GPUdbException
remotePaths
- List of KIFS files and/or directory names to report
statistics on.KifsFileInfo
objects, containing statistics
about the given files.GPUdbException
- If an error occurs looking up the files.public List<KifsDirectoryInfo> showDirectories(Set<String> remoteDirNames) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirNames
- Set of KIFS directory names to report statistics
on.KifsDirectoryInfo
objects, containing statistics
about the given directories.GPUdbException
- If an error occurs looking up the directories.showDirectories(Set, Map)
public List<KifsDirectoryInfo> showDirectories(Set<String> remoteDirNames, Map<String,String> showDirectoryOptions) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirNames
- Set of KIFS directory names to report statistics
on.showDirectoryOptions
- Unused.KifsDirectoryInfo
objects, containing statistics
about the given directories.GPUdbException
public List<KifsDirectoryInfo> showDirectories(List<String> remoteDirNames) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirNames
- List of KIFS directory names to report statistics
on.KifsDirectoryInfo
objects, containing statistics
about the given directories.GPUdbException
- If an error occurs looking up the directories.showDirectories(Set, Map)
public List<KifsDirectoryInfo> showDirectories(List<String> remoteDirNames, Map<String,String> showDirectoryOptions) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirNames
- List of KIFS directory names to report statistics
on.showDirectoryOptions
- Reserved for future use.KifsDirectoryInfo
objects, containing statistics
about the given directories.GPUdbException
public List<KifsDirectoryInfo> showDirectory(String remoteDirName) throws GPUdbException
KifsDirectoryInfo
objects. This method uses default options.remoteDirName
- Name of the KIFS directory to report statistics on;
cannot be null or empty.KifsDirectoryInfo
objects, containing statistics
about the given directory.GPUdbException
showDirectory(String, Map)
public List<KifsDirectoryInfo> showDirectory(String remoteDirName, Map<String,String> showDirectoryOptions) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirName
- Name of the KIFS directory to report statistics on;
cannot be null or empty.showDirectoryOptions
- Reserved for future use.KifsDirectoryInfo
objects, containing statistics
about the given directory.GPUdbException
public List<KifsDirectoryInfo> showAllDirectories() throws GPUdbException
KifsDirectoryInfo
objects.KifsDirectoryInfo
objects, containing statistics
about the given directory.GPUdbException
- If an error occurs looking up the directories.showAllDirectories(Map)
public List<KifsDirectoryInfo> showAllDirectories(Map<String,String> showDirectoryOptions) throws GPUdbException
KifsDirectoryInfo
objects.showDirectoryOptions
- Reserved for future use.KifsDirectoryInfo
objects, containing statistics
about the given directory.GPUdbException
- If an error occurs looking up the directories.public void createDirectory(String remoteDirName) throws GPUdbException
remoteDirName
- Name of the KIFS directory to create.GPUdbException
- If the directory creation fails.public void createDirectory(String remoteDirName, boolean noErrorIfExists) throws GPUdbException
remoteDirName
- Name of the KIFS directory to create.noErrorIfExists
- True means that if the directory exists, there
will be no error thrown; false means an error will be thrown.GPUdbException
- If the directory creation fails.public void deleteDirectory(String remoteDirName) throws GPUdbException
remoteDirName
- Name of the KIFS directory to delete.GPUdbException
- If the directory deletion fails.deleteDirectory(String, boolean, boolean)
public void deleteDirectory(String remoteDirName, boolean recursive, boolean noErrorIfNotExists) throws GPUdbException
remoteDirName
- Name of the KIFS directory to delete.recursive
- Indicates all files and virtual subdirectories under
remoteDirName
will also be deleted; if false, an error
will be returned if the directory is not empty.noErrorIfNotExists
- True means no error will be returned if the
given directory does not exist.GPUdbException
public boolean kifsDirectoriesExist(Set<String> dirNames)
dirNames
- The set of full KIFS directory paths to check for.public boolean kifsDirectoryExists(String dirName)
dirName
- The full KIFS directory path to check for.public boolean kifsFileExists(String fileName)
fileName
- The full KIFS file path to check for.Copyright © 2025. All rights reserved.