]> git.efficios.com Git - deliverable/tracecompass.git/commitdiff
analysis: Fix TreeMapStore's serialization
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 14 Oct 2015 00:12:10 +0000 (20:12 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 14 Oct 2015 22:28:12 +0000 (18:28 -0400)
Change-Id: Ia6c3299d8e0e940cae52118c14ca04c16aedd049
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/58118
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/LatencyAnalysis.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/latency/SystemCall.java

index 2ee2ab25c032e442eefc2ca18a71bf87eedf9947..26cd42f5ffbd9c907ec96f5bc09d5da1b74ae0aa 100644 (file)
@@ -87,9 +87,18 @@ public class LatencyAnalysis extends TmfAbstractAnalysisModule {
         if (Files.exists(file)) {
             /* Attempt to read the existing file */
             try (ObjectInputStream ois = new ObjectInputStream(Files.newInputStream(file))) {
-                @SuppressWarnings("unchecked")
-                ISegmentStore<ISegment> syscalls = (ISegmentStore<ISegment>) ois.readObject();
-                fSystemCalls = syscalls;
+                Object[] syscallsArray = (Object[]) ois.readObject();
+                final ISegmentStore<ISegment> systemCalls = new TreeMapStore<>();
+                for (Object element : syscallsArray) {
+                    if (element instanceof ISegment) {
+                        ISegment segment = (ISegment) element;
+                        systemCalls.add(segment);
+                    }
+                }
+                fSystemCalls = systemCalls;
+                for (LatencyAnalysisListener listener : fListeners) {
+                    listener.onComplete(this, systemCalls);
+                }
                 return true;
             } catch (IOException | ClassNotFoundException | ClassCastException e) {
                 /*
@@ -131,7 +140,7 @@ public class LatencyAnalysis extends TmfAbstractAnalysisModule {
 
         /* Serialize the collections to disk for future usage */
         try (ObjectOutputStream oos = new ObjectOutputStream(Files.newOutputStream(file))) {
-            oos.writeObject(syscalls);
+            oos.writeObject(syscalls.toArray());
         } catch (IOException e) {
             /* Didn't work, oh well. We will just re-read the trace next time */
         }
index 1fbbbdd313ba685ed6b739899520cd67b10fb0b0..b57fa1855a67318ffe7068ac93f66bff66880de5 100644 (file)
@@ -71,7 +71,6 @@ public class SystemCall implements ISegment {
     private final InitialInfo fInfo;
     private final long fEndTime;
     private final int fRet;
-    private final transient long fDuration;
 
     /**
      * @param info
@@ -88,7 +87,6 @@ public class SystemCall implements ISegment {
         fInfo = info;
         fEndTime = endTime;
         fRet = ret;
-        fDuration = fEndTime - fInfo.fStartTime;
     }
 
     @Override
@@ -103,7 +101,7 @@ public class SystemCall implements ISegment {
 
     @Override
     public long getLength() {
-        return fDuration;
+        return fEndTime - fInfo.fStartTime;
     }
 
     /**
@@ -133,7 +131,6 @@ public class SystemCall implements ISegment {
         return fRet;
     }
 
-
     @Override
     public int compareTo(@Nullable ISegment o) {
         if (o == null) {
This page took 0.029759 seconds and 5 git commands to generate.