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 behaviours
of the
GPUdbFileHandler class
The two options available right now are:
1. threadPoolTerminationTimeout - in seconds
2. fullFileDispatcherThreadpoolSize - an integer |
Constructor and Description |
---|
GPUdbFileHandler(GPUdb db)
Constructor 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 filesystem.
|
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 KIFS paths exist or not.
|
boolean |
kifsDirectoryExists(String dirName)
This method checks whether a KIFS path exists or not.
|
boolean |
kifsFileExists(String fileName)
This method checks whether a 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> options)
This method retrieves the directory information all KIFS
directories and returns the information as a list of
KifsDirectoryInfo
objects. |
List<KifsDirectoryInfo> |
showDirectories(Set<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(Set<String> remoteDirNames,
Map<String,String> options)
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> |
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> options)
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> remoteDirNames)
This method shows the files
|
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 options,
FileUploadListener callback)
This method facilitates the upload of a single file from a given
local directory to a given remote directory.
|
public GPUdbFileHandler(GPUdb db, GPUdbFileHandler.Options options)
GPUdbFileHandler
object that allows the user to
upload and download files.db
- - GPUdb
instanceoptions
- - An instance of GPUdbFileHandler.Options
classpublic GPUdbFileHandler(GPUdb db)
GPUdbFileHandler.Options
db
- - the GPUdb
instancepublic 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 the remote directory to which the
file is to be saved.GPUdbException
- - from the method upload(List, String, UploadOptions, FileUploadListener)
FileUploadListener
,
UploadOptions
,
UploadOptions.defaultOptions()
,
upload(String, String, UploadOptions, FileUploadListener)
public void upload(String fileName, String remoteDirName, UploadOptions options, 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 the remote directory to which the
file is to be saved.options
- - 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
- - from the method upload(List, String, UploadOptions, FileUploadListener)
FileUploadListener
,
UploadOptions
public void upload(List<String> fileNames, String remoteDirName) throws GPUdbException
fileNames
- - ListremoteDirName
- - Name of the remote directory to which the
file is to be saved. This indicates a KIFS directoryGPUdbException
- - thrown from upload(List, String, UploadOptions, FileUploadListener)
FileUploadListener
,
UploadOptions
,
UploadOptions.defaultOptions()
,
upload(List, String, UploadOptions, FileUploadListener)
public void upload(List<String> fileNames, String remoteDirName, UploadOptions uploadOptions, FileUploadListener callback) throws GPUdbException
fileNames
- - ListremoteDirName
- - Name of the remote directory to which the
file is to be saved. This indicates a KIFS directoryuploadOptions
- - 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
- - Where parameters value checks failFileUploadListener
,
UploadOptions
public void download(List<String> fileNames, String localDirName) throws GPUdbException
fileNames
- - A list of fully qualified file names
residing on the KIFS directory e.g., 'a/b/c/d.txt'
where 'a/b/c' is a full path on the KIFS.localDirName
- - String - This is the name of a local directory where the
files will be saved. This directory must exist on the
local filesystem.GPUdbException
DownloadOptions
,
DownloadOptions.defaultOptions()
,
FileDownloadListener
public void download(List<String> fileNames, String localDirName, DownloadOptions downloadOptions, FileDownloadListener callback) throws GPUdbException
fileNames
- - A list of fully qualified file names
residing on the KIFS directory e.g., 'a/b/c/d.txt'
where 'a/b/c' is a full path on the KIFS.localDirName
- - String - This is the name of a local directory where the
files will be saved. This directory must exist on the
local filesystem.downloadOptions
- - 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
- - String - A fully qualified file name
residing on the KIFS directory e.g., 'a/b/c/d.txt'
where 'a/b/c' is a full path on the KIFS.localDirName
- - String - This is the name of a local directory where the
files will be saved. This directory must exist on the
local filesystem.GPUdbException
public void download(String fileName, String localDirName, DownloadOptions downloadOptions, FileDownloadListener callback) throws GPUdbException
fileName
- - String - A fully qualified file name
residing on the KIFS directory e.g., 'a/b/c/d.txt'
where 'a/b/c' is a full path on the KIFS.localDirName
- - String - This is the name of a local directory where the
files will be saved. This directory must exist on the
local filesystem.downloadOptions
- - 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 directorylocalDirName
- - Name of the local directorydownloadOptions
- - A DownloadOptions
objectGPUdbException
- - throws a 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 ingestedtableName
- - Name of the table to ingest intoingestOptions
- - Options for ingestioncreateTableOptions
- - Options for table creation-
- GPUdbException
- if the ingestion or the underlying upload failsGPUdbException
IngestOptions
,
TableCreationOptions
public void deleteFiles(List<String> fileNames) throws GPUdbException
fileNames
- - a list of files on the KIFSGPUdbException
public void deleteFiles(List<String> fileNames, boolean noErrorIfNotExists) throws GPUdbException
fileNames
- - a list of files on the KIFSnoErrorIfNotExists
- - true indicates not to throw an error if the
files are not found on KIFS and false otherwiseGPUdbException
public void deleteFilesInDir(String remoteDirName) throws GPUdbException
remoteDirName
. This method uses default optionsremoteDirName
- - Name of the KIFS directoryGPUdbException
- - from deleteFilesInDir(String, boolean)
public void deleteFilesInDir(String remoteDirName, boolean noErrorIfNotExists) throws GPUdbException
remoteDirName
.remoteDirName
- - Name of the KIFS directorynoErrorIfNotExists
- - Indicates whether to allow deletion of files
in non-existent KIFS directory or not.GPUdbException
- - from downstream API callspublic List<KifsFileInfo> showFiles(List<String> remoteDirNames) throws GPUdbException
remoteDirNames
- - List of KIFS directory namesKifsFileInfo
objectsGPUdbException
public List<KifsDirectoryInfo> showDirectories(Set<String> remoteDirNames) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirNames
- - Set of KIFS directory namesKifsDirectoryInfo
objectsGPUdbException
- - from showDirectories(Set, Map)
showDirectories(Set, Map)
public List<KifsDirectoryInfo> showDirectories(Set<String> remoteDirNames, Map<String,String> options) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirNames
- - Set of names of the KIFS directoriesoptions
- - Map of String to String; the endpoint expects an empty
map.KifsDirectoryInfo
objects.GPUdbException
public List<KifsDirectoryInfo> showDirectory(String remoteDirName) throws GPUdbException
KifsDirectoryInfo
objects. This method uses default options.remoteDirName
- - Name of the KIFS directory, cannot be null or emptyKifsDirectoryInfo
objects.GPUdbException
showDirectory(String, Map)
public List<KifsDirectoryInfo> showDirectory(String remoteDirName, Map<String,String> options) throws GPUdbException
KifsDirectoryInfo
objects.remoteDirName
- - Name of the KIFS directory, cannot be null or emptyoptions
- - Map of String to String; the endpoint expects an empty
map.KifsDirectoryInfo
objects.GPUdbException
public List<KifsDirectoryInfo> showAllDirectories() throws GPUdbException
KifsDirectoryInfo
objects.KifsDirectoryInfo
objectsGPUdbException
- - from showAllDirectories(Map)
showAllDirectories(Map)
public List<KifsDirectoryInfo> showAllDirectories(Map<String,String> options) throws GPUdbException
KifsDirectoryInfo
objects.options
- - Map of String to String; the endpoint expects an empty
map.KifsDirectoryInfo
objects.GPUdbException
- - from downstream API callpublic void createDirectory(String remoteDirName) throws GPUdbException
remoteDirName
- - String - Name of the KIFS directory to createGPUdbException
- - from createDirectory(String, boolean)
public void createDirectory(String remoteDirName, boolean noErrorIfExists) throws GPUdbException
remoteDirName
- - String - Name of the KIFS directory to createnoErrorIfExists
- - boolean - true means if the directory exists
there will be no error thrown and false means
an existing directory name will throw an errorGPUdbException
public void deleteDirectory(String remoteDirName) throws GPUdbException
remoteDirName
- - Name of the KIFS directoryGPUdbException
- - from deleteDirectory(String, boolean, boolean)
deleteDirectory(String, boolean, boolean)
public void deleteDirectory(String remoteDirName, boolean recursive, boolean noErrorIfNotExists) throws GPUdbException
remoteDirName
- - Name of the KIFS directoryrecursive
- - Indicates deletion of all sub-directoriesnoErrorIfNotExists
- - If set to true will ignore if the directory
does not existGPUdbException
public boolean kifsDirectoriesExist(Set<String> dirNames)
dirNames
- - the set of full KIFS pathspublic boolean kifsDirectoryExists(String dirName)
dirName
- - the full KIFS pathspublic boolean kifsFileExists(String fileName)
fileName
- - the full KIFS path to a fileCopyright © 2024. All rights reserved.