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
RevLine 
[477]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){
[1396]20                if(unitName.equalsIgnoreCase(StandardResourceUnitName.CPU.getLabel()))
[477]21                        return new PEUnit(resId, totalAmount, usedAmount);
[1396]22                if(unitName.equalsIgnoreCase(StandardResourceUnitName.PE.getLabel()))
[477]23                        return new PEUnit(resId, totalAmount, usedAmount);
[1396]24                else if(unitName.equalsIgnoreCase(StandardResourceUnitName.MEMORY.getLabel()))
[477]25                         return new Memory(resId, totalAmount, usedAmount);
[1396]26                else if(unitName.equalsIgnoreCase(StandardResourceUnitName.STORAGE.getLabel()))
[477]27                         return new Storage(resId, totalAmount, usedAmount);
[1396]28                else if(unitName.equalsIgnoreCase(StandardResourceUnitName.GPU.getLabel()))
[477]29                         return new GPU(resId, totalAmount, usedAmount);
[1396]30                else if (unitName.equalsIgnoreCase(StandardResourceUnitName.CPUSPEED.getLabel()))
[477]31                        return new CpuSpeed(resId, totalAmount, usedAmount);
[1396]32                else if (unitName.equalsIgnoreCase(StandardResourceUnitName.COST.getLabel()))
[477]33                        return new Cost(resId, totalAmount);
[1396]34                else if (unitName.equalsIgnoreCase(StandardResourceUnitName.APPLICATION.getLabel()))
[477]35                        return new Applications(resId);
36                else
37                        return new SimpleResourceUnit(ResourceUnitNameFactory.createResourceUnitName(unitName), resId, totalAmount, usedAmount);
38        }
[1384]39
[477]40}
Note: See TracBrowser for help on using the repository browser.