linux.core: Remove throws runtime exceptions
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 8 Sep 2016 13:31:22 +0000 (09:31 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 9 Sep 2016 01:30:05 +0000 (21:30 -0400)
AttributeNotFoundException is now a runtime exception. In practice, it
should never happen here as the quarks are always added before accessing
them.

This removes a few warnings.

Change-Id: If6048d8c717f89d21e88e54cbb87a0f67aa26d59
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/80697
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/KernelEventHandlerUtils.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SchedSwitchHandler.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/StateDumpHandler.java

index b1cc556ccc17399cb081aebc494d03f9af07f371..61cceb0c5cca81aaddde461f95a2b9327bd0148c 100644 (file)
@@ -15,7 +15,6 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
-import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
@@ -88,10 +87,8 @@ public final class KernelEventHandlerUtils {
      *            the state system
      *
      * @return the current thread node quark
-     * @throws AttributeNotFoundException
-     *             current cpu node not found
      */
-    public static int getCurrentThreadNode(Integer cpuNumber, ITmfStateSystemBuilder ss) throws AttributeNotFoundException {
+    public static int getCurrentThreadNode(Integer cpuNumber, ITmfStateSystemBuilder ss) {
         /*
          * Shortcut for the "current thread" attribute node. It requires
          * querying the current CPU's current thread.
@@ -114,15 +111,13 @@ public final class KernelEventHandlerUtils {
      *            The current thread node
      * @param ssb
      *            the state system
-     * @throws AttributeNotFoundException
-     *             an attribute does not exists yet
      * @throws TimeRangeException
      *             the time is out of range
      * @throws StateValueTypeException
      *             the attribute was not set with int values
      */
     public static void setProcessToRunning(long timestamp, int currentThreadNode, ITmfStateSystemBuilder ssb)
-            throws AttributeNotFoundException, TimeRangeException,
+            throws TimeRangeException,
             StateValueTypeException {
         int quark;
         ITmfStateValue value;
@@ -199,14 +194,11 @@ public final class KernelEventHandlerUtils {
      *            State system
      * @throws StateValueTypeException
      *             the attribute is not set as an int
-     * @throws AttributeNotFoundException
-     *             the attribute was not created yet
      * @throws TimeRangeException
      *             the time is out of range
      */
     public static void cpuExitInterrupt(long timestamp, Integer cpuNumber, ITmfStateSystemBuilder ssb)
-            throws StateValueTypeException, AttributeNotFoundException,
-            TimeRangeException {
+            throws StateValueTypeException, TimeRangeException {
         int quark;
         int currentCPUNode = getCurrentCPUNode(cpuNumber, ssb);
 
@@ -235,10 +227,8 @@ public final class KernelEventHandlerUtils {
      *            The *quark* of the CPU we are looking for. Careful, this is
      *            NOT the CPU number (or attribute name)!
      * @return The state value that represents the status of the given CPU
-     * @throws AttributeNotFoundException
      */
-    private static ITmfStateValue getCpuStatus(ITmfStateSystemBuilder ssb, int cpuQuark)
-            throws AttributeNotFoundException {
+    private static ITmfStateValue getCpuStatus(ITmfStateSystemBuilder ssb, int cpuQuark) {
 
         /* Check if there is a IRQ running */
         int irqQuarks = ssb.getQuarkRelativeAndAdd(cpuQuark, Attributes.IRQS);
@@ -274,8 +264,6 @@ public final class KernelEventHandlerUtils {
             return StateValues.CPU_STATUS_IDLE_VALUE;
         }
         int threadSystemCallQuark = ssb.getQuarkAbsoluteAndAdd(Attributes.THREADS, Integer.toString(tid), Attributes.SYSTEM_CALL);
-        return (ssb.queryOngoingState(threadSystemCallQuark).isNull() ?
-                StateValues.CPU_STATUS_RUN_USERMODE_VALUE :
-                StateValues.CPU_STATUS_RUN_SYSCALL_VALUE);
+        return (ssb.queryOngoingState(threadSystemCallQuark).isNull() ? StateValues.CPU_STATUS_RUN_USERMODE_VALUE : StateValues.CPU_STATUS_RUN_SYSCALL_VALUE);
     }
 }
index d4d0ed35ea2cc30f3688ecf2caefc5dfeacd48aa..a30d37ca59cef17dd42e9968b9d9b931985e763e 100644 (file)
@@ -95,7 +95,7 @@ public class SchedSwitchHandler extends KernelEventHandler {
         setCpuStatus(ss, nextTid, newCurrentThreadNode, timestamp, currentCPUNode);
     }
 
-    private static void setOldProcessStatus(ITmfStateSystemBuilder ss, Long prevState, Integer formerThreadNode, long timestamp) throws AttributeNotFoundException {
+    private static void setOldProcessStatus(ITmfStateSystemBuilder ss, Long prevState, Integer formerThreadNode, long timestamp) {
         ITmfStateValue value;
         /*
          * Empirical observations and look into the linux code have
@@ -137,7 +137,7 @@ public class SchedSwitchHandler extends KernelEventHandler {
         return state == 0;
     }
 
-    private static void setCpuStatus(ITmfStateSystemBuilder ss, Integer nextTid, Integer newCurrentThreadNode, long timestamp, int currentCPUNode) throws AttributeNotFoundException {
+    private static void setCpuStatus(ITmfStateSystemBuilder ss, Integer nextTid, Integer newCurrentThreadNode, long timestamp, int currentCPUNode) {
         int quark;
         ITmfStateValue value;
         if (nextTid > 0) {
@@ -156,7 +156,7 @@ public class SchedSwitchHandler extends KernelEventHandler {
         ss.modifyAttribute(timestamp, value, quark);
     }
 
-    private static void setCpuProcess(ITmfStateSystemBuilder ss, Integer nextTid, long timestamp, int currentCPUNode) throws AttributeNotFoundException {
+    private static void setCpuProcess(ITmfStateSystemBuilder ss, Integer nextTid, long timestamp, int currentCPUNode) {
         int quark;
         ITmfStateValue value;
         quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
@@ -164,7 +164,7 @@ public class SchedSwitchHandler extends KernelEventHandler {
         ss.modifyAttribute(timestamp, value, quark);
     }
 
-    private static void setProcessPrio(ITmfStateSystemBuilder ss, Integer prio, Integer threadNode, long timestamp) throws AttributeNotFoundException {
+    private static void setProcessPrio(ITmfStateSystemBuilder ss, Integer prio, Integer threadNode, long timestamp) {
         int quark;
         ITmfStateValue value;
         quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.PRIO);
@@ -172,7 +172,7 @@ public class SchedSwitchHandler extends KernelEventHandler {
         ss.modifyAttribute(timestamp, value, quark);
     }
 
-    private static void setProcessExecName(ITmfStateSystemBuilder ss, String processName, Integer threadNode, long timestamp) throws AttributeNotFoundException {
+    private static void setProcessExecName(ITmfStateSystemBuilder ss, String processName, Integer threadNode, long timestamp) {
         int quark;
         ITmfStateValue value;
         quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.EXEC_NAME);
index 020b145c589a920ae8cf59552ab876b3303d1b29..36770ca6d0652213f9509d5be13d6644e67f37e7 100644 (file)
@@ -71,7 +71,7 @@ public class StateDumpHandler extends KernelEventHandler {
         setStatus(ss, status, curThreadNode, timestamp);
     }
 
-    private static void setStatus(ITmfStateSystemBuilder ss, int status, int curThreadNode, long timestamp) throws AttributeNotFoundException {
+    private static void setStatus(ITmfStateSystemBuilder ss, int status, int curThreadNode, long timestamp) {
         ITmfStateValue value;
         int quark;
         quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.STATUS);
@@ -96,7 +96,7 @@ public class StateDumpHandler extends KernelEventHandler {
         }
     }
 
-    private static void setPpid(ITmfStateSystemBuilder ss, int tid, int pid, int ppid, int curThreadNode, long timestamp) throws AttributeNotFoundException {
+    private static void setPpid(ITmfStateSystemBuilder ss, int tid, int pid, int ppid, int curThreadNode, long timestamp) {
         ITmfStateValue value;
         int quark;
         quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.PPID);
@@ -112,7 +112,7 @@ public class StateDumpHandler extends KernelEventHandler {
         }
     }
 
-    private static void setProcessName(ITmfStateSystemBuilder ss, String name, int curThreadNode, long timestamp) throws AttributeNotFoundException {
+    private static void setProcessName(ITmfStateSystemBuilder ss, String name, int curThreadNode, long timestamp) {
         ITmfStateValue value;
         int quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.EXEC_NAME);
         if (ss.queryOngoingState(quark).isNull()) {
This page took 0.029539 seconds and 5 git commands to generate.