@Override public int expectedEncodeSize() { return PACKET_HEADERS_SIZE + DataConstants.SIZE_BYTE + // buffer.writeByte(journalID); DataConstants.SIZE_LONG + // buffer.writeLong(txId); DataConstants.SIZE_LONG + // buffer.writeLong(id); DataConstants.SIZE_INT + // buffer.writeInt(encodingData.getEncodeSize()); encodingData.getEncodeSize(); // encodingData.encode(buffer); }
@Override public int getEncodeSize() { return JournalImpl.SIZE_DELETE_RECORD_TX + (record != null ? record.getEncodeSize() : 0) + 1; } }
@Override public int getEncodeSize() { return JournalImpl.SIZE_DELETE_RECORD_TX + (record != null ? record.getEncodeSize() : 0) + 1; } }
@Override public int getEncodeSize() { if (txRecordType == TX_RECORD_TYPE.COMMIT) { return JournalImpl.SIZE_COMPLETE_TRANSACTION_RECORD + 1; } else { return JournalImpl.SIZE_PREPARE_RECORD + (transactionData != null ? transactionData.getEncodeSize() : 0) + 1; } } }
@Override public int getEncodeSize() { if (txRecordType == TX_RECORD_TYPE.COMMIT) { return JournalImpl.SIZE_COMPLETE_TRANSACTION_RECORD + 1; } else { return JournalImpl.SIZE_PREPARE_RECORD + (transactionData != null ? transactionData.getEncodeSize() : 0) + 1; } } }
@Override public int expectedEncodeSize() { return PACKET_HEADERS_SIZE + DataConstants.SIZE_BYTE + // buffer.writeByte(journalID); DataConstants.SIZE_LONG + // buffer.writeLong(txId); DataConstants.SIZE_INT + // buffer.writeInt(encodingData.getEncodeSize()); encodingData.getEncodeSize(); // encodingData.encode(buffer); }
@Override public int getEncodeSize(EncodingSupport record) { return record.getEncodeSize(); }
@Override public int getEncodeSize(EncodingSupport record) { return record.getEncodeSize(); }
void setTxData(EncodingSupport txData) { this.txDataSize = txData.getEncodeSize(); ActiveMQBuffer encodedBuffer = ActiveMQBuffers.fixedBuffer(txDataSize); txData.encode(encodedBuffer); this.txData = new ActiveMQBufferInputStream(encodedBuffer); }
@Override public void write(EncodingSupport bytes, boolean sync, IOCallback callback) throws Exception { ActiveMQBuffer data = ActiveMQBuffers.fixedBuffer(bytes.getEncodeSize()); bytes.encode(data); write(data, sync, callback, true); }
/** * Writes an encoded sequence of bytes to this file from the given buffer. * <p> * <p> Bytes are written starting at this file's current position, */ public void write(EncodingSupport encodingSupport) throws IOException { final int encodedSize = encodingSupport.getEncodeSize(); final int nextPosition = this.position + encodedSize; checkCapacity(nextPosition); this.byteBufWrapper.setIndex(this.position, this.position); encodingSupport.encode(this.channelBufferWrapper); rawMovePositionAndLength(nextPosition); assert (byteBufWrapper.writerIndex() == this.position); }
/** * Writes an encoded sequence of bytes to this file from the given buffer. * <p> * <p> Bytes are written starting at this file's current position, */ public void write(EncodingSupport encodingSupport) throws IOException { final int encodedSize = encodingSupport.getEncodeSize(); final int nextPosition = this.position + encodedSize; checkCapacity(nextPosition); this.byteBufWrapper.setIndex(this.position, this.position); encodingSupport.encode(this.channelBufferWrapper); rawMovePositionAndLength(nextPosition); assert (byteBufWrapper.writerIndex() == this.position); }
@Override public void write(final EncodingSupport bytes, final boolean sync, final IOCallback callback) { if (timedBuffer != null) { timedBuffer.addBytes(bytes, sync, callback); } else { final int encodedSize = bytes.getEncodeSize(); ByteBuffer buffer = factory.newBuffer(encodedSize); ActiveMQBuffer outBuffer = ActiveMQBuffers.wrappedBuffer(buffer); bytes.encode(outBuffer); buffer.clear(); buffer.limit(encodedSize); writeDirect(buffer, sync, callback); } }
@Override public void encodeRest(final ActiveMQBuffer buffer) { buffer.writeByte(journalID); buffer.writeLong(txId); buffer.writeInt(encodingData.getEncodeSize()); encodingData.encode(buffer); }
@Override public void encodeRest(final ActiveMQBuffer buffer) { buffer.writeByte(journalID); buffer.writeLong(txId); buffer.writeLong(id); buffer.writeInt(encodingData.getEncodeSize()); encodingData.encode(buffer); }
@Override public void run() { try { SequentialFile file = factory.createSequentialFile("file.txt"); file.open(); Thread.currentThread().interrupt(); file.fill(fakeEncoding.getEncodeSize()); file.close(); } catch (Exception e) { e.printStackTrace(); } } };
@Override public void write(final EncodingSupport bytes, final boolean sync, final IOCallback callback) throws Exception { ByteBuffer buffer = newBuffer(bytes.getEncodeSize()); ActiveMQBuffer outbuffer = ActiveMQBuffers.wrappedBuffer(buffer); bytes.encode(outbuffer); write(outbuffer, sync, callback); }
@Override public void write(final EncodingSupport bytes, final boolean sync) throws Exception { ByteBuffer buffer = newBuffer(bytes.getEncodeSize()); ActiveMQBuffer outbuffer = ActiveMQBuffers.wrappedBuffer(buffer); bytes.encode(outbuffer); write(outbuffer, sync); }
@Override public void encode(final ActiveMQBuffer buffer) { buffer.writeByte(JournalImpl.DELETE_RECORD_TX); buffer.writeInt(fileID); buffer.writeByte(compactCount); buffer.writeLong(txID); buffer.writeLong(id); buffer.writeInt(record != null ? record.getEncodeSize() : 0); if (record != null) { record.encode(buffer); } buffer.writeInt(getEncodeSize()); }
@Override public void encode(final ActiveMQBuffer buffer) { buffer.writeByte(JournalImpl.DELETE_RECORD_TX); buffer.writeInt(fileID); buffer.writeByte(compactCount); buffer.writeLong(txID); buffer.writeLong(id); buffer.writeInt(record != null ? record.getEncodeSize() : 0); if (record != null) { record.encode(buffer); } buffer.writeInt(getEncodeSize()); }