本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.setIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.setIndex方法的具体用法?Java ActiveMQBuffer.setIndex怎么用?Java ActiveMQBuffer.setIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.artemis.api.core.ActiveMQBuffer
的用法示例。
在下文中一共展示了ActiveMQBuffer.setIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readSlice
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public ActiveMQBuffer readSlice(final int length) {
if ( isPooled ) {
ByteBuf fromBuffer = buffer.readSlice(length);
ByteBuf newNettyBuffer = Unpooled.buffer(fromBuffer.capacity());
int read = fromBuffer.readerIndex();
int writ = fromBuffer.writerIndex();
fromBuffer.readerIndex(0);
fromBuffer.readBytes(newNettyBuffer,0,writ);
newNettyBuffer.setIndex(read,writ);
ActiveMQBuffer returnBuffer = new ChannelBufferWrapper(newNettyBuffer,releasable,false);
returnBuffer.setIndex(read,writ);
return returnBuffer;
}
return new ChannelBufferWrapper(buffer.readSlice(length), releasable, isPooled);
}
示例2: write
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public void write(final ActiveMQBuffer bytes, final boolean sync, final IOCallback callback) throws IOException {
if (timedBuffer != null) {
bytes.setIndex(0, bytes.capacity());
timedBuffer.addBytes(bytes, sync, callback);
} else {
final int readableBytes = bytes.readableBytes();
final ByteBuffer buffer = factory.newBuffer(readableBytes);
//factory::newBuffer doesn't necessary return a buffer with limit == readableBytes!!
buffer.limit(readableBytes);
bytes.getBytes(bytes.readerIndex(), buffer);
buffer.flip();
writeDirect(buffer, sync, callback);
}
}
示例3: simulateRead
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void simulateRead(ActiveMQBuffer buf) {
buf.setIndex(buf.capacity() / 2, buf.capacity() / 2);
// ok this is not actually happening during the read process, but changing this shouldn't affect the buffer on copy
// this is to exaggerate the isolation on this test
buf.writeBytes(new byte[1024]);
}
示例4: testGetBytesILChannelBufferII
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Test
public void testGetBytesILChannelBufferII() throws Exception {
LargeMessageControllerImpl buffer = create15BytesSample();
ActiveMQBuffer dstBuffer = ActiveMQBuffers.fixedBuffer(20);
dstBuffer.setIndex(0, 5);
buffer.getBytes(0, dstBuffer);
byte[] compareBytes = new byte[15];
dstBuffer.getBytes(5, compareBytes);
validateAgainstSample(compareBytes);
}