use of org.iobserve.model.correspondence.AllocationEntry in project iobserve-analysis by research-iobserve.
the class EntryEventMapperStage method execute.
@Override
protected void execute(final EntryCallEvent event) throws Exception {
/**
* retrieve mapping.
*/
// TODO correct key names?
final List<ComponentEntry> entries = this.correspondenceResource.findObjectsByTypeAndProperty(ComponentEntry.class, CorrespondencePackage.Literals.COMPONENT_ENTRY, "implementationId", event.getClassSignature());
if (!entries.isEmpty()) {
final ComponentEntry componentEntry = entries.get(0);
final OperationEntry operationEntry = this.correspondenceResource.findObjectsByTypeAndProperty(OperationEntry.class, CorrespondencePackage.Literals.OPERATION_ENTRY, "implementationId", event.getOperationSignature()).get(0);
if (operationEntry != null) {
final AllocationEntry allocationEntry = this.correspondenceResource.findObjectsByTypeAndProperty(AllocationEntry.class, CorrespondencePackage.Literals.ALLOCATION_ENTRY, "implementationId", event.getHostname()).get(0);
if (allocationEntry != null) {
this.computePcmEntryCallEvent(componentEntry, operationEntry, allocationEntry, event);
} else {
this.logger.debug("No corresponding allocation for entry call {}", event.toString());
}
} else {
this.logger.debug("No corresponding component for entry call {}", event.toString());
}
} else {
this.logger.debug("No corresponding component for entry call {}", event.toString());
}
}
use of org.iobserve.model.correspondence.AllocationEntry in project iobserve-analysis by research-iobserve.
the class ProbeMapper method findAllocationEntry.
/**
* Find the corresponding AllocationEntry for an AllocationContext.
*
* @param allocation
* the allocation context
* @return returns the AllocationEntry
* @throws InvocationException
* @throws DBException
*/
private AllocationEntry findAllocationEntry(final AllocationContext allocation) throws InvocationException, DBException {
final List<AllocationEntry> allocations = this.correspondenceResource.collectAllObjectsByType(AllocationEntry.class, CorrespondencePackage.Literals.ALLOCATION_ENTRY);
for (final AllocationEntry entry : allocations) {
final AllocationContext entryAllocation = this.allocationResource.resolve(entry.getAllocation());
this.logger.debug("XXXXX entry id {} name {} / ac id {} name {}", entryAllocation.getId(), entryAllocation.getEntityName(), allocation.getId(), allocation.getEntityName());
if (entryAllocation.getId().equals(allocation.getId())) {
return entry;
}
}
throw new InternalError("Correspondence entry missing for " + allocation.getEntityName());
}
use of org.iobserve.model.correspondence.AllocationEntry 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);
}
Aggregations