tmf: Fix some Sonar warnings in the state system code
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / statesystem / backends / partial / PartialHistoryBackend.java
index f731170b916574930568f5cf38b8c5c369ec3dd8..5568d9f2a3f0400e9a17b41b8f4a64c62665a3c3 100644 (file)
@@ -33,6 +33,7 @@ import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
 import org.eclipse.linuxtools.tmf.core.statesystem.AbstractTmfStateProvider;
 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
 import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
@@ -100,12 +101,10 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
      */
     public PartialHistoryBackend(ITmfStateProvider partialInput, PartialStateSystem pss,
             IStateHistoryBackend realBackend, long granularity) {
-        if (granularity <= 0 || partialInput == null || pss == null) {
+        if (granularity <= 0 || partialInput == null || pss == null ||
+                partialInput.getAssignedStateSystem() != pss) {
             throw new IllegalArgumentException();
         }
-        if (partialInput.getAssignedStateSystem() != pss) {
-            throw new RuntimeException();
-        }
 
         final long startTime = realBackend.getStartTime();
 
@@ -218,8 +217,8 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
                  * caused by the event(s) happening exactly at 'checkpointTime',
                  * if any. We must not include those events in the query.
                  */
-                new TmfTimestamp(checkpointTime + 1, -9),
-                new TmfTimestamp(t, -9));
+                new TmfTimestamp(checkpointTime + 1, ITmfTimestamp.NANOSECOND_SCALE),
+                new TmfTimestamp(t, ITmfTimestamp.NANOSECOND_SCALE));
         ITmfEventRequest request = new PartialStateSystemRequest(partialInput, range);
         partialInput.getTrace().sendRequest(request);
 
@@ -286,7 +285,7 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
     private class CheckpointsRequest extends TmfEventRequest {
 
         /** The amount of events queried at a time through the requests */
-        private final static int chunkSize = 50000;
+        private static final int CHUNK_SIZE = 50000;
 
         private final ITmfTrace trace;
         private final Map<Long, Long> checkpts;
@@ -297,12 +296,13 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
             super(input.getExpectedEventType(),
                     TmfTimeRange.ETERNITY,
                     TmfDataRequest.ALL_DATA,
-                    chunkSize,
+                    CHUNK_SIZE,
                     ITmfDataRequest.ExecutionType.BACKGROUND);
             checkpoints.clear();
             this.trace = input.getTrace();
             this.checkpts = checkpoints;
-            eventCount = lastCheckpointAt = 0;
+            eventCount = 0;
+            lastCheckpointAt = 0;
 
             /* Insert a checkpoint at the start of the trace */
             checkpoints.put(input.getStartTime(), 0L);
@@ -331,7 +331,7 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
 
     private class PartialStateSystemRequest extends TmfEventRequest {
 
-        private final static int chunkSize = 50000;
+        private static final int CHUNK_SIZE = 50000;
         private final ITmfStateProvider sci;
         private final ITmfTrace trace;
 
@@ -339,7 +339,7 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
             super(sci.getExpectedEventType(),
                     range,
                     TmfDataRequest.ALL_DATA,
-                    chunkSize,
+                    CHUNK_SIZE,
                     ITmfDataRequest.ExecutionType.BACKGROUND);
             this.sci = sci;
             this.trace = sci.getTrace();
This page took 0.025717 seconds and 5 git commands to generate.