Search in sources :

Example 1 with AssemblyEntry

use of org.iobserve.model.correspondence.AssemblyEntry in project iobserve-analysis by research-iobserve.

the class CreateCorrespondenceMain method main.

/**
 * @param args
 *            arguments
 */
public static void main(final String[] args) {
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_FrontendService", "jpetstore-frontend-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_AccountService", "jpetstore-account-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_CatalogService", "jpetstore-catalog-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_OdrderService", "jpetstore-order-service");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_AccountDatabase", "jpetstore-account-database");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_CatalogDatabase", "jpetstore-catalog-database");
    CreateCorrespondenceMain.NAME_MAPS.put("Assembly_OrderDatabase", "jpetstore-order-database");
    final String pcmDirectory = "/home/reiner/Projects/iObserve/experiments/distributed-jpetstore-experiment/pcm/JPetStore";
    try {
        final ModelImporter modelHandler = new ModelImporter(new File(pcmDirectory));
        // final Repository repository = modelHandler.getRepositoryModel();
        // final ResourceEnvironment environment = modelHandler.getResourceEnvironmentModel();
        final System system = modelHandler.getSystemModel();
        // final Allocation allocation = modelHandler.getAllocationModel();
        final CorrespondenceModel correspondenceModel = CorrespondenceFactory.eINSTANCE.createCorrespondenceModel();
        final Part part = CorrespondenceFactory.eINSTANCE.createPart();
        correspondenceModel.getParts().add(part);
        part.setModelType(system);
        for (final AssemblyContext assembly : system.getAssemblyContexts__ComposedStructure()) {
            final AssemblyEntry entry = CorrespondenceFactory.eINSTANCE.createAssemblyEntry();
            final String value = CreateCorrespondenceMain.NAME_MAPS.get(assembly.getEntityName());
            entry.setImplementationId(value);
            entry.setAssembly(assembly);
            part.getEntries().add(entry);
        }
        final URI outputURI = URI.createFileURI("/home/reiner/correspondence.correspondence");
        CreateCorrespondenceMain.save(correspondenceModel, outputURI);
    } catch (final IOException e) {
        CreateCorrespondenceMain.LOGGER.error("Canot load all models {}", e.getLocalizedMessage());
    }
}
Also used : AssemblyEntry(org.iobserve.model.correspondence.AssemblyEntry) Part(org.iobserve.model.correspondence.Part) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) IOException(java.io.IOException) File(java.io.File) URI(org.eclipse.emf.common.util.URI) System(org.palladiosimulator.pcm.system.System)

Example 2 with AssemblyEntry

use of org.iobserve.model.correspondence.AssemblyEntry in project iobserve-analysis by research-iobserve.

the class UndeployPCMMapperStage method performMapping.

private void performMapping(final String service, final String context, final long observedTime) throws InvocationException, DBException {
    DeploymentLock.lock();
    final List<AssemblyEntry> assemblyEntry = this.correspondenceModelResource.findObjectsByTypeAndProperty(AssemblyEntry.class, CorrespondencePackage.Literals.ASSEMBLY_ENTRY, "implementationId", context);
    final List<ResourceContainer> resourceContainers = this.resourceEnvironmentResource.findObjectsByTypeAndProperty(ResourceContainer.class, ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER, "entityName", service);
    if (!resourceContainers.isEmpty()) {
        if (assemblyEntry.size() == 1) {
            final ResourceContainer resourceContainer = resourceContainers.get(0);
            final AssemblyContext assemblyContext = this.systemModelResource.resolve(assemblyEntry.get(0).getAssembly());
            this.outputPort.send(new PCMUndeployedEvent(service, assemblyContext, resourceContainer, observedTime));
        } else if (assemblyEntry.isEmpty()) {
            this.logger.error("Undeplyoment failed: No corresponding assembly context {} found on {}.", context, service);
        } else if (assemblyEntry.size() > 1) {
            this.logger.error("Undeplyoment failed: Multiple corresponding assembly contexts {} found on {}.", context, service);
        }
    } else {
        this.logger.warn("Undeplyoment issue: No resource container found {}.", service);
    }
    DeploymentLock.unlock();
}
Also used : AssemblyEntry(org.iobserve.model.correspondence.AssemblyEntry) PCMUndeployedEvent(org.iobserve.analysis.deployment.data.PCMUndeployedEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 3 with AssemblyEntry

use of org.iobserve.model.correspondence.AssemblyEntry in project iobserve-analysis by research-iobserve.

the class DeployPCMMapperStage method performMapping.

private void performMapping(final EServiceTechnology technology, final String service, final String context, final ISOCountryCode countryCode, final long timestamp) throws InvocationException, DBException {
    final List<AssemblyEntry> assemblyEntry = this.correspondenceModelResource.findObjectsByTypeAndProperty(AssemblyEntry.class, CorrespondencePackage.Literals.ASSEMBLY_ENTRY, "implementationId", context);
    // build the containerAllocationEvent
    final String urlContext = context.replaceAll("\\.", "/");
    final String url = "http://" + service + '/' + urlContext;
    if (assemblyEntry.size() == 1) {
        final AssemblyContext assemblyContext = this.systemModelResource.resolve(assemblyEntry.get(0).getAssembly());
        this.outputPort.send(new PCMDeployedEvent(technology, service, assemblyContext, url, countryCode, timestamp));
    } else if (assemblyEntry.isEmpty()) {
        this.logger.error("Deplyoment failed: No corresponding assembly context {} found on {}.", context, service);
    } else if (assemblyEntry.size() > 1) {
        this.logger.error("Deplyoment failed: Multiple corresponding assembly context {} found on {}.", context, service);
    }
}
Also used : AssemblyEntry(org.iobserve.model.correspondence.AssemblyEntry) PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 4 with AssemblyEntry

use of org.iobserve.model.correspondence.AssemblyEntry in project iobserve-analysis by research-iobserve.

the class ProbeMapper method computeAllocationComponentServletId.

/**
 * Compute allocation component servlet id.
 *
 * @param entry
 * @param allocation
 * @param operationSignature
 * @return
 * @throws InvocationException
 * @throws DBException
 */
private String computeAllocationComponentServletId(final AllocationEntry entry, final AllocationContext allocation, final OperationSignature operationSignature) throws InvocationException, DBException {
    final EList<Parameter> parameterList = operationSignature.getParameters__OperationSignature();
    String parameters = null;
    for (final Parameter parameter : parameterList) {
        if (parameters == null) {
            parameters = parameter.getParameterName();
        } else {
            parameters += ", " + parameter.getParameterName();
        }
    }
    AssemblyContext assemblyContext = this.assemblyResource.resolve(allocation.getAssemblyContext_AllocationContext());
    assemblyContext = this.assemblyResource.resolve(assemblyContext);
    String component = "ERROR";
    for (final AssemblyEntry assemblyEntry : this.correspondenceResource.collectAllObjectsByType(AssemblyEntry.class, CorrespondencePackage.Literals.ASSEMBLY_ENTRY)) {
        final AssemblyContext entryRelatedContext = this.assemblyResource.resolve(assemblyEntry.getAssembly());
        // assemblyContext.eIsProxy());
        if (entryRelatedContext.getId().equals(assemblyContext.getId())) {
            component = assemblyEntry.getImplementationId();
        }
    }
    final String methodId = String.format("%s.%s (%s)", component, operationSignature.getEntityName(), parameters);
    this.logger.debug("Constructed method string: {}", methodId);
    return methodId;
}
Also used : AssemblyEntry(org.iobserve.model.correspondence.AssemblyEntry) Parameter(org.palladiosimulator.pcm.repository.Parameter) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Aggregations

AssemblyEntry (org.iobserve.model.correspondence.AssemblyEntry)4 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)4 File (java.io.File)1 IOException (java.io.IOException)1 URI (org.eclipse.emf.common.util.URI)1 PCMDeployedEvent (org.iobserve.analysis.deployment.data.PCMDeployedEvent)1 PCMUndeployedEvent (org.iobserve.analysis.deployment.data.PCMUndeployedEvent)1 CorrespondenceModel (org.iobserve.model.correspondence.CorrespondenceModel)1 Part (org.iobserve.model.correspondence.Part)1 Parameter (org.palladiosimulator.pcm.repository.Parameter)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1 System (org.palladiosimulator.pcm.system.System)1