public class RSFileHelper
extends java.lang.Object
ResultSet element| Constructor and Description |
|---|
RSFileHelper() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
contentToHeader(java.lang.String contentName)
Converts a content file name to the respective header one.
|
static void |
copy(ResultSet rs,
java.lang.String src,
java.io.DataOutputStream dst)
Copies the source file to a new file
|
static void |
copy(java.lang.String src,
java.io.DataOutputStream dst)
Copies the source file to an output stream
|
static void |
copy(java.lang.String src,
java.lang.String dst)
Copies the source file to a new file
|
static boolean |
forceConsistency(java.lang.String filename)
forces the filesystem to remain consistent by using metadata changing functions
|
static java.lang.String |
generateName(short type,
java.lang.String seed)
Generates a name of the type that is provided which can either be unique or have the unique
value part equal to the provided one
|
static java.io.DataInputStream |
getBinaryContent(java.lang.String file,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
Retrieves the full content of the provided file
|
static byte[] |
getBytesFromFile(java.io.File file)
Read file into a byte array
|
static java.lang.String |
getContent(java.lang.String file,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
Retrieves the full content of the provided file
|
static int |
getNumberOfResultsInTextFile(java.lang.String filename)
Retrives the number of results in the provided file that has been structured as a text
payload part
|
static java.lang.String |
headerToContent(java.lang.String headerName)
Converts a header file name to the respective content one.
|
static java.lang.String |
headToFlowControl(java.lang.String head)
Constructs the flag used for on demand production file that corresponds to the specfic head part
|
static java.lang.String |
headToFlowControlTmp(java.lang.String head)
Constructs the temporary flag used for on demand production file that corresponds to the specfic head part
|
static boolean |
isReady(java.lang.String filename)
Checks if the provided file is ready for consumption
|
static void |
notifyOnFlowCreation(java.lang.String headname)
notidies the consumer that more records were created
|
static void |
persistContent(java.lang.String filename,
java.lang.String inWrap,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
Persists the content of the provided source file to the provided target file
|
static void |
persistContent(java.lang.String filename,
java.util.Vector<java.lang.String> results,
int count,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
Persists the content available in the provided vector o a file whose name is given.
|
static void |
persistHeader(HeaderRef header)
Persists a header file with the information available in its argument
|
static java.lang.String |
persistStream(java.io.InputStream content)
persists the stream in a file and returns the filename
|
static HeaderRef |
populateHeader(java.lang.String filename)
Populates a header info class instance from the content of the provided file
|
static java.util.Vector<java.lang.String> |
populateResults(java.lang.String filename,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
Populates a record vecror with the records available in the provided file
|
static java.lang.String |
publicToTmp(java.lang.String pubName)
Converts a public file name to a private temparary one
|
static void |
requestFlowCreation(java.lang.String headname)
notifies the producer of an RS that more records are needed
|
static void |
runGC()
Attempt to call the garbage collector
|
static java.lang.String[] |
splitFile(java.lang.String filename)
Splits the provided file in smaller parts as is dictated by
RSConstants.partSize |
static java.lang.String |
tmpToPublic(java.lang.String tmpName)
Converts a tmp file name to a public one
|
static void |
touchHeader(java.lang.String filename)
Populates a header info class instance from the content of the provided file
|
static boolean |
waitForIt(java.lang.String filename,
boolean flowControl,
java.lang.String headname)
Waits until the provided file is ready to be consumed or a maximum amount of time has been reached.
|
static boolean |
waitForIt(java.lang.String filename,
long time,
boolean flowControl,
java.lang.String headname)
Waits until the provided file is ready to be consumed or a maximum amount of time has been reached.
|
static RSConstants.CONTROLFLOW |
waitOnFlowNotification(java.lang.String headname,
long time)
blocks waiting for notifications on result production for the specified time period
|
public static java.lang.String generateName(short type,
java.lang.String seed)
throws java.lang.Exception
type - The type of filename to generate. This can be one of RSConstants.CONTENT,
RSConstants.HEADER, RSConstants.PAGEDCONTENTseed - If a non null value is provided, The unique part of the generated file
will have the supplied value. Otherwise, a unique value is generated and usedjava.lang.Exception - An unrecoverable for the operation error occuredpublic static java.lang.String headToFlowControl(java.lang.String head)
head - The head file of the RSpublic static java.lang.String headToFlowControlTmp(java.lang.String head)
head - The head file of the RSpublic static RSConstants.CONTROLFLOW waitOnFlowNotification(java.lang.String headname, long time)
headname - The head filetime - The timeoutpublic static void notifyOnFlowCreation(java.lang.String headname)
headname - The head name of the RS that needed more resultspublic static void requestFlowCreation(java.lang.String headname)
headname - The head name of the RS that needs more resultspublic static java.lang.String publicToTmp(java.lang.String pubName)
throws java.lang.Exception
pubName - The file name to convertjava.lang.Exception - An unrecoverable for the operation error occuredpublic static java.lang.String tmpToPublic(java.lang.String tmpName)
throws java.lang.Exception
tmpName - the temporary namejava.lang.Exception - An unrecoverable for the operation error occuredpublic static java.lang.String headerToContent(java.lang.String headerName)
throws java.lang.Exception
headerName - THe header name to convertjava.lang.Exception - An unrecoverable for the operation error occuredpublic static java.lang.String contentToHeader(java.lang.String contentName)
throws java.lang.Exception
contentName - The content name to convertjava.lang.Exception - An unrecoverable for the operation error occuredpublic static void persistContent(java.lang.String filename,
java.util.Vector<java.lang.String> results,
int count,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
throws java.lang.Exception
filename - The filename to perist the content inresults - The vector holding the payloadmne - the encryption classcount - The number of records to persist. If this is negative, all the available records are persistedjava.lang.Exception - An unrecoverable for the operation error occuredpublic static boolean forceConsistency(java.lang.String filename)
throws java.lang.Exception
filename - the filenamejava.lang.Exception - An error has occuredpublic static void persistContent(java.lang.String filename,
java.lang.String inWrap,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
throws java.lang.Exception
filename - The target fileinWrap - The source filemne - the encryption classjava.lang.Exception - An unrecoverable for the operation error occurredpublic static void persistHeader(HeaderRef header) throws java.lang.Exception
header - The header infojava.lang.Exception - An unrecoverable for the operation error occuredpublic static HeaderRef populateHeader(java.lang.String filename) throws java.lang.Exception
filename - The file holding the header payloadjava.lang.Exception - An unrecoverable for the operation error occuredpublic static void touchHeader(java.lang.String filename)
filename - The file holding the header to touchpublic static boolean waitForIt(java.lang.String filename,
boolean flowControl,
java.lang.String headname)
RSConstants.sleepMax in millisecondsfilename - The filename to wait forflowControl - whether or not the RS supports on demand production of resultsheadname - The head file name of this RSpublic static boolean waitForIt(java.lang.String filename,
long time,
boolean flowControl,
java.lang.String headname)
filename - The filename to wait fortime - The maximum time in milliseconds to wait for the fileflowControl - whether or not the RS supports on demand production of resultsheadname - The head file name of this RSpublic static boolean isReady(java.lang.String filename)
filename - The name of the file to check if it is readytrue if it is, false otherwisepublic static java.util.Vector<java.lang.String> populateResults(java.lang.String filename,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
throws java.lang.Exception
filename - The file to retrieve the records frommne - the encryption classjava.lang.Exception - An unrecoverable for the operation error occuredpublic static java.lang.String getContent(java.lang.String file,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
throws java.lang.Exception
file - The file whose content must be retrievedmne - the encryption classjava.lang.Exception - An unrecoverable for the operation error occurredpublic static java.io.DataInputStream getBinaryContent(java.lang.String file,
org.gcube.common.searchservice.searchlibrary.resultset.security.Mnemonic mne)
throws java.lang.Exception
file - The file whose content must be retrievedmne - the encryption classjava.lang.Exception - An unrecoverable for the operation error occurredpublic static java.lang.String[] splitFile(java.lang.String filename)
throws java.lang.Exception
RSConstants.partSizefilename - The file to splitjava.lang.Exception - An unrecoverable for the operation error occuredpublic static void copy(java.lang.String src,
java.io.DataOutputStream dst)
throws java.lang.Exception
src - The source filedst - The destination streamjava.lang.Exception - An unrecoverable for the operation error occuredpublic static void copy(java.lang.String src,
java.lang.String dst)
throws java.lang.Exception
src - The source filedst - The destination filejava.lang.Exception - An unrecoverable for the operation error occuredpublic static void copy(ResultSet rs, java.lang.String src, java.io.DataOutputStream dst) throws java.lang.Exception
rs - the RSsrc - The source filedst - The destination filejava.lang.Exception - An unrecoverable for the operation error occurredpublic static java.lang.String persistStream(java.io.InputStream content)
throws java.lang.Exception
content - the stream to persistjava.lang.Exception - an unrecoverable for the operation error occurredpublic static int getNumberOfResultsInTextFile(java.lang.String filename)
throws java.lang.Exception
filename - The file to retrieve the records fromjava.lang.Exception - An unrecoverable for the operation error occuredpublic static byte[] getBytesFromFile(java.io.File file)
throws java.lang.Exception
file - The File handlerjava.lang.Exception - in case of errorpublic static void runGC()