use of org.iobserve.common.record.ContainerAllocationEvent in project iobserve-analysis by research-iobserve.
the class DynamicEventDispatcherTest method initializeRecordSwitch.
/**
* Initialize the record switch test setup.
*/
@Before
public void initializeRecordSwitch() {
this.kiekerMetadataRecords.add(new KiekerMetadataRecord(DynamicEventDispatcherTest.VERSION, DynamicEventDispatcherTest.CONTROLLER_NAME, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.EXPERIMENT_ID, DynamicEventDispatcherTest.DEBUG_MODE, DynamicEventDispatcherTest.TIME_OFFSET, DynamicEventDispatcherTest.TIME_UNIT, DynamicEventDispatcherTest.NUMBER_OF_RECORDS));
/**
* allocation.
*/
this.allocationRecords.add(new ContainerAllocationEvent(DynamicEventDispatcherTest.URL));
/**
* declare deployment records.
*/
this.deploymentRecords.add(new ServletDeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
this.deploymentRecords.add(new EJBDeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
/**
* geolocation.
*/
this.geolocationRecords.add(new ServerGeoLocation(this.time++, DynamicEventDispatcherTest.COUNTRY_CODE, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.ADDRESS));
/**
* session event (start).
*/
final SessionStartEvent sessionStartEvent = new SessionStartEvent(this.time++, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.SESSION_ID);
this.sessionEventRecords.add(sessionStartEvent);
/**
* start trace.
*/
final TraceMetadata traceMetadata = new TraceMetadata(DynamicEventDispatcherTest.TRACE_ID, DynamicEventDispatcherTest.THREAD_ID, DynamicEventDispatcherTest.SESSION_ID, DynamicEventDispatcherTest.HOSTNAME, 0, -1);
this.traceMetadataRecords.add(traceMetadata);
this.flowRecords.add(traceMetadata);
/**
* flow record.
*/
this.flowRecords.add(new BeforeOperationEvent(this.time++, DynamicEventDispatcherTest.TRACE_ID, DynamicEventDispatcherTest.ORDER_INDEX, DynamicEventDispatcherTest.OPERATION_SIGNATURE, DynamicEventDispatcherTest.CLASS_SIGNATURE));
this.flowRecords.add(new AfterOperationEvent(this.time++, DynamicEventDispatcherTest.TRACE_ID, DynamicEventDispatcherTest.ORDER_INDEX + 1, DynamicEventDispatcherTest.OPERATION_SIGNATURE, DynamicEventDispatcherTest.CLASS_SIGNATURE));
/**
* session event (end).
*/
final SessionEndEvent sessionEndEvent = new SessionEndEvent(this.time++, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.SESSION_ID);
this.sessionEventRecords.add(sessionEndEvent);
/**
* declare undeployment records.
*/
this.undeploymentRecords.add(new ServletUndeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
this.undeploymentRecords.add(new EJBUndeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
/**
* allocation.
*/
this.deallocationRecords.add(new ContainerDeallocationEvent(DynamicEventDispatcherTest.URL));
/**
* other records.
*/
this.otherRecords.add(new GCRecord(this.time++, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.VM_NAME, DynamicEventDispatcherTest.GC_NAME, DynamicEventDispatcherTest.COLLECTION_COUNT, DynamicEventDispatcherTest.COLLECTION_TIME_MS));
/**
* declare all input record types.
*/
this.inputRecords.addAll(this.kiekerMetadataRecords);
this.inputRecords.addAll(this.allocationRecords);
this.inputRecords.addAll(this.deploymentRecords);
this.inputRecords.addAll(this.geolocationRecords);
this.inputRecords.add(sessionStartEvent);
this.inputRecords.addAll(this.flowRecords);
this.inputRecords.add(sessionEndEvent);
this.inputRecords.addAll(this.undeploymentRecords);
this.inputRecords.addAll(this.deallocationRecords);
this.inputRecords.addAll(this.otherRecords);
}
use of org.iobserve.common.record.ContainerAllocationEvent in project iobserve-analysis by research-iobserve.
the class SynthesizeAllocationEventStage method execute.
@Override
protected void execute(final PCMDeployedEvent event) throws Exception {
final ResourceContainer resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class), event.getService()).get();
if (resourceContainer != null) {
/**
* execution environment exists. Can deploy.
*/
event.setResourceContainer(resourceContainer);
this.deployedOutputPort.send(event);
} else {
/**
* If the resource container with this serverName is not available, send an event to
* TAllocation (creating the resource container) and forward the deployment event to
* TDeployment (deploying on created resource container).
*/
this.allocationOutputPort.send(new ContainerAllocationEvent(event.getUrl()));
this.deployedRelayOutputPort.send(event);
}
}
use of org.iobserve.common.record.ContainerAllocationEvent in project iobserve-analysis by research-iobserve.
the class AllocationStage method execute.
/**
* This method is triggered for every allocation event.
*
* @param event
* one allocation event to be processed
* @throws MalformedURLException
* malformed url exception
* @throws UnknownObjectException
* in case the allocation event is of an unknown type
*/
@Override
protected void execute(final IAllocationEvent event) throws MalformedURLException, UnknownObjectException {
final URL url;
if (event instanceof ContainerAllocationEvent) {
url = new URL(((ContainerAllocationEvent) event).getUrl());
} else {
throw new UnknownObjectException(event.getClass() + " is not supported by the allocation filter.");
}
final String hostName = url.getHost();
final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class), hostName);
if (!resourceContainer.isPresent()) {
/**
* new provider: update the resource environment graph.
*/
final ResourceEnvironment resourceEnvironmentModelGraph = this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class);
final ResourceContainer newResourceContainer = ResourceEnvironmentModelFactory.createResourceContainer(resourceEnvironmentModelGraph, hostName);
resourceEnvironmentModelGraph.getResourceContainer_ResourceEnvironment().add(newResourceContainer);
this.resourceEnvironmentModelGraphProvider.updateComponent(ResourceEnvironment.class, resourceEnvironmentModelGraph);
/**
* signal allocation update.
*/
this.allocationNotifyOutputPort.send(newResourceContainer);
this.allocationOutputPort.send(event);
} else {
/**
* error allocation already happened.
*/
this.logger.debug("ResourceContainer %s was available." + hostName);
final List<ProcessingResourceSpecification> procResSpec = resourceContainer.get().getActiveResourceSpecifications_ResourceContainer();
for (int i = 0; i < procResSpec.size(); i++) {
final String nodeGroupName = procResSpec.get(i).getActiveResourceType_ActiveResourceSpecification().getEntityName();
this.logger.debug(nodeGroupName);
}
/**
* Notify with existing container.
*/
this.allocationNotifyOutputPort.send(resourceContainer.get());
}
}
use of org.iobserve.common.record.ContainerAllocationEvent in project iobserve-analysis by research-iobserve.
the class DeallocationStage method execute.
@Override
protected void execute(final IDeallocationEvent event) throws Exception {
final URL url;
if (event instanceof ContainerAllocationEvent) {
url = new URL(((ContainerAllocationEvent) event).getUrl());
} else {
throw new UnknownObjectException(event.getClass() + " is not supported by the allocation filter.");
}
final String hostName = url.getHost();
final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(this.resourceEnvironmentModelProvider.readOnlyRootComponent(ResourceEnvironment.class), hostName);
if (resourceContainer.isPresent()) {
/**
* new provider: update the resource environment graph.
*/
final ResourceEnvironment resourceEnvironmentModelGraph = this.resourceEnvironmentModelProvider.readOnlyRootComponent(ResourceEnvironment.class);
resourceEnvironmentModelGraph.getResourceContainer_ResourceEnvironment().remove(resourceContainer.get());
this.resourceEnvironmentModelProvider.updateComponent(ResourceEnvironment.class, resourceEnvironmentModelGraph);
/**
* signal allocation update.
*/
this.deallocationNotifyOutputPort.send(resourceContainer.get());
this.deallocationOutputPort.send(event);
} else {
/**
* error deallocation already happened.
*/
this.logger.error("ResourceContainer %s is missing." + hostName);
}
}
Aggregations