/** * Tells the file that this block is no longer in use and can be recycled. This is * accomplished by putting it on the free list for the file. * * @throws IOException There was an error writing to the free list. */ public void free() throws IOException { blockFile.freeBlock(blockId); release(); }
/** * The rotate which is performed when the node is heavy on the left * sub-branch. * * @return the change in height of the node. * @throws IOException If an I/O error occurs. */ private int rotateL() throws IOException { AVLNode nodeL = getLeftChildNode(); int deltaHeight = (nodeL.block.getByte(IDX_BALANCE_B) >= 0) ? rotateLL(nodeL) : rotateLR(nodeL); nodeL.release(); return deltaHeight; }
/** * Writes this PersistableMetaRoot to the specified Block. The ints are * written at the specified offset. * * @param b the Block. * @param offset the offset into the Block to start writing. */ public void writeToBlock(Block b, int offset) { check(); b.putLong(offset + IDX_ROOT_ID, rootId); b.putLong(offset + IDX_NR_NODES, nrNodes); avlBlockFilePhase.writeToBlock(b, offset + HEADER_SIZE); }
private void selectCommonPhase(int phaseNumber, SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { try { for (SimpleXARecoveryHandler handler: handlers) handler.selectPhase(phaseNumber); } catch (IOException ei) { throw new SimpleXAResourceException("IO failure selecting phase on database", ei); } }
private void clearDatabase(SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { try { for (SimpleXARecoveryHandler handler: handlers) handler.clear(); } catch (IOException ei) { throw new SimpleXAResourceException("IO failure clearing database", ei); } }
/** * Construct a phase, copy the phase data found in an existing block. * * @param b The block containing the phase data. * @param offset The offset of the phase data within the block. * @throws IOException If an I/O error occurs. */ public Phase(Block b, int offset) throws IOException { rootId = b.getLong(offset + IDX_ROOT_ID); nrNodes = b.getLong(offset + IDX_NR_NODES); avlBlockFilePhase = avlBlockFile.new Phase(b, offset + HEADER_SIZE); check(); currentPhase = this; }
/** * Creates a new phase, using a freelist block. * * @param b The block in the freelist to start the new phase in. * @param offset The offset in the block to find the start of the freelist block. * @throws IOException If an I/O error occurred on the free list. */ public Phase(Block b, int offset) throws IOException { freeListPhase = freeList.new Phase(b, offset); currentPhase = this; check(); }
public void selectPhase(int phaseNumber) throws IOException, SimpleXAResourceException { persistentNodePool.selectPhase(phaseNumber); persistentStringPool.selectPhase(phaseNumber); }
/** * Creates a new ObjectStack. * * @return A fresh {@link ObjectStack}. */ private ObjectStack newObjectStackInstance() { ObjectStack os = (ObjectStack) get(TYPE_OBJECTSTACK); if (os == null) { os = new ObjectStack(OBJECT_STACK_SIZE_LIMIT); } return os; }
/** * Puts this buffer for this block back into the ObjectPool so it can be re-used in another Block. */ public void release() { if (blockFile != null) { blockFile.releaseBlock(objectPool, this); // blockFile should have been set to null in the call to releaseBlock() // (which calls dispose()), but just to be sure we set it to null again. blockFile = null; } else { dispose(objectPool); } }