diff --git a/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/Constants.java b/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/Constants.java index 55c3dce908dd2fe9fcd2739f99cea0f31512359b..6332920b8579bfcf0ccc1dfe1d85476ad0708f6a 100644 --- a/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/Constants.java +++ b/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/Constants.java @@ -27,7 +27,9 @@ package tools.descartes.prisma.agent.wildfly; public class Constants { - public static final long NANOS_IN_MILLIS = 1000000; + public static final long NANOS_IN_MILLIS = 1000000; public static final long MONITORING_INTERVAL_IN_MILLIS = 60000; + + public static final boolean ADD_NETWORK_DELAYS = true; } diff --git a/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/service/ModelExtractionService.java b/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/service/ModelExtractionService.java index e55572960b24eb2afb0e2cdfa0c66563870487e6..59c0fcd7e75478b90015cbfb1b539bc3dd705cc0 100644 --- a/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/service/ModelExtractionService.java +++ b/tools.descartes.prisma.agent.wildfly/src/main/java/tools/descartes/prisma/agent/wildfly/service/ModelExtractionService.java @@ -352,7 +352,7 @@ public class ModelExtractionService extends AgentController implements Service<M private void addComponent(InvocationRecord incomingIrec, InvocationRecord outgoingIrec) { ComponentRecord incomingCrec = incomingIrec.getOperation().getComponent(); String incomingInterfaceName = incomingIrec.getOperation().getInterfaceName(); - boolean isRemoteIncomingCall = !incomingIrec.getOperation().getProtocol().equals("java"); + boolean isRemoteIncomingCall = isRemoteCall(incomingIrec); ComponentRecord outgoingCrec = null; String outgoingInterfaceName = null; if (outgoingIrec != null) { @@ -415,8 +415,7 @@ public class ModelExtractionService extends AgentController implements Service<M ExternalCall externalCall = null; if (callerRequiringRole != null) { externalCall = addExternalCall(incomingCrec.getComponentClass(), implementationComponent, behavior, - callerRequiringRole, - outgoingSignature); + callerRequiringRole, outgoingSignature, outgoingIrec); } RepositoryComponent callerComponent = implementationComponent; @@ -771,7 +770,8 @@ public class ModelExtractionService extends AgentController implements Service<M } private ExternalCall addExternalCall(String componentName, BasicComponent implementationComponent, - FineGrainedBehavior behavior, InterfaceRequiringRole requiringRole, Signature outgoingSignature) { + FineGrainedBehavior behavior, InterfaceRequiringRole requiringRole, Signature outgoingSignature, + InvocationRecord outgoingInvocation) { ExternalCallAction callAction = ServicebehaviorFactory.eINSTANCE.createExternalCallAction(); ExternalCall call = ServicebehaviorFactory.eINSTANCE.createExternalCall(); call.setName(toName(requiringRole.getName() + "#" + outgoingSignature.getName())); @@ -799,6 +799,21 @@ public class ModelExtractionService extends AgentController implements Service<M iterationCount.setCharacterization(ModelVariableCharacterizationType.EMPIRICAL); loop.setLoopIterationCount(iterationCount); loop.setLoopBodyBehavior(ServicebehaviorFactory.eINSTANCE.createComponentInternalBehavior()); + + // We may add delay actions to represent the network delays for + // remote external calls. + if (Constants.ADD_NETWORK_DELAYS) { + if (isRemoteCall(outgoingInvocation)) { + InternalAction delayAction = ServicebehaviorFactory.eINSTANCE.createInternalAction(); + ResourceDemand demand = ServicebehaviorFactory.eINSTANCE.createResourceDemand(); + demand.setCharacterization(ModelVariableCharacterizationType.EMPIRICAL); + demand.setName("Network"); + demand.setResourceType( + ModelSkeletonUtil.adopt(this, getContainerScope().getSystemScope().getDelayResourceType())); + delayAction.getResourceDemand().add(demand); + loop.getLoopBodyBehavior().getActions().add(delayAction); + } + } loop.getLoopBodyBehavior().getActions().add(callAction); // We assume that the external calls are inserted in @@ -823,6 +838,10 @@ public class ModelExtractionService extends AgentController implements Service<M } } + private boolean isRemoteCall(InvocationRecord outgoingInvocation) { + return !outgoingInvocation.getOperation().getProtocol().equals("java"); + } + private CompositeComponent createCompositeComponent(ComponentRecord crec, RepositoryComponent implementationComponent) { String compositeName = getCompositeComponentName(crec);