|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.icenigrid.gridsam.core.util.BatchUtils
public class BatchUtils
Purpose:
Provide some utilities for the ease of manipulating the batch system
| Constructor Summary | |
|---|---|
BatchUtils()
|
|
| Method Summary | |
|---|---|
static DriverResponseParser |
cancel(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
To cancel local batch job. |
static java.lang.String |
catFile(java.lang.String owner,
java.lang.String filePath)
To cat the content of the indicated file, which is owned by targer user. |
static FileDriverResponseParser |
chmod(java.lang.String owner,
java.lang.String dirPath,
java.lang.String umask)
To chmod this directory. |
static FileDriverResponseParser |
chown(java.lang.String owner,
java.lang.String group,
java.lang.String filePath)
to change stagein-file's owner to localUser. |
static FileDriverResponseParser |
copyContent(java.lang.String owner,
java.lang.String sourceFilePath,
java.lang.String targetFilePath)
To read the content of source file and write to the target file. |
static FileDriverResponseParser |
deleteFile(java.lang.String owner,
java.lang.String dirPath)
To delete the indicated dir or file. |
static void |
deleteTempAfterFailed(JobInstance pJob)
To delete the temp dir after setting the job as failed! Just try once :) |
static DriverResponseParser |
detail(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
To get the details of the indicated local batch job. |
static void |
doProcess(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir,
java.lang.String processFile)
do post process in job working directory. |
static java.lang.String |
execProcess(java.lang.String _cmdline,
java.lang.String _homedir)
execute the command-line command in the home directory _homedir. |
static java.lang.String |
file2String(java.lang.String fn)
read the content of a file whose path is given in fn value , and change the format to String. |
static java.lang.String |
formalizePath(java.lang.String p,
java.lang.String h)
used when generate original job script |
static java.lang.String |
getElementBody(org.w3c.dom.Document d,
java.lang.String name)
get element body using name from document d. |
static FileDriverResponseParser |
getFirstExistPath(java.lang.String owner,
java.lang.String dirPath)
To get the first exist path of the given dirPath. |
static java.lang.String |
getPureName(java.lang.String path)
get the pure name , pure name means the name without path information. |
static FileDriverResponseParser |
isReadAble(java.lang.String owner,
java.lang.String filePath)
check owner can read filePath or not. |
static FileDriverResponseParser |
isWriteAble(java.lang.String owner,
java.lang.String filePath)
check owner can write in filePath or not. |
static java.lang.String[] |
listZipEntry(java.lang.String zipLocation)
handle zip file. |
static FileDriverResponseParser |
makeDir(java.lang.String owner,
java.lang.String dirPath)
To create the working dir for the indicated job, which is owned by the correponding linux user. |
static FileDriverResponseParser |
makeDirAndChmod(java.lang.String owner,
java.lang.String dirPath,
java.lang.String umask)
To create the dir for the indicated job, and chmod this directory. |
static FileDriverResponseParser |
moveFile(java.lang.String owner,
java.lang.String sourceFilePath,
java.lang.String targetFilePath)
To move source file and write to the target file. |
static byte[] |
readProxy(java.lang.String proxyPath)
To read the proxy content. |
static DriverResponseParser |
screenOutput(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
To get the screen output of the indicated local batch job. |
static DriverResponseParser |
status(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
To query local batch job status. |
static DriverResponseParser |
stdOutErr(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
To get the stdout and stderr file name of the indicated local batch job. |
static org.w3c.dom.Document |
string2Document(java.lang.String str)
convert a XML String into the XML Document object. |
static boolean |
string2File(java.lang.String src,
java.lang.String fn)
create a file in the intended location , and then inject the content into this file. |
static boolean |
string2FileAppend(java.lang.String src,
java.lang.String fn)
To write the string into the indicated file. |
static DriverResponseParser |
submit(java.lang.String owner,
java.lang.String prefix,
java.lang.String workingDir)
To submit local batch job. |
static java.lang.String |
tail(java.lang.String owner,
int lineNumber,
java.lang.String filePath)
get tail string of the file. |
static void |
UnZip(java.lang.String zipLocation,
java.lang.String toDir)
unzip . |
static void |
UnZipEntry(java.io.File dir,
java.io.InputStream zinputStream,
java.lang.String entryName,
boolean isDirectory)
unzip. |
static boolean |
ZipFiles(java.util.List list,
java.lang.String zipname,
boolean type)
|
static boolean |
ZipFiles(java.lang.String[] files,
java.lang.String zipname,
boolean type)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BatchUtils()
| Method Detail |
|---|
public static FileDriverResponseParser makeDir(java.lang.String owner,
java.lang.String dirPath)
throws java.rmi.RemoteException
owner - The owner of the working dir.dirPath - The path to working dir.java.rmi.RemoteException - fail to make directory.
public static FileDriverResponseParser makeDirAndChmod(java.lang.String owner,
java.lang.String dirPath,
java.lang.String umask)
throws java.rmi.RemoteException
owner - The owner of the working dir.dirPath - The path to working dir.umask - the umask of the dirPath.
java.rmi.RemoteException - fail to make directory and chmod.
public static FileDriverResponseParser chmod(java.lang.String owner,
java.lang.String dirPath,
java.lang.String umask)
throws java.rmi.RemoteException
owner - The owner of the working dir.dirPath - The path to working dir.umask - the umask of the dirPath.
java.rmi.RemoteException - fail to chmod.
public static java.lang.String catFile(java.lang.String owner,
java.lang.String filePath)
throws java.rmi.RemoteException
owner - The owner of the filefilePath - The path to indicated file.
java.rmi.RemoteException - fail to cat the file.
public static FileDriverResponseParser deleteFile(java.lang.String owner,
java.lang.String dirPath)
throws java.rmi.RemoteException
owner - The driver user name.dirPath - The path to target dir or file. /tmp/GOS-111111/result.txt
java.rmi.RemoteException - fail to delete file.
public static FileDriverResponseParser copyContent(java.lang.String owner,
java.lang.String sourceFilePath,
java.lang.String targetFilePath)
throws java.rmi.RemoteException
owner - The linux user who own the real working dir.sourceFilePath - The absulote path to the original file, which will be read and
in the temp dir.targetFilePath - The absulote path to the target file, which is in the real
working dir
java.rmi.RemoteException - fail to copy the source to target.
public static FileDriverResponseParser moveFile(java.lang.String owner,
java.lang.String sourceFilePath,
java.lang.String targetFilePath)
throws java.rmi.RemoteException
owner - The linux user who own the real working dir.sourceFilePath - The absulote path to the original file, which will be read and
in the temp dir.targetFilePath - The absulote path to the target file, which is in the real
working dir
java.rmi.RemoteException - fail to mv source to target.
public static FileDriverResponseParser chown(java.lang.String owner,
java.lang.String group,
java.lang.String filePath)
throws java.rmi.RemoteException
owner - file's owner.group - owner is belong to this group.filePath - file's path.
java.rmi.RemoteException - fail to change owner of the file.
public static FileDriverResponseParser isReadAble(java.lang.String owner,
java.lang.String filePath)
throws java.rmi.RemoteException
owner - localUser's namefilePath - file's path.
java.rmi.RemoteException - fail to get whether the file is readable or not.
public static java.lang.String tail(java.lang.String owner,
int lineNumber,
java.lang.String filePath)
throws java.rmi.RemoteException
owner - localUser's name.lineNumber - tail line number of the file.filePath - file's path.
java.rmi.RemoteException - fail to get whether the file is readable or not.
public static FileDriverResponseParser isWriteAble(java.lang.String owner,
java.lang.String filePath)
throws java.rmi.RemoteException
owner - localUser's namefilePath - file's path.
java.rmi.RemoteException - fail to get whether the file is writeable or not.
public static FileDriverResponseParser getFirstExistPath(java.lang.String owner,
java.lang.String dirPath)
throws java.rmi.RemoteException
owner - The owner of the working dir.dirPath - The path to check.java.rmi.RemoteException - fail to make directory.
public static void doProcess(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir,
java.lang.String processFile)
throws java.rmi.RemoteException
owner - the local userprefix - the prefix of the file that generate by systemlocalJobID - job idworkingDir - woring directoryprocessFile - the file that contain post process command.
java.rmi.RemoteException - fail to do process in job working directory.
public static DriverResponseParser submit(java.lang.String owner,
java.lang.String prefix,
java.lang.String workingDir)
throws java.rmi.RemoteException
owner - The linux user who own the real jobprefix - The file prefix of the indicated jobworkingDir - The path to the real working dir
java.rmi.RemoteException - fail to sumbit the job.
public static DriverResponseParser status(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
throws java.rmi.RemoteException
owner - The linux user who own the real jobprefix - The file prefix of the indicated joblocalJobID - The jobId of the indicated pbs/lsf job.workingDir - The path to the real working dir
java.rmi.RemoteException - fail to get status of the job.
public static DriverResponseParser cancel(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
throws java.rmi.RemoteException
owner - The linux user who own the real jobprefix - The file prefix of the indicated joblocalJobID - The jobId of the indicated pbs/lsf job.workingDir - The path to the real working dir
java.rmi.RemoteException - fail to cancel the job.
public static DriverResponseParser screenOutput(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
throws java.rmi.RemoteException
owner - The linux user who own the real jobprefix - The file prefix of the indicated joblocalJobID - The jobId of the indicated pbs/lsf job.workingDir - The path to the real working dir
java.rmi.RemoteException - fail to get screen-output of the job.
public static DriverResponseParser detail(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
throws java.rmi.RemoteException
owner - The linux user who own the real jobprefix - The file prefix of the indicated joblocalJobID - The jobId of the indicated pbs/lsf job.workingDir - The path to the real working dir
java.rmi.RemoteException - fail to get detail info of the job.
public static DriverResponseParser stdOutErr(java.lang.String owner,
java.lang.String prefix,
java.lang.String localJobID,
java.lang.String workingDir)
throws java.rmi.RemoteException
owner - The linux user who own the real jobprefix - The file prefix of the indicated joblocalJobID - The jobId of the indicated pbs/lsf job.workingDir - The path to the real working dir
java.rmi.RemoteException - fail to get standand ouput or standard error output.public static void deleteTempAfterFailed(JobInstance pJob)
pJob - The job instance which own the temp Dir.
public static byte[] readProxy(java.lang.String proxyPath)
throws java.lang.Exception
proxyPath - the path of the proxy file.
java.lang.Exception - fail to read proxy file.
public static boolean string2File(java.lang.String src,
java.lang.String fn)
src - content which should be written into the created filefn - file location which will be created
public static boolean string2FileAppend(java.lang.String src,
java.lang.String fn)
src - the content you want to set to a file.fn - file name.
public static org.w3c.dom.Document string2Document(java.lang.String str)
str - xml String.
public static java.lang.String getPureName(java.lang.String path)
path - path name.
public static java.lang.String getElementBody(org.w3c.dom.Document d,
java.lang.String name)
d - document instance.name - element tag name.
public static java.lang.String execProcess(java.lang.String _cmdline,
java.lang.String _homedir)
_cmdline - command._homedir - home directory.
public static java.lang.String file2String(java.lang.String fn)
fn - file name.
public static java.lang.String[] listZipEntry(java.lang.String zipLocation)
throws java.lang.Exception
zipLocation - zip file path.
java.lang.Exception - fail to list zip entry of the file.
public static void UnZip(java.lang.String zipLocation,
java.lang.String toDir)
throws java.lang.Exception
zipLocation - zip file path.toDir - unzip file to this directory.
java.lang.Exception - fail to unzip the file.
public static void UnZipEntry(java.io.File dir,
java.io.InputStream zinputStream,
java.lang.String entryName,
boolean isDirectory)
throws java.io.IOException
dir - zinputStream - entryName - isDirectory -
java.io.IOException
public static boolean ZipFiles(java.util.List list,
java.lang.String zipname,
boolean type)
throws java.lang.Exception
list - zipname - type -
java.lang.Exception
public static java.lang.String formalizePath(java.lang.String p,
java.lang.String h)
p - h -
public static boolean ZipFiles(java.lang.String[] files,
java.lang.String zipname,
boolean type)
throws java.lang.Exception
files - zipname - type -
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||