From 05cbb7f31659b5ab649691d37e7f057f82b53149 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Fri, 20 Mar 2015 12:14:22 -0400 Subject: [PATCH] ctf: remove StreamInputPacketReader string literals Also remove overridable methods from constructor Change-Id: I8ecbbb0fc46b7fd3d98462669e746279cf0872d1 Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/44266 Reviewed-by: Patrick Tasse Reviewed-by: Hudson CI --- .../tracecompass/ctf/core/CTFStrings.java | 56 ++++++++++++++++++- .../trace/StreamInputPacketIndexEntry.java | 25 +++++---- 2 files changed, 68 insertions(+), 13 deletions(-) diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/CTFStrings.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/CTFStrings.java index d71874401f..6ddf16b135 100644 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/CTFStrings.java +++ b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/CTFStrings.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 Ericsson + * Copyright (c) 2013, 2015 Ericsson * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which @@ -8,6 +8,7 @@ * * Contributors: * Alexandre Montplaisir - Initial API and implementation + * Matthew Khouzam - Add packet header Strings *******************************************************************************/ package org.eclipse.tracecompass.ctf.core; @@ -37,4 +38,57 @@ public interface CTFStrings { * Name of the field in lost events indicating the time range */ String LOST_EVENTS_DURATION = "duration"; + + // ------------------------------------------------------------------------- + // Packet header strings + // ------------------------------------------------------------------------- + + /** + * Lost events so far in this stream (LTTng Specific) + * + * @since 1.0 + */ + String EVENTS_DISCARDED = "events_discarded"; + + /** + * The CPU ID of this packet (LTTng Specific) + * + * @since 1.0 + */ + String CPU_ID = "cpu_id"; + + /** + * The device of this packet + * + * @since 1.0 + */ + String DEVICE = "device"; + + /** + * The first time stamp of this packet + * + * @since 1.0 + */ + String TIMESTAMP_BEGIN = "timestamp_begin"; + + /** + * The last time stamp of this packet + * + * @since 1.0 + */ + String TIMESTAMP_END = "timestamp_end"; + + /** + * Size of this packet + * + * @since 1.0 + */ + String PACKET_SIZE = "packet_size"; + + /** + * Size of data in this packet (not necessarily the packet size) + * + * @since 1.0 + */ + String CONTENT_SIZE = "content_size"; } diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndexEntry.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndexEntry.java index f0c8a3e5fa..51145b195a 100644 --- a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndexEntry.java +++ b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndexEntry.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.internal.ctf.core.trace; import java.util.HashMap; import java.util.Map; +import org.eclipse.tracecompass.ctf.core.CTFStrings; import org.eclipse.tracecompass.ctf.core.event.types.EnumDefinition; import org.eclipse.tracecompass.ctf.core.event.types.FloatDefinition; import org.eclipse.tracecompass.ctf.core.event.types.IDefinition; @@ -122,24 +123,24 @@ public class StreamInputPacketIndexEntry { for (String field : streamPacketContextDef.getDeclaration().getFieldsList()) { IDefinition id = streamPacketContextDef.lookupDefinition(field); if (id instanceof IntegerDefinition) { - addAttribute(field, ((IntegerDefinition) id).getValue()); + fAttributes.put(field, ((IntegerDefinition) id).getValue()); } else if (id instanceof FloatDefinition) { - addAttribute(field, ((FloatDefinition) id).getValue()); + fAttributes.put(field, ((FloatDefinition) id).getValue()); } else if (id instanceof EnumDefinition) { - addAttribute(field, ((EnumDefinition) id).getValue()); + fAttributes.put(field, ((EnumDefinition) id).getValue()); } else if (id instanceof StringDefinition) { - addAttribute(field, ((StringDefinition) id).getValue()); + fAttributes.put(field, ((StringDefinition) id).getValue()); } } - Long contentSize = (Long) this.lookupAttribute("content_size"); //$NON-NLS-1$ - Long packetSize = (Long) this.lookupAttribute("packet_size"); //$NON-NLS-1$ - Long tsBegin = (Long) this.lookupAttribute("timestamp_begin"); //$NON-NLS-1$ - Long tsEnd = (Long) this.lookupAttribute("timestamp_end"); //$NON-NLS-1$ - String device = (String) this.lookupAttribute("device"); //$NON-NLS-1$ + Long contentSize = (Long) fAttributes.get(CTFStrings.CONTENT_SIZE); + Long packetSize = (Long) fAttributes.get(CTFStrings.PACKET_SIZE); + Long tsBegin = (Long) fAttributes.get(CTFStrings.TIMESTAMP_BEGIN); + Long tsEnd = (Long) fAttributes.get(CTFStrings.TIMESTAMP_END); + String device = (String) fAttributes.get(CTFStrings.DEVICE); // LTTng Specific - Long cpuId = (Long) this.lookupAttribute("cpu_id"); //$NON-NLS-1$ - Long lostEvents = (Long) this.lookupAttribute("events_discarded"); //$NON-NLS-1$ + Long cpuId = (Long) fAttributes.get(CTFStrings.CPU_ID); + Long lostEvents = (Long) fAttributes.get(CTFStrings.EVENTS_DISCARDED); /* Read the content size in bits */ if (contentSize != null) { @@ -154,7 +155,7 @@ public class StreamInputPacketIndexEntry { if (packetSize != null) { fPacketSizeBits = (packetSize.longValue()); } else if (this.getContentSizeBits() != 0) { - fPacketSizeBits = (getContentSizeBits()); + fPacketSizeBits = fContentSizeBits; } else { fPacketSizeBits = (fileSizeBytes * Byte.SIZE); } -- 2.34.1