use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class AllocationModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
final Neo4JModelResource<Allocation> resource = ModelProviderTestUtils.prepareResource(AllocationModelProviderTest.CREATE_THEN_UPDATE_THEN_READ_UPDATED, this.prefix, this.ePackage);
final AllocationContext businessOrderServerAllocationContext = AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.BUSINESS_ORDER_ALLOCATION_CONTEXT);
final AllocationContext privateOrderServerAllocationContext = AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.PRIVATE_ORDER_ALLOCATION_CONTEXT);
resource.storeModelPartition(this.testModel);
// Update the model by allocating new separate servers for business and private orders
final ResourceContainer businessOrderServer = ResourceEnvironmentDataFactory.cloneContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.BUSINESS_ORDER_CONTAINER, "additionalBusinessOrderServer");
final ResourceContainer privateOrderServer = ResourceEnvironmentDataFactory.cloneContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.PRIVATE_ORDER_CONTAINER, "additionalPrivateOrderServer");
this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(businessOrderServer);
this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(privateOrderServer);
businessOrderServerAllocationContext.setResourceContainer_AllocationContext(businessOrderServer);
privateOrderServerAllocationContext.setResourceContainer_AllocationContext(privateOrderServer);
resource.updatePartition(this.testModel);
final Allocation readModel = resource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
resource.getGraphDatabaseService().shutdown();
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class AllocationDataFactory method createAllocationContext.
private static AllocationContext createAllocationContext(final System system, final ResourceEnvironment resourceEnvironment, final String allocation, final String assemblyContextName, final String containerName) {
final AllocationContext context = AllocationFactory.eINSTANCE.createAllocationContext();
final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(system, assemblyContextName);
final ResourceContainer container = ResourceEnvironmentDataFactory.findContainer(resourceEnvironment, containerName);
context.setEntityName(allocation);
context.setAssemblyContext_AllocationContext(assemblyContext);
context.setResourceContainer_AllocationContext(container);
return context;
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class UndeploymentModelUpdater method execute.
/**
* This method is triggered for every undeployment event.
*
* @param event
* undeployment event
* @throws DBException
* on db errors
*/
@Override
protected void execute(final PCMUndeployedEvent event) throws DBException {
DeploymentLock.lock();
ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_ENTRY);
this.logger.debug("Undeployment assemblyContext={} resourceContainer={}", event.getAssemblyContext(), event.getResourceContainer());
final String allocationContextName = NameFactory.createAllocationContextName(event.getAssemblyContext(), event.getResourceContainer());
final List<AllocationContext> allocationContexts = this.allocationModelResource.findObjectsByTypeAndProperty(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, "entityName", allocationContextName);
if (allocationContexts.size() == 1) {
final AllocationContext allocationContext = allocationContexts.get(0);
this.allocationModelResource.deleteObject(allocationContext);
ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
DeploymentLock.unlock();
this.outputPort.send(event);
} else if (allocationContexts.size() > 1) {
ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
this.logger.error("Undeployment failed: More than one allocation found for allocation {}", allocationContextName);
DeploymentLock.unlock();
} else {
ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
this.logger.error("Undeployment failed: No allocation found for allocation {}", allocationContextName);
DeploymentLock.unlock();
}
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class PCMNeo4JTest method testUpdate.
/**
* Test whether updates work as suggested.
*
* @throws NodeLookupException
* on node lookup errors
* @throws DBException
* on db errors
*/
@Test
public void testUpdate() throws NodeLookupException, DBException {
/**
* store model in database.
*/
this.repositoryResource.storeModelPartition(this.repository);
this.resourceEnvironmentResource.storeModelPartition(this.resourceEnvironment);
this.systemResource.storeModelPartition(this.system);
this.allocationResource.storeModelPartition(this.allocation);
final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
final ResourceContainer container = ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3);
final Allocation allocationModel = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
final AllocationContext newAllocationContext = AllocationFactory.eINSTANCE.createAllocationContext();
newAllocationContext.setEntityName(AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_3);
newAllocationContext.setAssemblyContext_AllocationContext(assemblyContext);
newAllocationContext.setResourceContainer_AllocationContext(container);
allocationModel.getAllocationContexts_Allocation().add(newAllocationContext);
this.allocationResource.updatePartition(allocationModel);
for (final AllocationContext context : this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT)) {
// NOCS
// TODO
}
}
use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.
the class HostComponentAllocationGraphFactory method createComponentNodes.
private Map<String, ComponentNode> createComponentNodes(final Map<String, DeploymentNode> servers, final ModelGraphRevision revision) {
final Map<String, ComponentNode> components = new HashMap<>();
for (final AllocationContext allocationContext : this.allocationContexts.values()) {
final DeploymentNode hostServer = servers.get(allocationContext.getResourceContainer_AllocationContext().getId());
final String assemblyContextID = allocationContext.getAssemblyContext_AllocationContext().getId();
final AssemblyContext assemblyContext = this.assemblyContexts.get(assemblyContextID);
final DataPrivacyLvl acPrivacyLvl = this.assemblyContextPrivacyLvl.get(assemblyContextID);
final ComponentNode component = new ComponentNode(assemblyContextID, assemblyContext.getEntityName(), acPrivacyLvl, hostServer, assemblyContext.getEncapsulatedComponent__AssemblyContext().getId(), allocationContext.getId(), revision);
hostServer.addComponent(component);
components.put(allocationContext.getId(), component);
}
return components;
}
Aggregations