package schedframe.resources.computing; import schedframe.resources.StandardResourceType; import schedframe.resources.computing.description.ComputingResourceDescription; import schedframe.scheduling.Scheduler; import schedframe.scheduling.manager.resources.ManagedResources; import schedframe.scheduling.plugin.SchedulingPlugin; import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; import schedframe.scheduling.policy.AbstractManagementSystem; import schedframe.scheduling.policy.global.GridBroker; import schedframe.scheduling.policy.local.LocalManagementSystem; import schedframe.scheduling.queue.TaskQueueList; import simulator.DCWormsConstants; public class ResourceFactory { public static ComputingResource createResource(ComputingResourceDescription resDesc){ if (resDesc.getType().equals(StandardResourceType.DataCenter)) return new DataCenter(resDesc); else if (resDesc.getType().equals(StandardResourceType.Rack)) return new Rack(resDesc); else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) return new ComputingNode(resDesc); else if (resDesc.getType().equals(StandardResourceType.Processor)) return new Processor(resDesc); else if (resDesc.getType().equals(StandardResourceType.Core)) return new Core(resDesc); else return new ComputingResource(resDesc); /*switch(resDesc.getType()){ case Grid: return new Grid(resDesc); case DataCenter: return new DataCenter(resDesc); case ComputingNode: return new ComputingNode(resDesc); case Processor: return new Processor(resDesc); default: return new ComputingResource(resDesc); }*/ } public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{ AbstractManagementSystem ms; switch(type){ case GS: { ms = new GridBroker("grid", schedulingPlugin, execTimeEstimationPlugin, queues); return new Scheduler(ms, type, managedResources); } case LS: { ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, schedulingPlugin, execTimeEstimationPlugin, queues); return new Scheduler(ms, type, managedResources); } default:{ ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, schedulingPlugin, execTimeEstimationPlugin, queues); return new Scheduler(ms, type, managedResources); } } } }