@Test(expected=Exception.class) public void testSizeChanged() throws Exception { PhysicalInfo info = new PhysicalInfo(1l, 1l, -1, 0, 0); info.setSize(1<<13); assertEquals(0, info.sizeIndex); info.setSize(1 + (1<<13)); }
@Override public PhysicalInfo lockForLoad(Long oid, Serializer<?> serializer) { Map<Long, PhysicalInfo> map = physicalMapping.get(serializer.getId()); if (map == null) { return null; } PhysicalInfo info = map.get(oid); if (info == null) { return null; } info.lockForLoad(); return info; }
@Override public void unlockForLoad(PhysicalInfo info) { if (info == null) { return; } info.unlockForLoad(); }
info.await(true, true); if (info.inode == EMPTY_ADDRESS) { continue;
/** * Determine if an object should be in the memory buffer. * @param currentTime * @param info * @return */ private boolean shouldPlaceInMemoryBuffer(PhysicalInfo info) { if (info.evicting || info.inode != EMPTY_ADDRESS) { return false; } if (info.block == EMPTY_ADDRESS) { return true; } PhysicalInfo lowest = memoryBufferEntries.firstEntry(false); CacheKey key = info.getKey(); return (blocksInuse.getTotalBits() - blocksInuse.getBitsSet()) > (cleaningThreshold + info.memoryBlockCount) || (lowest != null && lowest.block != EMPTY_ADDRESS && lowest.getKey().getOrderingValue() < key.getOrderingValue()); }
boolean locked = false; try { manager = getBlockManager(info.gid, info.getId(), EMPTY_ADDRESS);
info.await(true, true); if (info.inode == EMPTY_ADDRESS) { continue;
/** * Determine if an object should be in the memory buffer. * @param currentTime * @param info * @return */ private boolean shouldPlaceInMemoryBuffer(PhysicalInfo info) { if (info.evicting || info.inode != EMPTY_ADDRESS) { return false; } if (info.block == EMPTY_ADDRESS) { return true; } PhysicalInfo lowest = memoryBufferEntries.firstEntry(false); CacheKey key = info.getKey(); return (blocksInuse.getTotalBits() - blocksInuse.getBitsSet()) > (cleaningThreshold + info.memoryBlockCount) || (lowest != null && lowest.block != EMPTY_ADDRESS && lowest.getKey().getOrderingValue() < key.getOrderingValue()); }
boolean locked = false; try { manager = getBlockManager(info.gid, info.getId(), EMPTY_ADDRESS);
@Test public void testSizeIndex() throws Exception { PhysicalInfo info = new PhysicalInfo(1l, 1l, -1, 0, 0); info.setSize(1<<13); assertEquals(0, info.sizeIndex); info = new PhysicalInfo(1l, 1l, -1, 0, 0); info.setSize(1 + (1<<13)); assertEquals(1, info.sizeIndex); info = new PhysicalInfo(1l, 1l, -1, 0, 0); info.setSize(2 + (1<<15)); assertEquals(3, info.sizeIndex); }
info.await(true, true); if (info.inode == EMPTY_ADDRESS) { continue;
@Override public void unlockForLoad(PhysicalInfo info) { if (info == null) { return; } info.unlockForLoad(); }
@Override public PhysicalInfo lockForLoad(Long oid, Serializer<?> serializer) { Map<Long, PhysicalInfo> map = physicalMapping.get(serializer.getId()); if (map == null) { return null; } PhysicalInfo info = map.get(oid); if (info == null) { return null; } info.lockForLoad(); return info; }
/** * Determine if an object should be in the memory buffer. * Adds are indicated by a current time of 0. * @param currentTime * @param info * @return */ private boolean shouldPlaceInMemoryBuffer(long currentTime, PhysicalInfo info) { PhysicalInfo lowest = memoryBufferEntries.firstEntry(false); CacheKey key = info.getKey(); return (blocksInuse.getTotalBits() - blocksInuse.getBitsSet()) > (cleaningThreshold + info.memoryBlockCount) || (lowest != null && lowest.block != EMPTY_ADDRESS && lowest.getKey().getOrderingValue() < (currentTime>0?memoryBufferEntries.computeNextOrderingValue(currentTime, key.getLastAccess(), key.getOrderingValue()):key.getOrderingValue())); }
boolean locked = false; try { manager = getBlockManager(info.gid, info.getId(), EMPTY_ADDRESS);
return true; //already removed info = new PhysicalInfo(s.getId(), entry.getId(), EMPTY_ADDRESS, readAttempts.get(), entry.getSizeEstimate()); info.adding = true; map.put(entry.getId(), info); synchronized (info) { info.setSize(bos.getBytesWritten()); info.inode = blockManager.getInode(); memoryBufferEntries.add(info);