use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class AssemblyContextActionFactory method generateDereplicateAction.
/**
* Create a dereplication action.
*
* @param runtimeNode
* node to be deallocated
* @return returns the dereplication action
*/
public static DereplicateAction generateDereplicateAction(final ComponentNode runtimeNode) {
final DereplicateAction action = SystemadaptationFactory.eINSTANCE.createDereplicateAction();
final Allocation runtimeAllocation = ActionFactory.getRuntimeModels().getAllocationModel();
final System runtimeSystem = ActionFactory.getRuntimeModels().getSystemModel();
AssemblyContextActionFactory.initializeAssemblyContextAction(action, runtimeNode, runtimeAllocation, runtimeSystem);
return action;
}
use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class AssemblyContextActionFactory method generateReplicateAction.
/**
* Create an replication action.
*
* @param runtimeNode
* node to be replicated
* @param reDeploymentNode
* target node of replication
* @return returns the replication action
*/
public static ReplicateAction generateReplicateAction(final ComponentNode runtimeNode, final ComponentNode reDeploymentNode) {
final ReplicateAction action = SystemadaptationFactory.eINSTANCE.createReplicateAction();
final Allocation runtimeAllocation = ActionFactory.getRuntimeModels().getAllocationModel();
final Allocation redeploymentAllocation = ActionFactory.getRedeploymentModels().getAllocationModel();
final System redeploymentSystem = ActionFactory.getRedeploymentModels().getSystemModel();
AssemblyContextActionFactory.initializeAssemblyContextAction(action, reDeploymentNode, redeploymentAllocation, redeploymentSystem);
action.setSourceAllocationContext(ActionFactory.getAllocationContext(runtimeNode.getAllocationContextID(), runtimeAllocation));
return action;
}
use of org.palladiosimulator.pcm.allocation.Allocation 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.Allocation in project iobserve-analysis by research-iobserve.
the class AllocationDataFactory method createAllocation.
/**
* Create a new allocation model and link it with {@code system} and {@code resourceEnvironment}
* model.
*
* @param system
* system model
* @param resourceEnvironment
* resource environment model
*
* @return allocation model
*/
public static Allocation createAllocation(final System system, final ResourceEnvironment resourceEnvironment) {
final Allocation allocation = AllocationFactory.eINSTANCE.createAllocation();
allocation.setEntityName("defaultAllocation");
allocation.setSystem_Allocation(system);
allocation.setTargetResourceEnvironment_Allocation(resourceEnvironment);
// Allocation contexts
final AllocationContext client1AllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_1, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.QUERY_CONTAINER_1);
final AllocationContext client2AllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_2, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.QUERY_CONTAINER_2);
final AllocationContext businessOrderServerAllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.BUSINESS_ORDER_ALLOCATION_CONTEXT, SystemDataFactory.BUSINESS_ORDER_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.BUSINESS_ORDER_CONTAINER);
final AllocationContext privateOrderServerAllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.PRIVATE_ORDER_ALLOCATION_CONTEXT, SystemDataFactory.PRIVATE_ORDER_ASSMEBLY_CONTEXT, ResourceEnvironmentDataFactory.PRIVATE_ORDER_CONTAINER);
final AllocationContext paymentServerAllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.PAYMENT_ALLOCATION_CONTEXT, SystemDataFactory.PAYMENT_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.PAYMENT_CONTAINER);
allocation.getAllocationContexts_Allocation().add(client1AllocationContext);
allocation.getAllocationContexts_Allocation().add(client2AllocationContext);
allocation.getAllocationContexts_Allocation().add(businessOrderServerAllocationContext);
allocation.getAllocationContexts_Allocation().add(privateOrderServerAllocationContext);
allocation.getAllocationContexts_Allocation().add(paymentServerAllocationContext);
return allocation;
}
use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class AllocationModelProviderTest method createThenReadByName.
/**
* Writes a model to the graph, reads it from the graph using
* {@link ModelProvider#findObjectsByTypeAndName(Class, String)} and asserts that it is equal to
* the one written to the graph.
*
* @throws DBException
*/
@Test
public final void createThenReadByName() throws DBException {
final Neo4JModelResource<Allocation> resource = ModelProviderTestUtils.prepareResource(AllocationModelProviderTest.CREATE_THEN_READ_BY_NAME, this.prefix, this.ePackage);
resource.storeModelPartition(this.testModel);
final List<Allocation> readModels = resource.findObjectsByTypeAndProperty(this.clazz, this.eClass, "entityName", this.testModel.getEntityName());
for (final Allocation readModel : readModels) {
Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
}
resource.getGraphDatabaseService().shutdown();
}
Aggregations