package test.rewolucja.scheduling; import eduni.simjava.Sim_event; import eduni.simjava.Sim_type_p; import gridsim.GridSimTags; import gridsim.IO_data; import gridsim.gssim.GssimTags; import java.util.ArrayList; import java.util.List; import java.util.Properties; import schedframe.exceptions.CandidateHostsNotFoundException; import schedframe.resources.ResourceDescription; import schedframe.resources.ResourceProvider; import schedframe.scheduling.AbstractResourceRequirements; import schedframe.scheduling.SecurityContextInterface; import schedframe.scheduling.plugin.grid.ModuleType; import schedframe.scheduling.plugin.grid.ResourceDiscovery; import test.rewolucja.resources.ResourceCharacteristics; import test.rewolucja.resources.ResourceStatus; import test.rewolucja.resources.ResourceType; import test.rewolucja.resources.exception.ResourceException; import test.rewolucja.resources.logical.LogicalResource; import test.rewolucja.resources.manager.interfaces.ResourceManagerInterface; import test.rewolucja.resources.physical.base.ComputingResource; public class GridResourceDiscovery implements ResourceManagerInterface, ResourceDiscovery { protected LogicalResource brokerResource; public GridResourceDiscovery(LogicalResource broker){ this.brokerResource = broker; } public List getAdministrationDomains(SecurityContextInterface secContext) { throw new RuntimeException("Not implemented."); } public List getProviders(SecurityContextInterface secContext) { throw new RuntimeException("Not implemented."); } public List getProviders(String admDomain, SecurityContextInterface secContext) { throw new RuntimeException("Not implemented."); } public ResourceDescription getResources( AbstractResourceRequirements reqDesc, SecurityContextInterface secContext) { throw new RuntimeException("Not implemented."); } public List getProviders( AbstractResourceRequirements reqDesc, SecurityContextInterface secContext) { throw new RuntimeException("Not implemented."); } public List getProviders( AbstractResourceRequirements reqDesc, List candidateHosts, SecurityContextInterface secContext) throws CandidateHostsNotFoundException { throw new RuntimeException("Not implemented"); } public List getResources(SecurityContextInterface secContext) { List resourceList = brokerResource.getChildren(); for(int i = 0; i < resourceList.size(); i++){ int resourceId = resourceList.get(i).get_id(); brokerResource.send(resourceId, GridSimTags.SCHEDULE_NOW, GssimTags.QUERY_RESOURCE_DESC, null); } //filter only the query response messages Sim_type_p pred = new Sim_type_p(GssimTags.QUERY_RESOURCE_DESC_RESULT); Sim_event ev = new Sim_event(); List result = new ArrayList(resourceList.size()); for (int i = 0; i < resourceList.size(); ++i) { brokerResource.sim_get_next(pred , ev); IO_data ioData = (IO_data) ev.get_data(); ResourceDescription resDesc = (ResourceDescription) ioData.getData(); result.add(resDesc); } return result; } public void dispose() { } public ModuleType getType() { return ModuleType.RESOURCE_DISCOVERY; } public void init(Properties properties) { } public List getResources() { for(int i = 0; i < brokerResource.getChildren().size(); i++){ int resourceId = brokerResource.getChildren().get(i).get_id(); brokerResource.send(resourceId, GridSimTags.SCHEDULE_NOW, GssimTags.QUERY_RESOURCE_DESC, null); } //filter only the query response messages Sim_type_p pred = new Sim_type_p(GssimTags.QUERY_RESOURCE_DESC_RESULT); Sim_event ev = new Sim_event(); List result = new ArrayList(brokerResource.getChildren().size()); for (int i = 0; i < brokerResource.getChildren().size(); ++i) { brokerResource.sim_get_next(pred , ev); IO_data ioData = (IO_data) ev.get_data(); ResourceDescription resDesc = (ResourceDescription) ioData.getData(); result.add(resDesc); } return result; } @Override public List getResourceProviders() { return brokerResource.getChildren(); } @Override public boolean areResourcesAchievable(ResourceType type) { throw new RuntimeException("Not available at Grid level. Please use getResourceProviders() method instead to explore available resource providers"); } @Override public List getResourcesOfType(ResourceType type) throws ResourceException { throw new RuntimeException("Not available at Grid level. Please use getResourceProviders() method instead to explore available resource providers"); } @Override public ComputingResource getResourceByName(String resourceName) { throw new RuntimeException("Not available at Grid level. Please use getResourceProviders() method instead to explore available resource providers"); } @Override public List getResourcesOfTypeWithStatus(ResourceType type, ResourceStatus status) throws ResourceException { throw new RuntimeException("Not available at Grid level. Please use getResourceProviders() method instead to explore available resource providers"); } @Override public ResourceCharacteristics getResourceCharacteristic() { throw new RuntimeException("Not available at Grid level. Please use getResourceProviders() method instead to explore available resource providers"); } @Override public List filterResources(Properties properties) { throw new RuntimeException("Not available at Grid level. Please use getResourceProviders() method instead to explore available resource providers"); } @Override public String getResourceProvider(String providerName) { throw new RuntimeException("Not available at Grid level. Please use getResourceProviders() method instead to explore available resource providers"); } }