/** * Creates instances of CloudSim's PowerDatacenter class from a list of datacenter registries. * * @param dcrList a list of datacenter registries. * @return a map containing names of datacenters as keys and PowerDatacenter instances as values. * @since 1.0 */ static HashMap<String, PowerDatacenter> createDatacenters() { List<DatacenterRegistry> dcrList = DatacenterRegistryBusiness.getListOfDatacenters(); HashMap<String, PowerDatacenter> map = new HashMap<String, PowerDatacenter>(); for (DatacenterRegistry dcr : dcrList) { List<PowerHost> hostList = createHosts(dcr.getHostList()); if (hostList == null) { return null; } DatacenterCharacteristics chars = new DatacenterCharacteristics( dcr.getArchitecture(), dcr.getOs(), dcr.getVmm(), hostList, dcr.getTimeZone(), dcr.getCostPerSec(), dcr.getCostPerMem(), dcr.getCostPerStorage(), dcr.getCostPerBw()); LinkedList<Storage> storageList = createStorageList(dcr.getSanList()); try { Optional<VmAllocationPolicy> allocationPolicy = VM_ALLOCATION_POLICY.getExtensionInstanceByName( dcr.getAllocationPolicyAlias(), hostList, dcr); if (!allocationPolicy.isPresent()) { Dialog.showErrorMessage( null, format( "Error on loading the allocation policy [%s]", dcr.getAllocationPolicyAlias())); return null; } PowerDatacenter newDC = new PowerDatacenter( dcr.getName(), chars, allocationPolicy.get(), storageList, dcr.getSchedulingInterval(), dcr.getMonitoringInterval()); newDC.setDisableMigrations(!dcr.isVmMigration()); map.put(dcr.getName(), newDC); } catch (Exception ex) { LOG.error("Error on creating data centers. Error message: [{}]", ex.getMessage(), ex); } } return map; }
public void readFile() throws IOException { try { FileInputStream fstream = new FileInputStream("dataIn.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; int memi = -1; int strLineMemory = 59; while ((strLine = br.readLine()) != null) { t.data[strLineMemory++][1] = String.valueOf(strLine); memi++; size++; while ((strLine = br.readLine()) != null && !strLine.startsWith("*")) { String[] arr = strLine.split(" "); String command = arr[0]; String operand = arr[1]; toMemory(command, operand, memarray[memi]); memarray[memi] = memarray[memi] + 2; System.out.printf("%s %s ", command, operand); } } in.close(); } catch (Exception e) { // Catch exception if any System.err.println("Error: " + e.getMessage()); } MOSMain mos = new MOSMain(); mos.planner(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); t.setSize(830, 800); t.setVisible(true); t.setTitle("Printer"); sortTime(); }