|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.bnl.star.offline.scheduler.lsf.LSFResourceStrategy
Encapsulate the resource usage parameter (-R) for an LSF farm. Essentially, its a placeholder for the prepareResourceUsageSwitch() which will calculate the appriate string. The administrator should be able to create different subclasses for each farm as needed.
This class provides a scheleton for a typical resource usage for files residing on different NFS servers. It was designed to fit STAR needs at two sites. In case it doesn't fit the needs, the class can be subclassed to define new behaviour.
The resource switch is prepared in this way:
Takes the list of input files and iterates over them.
Checks if each file needs a resource (resourceRequired()
).
To determine that, checks if the file is on NFS, and looks for the typical data
vault prefix (getDataVaultPrefix
). For example, "/star/dataxx/...";
it extract the vaultNumber and it substitute it in the resourceSyntax
Increases the count of the resource (increaseResourceUsage
)
Prepares the switch (prepareSwitch
)
The resource value for each resource will the be given by the following formula:
min (base+nCount*fileFactor, max)
The subclass need to implement the abstract methods, which defines things that always change between different farms.
TODO Further work should be done to be able to configure the ResourceStrategy depending on the farm on which the job will be dispatched. This should be included in the GRID dispatchers.
Field Summary | |
protected int |
base
Base value for the resource value formula. |
protected int |
fileFactor
FileFactor value for the resource value formula. |
protected int |
max
Max parameter for the standard increaseResourceUsage implementation. |
Constructor Summary | |
LSFResourceStrategy()
|
Method Summary | |
protected void |
addResource(java.lang.String resName,
int base)
Addes a new resource, and initializes the value to base . |
protected void |
calculateLSFResources(Job job)
Filles the resource table with all the resources. |
protected java.lang.String |
definedNames()
A list of names, comma separated, of all the resources used. |
protected boolean |
determineResourceNotUsed()
Determines whether any resources at all have been assigned. |
int |
getBase()
Returns the base value for the resource value formula. |
java.lang.String |
getDataVaultPrefix()
Returns the prefix with which a file on NFS identifies on which file server or data vault is residing. |
int |
getFileFactor()
Returns the fileFactor value for the resource value formula. |
int |
getMax()
Returns the max value for the resource value formula. |
java.lang.String |
getResourceNameSyntax()
Returns the syntax to be used to convert a data vault number to the LSF resource. |
java.lang.String |
getSwitchSyntax()
Returns the syntax that will be used to prepare the final switch |
protected int |
increaseResource(java.lang.String resName,
int base,
int amount)
Increases the value associated to the given resource by a given amount. |
protected int |
increaseResourceUptoLimit(java.lang.String resName,
int base,
int amount,
int limit)
Increases the value associated to the given resource by a given amount. |
protected void |
increaseResourceUsage(java.lang.String resource)
Increase the resource usage as part of the standard implementation. |
protected void |
initResources()
Initializes the resource table. |
boolean |
isRemoveCharactersFromVaultNumber()
If true removes all the characters from the vault number. |
boolean |
isTrimVaultNumberDecimal()
Getter for property trimVaultNumberDecimal. |
boolean |
isTrimVaultNumberLeadingZeros()
Returns true if the leading zeros of a vault number will be removed when creating the corresponding LSF resource. |
protected java.lang.String |
nameEqualValueColumnSeparated()
Returns a string already formatted containing names and values column separated (i.e. |
protected java.lang.String |
nameEqualValueCommaSeparated()
Returns a string already formatted containing names and values comma separated (i.e. |
protected java.lang.String |
prepareResourceName(java.lang.String vaultNumber)
Given the vault id, returns the LSF resource name to be used in the -R parameter. |
java.lang.String |
prepareResourceUsageSwitch(Job job)
Returns the -R parameter to be used to dispatch the given job. |
protected int |
prepareResourceValue(java.lang.String resName)
Returns the value currently associated to the resource. |
protected java.lang.String |
prepareSwitch()
Prepares the -R parameters to give to LSF at the end of the resource distribution. |
protected java.lang.String |
resourceRequired(PhysicalFile file)
Determines which resource the job might need to access the file. |
void |
setBase(int base)
Changes the base value for the resource value formula. |
void |
setDataVaultPrefix(java.lang.String dataVaultPrefix)
Changes the prefix of a NFS file. |
void |
setFileFactor(int fileFactor)
Changes the fileFactor value for the resource value formula. |
void |
setMax(int max)
Changes the max value for the resource value formula. |
void |
setRemoveCharactersFromVaultNumber(boolean removeCharactersFromVaultNumber)
Set to true removes all the characters from the vault number |
void |
setResourceNameSyntax(java.lang.String resourceNameSyntax)
Changes the syntax to be used to convert a data vault number to the LSF resource. |
void |
setSwitchSyntax(java.lang.String switchSyntax)
Changes the syntax that will be used to prepare the final switch. |
void |
setTrimVaultNumberDecimal(boolean trimVaultNumberDecimal)
Setter for property trimVaultNumberDecimal. |
void |
setTrimVaultNumberLeadingZeros(boolean trimVaultNumberLeadingZeros)
Set to true if the leading zeros of a vault number will be removed when creating the corresponding LSF resource. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int base
protected int fileFactor
protected int max
Constructor Detail |
public LSFResourceStrategy()
Method Detail |
public int getBase()
public void setBase(int base)
public int getFileFactor()
public void setFileFactor(int fileFactor)
public int getMax()
public void setMax(int max)
public java.lang.String getDataVaultPrefix()
public void setDataVaultPrefix(java.lang.String dataVaultPrefix)
public java.lang.String getResourceNameSyntax()
public void setResourceNameSyntax(java.lang.String resourceNameSyntax)
public boolean isTrimVaultNumberLeadingZeros()
public void setTrimVaultNumberLeadingZeros(boolean trimVaultNumberLeadingZeros)
protected java.lang.String prepareResourceName(java.lang.String vaultNumber)
vaultNumber
- the vault id, as identified in getDataVaultPrefix
public java.lang.String getSwitchSyntax()
public void setSwitchSyntax(java.lang.String switchSyntax)
protected java.lang.String prepareSwitch()
definedNames()
,
nameEqualValueCommaSeparated()
or
nameEqualValueColumnSeparated()
to prepare it more easily.
protected void increaseResourceUsage(java.lang.String resource)
base
, adds fileFactor
for
each usage until max
is reached. In pseudo-code:
if (nRes == 0) nRes = base;
nRes += nRes;
if (nRes > max) nRes = max;
One can modify the three protected parameters (base, fileFactor, max) to tune the usage.
resource
- the resource for which to increase the counting.protected void addResource(java.lang.String resName, int base)
base
.
resName
- the name of the resourcebase
- the initial value for the resourceprotected int increaseResource(java.lang.String resName, int base, int amount)
resName
- the name of the resourcebase
- the initial value if the resource has to be createdamount
- the amount to increase the resource by
protected int increaseResourceUptoLimit(java.lang.String resName, int base, int amount, int limit)
limit
- upper limit to which the resource value will be setresName
- the name of the resourcebase
- the initial value if the resource has to be createdamount
- the amount to increase the resource by
protected int prepareResourceValue(java.lang.String resName)
resName
- resource name
public java.lang.String prepareResourceUsageSwitch(Job job)
job
- the job to be dispatched
protected void initResources()
protected java.lang.String nameEqualValueCommaSeparated()
protected java.lang.String nameEqualValueColumnSeparated()
protected java.lang.String definedNames()
protected void calculateLSFResources(Job job)
increaseResourceUsage
for each file that map
to a resource.
job
- the jobprotected java.lang.String resourceRequired(PhysicalFile file)
file
- input file the job will be using
protected boolean determineResourceNotUsed()
public boolean isTrimVaultNumberDecimal()
public void setTrimVaultNumberDecimal(boolean trimVaultNumberDecimal)
trimVaultNumberDecimal
- New value of property trimVaultNumberDecimal.public boolean isRemoveCharactersFromVaultNumber()
public void setRemoveCharactersFromVaultNumber(boolean removeCharactersFromVaultNumber)
removeCharactersFromVaultNumber
- New value of property removeCharactersFromVaultNumber.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |