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());
}
}
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();
}
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);
}
}
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;
}
Aggregations