use of org.iobserve.planning.data.PlanningData in project iobserve-analysis by research-iobserve.
the class PlanningMain method main.
public static void main(final String[] args) throws IOException, InitializationException, ModelHandlingErrorException {
final CommandLineParser parser = new DefaultParser();
final String workingDir;
final String perOpteryxDir;
final CommandLine commandLine;
try {
for (final String arg : args) {
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("arg: " + arg);
}
}
commandLine = parser.parse(PlanningMain.createOptions(), args);
workingDir = commandLine.getOptionValue(PlanningMain.INPUT_WORKING_DIR_OPTION);
perOpteryxDir = commandLine.getOptionValue(PlanningMain.PEROPTERYX_DIR_OPTION);
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("Working dir: " + workingDir + ", PerOpteryx dir: " + perOpteryxDir);
}
} catch (final ParseException exp) {
// LOG.error("CLI error: " + exp.getMessage());
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("planning", PlanningMain.createOptions());
return;
}
final URI modelURI = URI.createFileURI(workingDir);
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("modelURI: " + modelURI);
}
final URI perOpteryxURI = URI.createFileURI(perOpteryxDir);
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("perOpteryxURI: " + perOpteryxURI);
PlanningMain.LOGGER.info("lqnsURI: " + perOpteryxURI);
}
PalladioEclipseEnvironment.INSTANCE.setup();
if (!commandLine.hasOption(PlanningMain.CREATE_RESOURCEENVIRONMENT_OPTION)) {
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("Executing optimization...");
}
final AdaptationData adaptationData = new AdaptationData();
adaptationData.setRuntimeModelURI(modelURI);
final PlanningData planningData = new PlanningData();
planningData.setAdaptationData(adaptationData);
planningData.setOriginalModelDir(modelURI);
planningData.setPerOpteryxDir(perOpteryxURI);
// Process model
final ModelTransformer transformer = new ModelTransformer(planningData);
transformer.transformModel();
// Execute PerOpteryx
final int result = 0;
if (result == 0) {
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("Optimization was successful.");
}
} else {
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("Optimization failed.");
}
}
} else {
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("Creating ResourceEnvironment...");
}
final PCMModelHandler modelHandler = new PCMModelHandler(new File(workingDir));
ModelHelper.fillResourceEnvironmentFromCloudProfile(org.eclipse.emf.common.util.URI.createFileURI(workingDir), modelHandler);
if (PlanningMain.LOGGER.isInfoEnabled()) {
PlanningMain.LOGGER.info("ResourceEnvironment successfully created.");
}
}
}
use of org.iobserve.planning.data.PlanningData in project iobserve-analysis by research-iobserve.
the class ModelProcessing method execute.
@Override
protected void execute(final URI element) throws Exception {
CandidateGeneration.LOG.info("Model Processing");
final PlanningData planningData = new PlanningData();
final AdaptationData adaptationData = new AdaptationData();
adaptationData.setRuntimeModelURI(element);
planningData.setAdaptationData(adaptationData);
planningData.setPerOpteryxDir(this.perOpteryxDir);
planningData.setOriginalModelDir(element);
planningData.setLqnsDir(this.lqnsDir);
final File directory = new File(adaptationData.getReDeploymentURI().toFileString());
final PCMModelHandler models = new PCMModelHandler(directory);
final SnapshotBuilder snapshotBuilder = new SnapshotBuilder(ModelProcessing.PROCESSED_MODEL_FOLDER, models);
final URI snapshotLocation = snapshotBuilder.createSnapshot();
planningData.setProcessedModelDir(snapshotLocation);
final ModelTransformer modelTransformer = new ModelTransformer(planningData);
modelTransformer.transformModel();
this.outputPort.send(planningData);
}
Aggregations