/** * Gets a {@link BufferedReader} to read a resource (a file or sub-directory inside the resources directory) * from its absolute path. * * @param klass a class from the project that will be used just to assist in getting the path of the given resource * @param resourceName the name of the resource to get a {@link BufferedReader} for it * @return a {@link BufferedReader} to read the resource * @throws FileNotFoundException when the file doesn't exist */ public static BufferedReader getBufferedReader(final Class klass, final String resourceName) { return new BufferedReader(new InputStreamReader(getInputStream(resourceName, klass))); }
/** * Instantiates a Network Topology from a file inside the <b>application's resource directory</b>. * @param fileName the <b>relative name</b> of the BRITE file * @return the BriteNetworkTopology instance. */ public static BriteNetworkTopology getInstance(final String fileName){ final InputStreamReader reader = new InputStreamReader(ResourceLoader.getInputStream(fileName, BriteNetworkTopology.class)); return new BriteNetworkTopology(reader); }
/** * Gets an {@link SlaContract} from a JSON file inside the <b>application's resource directory</b>. * @param jsonFilePath the <b>relative path</b> to the JSON file representing the SLA contract to read * @return a {@link SlaContract} read from the JSON file */ public static SlaContract getInstance(final String jsonFilePath) { return getInstanceInternal(ResourceLoader.getInputStream(jsonFilePath, SlaContract.class)); }
/** * Gets an AWS EC2 Instance from a JSON 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 jsonFilePath the <b>relative path</b> to the JSON file representing the template with * configurations for an AWS EC2 Instance * @return the AWS EC2 Instance from the JSON file */ public static AwsEc2Template getInstance(final String jsonFilePath) { final InputStreamReader reader = new InputStreamReader(ResourceLoader.getInputStream(jsonFilePath, AwsEc2Template.class)); return getInstanceInternal(jsonFilePath, reader); }
/** * Instantiates a new PlanetLab resource utilization model from a trace * file inside the <b>application's resource directory</b>. * * @param traceFilePath the <b>relative path</b> of a PlanetLab Datacenter trace file. * @param schedulingInterval the time interval in which precise utilization can be got from the file * @throws NumberFormatException the number format exception * @see #getSchedulingInterval() */ public static UtilizationModelPlanetLab getInstance(final String traceFilePath, final double schedulingInterval) { final InputStreamReader reader = new InputStreamReader(ResourceLoader.getInputStream(traceFilePath, UtilizationModelPlanetLab.class)); return new UtilizationModelPlanetLab(reader, schedulingInterval, DATA_SAMPLES); }
/** * Gets a {@link GoogleTaskUsageTraceReader} instance to read a "task usage" trace file * inside the <b>application's resource directory</b>. * * @param brokers a list of {@link DatacenterBroker}s that own running Cloudlets for which * resource usage will be read from the trace. * @param filePath the workload trace <b>relative file name</b> in one of the following formats: <i>ASCII text, zip, gz.</i> * @throws IllegalArgumentException when the trace file name is null or empty * @throws UncheckedIOException when the file cannot be accessed (such as when it doesn't exist) * @see #process() */ public static GoogleTaskUsageTraceReader getInstance( final List<DatacenterBroker> brokers, final String filePath) { final InputStream reader = ResourceLoader.getInputStream(filePath, GoogleTaskUsageTraceReader.class); return new GoogleTaskUsageTraceReader(brokers, filePath, reader); }
/** * 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); }
/** * Gets a {@link GoogleTaskEventsTraceReader} instance to read a "task events" trace file * inside the <b>application's resource directory</b>. * * @param simulation the simulation instance that the created tasks and brokers will belong to. * @param filePath the workload trace <b>relative file name</b> in one of the following formats: <i>ASCII text, zip, gz.</i> * @param cloudletCreationFunction A {@link Function} that will be called for every {@link Cloudlet} to be created * from a line inside the trace file. * The {@link Function} will receive a {@link TaskEvent} object containing * the task data read from the trace and must return a new Cloudlet * according to such data. * @throws IllegalArgumentException when the trace file name is null or empty * @throws UncheckedIOException when the file cannot be accessed (such as when it doesn't exist) * @see #process() */ public static GoogleTaskEventsTraceReader getInstance( final CloudSim simulation, final String filePath, final Function<TaskEvent, Cloudlet> cloudletCreationFunction) { final InputStream reader = ResourceLoader.getInputStream(filePath, GoogleTaskEventsTraceReader.class); return new GoogleTaskEventsTraceReader(simulation, filePath, reader, cloudletCreationFunction); }
/** * Gets a {@link GoogleMachineEventsTraceReader} instance to read a "machine events" trace file * inside the <b>application's resource directory</b>. * Created Hosts will have 16GB of maximum RAM and the maximum of 8 {@link Pe}s. * Use the available constructors if you want to load a file outside the resource directory. * * @param filePath the workload trace <b>relative file name</b> in one of the following formats: <i>ASCII text, zip, gz.</i> * @param hostCreationFunction A {@link Function} that will be called for every {@link Host} to be created * from a line inside the trace file. * The {@link Function} will receive a {@link MachineEvent} object containing * the Host data read from the trace and must return the created Host * according to such data. * @throws IllegalArgumentException when the trace file name is null or empty * @throws UncheckedIOException when the file cannot be accessed (such as when it doesn't exist) * @see #setMaxRamCapacity(long) * @see #setMaxCpuCores(int) * @see #process() */ public static GoogleMachineEventsTraceReader getInstance( final String filePath, final Function<MachineEvent, Host> hostCreationFunction) { final InputStream reader = ResourceLoader.getInputStream(filePath, GoogleMachineEventsTraceReader.class); return new GoogleMachineEventsTraceReader(filePath, reader, hostCreationFunction); }