public void testChooseKeyOneTry() throws CHKEncodeException, IOException, MetadataUnresolvedException, MetadataParseException, FetchException { int dataBlocks = 3, checkBlocks = 3; TestSplitfile test = TestSplitfile.constructSingleSegment(dataBlocks*BLOCK_SIZE, checkBlocks, null, false); StorageCallback cb = test.createStorageCallback(); FetchContext ctx = test.makeFetchContext(); ctx.maxSplitfileBlockRetries = 0; SplitFileFetcherStorage storage = test.createStorage(cb, ctx); boolean[] tried = new boolean[dataBlocks+checkBlocks]; innerChooseKeyTest(dataBlocks, checkBlocks, storage.segments[0], tried, test, false); assertEquals(storage.chooseRandomKey(), null); cb.waitForFailed(); }
public void testChooseKeyThreeTries() throws CHKEncodeException, IOException, MetadataUnresolvedException, MetadataParseException, FetchException { int dataBlocks = 3, checkBlocks = 3; TestSplitfile test = TestSplitfile.constructSingleSegment(dataBlocks*BLOCK_SIZE, checkBlocks, null, false); StorageCallback cb = test.createStorageCallback(); FetchContext ctx = test.makeFetchContext(); ctx.maxSplitfileBlockRetries = 2; SplitFileFetcherStorage storage = test.createStorage(cb, ctx); for(int i=0;i<3;i++) { boolean[] tried = new boolean[dataBlocks+checkBlocks]; innerChooseKeyTest(dataBlocks, checkBlocks, storage.segments[0], tried, test, false); } assertEquals(storage.chooseRandomKey(), null); cb.waitForFailed(); }
assertEquals(storage.chooseRandomKey(), -1); assertEquals(storage.getOverallCooldownTime(), Long.MAX_VALUE); assertEquals(storage.getOverallCooldownTime(), 0);
assertEquals(storage.chooseRandomKey(), null); Thread.sleep((long)(COOLDOWN_TIME+COOLDOWN_TIME/2+1)); cb.checkFailed();
public void testPersistenceReloadThenChooseKey() throws IOException, StorageFormatException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException, FetchException { int dataBlocks = 2; int checkBlocks = 3; long size = 32768*2-1; assertTrue(dataBlocks * (long)BLOCK_SIZE >= size); TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, null, true); StorageCallback cb = test.createStorageCallback(); FetchContext ctx = test.makeFetchContext(); ctx.maxSplitfileBlockRetries = 2; SplitFileFetcherStorage storage = test.createStorage(cb, ctx); // No need to shutdown the old storage. storage = test.createStorage(cb, ctx, cb.getRAF()); for(int i=0;i<3;i++) { boolean[] tried = new boolean[dataBlocks+checkBlocks]; innerChooseKeyTest(dataBlocks, checkBlocks, storage.segments[0], tried, test, false); } test.fetchingKeys.clear(); assertEquals(storage.chooseRandomKey(), null); cb.waitForFailed(); }
assertEquals(storage.chooseRandomKey(), null); cb.waitForFailed();