@BeforeMethod protected void prepare() throws IOException { cache0 = cache(0, CACHE_NAME); cache1 = cache(1, CACHE_NAME); dirA = createDirectory(cache0); dirB = createDirectory(cache1); CacheTestSupport.initializeDirectory(dirA); }
@Test public void testIndexWritingAndFinding() throws IOException, InterruptedException { verifyBoth(cache0, cache1); IndexOutput indexOutput = dirA.createOutput(filename, IOContext.DEFAULT); indexOutput.writeString("no need to write, nobody ever will read this"); indexOutput.close(); assertFileExistsHavingRLCount(filename, 1, true); IndexInput openInput = dirB.openInput(filename, IOContext.DEFAULT); assertFileExistsHavingRLCount(filename, 2, true); dirA.deleteFile(filename); assertFileExistsHavingRLCount(filename, 1, false); //Lucene does use clone() - lock implementation ignores it as a clone is //cast on locked segments and released before the close on the parent object IndexInput clone = (IndexInput) openInput.clone(); assertFileExistsHavingRLCount(filename, 1, false); clone.close(); assertFileExistsHavingRLCount(filename, 1, false); openInput.close(); assertFileNotExists(filename); dirA.close(); dirB.close(); verifyBoth(cache0, cache1); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder configurationBuilder = CacheTestSupport.createTestConfiguration(TransactionMode.NON_TRANSACTIONAL); createClusteredCaches(2, CACHE_NAME, configurationBuilder); }