public abstract class AbstractInterruptsTestCase extends AbstractRawStoreTestCase
ClosedByInterruptException
s. When
a commit group is aborted, the Thread
s for the tasks in that commit
group are interrupted. If a task was in the midst of an IO operation on a
Channel
then the channel will be asynchronously closed by the JDK.
Since we use a FileChannel
to access the backing store, this means
that we need to transparently re-open the channel so that we can continue
operations on the store.
Note: The tests in this class require a BufferStrategy
that is backed
by stable storage (i.e., by a FileChannel
). They doubtless will NOT
work for a mapped file since you have no control over when the file is
unmapped under Java.
TestCase2.MyProperties, TestCase2.RandomType
r
_randomType, log
Constructor and Description |
---|
AbstractInterruptsTestCase() |
AbstractInterruptsTestCase(String name) |
Modifier and Type | Method and Description |
---|---|
void |
test_reopenAfterInterrupt_checkWriteBuffer()
A simple test verifies that a read will transparently re-open the backing
FileChannel after a ClosedByInterruptException . |
void |
test_reopenAfterInterrupt()
A simple test verifies that a read will transparently re-open the backing
FileChannel after a ClosedByInterruptException . |
getRandomData, getStore, test_close, test_multipleWrites, test_read_correctRejection_0L, test_read_correctRejection_zeroLength, test_readImmutable, test_write_correctRejection_emptyRecord, test_write_correctRejection_null, test_writeImmutable, test_writeRead, test_writeReadRead, testBlobObjectStreams, testEmptyStream, testSimpleStringStream, testSimpleStringStreamFromStandardAllocation, testZipStreams
assertCondition, assertCondition, assertEquals, assertEquals, getBytes, getPort, getRandomData, getRandomData, setUp, tearDown
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsWithinUlps, assertSameArray, assertSameArray, assertSameBigDecimal, assertSameBigDecimal, assertSameBigInteger, assertSameBigInteger, assertSameIterator, assertSameIterator, assertSameIteratorAnyOrder, assertSameIteratorAnyOrder, assertSameValue, assertSameValue, assertZeroUlps, assertZeroUlps, fail, getInnerCause, getNormalInt, getProjectBuildPath, getProperties, getRandomObject, getRandomObject, getRandomOrder, getRandomString, getTestInputStream, getTestResource, getTestResource, getUlps, getUlps, isDEBUG, isDEBUG, isINFO, isINFO, isInnerCause, logProperties
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, toString
public AbstractInterruptsTestCase()
public AbstractInterruptsTestCase(String name)
name
- public void test_reopenAfterInterrupt()
FileChannel
after a ClosedByInterruptException
.
The test uses the IRawStore
API. It writes an initial record on
the store. It then interrupts the main thread and then
performs another low level write on the store. The store is then forced
to disk to ensure that a ClosedByInterruptException
is triggered
(during an IO), (alternatively, an InterruptedException
can be
triggered when we try to acquire a lock). Either way this second record
is never written.
Once the ClosedByInterruptException
or
InterruptedException
has been triggered, we then attempt to
re-read the 1st record, which was made restart safe by the commit.
Note: This test is only for IDiskBasedStrategy
implementations.
public void test_reopenAfterInterrupt_checkWriteBuffer()
FileChannel
after a ClosedByInterruptException
.
The test uses the IRawStore
API. It writes an initial record on
but does NOT force the store to the backing file. It then interrupts the
main thread and issues a request to force the store to disk. This request
triggers a ClosedByInterruptException
(during an IO) -or- an
InterruptedException
(when trying to acquire a lock). At this
point nothing has been written on the file.
Once the ClosedByInterruptException
or
InterruptedException
has been triggered, we then attempt to
re-read the record that was written. If the store buffers writes then
this operation will succeed.
Note: Both the DirectBufferStrategy
and the
DiskOnlyStrategy
buffer writes, so both should pass this test.
Note: This test is only for IDiskBasedStrategy
implementations.
Note: This test is not relevant for RWStrategy since it does not buffer
writes in a reliable way.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.