|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gcube.common.searchservice.searchlibrary.resultset.helpers.RSFileHelper
public class RSFileHelper
Helper class of the ResultSet
element
Constructor Summary | |
---|---|
RSFileHelper()
|
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RSFileHelper()
Method Detail |
---|
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.PAGEDCONTENT
seed
- 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 used
java.lang.Exception
- An unrecoverable for the operation error occuredpublic static java.lang.String headToFlowControl(java.lang.String head)
head
- The head file of the RS
public static java.lang.String headToFlowControlTmp(java.lang.String head)
head
- The head file of the RS
public static RSConstants.CONTROLFLOW waitOnFlowNotification(java.lang.String headname, long time)
headname
- The head filetime
- The timeout
public 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 convert
java.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 name
java.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 convert
java.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 convert
java.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 persisted
java.lang.Exception
- An unrecoverable for the operation error occuredpublic static boolean forceConsistency(java.lang.String filename) throws java.lang.Exception
filename
- the filename
java.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 class
java.lang.Exception
- An unrecoverable for the operation error occurredpublic static void persistHeader(HeaderRef header) throws java.lang.Exception
header
- The header info
java.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 payload
java.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 milliseconds
filename
- The filename to wait forflowControl
- whether or not the RS supports on demand production of resultsheadname
- The head file name of this RS
public 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 RS
public static boolean isReady(java.lang.String filename)
filename
- The name of the file to check if it is ready
true
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 class
java.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 class
java.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 class
java.lang.Exception
- An unrecoverable for the operation error occurredpublic static java.lang.String[] splitFile(java.lang.String filename) throws java.lang.Exception
RSConstants.partSize
filename
- The file to split
java.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 stream
java.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 file
java.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 file
java.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 persist
java.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 from
java.lang.Exception
- An unrecoverable for the operation error occuredpublic static byte[] getBytesFromFile(java.io.File file) throws java.lang.Exception
file
- The File handler
java.lang.Exception
- in case of errorpublic static void runGC()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |