noteAndClearInterrupt,
or (setInterrupted)), and retry whatever got interrupted,
continuing execution. To achieve this, Derby will always temporarily
clear the interrupted status flag.
Later, depending on the type of SQL statement, we may wish to
interrupt execution by throwing an SQLException at a safe place, say,
after a statement in a batch is complete (throwIf), or just
let the execution run to completion, and then just prior to returning
to the appliction, the thread's interrupted status flag will
resurrected (restoreIntrFlagIfSeen)
| Modifier and Type | Field and Description |
|---|---|
| private static final ThreadLocal | exception
Use thread local variable to store interrupt status flag *only* if we don't have lcc, e.g. during database creation, shutdown etc. |
| public static final int | |
| public static final int | MAX_INTERRUPT_RETRIES
Constants used by code that retries file operations after seeing the NIO file channel closed due to interrupts. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static Context | getContextOrNull(final String contextID)
Must be private so that user code can't call this entry point. |
| public static boolean | Returns: true if the thread's interrupt status flag was set(debug info) whence s, int (debug info) number of threads inside the NIO
code concurrently threadsInPageIO, int (debug info) container id hashCode)Checks if the thread has been interrupted in NIO, presumably because we saw an exception indicating this. |
| public static void | restoreIntrFlagIfSeen()
Check if the we ever noticed and reset the thread's interrupt status flag to allow safe operation during execution. |
| public static void | restoreIntrFlagIfSeen(LanguageConnectionContext
the language connection context for this session lcc)
Same purpose as |
| public static void | saveInfoFromLcc(LanguageConnectionContext lcc)
Use when lcc is dying to save info in thread local instead. |
| public static void | |
| public static void | throwIf(LanguageConnectionContext
the language connection context for this session lcc)Check if the we ever noticed and reset the thread's interrupt status flag to allow safe operation during execution, or if the interrupt status flag is set now. |
| exception | back to summary |
|---|---|
| private static final ThreadLocal<Exception> exception Use thread local variable to store interrupt status flag *only* if we don't have lcc, e.g. during database creation, shutdown etc. | |
| INTERRUPT_RETRY_SLEEP | back to summary |
|---|---|
| public static final int INTERRUPT_RETRY_SLEEP | |
| MAX_INTERRUPT_RETRIES | back to summary |
|---|---|
| public static final int MAX_INTERRUPT_RETRIES Constants used by code that retries file operations after seeing the NIO file channel closed due to interrupts. | |
| InterruptStatus | back to summary |
|---|---|
| public InterruptStatus() | |
| getContextOrNull | back to summary |
|---|---|
| private static Context getContextOrNull(final String contextID) Must be private so that user code can't call this entry point. | |
| noteAndClearInterrupt | back to summary |
|---|---|
| public static boolean noteAndClearInterrupt(String s, int threadsInPageIO, int hashCode)
Checks if the thread has been interrupted in NIO, presumably because we
saw an exception indicating this. Make a note of this and clear the
thread's interrupt status flag (NIO doesn't clear it when throwing) so
we can retry whatever we are doing. It will be set back ON before
control is transferred back to the application, cf.
The note that we saw an interrupt is stored in the lcc if available, if
not, in thread local
| |
| restoreIntrFlagIfSeen | back to summary |
|---|---|
| public static void restoreIntrFlagIfSeen()
Check if the we ever noticed and reset the thread's interrupt status
flag to allow safe operation during execution. Called from JDBC API
methods before returning control to user application. Typically, this
happens just prior to return in methods that catch
:
InterruptStatus.restoreIntrFlagIfSeen();
return ...;
} catch (Throwable t) {
throw handleException(t);
}
If an interrupt status flag was seen, we set it back on here. | |
| restoreIntrFlagIfSeen | back to summary |
|---|---|
| public static void restoreIntrFlagIfSeen(LanguageConnectionContext lcc)
Same purpose as
If no
| |
| saveInfoFromLcc | back to summary |
|---|---|
| public static void saveInfoFromLcc(LanguageConnectionContext lcc) Use when lcc is dying to save info in thread local instead. Useful under shutdown. | |
| setInterrupted | back to summary |
|---|---|
| public static void setInterrupted() Make a note that this thread saw an interrupt. Thread's intr status flag is presumably off already, but we reset it here also. Use lcc if available, else thread local variable. | |
| throwIf | back to summary |
|---|---|
| public static void throwIf(LanguageConnectionContext lcc) throws StandardException Check if the we ever noticed and reset the thread's interrupt status flag to allow safe operation during execution, or if the interrupt status flag is set now. Called when operations want to be prematurely terminated due to interrupt. If an interrupt status flag was seen, but temporarily switched off, we set it back ON here.
| |