source: DCWoRMS/branches/coolemall/src/schedframe/resources/units/ResourceUnitFactory.java @ 1396

Revision 1396, 1.9 KB checked in by wojtekp, 11 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.resources.units;
2
3
4
5public class ResourceUnitFactory {
6       
7        /*public static ResourceUnit creteUnit(String resourceClass, int totalAmount, int usedAmount){
8                switch(ResourceParameterName.fromValue(resourceClass)){
9                        case CPUCOUNT: return new Processors(totalAmount, usedAmount, 1);
10                        case MEMORY: return new Memory(totalAmount, usedAmount);
11                        case FREEMEMORY: return new FreeMemory(totalAmount, usedAmount);
12                        case CPUSPEED: return new CpuSpeed(totalAmount, usedAmount);
13                default:
14                        return new FreeMemory(totalAmount, usedAmount);
15                        //throw new IllegalArgumentException("Paramter " + resourceClass + " is not supported.");
16                }
17        }*/
18       
19        public static ResourceUnit createUnit(String unitName, String resId, int totalAmount, int usedAmount){
20                if(unitName.equalsIgnoreCase(StandardResourceUnitName.CPU.getLabel()))
21                        return new PEUnit(resId, totalAmount, usedAmount);
22                if(unitName.equalsIgnoreCase(StandardResourceUnitName.PE.getLabel()))
23                        return new PEUnit(resId, totalAmount, usedAmount);
24                else if(unitName.equalsIgnoreCase(StandardResourceUnitName.MEMORY.getLabel()))
25                         return new Memory(resId, totalAmount, usedAmount);
26                else if(unitName.equalsIgnoreCase(StandardResourceUnitName.STORAGE.getLabel()))
27                         return new Storage(resId, totalAmount, usedAmount);
28                else if(unitName.equalsIgnoreCase(StandardResourceUnitName.GPU.getLabel()))
29                         return new GPU(resId, totalAmount, usedAmount);
30                else if (unitName.equalsIgnoreCase(StandardResourceUnitName.CPUSPEED.getLabel()))
31                        return new CpuSpeed(resId, totalAmount, usedAmount);
32                else if (unitName.equalsIgnoreCase(StandardResourceUnitName.COST.getLabel()))
33                        return new Cost(resId, totalAmount);
34                else if (unitName.equalsIgnoreCase(StandardResourceUnitName.APPLICATION.getLabel()))
35                        return new Applications(resId);
36                else
37                        return new SimpleResourceUnit(ResourceUnitNameFactory.createResourceUnitName(unitName), resId, totalAmount, usedAmount);
38        }
39
40}
Note: See TracBrowser for help on using the repository browser.