[104] | 1 | package schedframe.scheduling; |
---|
| 2 | |
---|
| 3 | import schedframe.scheduling.utils.DescriptionContainer; |
---|
| 4 | import schedframe.scheduling.utils.ResourceParameterName; |
---|
| 5 | |
---|
| 6 | /** |
---|
| 7 | * |
---|
| 8 | * @author Marcin Krystek |
---|
| 9 | * |
---|
| 10 | * @param <T> |
---|
| 11 | */ |
---|
| 12 | public abstract class AbstractResourceRequirements<T> implements DescriptionContainer<T> { |
---|
| 13 | |
---|
| 14 | protected T resourceRequirements; |
---|
| 15 | protected boolean isBestEffort; |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | protected AbstractResourceRequirements(){ |
---|
| 19 | this.isBestEffort = true; |
---|
| 20 | } |
---|
| 21 | /** |
---|
| 22 | * |
---|
| 23 | * @param parameterName name of the task resource requirement |
---|
| 24 | * @return value of the numeral parameter which describes task resource requirement |
---|
| 25 | * @throws NoSuchFieldException if such parameter is not defined |
---|
| 26 | * @throws IllegalArgumentException if requested parameter is String value |
---|
| 27 | */ |
---|
| 28 | public abstract double getParameterDoubleValue(ResourceParameterName parameterName) |
---|
| 29 | throws NoSuchFieldException, IllegalArgumentException; |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * |
---|
| 33 | * @param parameterName name of the task resource requirement |
---|
| 34 | * @return value of the String parameter which describes task resource requirement |
---|
| 35 | * @throws NoSuchFieldException if such parameter is not defined |
---|
| 36 | * @throws IllegalArgumentException if requested parameter is Double value |
---|
| 37 | */ |
---|
| 38 | public abstract String getParameterStringValue(ResourceParameterName parameterName) |
---|
| 39 | throws NoSuchFieldException, IllegalArgumentException; |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | public double getCpuCntRequest() throws NoSuchFieldException{ |
---|
| 43 | return getParameterDoubleValue(ResourceParameterName.CPUCOUNT); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | public double getMemoryRequest() throws NoSuchFieldException{ |
---|
| 47 | return getParameterDoubleValue(ResourceParameterName.MEMORY); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | public int getProcessesCount(){ |
---|
| 51 | return 1; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | public boolean isBestEffort(){ |
---|
| 55 | return this.isBestEffort; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | public void setBestEffort(boolean value){ |
---|
| 59 | this.isBestEffort = value; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | } |
---|