public int getMemoryEstimate() { if (memoryEstimate == -1) { memoryEstimate = ServerMessageImpl.memoryOffset + buffer.capacity() + properties.getMemoryOffset(); } return memoryEstimate; }
public int getMemoryEstimate() { if (memoryEstimate == -1) { memoryEstimate = ServerMessageImpl.memoryOffset + buffer.capacity() + properties.getMemoryOffset(); } return memoryEstimate; }
public void write(final HornetQBuffer bytes, final boolean sync, final IOAsyncTask callback) throws IOException { if (timedBuffer != null) { bytes.setIndex(0, bytes.capacity()); timedBuffer.addBytes(bytes, sync, callback); } else { ByteBuffer buffer = factory.newBuffer(bytes.capacity()); buffer.put(bytes.toByteBuffer().array()); buffer.rewind(); writeDirect(buffer, sync, callback); } }
public void write(final HornetQBuffer bytes, final boolean sync, final IOAsyncTask callback) throws Exception { if (timedBuffer != null) { bytes.setIndex(0, bytes.capacity()); timedBuffer.addBytes(bytes, sync, callback); } else { ByteBuffer buffer = factory.newBuffer(bytes.capacity()); buffer.put(bytes.toByteBuffer().array()); buffer.rewind(); writeDirect(buffer, sync, callback); } }
public void write(final HornetQBuffer bytes, final boolean sync, final IOAsyncTask callback) throws IOException { if (timedBuffer != null) { bytes.setIndex(0, bytes.capacity()); timedBuffer.addBytes(bytes, sync, callback); } else { ByteBuffer buffer = factory.newBuffer(bytes.capacity()); buffer.put(bytes.toByteBuffer().array()); buffer.rewind(); writeDirect(buffer, sync, callback); } }
@Override public String toString() { return "ServerMessage[messageID=" + messageID + ",priority=" + this.getPriority() + ", bodySize=" + this.getBodyBuffer().capacity() + ",expiration=" + (this.getExpiration() != 0 ? new java.util.Date(this.getExpiration()) : 0) + ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this); }
private void forceCopy() { // Must copy buffer before sending it buffer = buffer.copy(0, buffer.capacity()); buffer.setIndex(0, getEndOfBodyPosition()); if (bodyBuffer != null) { bodyBuffer.setBuffer(buffer); } bufferUsed = false; }
public synchronized HornetQBuffer getBodyBufferCopy() { // Must copy buffer before sending it HornetQBuffer newBuffer = buffer.copy(0, buffer.capacity()); newBuffer.setIndex(0, getEndOfBodyPosition()); return new ResetLimitWrappedHornetQBuffer(BODY_OFFSET, newBuffer, null); }
public synchronized HornetQBuffer getBodyBufferCopy() { // Must copy buffer before sending it HornetQBuffer newBuffer = buffer.copy(0, buffer.capacity()); newBuffer.setIndex(0, getEndOfBodyPosition()); return new ResetLimitWrappedHornetQBuffer(BODY_OFFSET, newBuffer, null); }
private void forceCopy() { // Must copy buffer before sending it buffer = buffer.copy(0, buffer.capacity()); buffer.setIndex(0, getEndOfBodyPosition()); if (bodyBuffer != null) { bodyBuffer.setBuffer(buffer); } bufferUsed = false; }
/** Write pending output into file */ public void flush() throws Exception { if (writingChannel != null) { sequentialFile.position(0); // To Fix the size of the file writingChannel.writerIndex(writingChannel.capacity()); sequentialFile.writeInternal(writingChannel.toByteBuffer()); sequentialFile.close(); newDataFiles.add(currentFile); } writingChannel = null; }
/** Write pending output into file */ public void flush() throws Exception { if (writingChannel != null) { sequentialFile.position(0); // To Fix the size of the file writingChannel.writerIndex(writingChannel.capacity()); sequentialFile.writeInternal(writingChannel.toByteBuffer()); sequentialFile.close(); newDataFiles.add(currentFile); } writingChannel = null; }
/** Write pending output into file */ public void flush() throws Exception { if (writingChannel != null) { sequentialFile.position(0); // To Fix the size of the file writingChannel.writerIndex(writingChannel.capacity()); sequentialFile.writeInternal(writingChannel.toByteBuffer()); sequentialFile.close(); newDataFiles.add(currentFile); } writingChannel = null; }
@Override public String toString() { return "ServerMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority() + ", bodySize=" + this.getBodyBufferCopy().capacity() + ",expiration=" + (this.getExpiration() != 0 ? new java.util.Date(this.getExpiration()) : 0) + ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this); }
public synchronized HornetQBuffer getEncodedBuffer() { HornetQBuffer buff = encodeToBuffer(); if (bufferUsed) { HornetQBuffer copied = buff.copy(0, buff.capacity()); copied.setIndex(0, endOfMessagePosition); return copied; } else { buffer.setIndex(0, endOfMessagePosition); bufferUsed = true; return buffer; } }
public synchronized HornetQBuffer getEncodedBuffer() { HornetQBuffer buff = encodeToBuffer(); if (bufferUsed) { HornetQBuffer copied = buff.copy(0, buff.capacity()); copied.setIndex(0, endOfMessagePosition); return copied; } else { buffer.setIndex(0, endOfMessagePosition); bufferUsed = true; return buffer; } }
protected MessageImpl(final MessageImpl other, TypedProperties properties) { messageID = other.getMessageID(); userID = other.getUserID(); address = other.getAddress(); type = other.getType(); durable = other.isDurable(); expiration = other.getExpiration(); timestamp = other.getTimestamp(); priority = other.getPriority(); this.properties = new TypedProperties(properties); // This MUST be synchronized using the monitor on the other message to prevent it running concurrently // with getEncodedBuffer(), otherwise can introduce race condition when delivering concurrently to // many subscriptions and bridging to other nodes in a cluster synchronized (other) { bufferValid = other.bufferValid; endOfBodyPosition = other.endOfBodyPosition; endOfMessagePosition = other.endOfMessagePosition; copied = other.copied; if (other.buffer != null) { createBody(other.buffer.capacity()); // We need to copy the underlying buffer too, since the different messsages thereafter might have different // properties set on them, making their encoding different buffer = other.buffer.copy(0, other.buffer.capacity()); buffer.setIndex(other.buffer.readerIndex(), other.buffer.writerIndex()); } } }
private void checkSize(final int size, final int compactCount) throws Exception { if (getWritingChannel() == null) { if (!checkCompact(compactCount)) { // will need to open a file either way openFile(); } } else { if (compactCount >= 0) { if (checkCompact(compactCount)) { // The file was already moved on this case, no need to check for the size. // otherwise we will also need to check for the size return; } } if (getWritingChannel().writerIndex() + size > getWritingChannel().capacity()) { openFile(); } } }
if ((bodySize + 4) > buffer.capacity())
protected MessageImpl(final MessageImpl other, TypedProperties properties) { messageID = other.getMessageID(); userID = other.getUserID(); address = other.getAddress(); type = other.getType(); durable = other.isDurable(); expiration = other.getExpiration(); timestamp = other.getTimestamp(); priority = other.getPriority(); this.properties = new TypedProperties(properties); // This MUST be synchronized using the monitor on the other message to prevent it running concurrently // with getEncodedBuffer(), otherwise can introduce race condition when delivering concurrently to // many subscriptions and bridging to other nodes in a cluster synchronized (other) { bufferValid = other.bufferValid; endOfBodyPosition = other.endOfBodyPosition; endOfMessagePosition = other.endOfMessagePosition; copied = other.copied; if (other.buffer != null) { other.bufferUsed = true; // We need to copy the underlying buffer too, since the different messsages thereafter might have different // properties set on them, making their encoding different buffer = other.buffer.copy(0, other.buffer.writerIndex()); buffer.setIndex(other.buffer.readerIndex(), buffer.capacity()); } } }