@Override protected List<Cloudlet> createCloudlets() { final SwfWorkloadFileReader reader = SwfWorkloadFileReader.getInstance("METACENTRUM-2009-2.swf", 1); reader.setPredicate(cloudlet -> cloudlet.getLength() > 1000); reader.setMaxLinesToRead(CLOUDLETS); final List<Cloudlet> list = reader.generateWorkload(); System.out.printf("Created %d Cloudlets from the workload file\n", list.size()); return list; }
/** * Generates a list of jobs ({@link Cloudlet Cloudlets}) to be executed, * if it wasn't generated yet. * * @return a generated Cloudlet list */ public List<Cloudlet> generateWorkload() { if (cloudlets.isEmpty()) { readFile(this::createCloudletFromTraceLine); } return cloudlets; }
@Override protected List<Cloudlet> createCloudlets() { final SwfWorkloadFileReader reader = SwfWorkloadFileReader.getInstance("METACENTRUM-2009-2.swf", 1); reader.setMaxLinesToRead(70); return reader.generateWorkload(); }
/** * Create a new SwfWorkloadFileReader object. * * @param filePath the workload trace file path in one of the following formats: <i>ASCII text, zip, gz.</i> * @param reader a {@link InputStreamReader} object to read the file * @param mips the MIPS capacity of the PEs from the VM where each created Cloudlet is supposed to run. * Considering the workload reader provides the run time for each * application registered inside the reader, the MIPS value will be used * to compute the {@link Cloudlet#getLength() length of the Cloudlet (in MI)} * so that it's expected to execute, inside the VM with the given MIPS capacity, * for the same time as specified into the workload reader. * @throws IllegalArgumentException when the workload trace file name is null or empty; or the resource PE mips <= 0 * @see #getInstance(String, int) */ private SwfWorkloadFileReader(final String filePath, final InputStream reader, final int mips) { super(filePath, reader); this.setMips(mips); this.cloudlets = new ArrayList<>(); /* A default predicate which indicates that a Cloudlet will be created for any job read from the workload reader. That is, there isn't an actual condition to create a Cloudlet. */ this.predicate = cloudlet -> true; }
/** * Gets a {@link SwfWorkloadFileReader} instance from a workload file * inside the <b>application's resource directory</b>. * Use the available constructors if you want to load a file outside the resource directory. * * @param fileName the workload trace <b>relative file name</b> in one of the following formats: <i>ASCII text, zip, gz.</i> * @param mips the MIPS capacity of the PEs from the VM where each created Cloudlet is supposed to run. * Considering the workload reader provides the run time for each * application registered inside the reader, the MIPS value will be used * to compute the {@link Cloudlet#getLength() length of the Cloudlet (in MI)} * so that it's expected to execute, inside the VM with the given MIPS capacity, * for the same time as specified into the workload reader. * @throws IllegalArgumentException when the workload trace file name is null or empty; or the resource PE mips <= 0 * @throws UncheckedIOException when the file cannot be accessed (such as when it doesn't exist) */ public static SwfWorkloadFileReader getInstance(final String fileName, final int mips) { final InputStream reader = ResourceLoader.getInputStream(fileName, SwfWorkloadFileReader.class); return new SwfWorkloadFileReader(fileName, reader, mips); }
final int numProc = Math.max(maxNumProc, 1); final Cloudlet cloudlet = createCloudlet(id, runTime, numProc); final long submitTime = Long.parseLong(parsedLineArray[this.SUBMIT_TIME_INDEX].trim()); cloudlet.setSubmissionDelay(submitTime);
private void createCloudletsFromWorkloadFile() { final String fileName = WORKLOAD_BASE_DIR + WORKLOAD_FILENAME; SwfWorkloadFileReader reader = SwfWorkloadFileReader.getInstance(fileName, CLOUDLETS_MIPS); reader.setMaxLinesToRead(maximumNumberOfCloudletsToCreateFromTheWorkloadFile); this.cloudletList = reader.generateWorkload(); System.out.printf("# Created %d Cloudlets for %s\n", this.cloudletList.size(), broker); }