// When a file gets opened, it uses the file size to determine where // new slots can be appended. If this method would not be called, the // freespace system could already contain a slot that points beyond // the end of the file and this space could be allocated and used twice, // for instance if a slot was allocated and freed without ever being // written to file. void ensureLastSlotWritten() { if (!Debug4.xbytes) { if (Deploy.overwrite) { if (_blockEndAddress > _blockConverter.bytesToBlocks(fileLength())) { StatefulBuffer writer = createStatefulBuffer(systemTransaction(), _blockEndAddress - 1, blockSize()); writer.write(); } } } }
public StatefulBuffer readStatefulBufferBySlot(Transaction trans, int id, Slot slot) { if (Slot.isNull(slot)) { return null; } if (DTrace.enabled) { DTrace.READ_SLOT.logLength(slot.address(), slot.length()); } StatefulBuffer buffer = createStatefulBuffer(trans, slot.address(), slot.length()); buffer.setID(id); buffer.readEncrypt(this, slot.address()); return buffer; }
private void debugCheckBuffer(ByteArrayBuffer buffer, FreeSlotNode node) { if (!(buffer instanceof StatefulBuffer)) { return; } Transaction trans = ((StatefulBuffer) buffer).transaction(); if (!(trans.container() instanceof IoAdaptedObjectContainer)) { return; } StatefulBuffer checker = trans.container().getWriter(trans, node._peer._key, node._key); checker.read(); for (int i = 0; i < node._key; i++) { if (checker.readByte() != (byte) 'X') { System.out.println("!!! Free space corruption at:" + node._peer._key); break; } } }
public final boolean delete4( Transaction transaction, ObjectReference ref, Object obj, int cascade, boolean userCall) { int id = ref.getID(); StatefulBuffer reader = readStatefulBufferById(transaction, id); if (reader != null) { if (obj != null) { if ((!showInternalClasses()) && Const4.CLASS_INTERNAL.isAssignableFrom(obj.getClass())) { return false; } } reader.setCascadeDeletes(cascade); transaction.idSystem().notifySlotDeleted(id, SlotChangeFactory.USER_OBJECTS); ClassMetadata classMetadata = ref.classMetadata(); classMetadata.delete(reader, obj); return true; } return false; }