diff --git a/tools.descartes.pmx.console/src/tools/descartes/pmx/console/PMXCommandLine.java b/tools.descartes.pmx.console/src/tools/descartes/pmx/console/PMXCommandLine.java index 75747f784869c16dd753b7a4996cc74ff5b48760..976ccd86d0386aacb2b8659624f8704aae30d95f 100644 --- a/tools.descartes.pmx.console/src/tools/descartes/pmx/console/PMXCommandLine.java +++ b/tools.descartes.pmx.console/src/tools/descartes/pmx/console/PMXCommandLine.java @@ -165,14 +165,14 @@ public class PMXCommandLine { private PMXController createPMX() { try { - String inputDir = getInputDir(); + String[] inputDirs = getInputDirs(); Configuration pmxConfiguration = new Configuration(); AnalysisController analysisController = new AnalysisController(pmxConfiguration); - registerFSReader(analysisController, inputDir); + registerFSReader(analysisController, inputDirs); String outputDir = commandLine.getOptionValue(CMD_LONG_OPT_OUTPUT_DIR); if(outputDir == null){ - outputDir = inputDir; + outputDir = inputDirs[0]; log.info("No output directory specified. Logging to input directory."); } @@ -197,24 +197,27 @@ public class PMXCommandLine { } - private String getInputDir() { - String inputDir = commandLine.getOptionValue(CMD_LONG_OPT_INPUT_DIR); - if (inputDir == null) { - log.info("missing value for command line option '" + CMD_LONG_OPT_INPUT_DIR + "'"); - System.exit(1); - } else if (!new File(inputDir).exists()) { - log.info("File does not exist: " + CMD_LONG_OPT_INPUT_DIR); - log.info("\tcurrent:" + System.getProperty("user.dir")); - log.info("\trequested:" +inputDir); - System.exit(1); // or other exit code? + private String[] getInputDirs() { + String inputDirCmd = commandLine.getOptionValue(CMD_LONG_OPT_INPUT_DIR); + String[] inputDirs = inputDirCmd.split(";"); + for(int idx = 0; idx < inputDirs.length; idx++) { + final String inputDir = inputDirs[idx]; + if (inputDir == null) { + log.info("missing value for command line option '" + CMD_LONG_OPT_INPUT_DIR + "'"); + System.exit(1); + } else if (!new File(inputDir).exists()) { + log.info("File does not exist: " + CMD_LONG_OPT_INPUT_DIR); + log.info("\tcurrent:" + System.getProperty("user.dir")); + log.info("\trequested:" +inputDir); + System.exit(1); // or other exit code? + } } - return inputDir; + + return inputDirs; } - private static FSReader registerFSReader(IAnalysisController analysisInstance, final String kiekerTraceFile) { - String[] inputDirs; - inputDirs = new String[1]; - inputDirs[0] = kiekerTraceFile; + private static FSReader registerFSReader(IAnalysisController analysisInstance, final String[] kiekerTraceFiles) { + final String[] inputDirs = kiekerTraceFiles; // if (new File(kiekerTraceFile).getName().startsWith("kieker-")) { // inputDirs = new String[1]; @@ -324,7 +327,7 @@ public class PMXCommandLine { private String parseOutputDir() { String outputDir = commandLine.getOptionValue(CMD_LONG_OPT_OUTPUT_DIR); if (outputDir == null) { - outputDir = getInputDir(); + outputDir = getInputDirs()[0]; log.info("No output directory specified. Logging to input directory."); } return outputDir; diff --git a/tools.descartes.pmx.pcm.builder/src/tools/descartes/pmx/pcm/builder/PCMSEFFFactory.java b/tools.descartes.pmx.pcm.builder/src/tools/descartes/pmx/pcm/builder/PCMSEFFFactory.java index 477dda5d92ae81bc53dbb87e3cb6209cb2a37440..c15fc3c6d5d50cd64a2a289c41bee56da6934067 100644 --- a/tools.descartes.pmx.pcm.builder/src/tools/descartes/pmx/pcm/builder/PCMSEFFFactory.java +++ b/tools.descartes.pmx.pcm.builder/src/tools/descartes/pmx/pcm/builder/PCMSEFFFactory.java @@ -61,263 +61,274 @@ import tools.descartes.pmx.filter.controlflow.ExternalCall; import tools.descartes.pmx.filter.util.Util; public class PCMSEFFFactory { - private static final Logger log = Logger.getLogger(PCMSEFFFactory.class); - - public static ResourceDemandingSEFF createSEFF(IModelBuilder builder, BasicComponent component, Signature signature, - List<ExternalCall> externalCalls, ResourceContainer host, double meanResourceDemand) { - - ResourceDemandingSEFF seff = SeffFactory.eINSTANCE.createResourceDemandingSEFF(); - seff.setBasicComponent_ServiceEffectSpecification(component); - seff.setDescribedService__SEFF(signature); - - // create start, stop and branchAction - StartAction startAction = SeffFactory.eINSTANCE.createStartAction(); - startAction.setEntityName("startAction"); - seff.getSteps_Behaviour().add(startAction); - - AbstractAction currentAction; - AbstractAction nextAction; - double minimumResourceDemandThreshhold = 0.00; - if (meanResourceDemand > minimumResourceDemandThreshhold) { - InternalAction internalAction = SeffFactory.eINSTANCE.createInternalAction(); - internalAction.setEntityName("method internal"); - seff.getSteps_Behaviour().add(internalAction); - - addResourceDemand(internalAction, meanResourceDemand, host); - - connectActions(startAction, internalAction); - - currentAction = internalAction; - } else { - currentAction = startAction; - } - - /** - * Loops [total average calls] times choosing the transaction - * probability based - */ - - double totalAverageCalls = 0; - for (ExternalCall externalCall : externalCalls) { - totalAverageCalls += externalCall.getNumCalls(); - } - - // TODO check if methodNames are the same (signature.getEntityName() == - // externalCall.getMethodName()) ==> inheritance - for (ExternalCall call : externalCalls) { - if (signature == null) { - log.error("signature is null"); - } else { - log.info(signature.getEntityName()); - log.info(call.getMethodName()); - if (signature.getEntityName().endsWith(call.getMethodName())) { - log.info("Same interface: " + component.getEntityName() + " and " + call.getClassName() + " (" - + call.getMethodName() + ")" + "<== Candidate for inheritance"); - OperationInterface op = (OperationInterface) builder - .getInterface("I" + ModelBuilder.applyComponentNameFix(component.getEntityName())); - } - } - } - - if (externalCalls.size() > 1) { - if (totalAverageCalls >= 1) { - if (totalAverageCalls == 1) { - nextAction = createBranchAction(builder, component, seff, externalCalls); - } else { - nextAction = createLoopActionIncludingInternalBranchingAction(builder, component, seff, - externalCalls); - } - connectActions(currentAction, nextAction); - currentAction = nextAction; - } - } else if (externalCalls.size() == 1) { - if (totalAverageCalls >= 1) { - if (totalAverageCalls == 1) { - nextAction = createExternalCallAction(builder, component, seff, externalCalls.get(0)); - } else { - nextAction = createLoopAction(builder, component, seff, externalCalls.get(0)); - } - connectActions(currentAction, nextAction); - currentAction = nextAction; - } - } - - StopAction stopAction = SeffFactory.eINSTANCE.createStopAction(); - stopAction.setEntityName("stopAction"); - seff.getSteps_Behaviour().add(stopAction); - connectActions(currentAction, stopAction); - return seff; - } - - private static AbstractAction createLoopActionIncludingInternalBranchingAction(IModelBuilder builder, - BasicComponent component, ResourceDemandingSEFF seff, List<ExternalCall> externalCalls) { - LoopAction loopAction = SeffFactory.eINSTANCE.createLoopAction(); - PCMRandomVariable iterationCount = CoreFactory.eINSTANCE.createPCMRandomVariable(); - double totalAverageCalls = 0; - for (ExternalCall externalCall : externalCalls) { - totalAverageCalls += externalCall.getNumCalls(); - } - iterationCount.setSpecification("" + (int) Math.ceil(totalAverageCalls)); - loopAction.setIterationCount_LoopAction(iterationCount); - loopAction.setEntityName("Loop action with internal branch actions"); - seff.getSteps_Behaviour().add(loopAction); - - ResourceDemandingBehaviour resourceDemandingBehaviour = SeffFactory.eINSTANCE - .createResourceDemandingBehaviour(); - - StartAction startAction = SeffFactory.eINSTANCE.createStartAction(); - startAction.setEntityName("startAction"); - resourceDemandingBehaviour.getSteps_Behaviour().add(startAction); - - AbstractAction externalAction = null; - if (externalCalls.size() > 1) { - externalAction = createBranchAction(builder, component, seff, externalCalls); - } else if (externalCalls.size() == 1) { - externalAction = createExternalCallAction(builder, component, seff, externalCalls.get(0)); - } - resourceDemandingBehaviour.getSteps_Behaviour().add(externalAction); - connectActions(startAction, externalAction); - - StopAction stopAction = SeffFactory.eINSTANCE.createStopAction(); - stopAction.setEntityName("stopAction"); - resourceDemandingBehaviour.getSteps_Behaviour().add(stopAction); - connectActions(externalAction, stopAction); - - resourceDemandingBehaviour.setAbstractLoopAction_ResourceDemandingBehaviour(loopAction); - - return loopAction; - } - - private static AbstractAction createBranchAction(IModelBuilder builder, BasicComponent component, - ResourceDemandingSEFF seff, List<ExternalCall> externalCalls) { - BranchAction branchAction = SeffFactory.eINSTANCE.createBranchAction(); - branchAction.setEntityName("external branching"); - seff.getSteps_Behaviour().add(branchAction); - - double totalCalls = 0; - for (ExternalCall externalCall : externalCalls) { - totalCalls += externalCall.getNumCalls(); - } - - for (ExternalCall externalCall : externalCalls) { - branchAction.getBranches_Branch() - .add(getBranchTransition(builder, component, externalCall, (int) totalCalls)); - } - - /** Quick and dirty rounding error fix */ - if (((ProbabilisticBranchTransition) branchAction.getBranches_Branch().get(0)) - .getBranchProbability() == 0.3333333333333333) { - ((ProbabilisticBranchTransition) branchAction.getBranches_Branch().get(0)) - .setBranchProbability(0.3333333333333334); - } - return branchAction; - } - - private static AbstractBranchTransition getBranchTransition(IModelBuilder builder, BasicComponent component, - ExternalCall externalCall, int totalCalls) { - // Guarded uses BranchCondition (e.g. file type) - // AbstractBranchTransition branchTransition = - // SeffFactory.eINSTANCE.createGuardedBranchTransition(); - ProbabilisticBranchTransition branchTransition = SeffFactory.eINSTANCE.createProbabilisticBranchTransition(); - branchTransition.setEntityName("" + externalCall.getClassName() + " " + externalCall.getMethodName()); - double probability = externalCall.getNumCalls() / totalCalls; - branchTransition.setBranchProbability(probability); - - ResourceDemandingBehaviour resourceDemandingBehaviour = createResourceDemandingBehaviorWithExternalAction( - builder, component, externalCall); - branchTransition.setBranchBehaviour_BranchTransition(resourceDemandingBehaviour); - - return branchTransition; - } - - private static AbstractAction createLoopAction(IModelBuilder builder, BasicComponent component, - ResourceDemandingSEFF seff, ExternalCall externalCall) { - LoopAction loopAction = SeffFactory.eINSTANCE.createLoopAction(); - PCMRandomVariable iterationCount = CoreFactory.eINSTANCE.createPCMRandomVariable(); - iterationCount.setSpecification("" + (int) (Math.ceil(externalCall.getNumCalls()))); - loopAction.setIterationCount_LoopAction(iterationCount); - loopAction.setEntityName(externalCall.getClassName() + "." + externalCall.getMethodName() + "Loop"); // loop - // iteration - // has - // to - // be - // int - seff.getSteps_Behaviour().add(loopAction); - - ResourceDemandingBehaviour resourceDemandingBehaviour = createResourceDemandingBehaviorWithExternalAction( - builder, component, externalCall); - - resourceDemandingBehaviour.setAbstractLoopAction_ResourceDemandingBehaviour(loopAction); - - return loopAction; - } - - private static ResourceDemandingBehaviour createResourceDemandingBehaviorWithExternalAction(IModelBuilder builder, - BasicComponent component, ExternalCall externalCall) { - ResourceDemandingBehaviour resourceDemandingBehaviour = SeffFactory.eINSTANCE - .createResourceDemandingBehaviour(); - - StartAction startAction = SeffFactory.eINSTANCE.createStartAction(); - startAction.setEntityName("startAction"); - resourceDemandingBehaviour.getSteps_Behaviour().add(startAction); - - AbstractAction externalCallAction = createExternalCallAction(builder, component, resourceDemandingBehaviour, - externalCall); - resourceDemandingBehaviour.getSteps_Behaviour().add(externalCallAction); - connectActions(startAction, externalCallAction); - - StopAction stopAction = SeffFactory.eINSTANCE.createStopAction(); - stopAction.setEntityName("stopAction"); - resourceDemandingBehaviour.getSteps_Behaviour().add(stopAction); - connectActions(externalCallAction, stopAction); - return resourceDemandingBehaviour; - } - - private static AbstractAction createExternalCallAction(IModelBuilder builder, BasicComponent component, - ResourceDemandingBehaviour seff, ExternalCall externalCall) { - ExternalCallAction externalCallAction = SeffFactory.eINSTANCE.createExternalCallAction(); - externalCallAction.setEntityName(externalCall.getClassName() + "." + externalCall.getMethodName()); - externalCallAction.setCalledService_ExternalService( - (OperationSignature) builder.getMethod(Util.createMethodKey(externalCall.getMethodName(), - ModelBuilder.applyComponentNameFix(externalCall.getClassName())))); - builder.addRequiredRole(component.getEntityName(), "I"+externalCall.getClassName()); - OperationRequiredRole role = (OperationRequiredRole) builder.getRole("Required_" + "I" - + externalCall.getClassName() + ModelBuilder.seperatorChar + component.getEntityName()); - externalCallAction.setRole_ExternalService(role); - seff.getSteps_Behaviour().add(externalCallAction); - - return externalCallAction; - } - - private static void addResourceDemand(InternalAction action, double meanResourceDemand, ResourceContainer host) { - ParametricResourceDemand parametricResourceDemand = SeffPerformanceFactory.eINSTANCE - .createParametricResourceDemand(); - EList<ProcessingResourceSpecification> resources = host.getActiveResourceSpecifications_ResourceContainer(); - ProcessingResourceType cpu = resources.get(0).getActiveResourceType_ActiveResourceSpecification(); - - parametricResourceDemand.setRequiredResource_ParametricResourceDemand(cpu); - parametricResourceDemand.setAction_ParametricResourceDemand(action); - PCMRandomVariable randomVariable = CoreFactory.eINSTANCE.createPCMRandomVariable(); - // Expression x = randomVariable.getExpression(); - // randomVariable.setVariableCharacterisation_Specification(x); - // randomVariable.setSpecification("IntPMF[(5; 0.0)(10; 0.051)(20; - // 0.134)(30; 0.193)(40; 0.212)(50; 0.224)(60; 0.186)]*100000"); - // randomVariable.setSpecification("IntPMF["+"("+Double.toString(meanResourceDemand)+";1)"+"]"); - randomVariable.setSpecification(Double.toString(meanResourceDemand)); - parametricResourceDemand.setSpecification_ParametericResourceDemand(randomVariable); - } - - private static void connectActions(AbstractAction startAction, AbstractAction stopAction) { - if (startAction == null) { - log.warn("StartAction == null"); - } - if (stopAction == null) { - log.warn("StopAction == null"); - } - - startAction.setSuccessor_AbstractAction(stopAction); - stopAction.setPredecessor_AbstractAction(startAction); - } + private static final Logger log = Logger.getLogger(PCMSEFFFactory.class); + private static final double DELTA = 1E-9; + + public static ResourceDemandingSEFF createSEFF(IModelBuilder builder, BasicComponent component, Signature signature, + List<ExternalCall> externalCalls, ResourceContainer host, double meanResourceDemand) { + + ResourceDemandingSEFF seff = SeffFactory.eINSTANCE.createResourceDemandingSEFF(); + seff.setBasicComponent_ServiceEffectSpecification(component); + seff.setDescribedService__SEFF(signature); + + // create start, stop and branchAction + StartAction startAction = SeffFactory.eINSTANCE.createStartAction(); + startAction.setEntityName("startAction"); + seff.getSteps_Behaviour().add(startAction); + + AbstractAction currentAction; + AbstractAction nextAction; + double minimumResourceDemandThreshhold = 0.00; + if (meanResourceDemand > minimumResourceDemandThreshhold) { + InternalAction internalAction = SeffFactory.eINSTANCE.createInternalAction(); + internalAction.setEntityName("method internal"); + seff.getSteps_Behaviour().add(internalAction); + + addResourceDemand(internalAction, meanResourceDemand, host); + + connectActions(startAction, internalAction); + + currentAction = internalAction; + } else { + currentAction = startAction; + } + + /** + * Loops [total average calls] times choosing the transaction probability based + */ + + double totalAverageCalls = 0; + for (ExternalCall externalCall : externalCalls) { + totalAverageCalls += externalCall.getNumCalls(); + } + + // TODO check if methodNames are the same (signature.getEntityName() == + // externalCall.getMethodName()) ==> inheritance + for (ExternalCall call : externalCalls) { + if (signature == null) { + log.error("signature is null"); + } else { + log.info(signature.getEntityName()); + log.info(call.getMethodName()); + if (signature.getEntityName().endsWith(call.getMethodName())) { + log.info("Same interface: " + component.getEntityName() + " and " + call.getClassName() + " (" + + call.getMethodName() + ")" + "<== Candidate for inheritance"); + OperationInterface op = (OperationInterface) builder + .getInterface("I" + ModelBuilder.applyComponentNameFix(component.getEntityName())); + } + } + } + + nextAction = createLoopActionIncludingInternalBranchingAction(builder, component, seff, externalCalls); + + connectActions(currentAction, nextAction); + currentAction = nextAction; + + StopAction stopAction = SeffFactory.eINSTANCE.createStopAction(); + stopAction.setEntityName("stopAction"); + seff.getSteps_Behaviour().add(stopAction); + connectActions(currentAction, stopAction); + return seff; + } + + private static AbstractAction createLoopActionIncludingInternalBranchingAction(IModelBuilder builder, + BasicComponent component, ResourceDemandingSEFF seff, List<ExternalCall> externalCalls) { + LoopAction loopAction = SeffFactory.eINSTANCE.createLoopAction(); + PCMRandomVariable iterationCount = CoreFactory.eINSTANCE.createPCMRandomVariable(); + iterationCount.setSpecification("1"); + loopAction.setIterationCount_LoopAction(iterationCount); + loopAction.setEntityName("Loop action with internal branch actions"); + seff.getSteps_Behaviour().add(loopAction); + + ResourceDemandingBehaviour resourceDemandingBehaviour = SeffFactory.eINSTANCE + .createResourceDemandingBehaviour(); + + StartAction startAction = SeffFactory.eINSTANCE.createStartAction(); + startAction.setEntityName("startAction"); + resourceDemandingBehaviour.getSteps_Behaviour().add(startAction); + + AbstractAction prevExternalAction = startAction; + for (final ExternalCall curExternalCall : externalCalls) { + AbstractAction curAction; + if (Math.abs(curExternalCall.getNumCalls() - 1) <= DELTA) { + curAction = createExternalCallAction(builder, component, seff, curExternalCall); + } else { + curAction = createExternalLoop(builder, component, seff, curExternalCall); + } + + resourceDemandingBehaviour.getSteps_Behaviour().add(curAction); + connectActions(prevExternalAction, curAction); + prevExternalAction = curAction; + } + + StopAction stopAction = SeffFactory.eINSTANCE.createStopAction(); + stopAction.setEntityName("stopAction"); + resourceDemandingBehaviour.getSteps_Behaviour().add(stopAction); + connectActions(prevExternalAction, stopAction); + + resourceDemandingBehaviour.setAbstractLoopAction_ResourceDemandingBehaviour(loopAction); + + return loopAction; + } + + private static LoopAction createExternalLoop(IModelBuilder builder, BasicComponent component, + ResourceDemandingSEFF seff, ExternalCall curExternalCall) { + LoopAction curLoop = SeffFactory.eINSTANCE.createLoopAction(); + int lower = (int) Math.floor(curExternalCall.getNumCalls()); + int upper = (int) Math.ceil(curExternalCall.getNumCalls()); + double upperProb = curExternalCall.getNumCalls() - lower; + PCMRandomVariable curIterationCount = CoreFactory.eINSTANCE.createPCMRandomVariable(); + if (lower != upper) { + curIterationCount.setSpecification( + "IntPMF[(" + lower + ";" + (1d - upperProb) + ")" + " (" + upper + ";" + upperProb + ")]"); + } else { + curIterationCount.setSpecification(Integer.toString(lower)); + } + curLoop.setIterationCount_LoopAction(curIterationCount); + ResourceDemandingBehaviour curBehaviour = SeffFactory.eINSTANCE.createResourceDemandingBehaviour(); + curBehaviour.setAbstractLoopAction_ResourceDemandingBehaviour(curLoop); + StartAction curStart = SeffFactory.eINSTANCE.createStartAction(); + curBehaviour.getSteps_Behaviour().add(curStart); + + AbstractAction curExternalAction = createExternalCallAction(builder, component, seff, curExternalCall); + curExternalAction.setPredecessor_AbstractAction(curStart); + curBehaviour.getSteps_Behaviour().add(curExternalAction); + StopAction curStopAction = SeffFactory.eINSTANCE.createStopAction(); + curExternalAction.setSuccessor_AbstractAction(curStopAction); + curBehaviour.getSteps_Behaviour().add(curStopAction); + return curLoop; + } + + private static AbstractAction createBranchAction(IModelBuilder builder, BasicComponent component, + ResourceDemandingSEFF seff, List<ExternalCall> externalCalls) { + BranchAction branchAction = SeffFactory.eINSTANCE.createBranchAction(); + branchAction.setEntityName("external branching"); + seff.getSteps_Behaviour().add(branchAction); + + double totalCalls = 0; + for (ExternalCall externalCall : externalCalls) { + totalCalls += externalCall.getNumCalls(); + } + + for (ExternalCall externalCall : externalCalls) { + branchAction.getBranches_Branch() + .add(getBranchTransition(builder, component, externalCall, (int) totalCalls)); + } + + /** Quick and dirty rounding error fix */ + if (((ProbabilisticBranchTransition) branchAction.getBranches_Branch().get(0)) + .getBranchProbability() == 0.3333333333333333) { + ((ProbabilisticBranchTransition) branchAction.getBranches_Branch().get(0)) + .setBranchProbability(0.3333333333333334); + } + return branchAction; + } + + private static AbstractBranchTransition getBranchTransition(IModelBuilder builder, BasicComponent component, + ExternalCall externalCall, int totalCalls) { + // Guarded uses BranchCondition (e.g. file type) + // AbstractBranchTransition branchTransition = + // SeffFactory.eINSTANCE.createGuardedBranchTransition(); + ProbabilisticBranchTransition branchTransition = SeffFactory.eINSTANCE.createProbabilisticBranchTransition(); + branchTransition.setEntityName("" + externalCall.getClassName() + " " + externalCall.getMethodName()); + double probability = externalCall.getNumCalls() / totalCalls; + branchTransition.setBranchProbability(probability); + + ResourceDemandingBehaviour resourceDemandingBehaviour = createResourceDemandingBehaviorWithExternalAction( + builder, component, externalCall); + branchTransition.setBranchBehaviour_BranchTransition(resourceDemandingBehaviour); + + return branchTransition; + } + + private static AbstractAction createLoopAction(IModelBuilder builder, BasicComponent component, + ResourceDemandingSEFF seff, ExternalCall externalCall) { + LoopAction loopAction = SeffFactory.eINSTANCE.createLoopAction(); + PCMRandomVariable iterationCount = CoreFactory.eINSTANCE.createPCMRandomVariable(); + iterationCount.setSpecification("" + (int) (Math.ceil(externalCall.getNumCalls()))); + loopAction.setIterationCount_LoopAction(iterationCount); + loopAction.setEntityName(externalCall.getClassName() + "." + externalCall.getMethodName() + "Loop"); // loop + // iteration + // has + // to + // be + // int + seff.getSteps_Behaviour().add(loopAction); + + ResourceDemandingBehaviour resourceDemandingBehaviour = createResourceDemandingBehaviorWithExternalAction( + builder, component, externalCall); + + resourceDemandingBehaviour.setAbstractLoopAction_ResourceDemandingBehaviour(loopAction); + + return loopAction; + } + + private static ResourceDemandingBehaviour createResourceDemandingBehaviorWithExternalAction(IModelBuilder builder, + BasicComponent component, ExternalCall externalCall) { + ResourceDemandingBehaviour resourceDemandingBehaviour = SeffFactory.eINSTANCE + .createResourceDemandingBehaviour(); + + StartAction startAction = SeffFactory.eINSTANCE.createStartAction(); + startAction.setEntityName("startAction"); + resourceDemandingBehaviour.getSteps_Behaviour().add(startAction); + + AbstractAction externalCallAction = createExternalCallAction(builder, component, resourceDemandingBehaviour, + externalCall); + resourceDemandingBehaviour.getSteps_Behaviour().add(externalCallAction); + connectActions(startAction, externalCallAction); + + StopAction stopAction = SeffFactory.eINSTANCE.createStopAction(); + stopAction.setEntityName("stopAction"); + resourceDemandingBehaviour.getSteps_Behaviour().add(stopAction); + connectActions(externalCallAction, stopAction); + return resourceDemandingBehaviour; + } + + private static AbstractAction createExternalCallAction(IModelBuilder builder, BasicComponent component, + ResourceDemandingBehaviour seff, ExternalCall externalCall) { + ExternalCallAction externalCallAction = SeffFactory.eINSTANCE.createExternalCallAction(); + externalCallAction.setEntityName(externalCall.getClassName() + "." + externalCall.getMethodName()); + externalCallAction.setCalledService_ExternalService( + (OperationSignature) builder.getMethod(Util.createMethodKey(externalCall.getMethodName(), + ModelBuilder.applyComponentNameFix(externalCall.getClassName())))); + builder.addRequiredRole(component.getEntityName(), "I" + externalCall.getClassName()); + OperationRequiredRole role = (OperationRequiredRole) builder.getRole("Required_" + "I" + + externalCall.getClassName() + ModelBuilder.seperatorChar + component.getEntityName()); + externalCallAction.setRole_ExternalService(role); + seff.getSteps_Behaviour().add(externalCallAction); + + return externalCallAction; + } + + private static void addResourceDemand(InternalAction action, double meanResourceDemand, ResourceContainer host) { + ParametricResourceDemand parametricResourceDemand = SeffPerformanceFactory.eINSTANCE + .createParametricResourceDemand(); + EList<ProcessingResourceSpecification> resources = host.getActiveResourceSpecifications_ResourceContainer(); + ProcessingResourceType cpu = resources.get(0).getActiveResourceType_ActiveResourceSpecification(); + + parametricResourceDemand.setRequiredResource_ParametricResourceDemand(cpu); + parametricResourceDemand.setAction_ParametricResourceDemand(action); + PCMRandomVariable randomVariable = CoreFactory.eINSTANCE.createPCMRandomVariable(); + // Expression x = randomVariable.getExpression(); + // randomVariable.setVariableCharacterisation_Specification(x); + // randomVariable.setSpecification("IntPMF[(5; 0.0)(10; 0.051)(20; + // 0.134)(30; 0.193)(40; 0.212)(50; 0.224)(60; 0.186)]*100000"); + // randomVariable.setSpecification("IntPMF["+"("+Double.toString(meanResourceDemand)+";1)"+"]"); + randomVariable.setSpecification(Double.toString(meanResourceDemand)); + parametricResourceDemand.setSpecification_ParametericResourceDemand(randomVariable); + } + + private static void connectActions(AbstractAction startAction, AbstractAction stopAction) { + if (startAction == null) { + log.warn("StartAction == null"); + } + if (stopAction == null) { + log.warn("StopAction == null"); + } + + startAction.setSuccessor_AbstractAction(stopAction); + stopAction.setPredecessor_AbstractAction(startAction); + } } diff --git a/tools.descartes.pmx.pcm.eclipse/src/tools/descartes/pmx/frontend/pcm/importWizards/InputSelctionWizardPage.java b/tools.descartes.pmx.pcm.eclipse/src/tools/descartes/pmx/frontend/pcm/importWizards/InputSelctionWizardPage.java index ca1477924927ad69c24464a09f33c37f2db5a479..55d78faccf475460e136d92e9b7d3d36db13655c 100644 --- a/tools.descartes.pmx.pcm.eclipse/src/tools/descartes/pmx/frontend/pcm/importWizards/InputSelctionWizardPage.java +++ b/tools.descartes.pmx.pcm.eclipse/src/tools/descartes/pmx/frontend/pcm/importWizards/InputSelctionWizardPage.java @@ -27,6 +27,9 @@ package tools.descartes.pmx.frontend.pcm.importWizards; import java.io.File; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; @@ -44,147 +47,167 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; public class InputSelctionWizardPage extends WizardPage { - private static InputSelctionWizardPage singleton = new InputSelctionWizardPage(); - public static Text inputDirectory; + private static InputSelctionWizardPage singleton = new InputSelctionWizardPage(); + public static Text inputDirectory; Display display = Display.getDefault(); Label label1; Label label2; Label label3; - - private InputSelctionWizardPage() { - super("Enter Trace Location Information"); - setTitle("Enter Trace Location Information"); - setDescription("Define the directory of the Kieker monitoring logs you want to extract a performance model from."); - } - - public void createControl_old(Composite parent) { - Composite container = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - layout.numColumns = 1; - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - - label1 = new Label(container, GridData.FILL_HORIZONTAL); - label1.setText("Enter inputDirectory to Kieker files here:"); - -// label2 = new Label(composite, GridData.FILL_HORIZONTAL); -// Image logo_image = new Image(display,"C:\\Users\\Jürgen\\git\\pmx\\tools.descartes.pmx.frontend.pcm"+File.separatorChar+"pmx_logo.png"); -// label2.setImage(logo_image); - - inputDirectory = new Text(container, SWT.BORDER | SWT.SINGLE); - - label3 = new Label(container, SWT.NONE); - label3.setText("waiting for input ..."); - label3.setLayoutData(gd); - - inputDirectory.setLayoutData(gd); - - inputDirectory.addKeyListener(new KeyListener() { - @Override - public void keyPressed(KeyEvent e) { - } - @Override - public void keyReleased(KeyEvent e) { - if (!inputDirectory.getText().isEmpty()) { - if ((new File(inputDirectory.getText())).isDirectory()){ - label3.setText("input is a directory ..."); - OutputSelectionWizardPage.setOutputDirectory(inputDirectory.getText() + File.separatorChar+"pcm"+File.separatorChar); - setPageComplete(true); - }else{ - label3.setText("input is no directory ..."); - setPageComplete(false); - } - }else{ - setPageComplete(false); - } - } - }); - - inputDirectory.setText(""); -// inputDirectory.setText("C:\\Users\\Jürgen\\git\\pmx\\tools.descartes.pmx.console\\console\\kieker-20141103-190203561-UTC-j2eeservice-KIEKER-TEST"); -// inputDirectory.setText("C:\\Users\\Jürgen\\Desktop\\eclipse versions\\pcm3.5.0\\workspace\\abc\\testFiles\\kieker-20151008-145457358-UTC-WIN-JQHNDE89VN4-KIEKER"); - - // required to avoid an error in the system - setControl(container); - setPageComplete(false); - } - - @Override - public void createControl(Composite parent) { - Composite container = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - layout.numColumns = 1; - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - - label1 = new Label(container, GridData.FILL_HORIZONTAL); - label1.setText("Enter inputDirectory to Kieker files here:"); - -// label2 = new Label(composite, GridData.FILL_HORIZONTAL); -// Image logo_image = new Image(display,"C:\\Users\\Jürgen\\git\\pmx\\tools.descartes.pmx.frontend.pcm"+File.separatorChar+"pmx_logo.png"); -// label2.setImage(logo_image); - - inputDirectory = new Text(container, SWT.BORDER | SWT.SINGLE); - label3 = new Label(container, SWT.NONE); - label3.setText("waiting for input ..."); - label3.setLayoutData(gd); - - inputDirectory.setLayoutData(gd); - - inputDirectory.addKeyListener(new KeyListener() { - @Override - public void keyPressed(KeyEvent e) { - } - @Override - public void keyReleased(KeyEvent e) { - if (!inputDirectory.getText().isEmpty()) { - testDirectoryInput(); - }else{ - setPageComplete(false); - } - } - public void testDirectoryInput() { - if ((new File(inputDirectory.getText())).isDirectory()){ - label3.setText("input is a directory ..."); - OutputSelectionWizardPage.setOutputDirectory(inputDirectory.getText() + File.separatorChar+"pcm"+File.separatorChar); - setPageComplete(true); - }else{ - label3.setText("input is no directory ..."); - setPageComplete(false); - } - } - }); - - inputDirectory.setText(""); - - Button browseButton = new Button(container, SWT.PUSH); - browseButton.setText("Browse"); - browseButton.addSelectionListener(new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent arg0) { - DirectoryDialog fileDialog = new DirectoryDialog(container.getShell(), SWT.OPEN); - fileDialog.setText("Open directory of Kieker trace file"); - inputDirectory.setText(fileDialog.open()+File.separator); - label3.setText("input is a directory ..."); - OutputSelectionWizardPage.setOutputDirectory(inputDirectory.getText() + File.separatorChar+"pcm"+File.separatorChar); - setPageComplete(true); } - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - setControl(container); - setPageComplete(false); - } - - public static String getInputDirectory() { - return inputDirectory.getText(); - } - - public static WizardPage getSingleton() { - return singleton; - } - - + + private InputSelctionWizardPage() { + super("Enter Trace Location Information"); + setTitle("Enter Trace Location Information"); + setDescription( + "Define the directory of the Kieker monitoring logs you want to extract a performance model from."); + } + + public void createControl_old(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + + label1 = new Label(container, GridData.FILL_HORIZONTAL); + label1.setText("Enter inputDirectory to Kieker files here:"); + + // label2 = new Label(composite, GridData.FILL_HORIZONTAL); + // Image logo_image = new + // Image(display,"C:\\Users\\Jürgen\\git\\pmx\\tools.descartes.pmx.frontend.pcm"+File.separatorChar+"pmx_logo.png"); + // label2.setImage(logo_image); + + inputDirectory = new Text(container, SWT.BORDER | SWT.SINGLE); + + label3 = new Label(container, SWT.NONE); + label3.setText("waiting for input ..."); + label3.setLayoutData(gd); + + inputDirectory.setLayoutData(gd); + + inputDirectory.addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (!inputDirectory.getText().isEmpty()) { + final String[] fileNames = inputDirectory.getText().split(";"); + final List<String> fileList = Arrays.asList(fileNames); + final boolean allFiles = fileList.stream().allMatch(a -> new File(a).isDirectory()); + if (allFiles) { + label3.setText("input are all directories ..."); + OutputSelectionWizardPage + .setOutputDirectory(fileNames[0] + File.separatorChar + "pcm" + File.separatorChar); + setPageComplete(true); + } else { + label3.setText("input is no directory ..."); + setPageComplete(false); + } + } else { + setPageComplete(false); + } + } + }); + + inputDirectory.setText(""); + // inputDirectory.setText("C:\\Users\\Jürgen\\git\\pmx\\tools.descartes.pmx.console\\console\\kieker-20141103-190203561-UTC-j2eeservice-KIEKER-TEST"); + // inputDirectory.setText("C:\\Users\\Jürgen\\Desktop\\eclipse + // versions\\pcm3.5.0\\workspace\\abc\\testFiles\\kieker-20151008-145457358-UTC-WIN-JQHNDE89VN4-KIEKER"); + + // required to avoid an error in the system + setControl(container); + setPageComplete(false); + } + + @Override + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + + label1 = new Label(container, GridData.FILL_HORIZONTAL); + label1.setText("Enter inputDirectory to Kieker files here:"); + + // label2 = new Label(composite, GridData.FILL_HORIZONTAL); + // Image logo_image = new + // Image(display,"C:\\Users\\Jürgen\\git\\pmx\\tools.descartes.pmx.frontend.pcm"+File.separatorChar+"pmx_logo.png"); + // label2.setImage(logo_image); + + inputDirectory = new Text(container, SWT.BORDER | SWT.SINGLE); + label3 = new Label(container, SWT.NONE); + label3.setText("waiting for input ..."); + label3.setLayoutData(gd); + + inputDirectory.setLayoutData(gd); + + inputDirectory.addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (!inputDirectory.getText().isEmpty()) { + testDirectoryInput(); + } else { + setPageComplete(false); + } + } + + public void testDirectoryInput() { + if (!inputDirectory.getText().isEmpty()) { + final String[] fileNames = inputDirectory.getText().split(";"); + final List<String> fileList = Arrays.asList(fileNames); + final boolean allFiles = fileList.stream().allMatch(a -> new File(a).isDirectory()); + if (allFiles) { + label3.setText("input are all directories ..."); + OutputSelectionWizardPage + .setOutputDirectory(fileNames[0] + File.separatorChar + "pcm" + File.separatorChar); + setPageComplete(true); + } else { + label3.setText("input is no directory ..."); + setPageComplete(false); + } + } else { + setPageComplete(false); + } + } + }); + + inputDirectory.setText(""); + + Button browseButton = new Button(container, SWT.PUSH); + browseButton.setText("Browse"); + browseButton.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent arg0) { + DirectoryDialog fileDialog = new DirectoryDialog(container.getShell(), SWT.OPEN); + fileDialog.setText("Open directory of Kieker trace file"); + inputDirectory.setText(fileDialog.open() + File.separator); + label3.setText("input is a directory ..."); + OutputSelectionWizardPage + .setOutputDirectory(inputDirectory.getText() + File.separatorChar + "pcm" + File.separatorChar); + setPageComplete(true); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + setControl(container); + setPageComplete(false); + } + + public static String getInputDirectory() { + return inputDirectory.getText(); + } + + public static WizardPage getSingleton() { + return singleton; + } } diff --git a/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/EstimationSpecificationFactory.java b/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/EstimationSpecificationFactory.java index 93e4ada5adc1c58b805f52b327c9a36d905954d7..91ecec4a861675e842f7a66ccb3a16ed975f30b8 100644 --- a/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/EstimationSpecificationFactory.java +++ b/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/EstimationSpecificationFactory.java @@ -117,7 +117,7 @@ public class EstimationSpecificationFactory { log.info("\tcan only apply response time estimation approach"); Resource cpu = ConfigurationFactory.eINSTANCE.createResource(); cpu.setName("CPU@" + host); - cpu.setNumberOfServers(2); + cpu.setNumberOfServers(48); workloadDescription.getResources().add(cpu); LibReDEAdapter.mapServicesToResources(workloadDescription); diff --git a/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/LibReDEAdapter.java b/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/LibReDEAdapter.java index 3bac47f1501a7efa5e5a62bf7454c81562991ab7..801ade19f95f264a5aa5596df16eefbe59b2ec3f 100644 --- a/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/LibReDEAdapter.java +++ b/tools.descartes.pmx/src/tools/descartes/pmx/filter/resourcedemands/adapter/LibReDEAdapter.java @@ -131,9 +131,9 @@ public class LibReDEAdapter { for (String resourceName: resourceTimeSeriesMap.keySet()) { // log.info("Enter number of CPU cores for "+host); // cpu.setNumberOfServers(getInputInt()); - if(resourceName.replace("CPU", "").endsWith(ModelBuilder.seperatorChar+host)){ + if(resourceName.replace("CPU", "").endsWith("_"+host)){ log.info("\tnumber of servers for "+resourceName+ " = 1"); - TraceConfiguration traceConfiguration = addResourceToLibReDE(dataSource, workloadDescription, host, resourceName.split("@"+host)[0], 1, resourceTimeSeriesMap.get(resourceName)); + TraceConfiguration traceConfiguration = addResourceToLibReDE(dataSource, workloadDescription, host, resourceName.split("_"+host)[0], 1, resourceTimeSeriesMap.get(resourceName)); //conf.getInput().getObservations().add(traceConfiguration); traceConfigurations.add(traceConfiguration); }