public class Sandbox
extends java.lang.Object
A Sandbox is created before the job is started. The input files (or directories) necessary to run the job are then
added to the Sandbox using addUploadFile(Path, String)
. Once all files have been added they can be uploaded to the
Sandbox using upload(CopyOption...)
.
Similarly, the output files (or directories) produced by the job can be registered with the Sandbox using
addDownloadFile(String, Path)
. These may be added before or after the job runs.
Next the job is run using the sandbox as a working directory.
After the job has terminated, the output files can be downloaded using download(CopyOption...)
.
Finally, the Sandbox can be deleted using delete()
.
Modifier and Type | Class and Description |
---|---|
static class |
Sandbox.Pair
Pair represents the combination of a source and destination path
|
Modifier and Type | Field and Description |
---|---|
private java.util.List<Sandbox.Pair> |
downloadFiles |
private Files |
files |
private Path |
path |
private java.util.List<Sandbox.Pair> |
uploadFiles |
Constructor and Description |
---|
Sandbox(Files files,
Path root,
java.lang.String sandboxName)
Creates a sandbox.
|
Modifier and Type | Method and Description |
---|---|
void |
addDownloadFile(java.lang.String src,
Path dest)
Add a file to the list of files to download.
|
void |
addUploadFile(Path src)
Add a file to the list of files to upload.
|
void |
addUploadFile(Path src,
java.lang.String dest)
Add a file to the list of files to upload.
|
private void |
copy(java.util.List<Sandbox.Pair> pairs,
CopyOption... options) |
void |
delete()
Recursively delete the sandbox.
|
void |
download(CopyOption... options)
Download files from sandbox.
|
boolean |
equals(java.lang.Object obj) |
java.util.List<Sandbox.Pair> |
getDownloadFiles()
Returns the list of files that will be downloaded when calling
download . |
Path |
getPath()
The sandbox directory.
|
java.util.List<Sandbox.Pair> |
getUploadFiles()
Returns the list of files that will be uploaded when calling
upload . |
int |
hashCode() |
private static Path |
resolve(Files files,
Path root,
java.lang.String path) |
void |
setUploadFiles(Path... files)
Sets the list of files that will be uploaded to
files . |
java.lang.String |
toString() |
void |
upload(CopyOption... options)
Upload files to sandbox.
|
private final Files files
private final Path path
private java.util.List<Sandbox.Pair> uploadFiles
private final java.util.List<Sandbox.Pair> downloadFiles
public Sandbox(Files files, Path root, java.lang.String sandboxName) throws XenonException
files
- A Files interface used to access the files.root
- Directory in which sandbox will be created.sandboxName
- Name of the sandbox. If null a random name will be used.XenonException
XenonException
private static Path resolve(Files files, Path root, java.lang.String path) throws XenonException
XenonException
public Path getPath()
public java.util.List<Sandbox.Pair> getUploadFiles()
upload
.public void setUploadFiles(Path... files) throws XenonException
files
.
Any existing upload files will be discarded.files
- the files to upload.XenonException
public void addUploadFile(Path src) throws XenonException
src
- Source path of file. May not be null
.XenonException
public void addUploadFile(Path src, java.lang.String dest) throws XenonException
src
- The source file. May not be null
.dest
- The name of file in the sandbox. If null
then src.getFilename()
will be used.XenonException
public java.util.List<Sandbox.Pair> getDownloadFiles()
download
.public void addDownloadFile(java.lang.String src, Path dest) throws XenonException
src
- Name of the source file in the sandbox. When null
the dest.getFilename()
will be used.dest
- The target file. May not be null
.XenonException
private void copy(java.util.List<Sandbox.Pair> pairs, CopyOption... options) throws XenonException
XenonException
public void upload(CopyOption... options) throws XenonException
options
- the options to use while copying. See CopyOption
for details.InvalidCopyOptionsException
- if an invalid combination of options is used.XenonException
- if an I/O error occurs during the copyingpublic void download(CopyOption... options) throws XenonException
options
- the options to use while copying. See CopyOption
for details.InvalidCopyOptionsException
- if an invalid combination of options is used.XenonException
- if an I/O error occurs during the copyingpublic void delete() throws XenonException
XenonException
- if an I/O error occurs during deletionpublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object