ss: Add a custom state value type
authorGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 7 Apr 2016 18:49:52 +0000 (14:49 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 12 May 2016 00:43:51 +0000 (20:43 -0400)
This patch just adds the type and updates all the switch cases.

It does nothing else for now, but it reduces the noise of the
other patch which actually adds the behavior of the custom value.

Change-Id: Ie16b2ff851968edc581f14abce175f0c0f2c6cc3
Signed-off-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/70173
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Alexandre Montplaisir <alexmonthy@efficios.com>
18 files changed:
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/GenerateTestValues.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/statevalue/DoubleStateValue.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/statevalue/ITmfStateValue.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/statevalue/IntegerStateValue.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/statevalue/LongStateValue.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/statevalue/StringStateValue.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlPatternSegmentBuilder.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlStateValue.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfStateSystemOperations.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/Messages.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/messages.properties

index 390e49d480587900b0312ce1d6e2845f296f4d17..5c90267ffee4b97da4ef8bd2ff32cc24c0340b1d 100644 (file)
@@ -131,6 +131,7 @@ public class GenerateTestValues {
                 case STRING:
                     writer.println("TmfStateValue.newValueString(\"" + val.unboxStr() + "\"),");
                     break;
+                case CUSTOM:
                 default:
                     writer.println(val.toString());
                     break;
index 0350389b77bd9b103ef4700db2c1b9c20884178b..407ef5114d5650ab57a7fbae229940ec30d27ee5 100644 (file)
@@ -31,6 +31,7 @@ import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
@@ -192,8 +193,7 @@ public class VirtualMachineCpuAnalysis extends TmfStateSystemAnalysisModule {
 
                 for (ITmfStateInterval cpuInterval : StateSystemUtils.queryHistoryRange(ss, statusQuark, start, end - 1, resolution, monitor)) {
                     ITmfStateValue stateValue = cpuInterval.getStateValue();
-                    switch (stateValue.getType()) {
-                    case INTEGER:
+                    if (stateValue.getType() == Type.INTEGER) {
                         int value = stateValue.unboxInt();
                         /*
                          * If the current CPU is either preempted or in
@@ -201,21 +201,13 @@ public class VirtualMachineCpuAnalysis extends TmfStateSystemAnalysisModule {
                          * processes
                          */
                         if ((value & (VcpuStateValues.VCPU_PREEMPT | VcpuStateValues.VCPU_VMM)) == 0) {
-                            break;
+                            continue;
                         }
                         Integer threadOnCpu = KernelThreadInformationProvider.getThreadOnCpu(kernelModule, virtualCPU, cpuInterval.getStartTime());
                         if (threadOnCpu != null) {
                             map.put(threadOnCpu, new TmfStateInterval(cpuInterval.getStartTime(), cpuInterval.getEndTime(), threadOnCpu, VCPU_PREEMPT_VALUE));
                         }
-                        break;
-                    case DOUBLE:
-                    case LONG:
-                    case NULL:
-                    case STRING:
-                    default:
-                        break;
                     }
-
                 }
             }
         } catch (AttributeNotFoundException | StateSystemDisposedException e) {
index 99abcf558864d4f873d3fe22c1b1b52b182f029d..44eada2b9cc8c2b76d099b91d88a03577f500335 100644 (file)
@@ -40,6 +40,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
     private static final byte TYPE_STRING = 1;
     private static final byte TYPE_LONG = 2;
     private static final byte TYPE_DOUBLE = 3;
+    private static final byte TYPE_CUSTOM = 20;
 
     private final long start;
     private final long end;
@@ -102,6 +103,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
              * String's length + 2 (1 byte for size, 1 byte for \0 at the end
              */
             return (minSize + sv.unboxStr().getBytes().length + 2);
+        case CUSTOM:
         default:
             /*
              * It's very important that we know how to write the state value in
@@ -202,6 +204,7 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
             value = TmfStateValue.newValueDouble(buffer.getDouble());
             break;
 
+        case TYPE_CUSTOM:
         default:
             /* Unknown data, better to not make anything up... */
             throw new IOException(errMsg);
@@ -378,6 +381,8 @@ public final class HTInterval implements ITmfStateInterval, Comparable<HTInterva
             return TYPE_LONG;
         case DOUBLE:
             return TYPE_DOUBLE;
+        case CUSTOM:
+            return TYPE_CUSTOM;
         default:
             /* Should not happen if the switch is fully covered */
             throw new IllegalStateException();
index d53c83c5602495583be8bc9afa09db0752ce3579..79e798776404a7593419348170999225ba2ed205 100644 (file)
@@ -87,6 +87,7 @@ final class DoubleStateValue extends TmfStateValue {
             return Double.compare(this.value, other.unboxDouble());
         case STRING:
             throw new StateValueTypeException("A Double state value cannot be compared to a String state value."); //$NON-NLS-1$
+        case CUSTOM:
         default:
             throw new StateValueTypeException("A Double state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
         }
index a5a9e864032b954b9f514e29025a61377b1aa48a..3fe4846b81780e1422ecb9873c0cceecb7cb2f98 100644 (file)
@@ -35,6 +35,9 @@ public interface ITmfStateValue extends Comparable<ITmfStateValue> {
         DOUBLE,
         /** Variable-length string value */
         STRING,
+        /** Custom state value type
+         * @since 2.0 */
+        CUSTOM;
     }
 
     /**
index 41216f2153ca8395bf771dffd6664ccefe8ed575..d097e78220ab9761e516be8e5564ff646f676394 100644 (file)
@@ -93,6 +93,7 @@ final class IntegerStateValue extends TmfStateValue {
             return Integer.compare(this.value, other.unboxInt());
         case STRING:
             throw new StateValueTypeException("An Integer state value cannot be compared to a String state value."); //$NON-NLS-1$
+        case CUSTOM:
         default:
             throw new StateValueTypeException("An Integer state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
         }
index 0770024a133d99979f43d7b0a510abbe2171385f..77ff0b96e3d7b77e6e8f549b0ccb014f583920d5 100644 (file)
@@ -87,6 +87,7 @@ final class LongStateValue extends TmfStateValue {
             return Long.compare(this.value, other.unboxLong());
         case STRING:
             throw new StateValueTypeException("A Long state value cannot be compared to a String state value."); //$NON-NLS-1$
+        case CUSTOM:
         default:
             throw new StateValueTypeException("A Long state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
         }
index 4e56b8f6efa7186b3e7335c07fb8ec7328af5a9a..b5a6732f88c8f008a07011e6c7bda03a5ce47317 100644 (file)
@@ -89,6 +89,7 @@ final class StringStateValue extends TmfStateValue {
         case STRING:
             StringStateValue otherStringValue = (StringStateValue) other;
             return value.compareTo(otherStringValue.value);
+        case CUSTOM:
         default:
             throw new StateValueTypeException("A String state value cannot be compared to the type " + other.getType()); //$NON-NLS-1$
         }
index 19bb1af59a35801d6e2c125291392ccc144a385e..cc77e28df50c85393d081a22ef7ad0c6326b0410 100644 (file)
@@ -207,6 +207,7 @@ public class TmfXmlPatternSegmentBuilder {
             case STRING:
                 builder.append(value.unboxStr());
                 break;
+            case CUSTOM:
             default:
                 throw new StateValueTypeException("Invalid type of state value"); //$NON-NLS-1$
             }
index cbe56f6b05b942b6d65effd76b69056aeba9fcfd..c1f1de62f15c7733ccd5bbd4eae719a022a13377 100644 (file)
@@ -288,6 +288,7 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute {
                 }
                 case DOUBLE:
                 case NULL:
+                case CUSTOM:
                 default:
                     quark = IXmlStateSystemContainer.ERROR_QUARK; // error
                     break;
index b5d44cafc98043686ffa71cdc08f2962feeafbe4..e7e8533a2949a6fea0b39434ff2e8535523dd37a 100644 (file)
@@ -286,6 +286,8 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue {
             case DOUBLE:
                 value = TmfStateValue.newValueDouble(Double.parseDouble(fieldString));
                 break;
+            case CUSTOM:
+                throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
             case NULL:
             case STRING:
             default:
@@ -305,6 +307,8 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue {
             case DOUBLE:
                 value = TmfStateValue.newValueDouble(fieldLong.doubleValue());
                 break;
+            case CUSTOM:
+                throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
             case LONG:
             case NULL:
             default:
@@ -324,6 +328,8 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue {
             case DOUBLE:
                 value = TmfStateValue.newValueDouble(fieldInteger.doubleValue());
                 break;
+            case CUSTOM:
+                throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
             case INTEGER:
             case NULL:
             default:
@@ -343,6 +349,8 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue {
             case INTEGER:
                 value = TmfStateValue.newValueInt(fieldDouble.intValue());
                 break;
+            case CUSTOM:
+                throw new IllegalStateException("Custom type cannot be forced"); //$NON-NLS-1$
             case DOUBLE:
             case NULL:
             default:
index 9ecaf9a04cb9969ea61e817682b6f99224fdaaed..c2f3da9c36730a4e259d0347b1b2498e686088b3 100644 (file)
@@ -226,6 +226,7 @@ public class TmfXmlPatternSegment implements ISegment {
         case LONG:
             return TYPE_LONG;
         case DOUBLE:
+        case CUSTOM:
         default:
             /* Should not happen if the switch is fully covered */
             throw new IllegalStateException("Data type " + type + " not supported"); //$NON-NLS-1$ //$NON-NLS-2$
index 438422b219e43ccd5c3f33182537118314c4becb..8be63d53f0218eea3e420c3eae335b3207ad4234 100644 (file)
@@ -307,6 +307,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
                                 break;
                             case NULL:
                             case STRING:
+                            case CUSTOM:
                             default:
                                 break;
                             }
index b6fd0c8e2ed1fe0e3c35b127d77d1de5dd4e8774..8ee24953aebb49988f4b9a495af643e04f82bd50 100644 (file)
@@ -85,6 +85,7 @@ public final class TmfStateSystemOperations {
 
             case NULL:
             case STRING:
+            case CUSTOM:
             default:
                 throw new StateValueTypeException(ss.getSSID() + " Quark:" + quark + ", Type:" + value.getType()); //$NON-NLS-1$ //$NON-NLS-2$
             }
@@ -140,6 +141,7 @@ public final class TmfStateSystemOperations {
 
             case NULL:
             case STRING:
+            case CUSTOM:
             default:
                 throw new StateValueTypeException(ss.getSSID() + " Quark:" + quark + ", Type:" + value.getType()); //$NON-NLS-1$ //$NON-NLS-2$
             }
index 84ed2f256fea491ea8d5bc324d886ea294cc447a..96537727f2791ce354a6c8ca59b93fc2ff9eab66 100644 (file)
@@ -76,4 +76,8 @@ public class Messages extends NLS {
 
     /** Label for the type String */
     public static String TypeString;
+
+    /** Label for the type Custom
+     * @since 2.0 */
+    public static String TypeCustom;
 }
index edda1f7f514c8b58f8bb29a7efa8fa490b6cc032..5ed89b296c044b05cddda98146259dab3ce34c5e 100644 (file)
@@ -412,6 +412,7 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer {
             case LONG:
             case DOUBLE:
             case STRING:
+            case CUSTOM:
                 return fValue.toString();
             case NULL:
             default:
@@ -432,6 +433,8 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer {
                 return Messages.TypeDouble;
             case STRING:
                 return Messages.TypeString;
+            case CUSTOM:
+                return Messages.TypeCustom;
             case NULL:
             default:
                 return EMPTY_STRING;
This page took 0.033986 seconds and 5 git commands to generate.