void setTxData(EncodingSupport txData) { this.txDataSize = txData.getEncodeSize(); ActiveMQBuffer encodedBuffer = ActiveMQBuffers.fixedBuffer(txDataSize); txData.encode(encodedBuffer); this.txData = new ActiveMQBufferInputStream(encodedBuffer); }
@Override public EncodingSupport decode(ActiveMQBuffer buffer, EncodingSupport record) { record.decode(buffer); return record; } }
@Override public int getEncodeSize() { return JournalImpl.SIZE_DELETE_RECORD_TX + (record != null ? record.getEncodeSize() : 0) + 1; } }
@Override public void encode(ActiveMQBuffer buffer, EncodingSupport record) { record.encode(buffer); }
@Override public int getEncodeSize() { return JournalImpl.SIZE_DELETE_RECORD_TX + (record != null ? record.getEncodeSize() : 0) + 1; } }
@Override public void encode(ActiveMQBuffer buffer, EncodingSupport record) { record.encode(buffer); }
@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); }
@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); }
public void addBytes(final EncodingSupport bytes, final boolean sync, final IOCallback callback) { enterCritical(CRITICAL_PATH_ADD_BYTES); try { synchronized (this) { if (!started) { throw new IllegalStateException("TimedBuffer is not started"); } delayFlush = false; bytes.encode(buffer); callbacks.add(callback); if (sync) { pendingSync = true; startSpin(); } } } finally { leaveCritical(CRITICAL_PATH_ADD_BYTES); } }
@Override public EncodingSupport decode(ActiveMQBuffer buffer, EncodingSupport record) { record.decode(buffer); return record; } }
/** * 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 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; } } }
public void addBytes(final EncodingSupport bytes, final boolean sync, final IOCallback callback) { enterCritical(CRITICAL_PATH_ADD_BYTES); try { synchronized (this) { if (!started) { throw new IllegalStateException("TimedBuffer is not started"); } delayFlush = false; bytes.encode(buffer); callbacks.add(callback); if (sync) { pendingSync = true; startSpin(); } } } finally { leaveCritical(CRITICAL_PATH_ADD_BYTES); } }
idReturn.decode(buffer);
@Override public void encodeRest(final ActiveMQBuffer buffer) { buffer.writeByte(journalID); buffer.writeLong(txId); buffer.writeInt(encodingData.getEncodeSize()); encodingData.encode(buffer); }
@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; } } }
/** * 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 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 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 int getEncodeSize(EncodingSupport record) { return record.getEncodeSize(); }