/** * aggiunge l'event metadata alla lista. * * @param in oggetto EventMetadata */ public final void addEventMetadata(final EventMetadata in) { eventMetadata.add(in); in.setEvent(this); }
protected void computeStats(InputStream eventStream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(eventStream)); boolean done = false; e2eLatencies = new ArrayList<Long>(); processingLatencies = new ArrayList<Long>(); inLatencies = new ArrayList<Long>(); outLatencies = new ArrayList<Long>(); e2eLatenciesPerType = new HashMap<String, ArrayList<Long>>(); eventLog = new ArrayList<EventLogEntry>(); eventLogMap = new HashMap<>(); JsonEventDecoder decoder = new JsonEventDecoder(); do { String line = reader.readLine(); if (line == null) { done = true; continue; } String[] eventEntry = line.split(":", 2); long timestamp = Long.parseLong(eventEntry[0].trim()); if (timestamp < startTimestamp) { continue; } if (isJSON(eventEntry[1])) { // events emitted by speedd runtime are in JSON format (opposite to raw events which are // csv) Event event = decoder.fromBytes(eventEntry[1].trim().getBytes()); if (event.getAttributes().containsKey("timestamps")) { // derived event - update latencies regarding the contributing events updateLatencies(event, timestamp); } else { updateLatenciesForRawEvents(event, timestamp); } } else { // input (csv) event // input event - does not contain 'timestamps' - use to compute real rates Event event = eventMetadata.getEventParser().fromBytes(eventEntry[1].trim().getBytes()); updateInEventMetrics(event, timestamp); } } while (!done); Collections.sort(e2eLatencies); Collections.sort(processingLatencies); Collections.sort(inLatencies); Collections.sort(outLatencies); for (String type : e2eLatenciesPerType.keySet()) { Collections.sort(e2eLatenciesPerType.get(type)); } }