package test.rewolucja.resources.utils; import eduni.simjava.Sim_event; import eduni.simjava.Sim_port; import eduni.simjava.Sim_system; import gridsim.GridSimTags; import gridsim.gssim.GssimTags; import gridsim.gssim.network.ExtendedGridSimCore; import test.rewolucja.resources.logical.base.LogicalResource; import test.rewolucja.resources.physical.base.ComputingResource; public class ResourceController extends ExtendedGridSimCore{ public LogicalResource getLogicalStructure() { return logicalStructure; } public ComputingResource getResources() { return resources; } protected LogicalResource logicalStructure; protected ComputingResource resources; public ResourceController(String name, LogicalResource logicalStructure, ComputingResource resources) throws Exception { super(name); this.logicalStructure = logicalStructure; this.resources = resources; // TODO Auto-generated constructor stub } public void body() { // Process events until END_OF_SIMULATION is received from the // GridSimShutdown Entity Sim_event ev = new Sim_event(); sim_get_next(ev); // boolean run = true; while (Sim_system.running()) { // sim_get_next(ev); // if the simulation finishes then exit the loop if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { // managemetnSystem_.setEndSimulation(); break; } // process the received event processRequest(ev); sim_get_next(ev); } } protected void processRequest(Sim_event ev) { switch (ev.get_tag()) { case GridSimTags.GRIDLET_SUBMIT: break; default: break; } } public void send(String entityName, double delay, int gridSimTag, Object data){ super.send(entityName, delay, gridSimTag, data); } public void send(int entityID, double delay, int gridSimTag){ super.send(entityID, delay, gridSimTag); } public void send(int entityID, double delay, int gridSimTag, Object data){ super.send(entityID, delay, gridSimTag, data); } public void send(Sim_port destPort, double delay, int gridSimTag, Object data) { super.send(destPort, delay, gridSimTag, data); } public void sendInternal(double delay, int gridSimTag, Object data) { this.send(this.get_id(), delay, gridSimTag, data); } public void notifLogicalResources(){ for(LogicalResource lr : logicalStructure.getChildren()){ send(lr.get_name(), 0.0, GssimTags.UPDATE); } } }