From: <tho...@us...> - 2010-10-08 14:37:05
|
Revision: 3753 http://bigdata.svn.sourceforge.net/bigdata/?rev=3753&view=rev Author: thompsonbry Date: 2010-10-08 14:36:59 +0000 (Fri, 08 Oct 2010) Log Message: ----------- Modified the WriteCacheService to set open:=false at the top of close() and to trap a thrown IllegalStateException in read() and return null so that the caller will read through to the backing store if the write cache service is concurrently closed (this is per its API). Modified the TestConcurrentJournal to check for isCancelled() since the test_concurrentReaders() was running with a timeout and failing if any tasks were cancelled. Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/io/writecache/WriteCacheService.java branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestConcurrentJournal.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/io/writecache/WriteCacheService.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/io/writecache/WriteCacheService.java 2010-10-08 12:50:48 UTC (rev 3752) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/io/writecache/WriteCacheService.java 2010-10-08 14:36:59 UTC (rev 3753) @@ -226,6 +226,8 @@ * write lock prevents {@link #acquireForWriter()} when we must either reset * the {@link #current} cache buffer or change the {@link #current} * reference. E.g., {@link #flush(boolean, long, TimeUnit)}. + * <p> + * Note: {@link #read(long)} is non-blocking. It does NOT use this lock!!! */ final private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); @@ -957,6 +959,9 @@ return; } + // Closed. + open = false; + // Interrupt the write task. localWriteFuture.cancel(true/* mayInterruptIfRunning */); final Future<?> rwf = remoteWriteFuture; @@ -1031,9 +1036,6 @@ // if (haServer != null) // haServer.interrupt(); - // Closed. - open = false; - } finally { writeLock.unlock(); } @@ -1910,8 +1912,6 @@ * Not open. Return [null] rather than throwing an exception per the * contract for this implementation. */ - log.warn("Reading from closed writeCacheService"); - return null; } @@ -1934,9 +1934,17 @@ * Ask the cache buffer if it has the record still. It will not if the * cache buffer has been concurrently reset. */ + try { + return cache.read(off.longValue()); + } catch (IllegalStateException ex) { + /* + * The write cache was closed. Per the API for this method, return + * [null] so that the caller will read through to the backing store. + */ + assert !open; + return null; + } - return cache.read(off.longValue()); - } /** Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestConcurrentJournal.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestConcurrentJournal.java 2010-10-08 12:50:48 UTC (rev 3752) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestConcurrentJournal.java 2010-10-08 14:36:59 UTC (rev 3753) @@ -1784,7 +1784,7 @@ for(Future f : futures) { - if(f.isDone()) { + if(f.isDone()&&!f.isCancelled()) { // all tasks that complete should have done so without error. f.get(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |