use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class HostComponentAllocationGraphFactory method createEdges.
private void createEdges(final Map<String, ComponentNode> components, final ModelGraphRevision revision) {
for (final AssemblyConnector acp : this.assemblyConnectors.values()) {
final String provACID = acp.getProvidingAssemblyContext_AssemblyConnector().getId();
final String reqACID = acp.getRequiringAssemblyContext_AssemblyConnector().getId();
ComponentNode provNode;
ComponentNode reqNode;
for (final AllocationContext provAlloc : this.assCtxt2AllocCtxts.get(provACID)) {
provNode = components.get(provAlloc.getId());
for (final AllocationContext reqAlloc : this.assCtxt2AllocCtxts.get(reqACID)) {
reqNode = components.get(reqAlloc.getId());
final ComponentEdge edge;
if (acp instanceof AssemblyConnectorPrivacy) {
edge = new ComponentEdge(acp.getId(), acp.getEntityName(), provNode, reqNode, ((AssemblyConnectorPrivacy) acp).getPrivacyLevel(), revision);
} else {
edge = new ComponentEdge(acp.getId(), acp.getEntityName(), provNode, reqNode, null, revision);
}
provNode.addCommunicationEdge(edge);
reqNode.addCommunicationEdge(edge);
}
}
}
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class DebugHelper method listAllocations.
/**
* List all {@link AllocationContext}s of an {@link Allocation} model.
*
* @param caller
* caller class
* @param label
* prefix label
* @param allocation
* allocation model
*/
public static void listAllocations(final Class<?> caller, final String label, final Allocation allocation) {
int i = 1;
for (final AllocationContext context : allocation.getAllocationContexts_Allocation()) {
DebugHelper.LOGGER.debug(String.format("%s %s %d %s %s", caller, label, i, context.getEntityName(), context.getAssemblyContext_AllocationContext()));
i++;
}
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class DeploymentModelUpdaterTest method testExecutePCMDeployedEvent.
/**
* Test method for
* {@link org.iobserve.analysis.deployment.DeploymentModelUpdater#execute(org.iobserve.analysis.deployment.data.PCMDeployedEvent)}.
*
* @throws DBException
*/
@Test
public void testExecutePCMDeployedEvent() throws DBException {
java.lang.System.err.println("AAAAAAAAAAAAAAAAAAAAAAa");
this.initializationDatabase();
java.lang.System.err.println("q alloc");
final Allocation initDbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
java.lang.System.err.println("deployer filter");
final DeploymentModelUpdater deploymentModelUpdater = new DeploymentModelUpdater(this.correspondenceResource, this.allocationResource);
/**
* input deployment event
*/
final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
final PCMDeployedEvent deploymentEvent = ModelLevelDataFactory.createPCMDeployedEvent(ISOCountryCode.EVIL_EMPIRE, assemblyContext);
deploymentEvent.setResourceContainer(ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3));
final List<PCMDeployedEvent> inputEvents = new ArrayList<>();
inputEvents.add(deploymentEvent);
StageTester.test(deploymentModelUpdater).and().send(inputEvents).to(deploymentModelUpdater.getInputPort()).start();
Assert.assertThat(deploymentModelUpdater.getDeployedNotifyOutputPort(), StageTester.produces(deploymentEvent));
// TODO check is DB contains a deployment
final Allocation dbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
for (final AllocationContext context : dbAllocation.getAllocationContexts_Allocation()) {
Assert.assertNotEquals("No assembly context for " + context.getEntityName(), context.getAssemblyContext_AllocationContext(), null);
}
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class DeploymentModelUpdater method execute.
/**
* Execute an deployment event.
*
* @param event
* one deployment event to be processed
* @throws NodeLookupException
* node lookup failed
* @throws DBException
* on db error
* @throws InvocationException
* on invocation errors
*/
@Override
protected void execute(final PCMDeployedEvent event) throws NodeLookupException, InvocationException, DBException {
DeploymentLock.lock();
ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.DEPLOYMENT, ObservationPoint.MODEL_UPDATE_ENTRY);
this.logger.debug("Send event from {}", this.getInputPort().getPipe().getSourcePort().getOwningStage().getId());
this.logger.debug("Deployment model update: assemblyContext={} resourceContainer={} service={}", event.getAssemblyContext(), event.getResourceContainer(), event.getService());
final String allocationContextName = NameFactory.createAllocationContextName(event.getAssemblyContext(), event.getResourceContainer());
final List<AllocationContext> allocationContext = this.allocationModelResource.findObjectsByTypeAndProperty(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, "entityName", allocationContextName);
if (allocationContext.isEmpty()) {
this.logger.debug("Create allocation context (deploy) {}", event);
final Allocation allocationModel = this.allocationModelResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
final AllocationContext newAllocationContext = AllocationFactory.eINSTANCE.createAllocationContext();
newAllocationContext.setEntityName(allocationContextName);
newAllocationContext.setAssemblyContext_AllocationContext(event.getAssemblyContext());
newAllocationContext.setResourceContainer_AllocationContext(event.getResourceContainer());
allocationModel.getAllocationContexts_Allocation().add(newAllocationContext);
this.allocationModelResource.updatePartition(allocationModel);
final AllocationContext storedAllocationContext = this.allocationModelResource.resolve(newAllocationContext);
/**
* create correspondence model entry.
*/
final CorrespondenceModel correspondenceModel = this.correspondenceModelResource.getModelRootNode(CorrespondenceModel.class, CorrespondencePackage.Literals.CORRESPONDENCE_MODEL);
final Part part = this.findOrCreate(correspondenceModel, allocationModel);
final AllocationEntry entry = CorrespondenceFactory.eINSTANCE.createAllocationEntry();
entry.setAllocation(storedAllocationContext);
entry.setTechnology(event.getTechnology());
entry.setImplementationId(event.getUrl());
part.getEntries().add(entry);
this.correspondenceModelResource.updatePartition(correspondenceModel);
this.logger.debug("PUSHED CORRESPONDENCE {} {} {}", newAllocationContext.getEntityName(), event.getTechnology().getLiteral(), event.getUrl());
} else {
this.logger.error("Deployment failed: Allocation Context {} already exists in allocation model.", allocationContextName);
}
// signal deployment update
ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.DEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
DeploymentLock.unlock();
this.deployedNotifyOutputPort.send(event);
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class ProbeMapper method createMethodsToUpdate.
private void createMethodsToUpdate(final ProbeManagementData element) throws ControlEventCreationFailedException, InvocationException, DBException {
final Map<AllocationContext, Set<OperationSignature>> methodsToUpdate = element.getMethodsToUpdate();
if (methodsToUpdate != null && element.getWhitelist() != null) {
for (final AllocationContext allocation : methodsToUpdate.keySet()) {
this.logger.debug("AllocationContext to update {}", allocation.getEntityName());
for (final OperationSignature operationSignature : methodsToUpdate.get(allocation)) {
try {
final String pattern = this.computeAllocationComponentIdentifierPattern(allocation, operationSignature);
this.logger.debug("AllocationContext update operation {} -- {}", operationSignature.getEntityName(), pattern);
final Map<String, List<String>> parameters = new HashMap<>();
parameters.put("whitelist", element.getWhitelist());
final TcpUpdateParameterEvent currentEvent = new TcpUpdateParameterEvent(pattern, element.getTriggerTime(), parameters);
this.fillTcpControlEvent(currentEvent, allocation);
this.outputPort.send(currentEvent);
} catch (final ControlEventCreationFailedException e) {
this.logger.error("Could not construct activation event for: {} {}", operationSignature.toString(), e.getLocalizedMessage());
}
}
}
}
}
Aggregations