Search in sources :

Example 11 with PayloadAwareEntryCallEvent

use of org.iobserve.stages.general.data.PayloadAwareEntryCallEvent in project iobserve-analysis by research-iobserve.

the class EntryCallStage method createEntryCall.

/**
 * This method is triggered for every deployment event.
 *
 * @param event
 *            all IFlowRecord like TraceMetadata, BeforeOperationEvent and AfterOperationEvent
 * @throws IOException
 * @throws JsonProcessingException
 */
private PayloadAwareEntryCallEvent createEntryCall(final TraceMetadata traceMetaData) throws JsonProcessingException, IOException {
    final BeforeOperationEvent beforeOperationEvent = this.matcher.getBeforeOperationEvent();
    final AfterOperationEvent afterOperationEvent = this.matcher.getAfterOperationEvent();
    if (beforeOperationEvent instanceof EntryLevelBeforeOperationEvent) {
        final EntryLevelBeforeOperationEvent entryLevelBeforeEvent = (EntryLevelBeforeOperationEvent) beforeOperationEvent;
        return new PayloadAwareEntryCallEvent(beforeOperationEvent.getTimestamp(), afterOperationEvent.getTimestamp(), beforeOperationEvent.getOperationSignature(), beforeOperationEvent.getClassSignature(), traceMetaData.getSessionId(), traceMetaData.getHostname(), entryLevelBeforeEvent.getParameters(), entryLevelBeforeEvent.getValues(), entryLevelBeforeEvent.getRequestType());
    } else if (afterOperationEvent instanceof ExtendedAfterOperationEvent) {
        final ExtendedAfterOperationEvent entryLevelAfterEvent = (ExtendedAfterOperationEvent) afterOperationEvent;
        final String parameters = entryLevelAfterEvent.getInformations();
        final ObjectMapper mapper = new ObjectMapper();
        final JsonNode actualObj = mapper.readTree(parameters);
        final List<String> parameterNames = new ArrayList<>();
        final List<String> parameterValues = new ArrayList<>();
        if (actualObj instanceof ArrayNode) {
            final ArrayNode values = (ArrayNode) actualObj;
            final Iterator<JsonNode> valuesIterator = values.elements();
            while (valuesIterator.hasNext()) {
                final JsonNode entry = valuesIterator.next();
                if (entry instanceof ObjectNode) {
                    final ObjectNode objectNode = (ObjectNode) entry;
                    final Iterator<String> fieldNames = objectNode.fieldNames();
                    String fieldName;
                    if (fieldNames.hasNext()) {
                        fieldName = fieldNames.next();
                        parameterNames.add(objectNode.get(fieldName).textValue());
                    }
                    if (fieldNames.hasNext()) {
                        fieldName = fieldNames.next();
                        parameterValues.add(objectNode.get(fieldName).textValue());
                    }
                }
            }
        }
        return new PayloadAwareEntryCallEvent(beforeOperationEvent.getTimestamp(), afterOperationEvent.getTimestamp(), beforeOperationEvent.getOperationSignature(), beforeOperationEvent.getClassSignature(), traceMetaData.getSessionId(), traceMetaData.getHostname(), parameterNames.toArray(new String[parameterNames.size()]), parameterValues.toArray(new String[parameterValues.size()]), 0);
    } else {
        return new PayloadAwareEntryCallEvent(beforeOperationEvent.getTimestamp(), afterOperationEvent.getTimestamp(), beforeOperationEvent.getOperationSignature(), beforeOperationEvent.getClassSignature(), traceMetaData.getSessionId(), traceMetaData.getHostname(), new String[0], new String[0], 0);
    }
}
Also used : ExtendedAfterOperationEvent(org.iobserve.common.record.ExtendedAfterOperationEvent) AfterOperationEvent(kieker.common.record.flow.trace.operation.AfterOperationEvent) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) EntryLevelBeforeOperationEvent(org.iobserve.common.record.EntryLevelBeforeOperationEvent) ExtendedAfterOperationEvent(org.iobserve.common.record.ExtendedAfterOperationEvent) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) EntryLevelBeforeOperationEvent(org.iobserve.common.record.EntryLevelBeforeOperationEvent) BeforeOperationEvent(kieker.common.record.flow.trace.operation.BeforeOperationEvent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

PayloadAwareEntryCallEvent (org.iobserve.stages.general.data.PayloadAwareEntryCallEvent)11 ArrayList (java.util.ArrayList)6 List (java.util.List)4 EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 UserSession (org.iobserve.analysis.session.data.UserSession)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Arrays (java.util.Arrays)2 Optional (java.util.Optional)2 Pair (org.apache.commons.math3.util.Pair)2 SingleOrNoneCollector (org.iobserve.analysis.behavior.SingleOrNoneCollector)2 CallInformation (org.iobserve.analysis.behavior.models.extended.CallInformation)2 BehaviorModelGED (org.iobserve.service.behavior.analysis.model.BehaviorModelGED)2 BehaviorModelNode (org.iobserve.service.behavior.analysis.model.BehaviorModelNode)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2