--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and Implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.statistics;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages file for statistics view strings.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.1
+ */
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.core.statistics.messages"; //$NON-NLS-1$
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {}
+
+ /** String for the name "Lost events" (displayed in the Statistics View) */
+ public static String LostEventsName;
+}
package org.eclipse.linuxtools.tmf.core.statistics;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
import org.eclipse.linuxtools.tmf.core.statesystem.AbstractTmfStateProvider;
+import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue;
import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics.Attributes;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
* Version number of this input handler. Please bump this if you modify the
* contents of the generated state history in some way.
*/
- private static final int VERSION = 0;
+ private static final int VERSION = 1;
/**
* Constructor
final String eventName = event.getType().getName();
try {
+ /* Special handling for lost events */
+ if (event instanceof ITmfLostEvent) {
+ ITmfLostEvent le = (ITmfLostEvent) event;
+ quark = ss.getQuarkAbsoluteAndAdd(Attributes.EVENT_TYPES, Messages.LostEventsName);
+
+ int curVal = ss.queryOngoingState(quark).unboxInt();
+ if (curVal == -1) { curVal = 0; }
+
+ TmfStateValue value = TmfStateValue.newValueInt((int) (curVal + le.getNbLostEvents()));
+ ss.modifyAttribute(ts, value, quark);
+ return;
+ }
/* Total number of events */
quark = ss.getQuarkAbsoluteAndAdd(Attributes.TOTAL);
import java.util.TreeMap;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
- if (event != null) {
- if (event.getTrace() == trace) {
- total += 1;
- }
+ if (!(event instanceof ITmfLostEvent) && event.getTrace() == trace) {
+ total += 1;
}
}
}
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
- if (event != null) {
- if (event.getTrace() == trace) {
- processEvent(event);
+ if (event != null && event.getTrace() == trace) {
+ /*
+ * Special handling for lost events: instead of counting just
+ * one, we will count how many actual events it represents.
+ */
+ if (event instanceof ITmfLostEvent) {
+ ITmfLostEvent le = (ITmfLostEvent) event;
+ incrementStats(Messages.LostEventsName, le.getNbLostEvents());
+ return;
}
+
+ /* For standard event types, just increment by one */
+ String eventType = event.getType().getName();
+ incrementStats(eventType, 1L);
}
}
- private void processEvent(ITmfEvent event) {
- String eventType = event.getType().getName();
- if (stats.containsKey(eventType)) {
- long curValue = stats.get(eventType);
- stats.put(eventType, curValue + 1L);
+ private void incrementStats(String key, long count) {
+ if (stats.containsKey(key)) {
+ long curValue = stats.get(key);
+ stats.put(key, curValue + count);
} else {
- stats.put(eventType, 1L);
+ stats.put(key, count);
}
}
}
--- /dev/null
+###############################################################################
+# Copyright (c) 2013 Ericsson
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Alexandre Montplaisir - Initial API and implementation
+###############################################################################
+
+LostEventsName = Lost events