当前位置: 首页>>代码示例>>Java>>正文


Java ActiveMQBuffer.setIndex方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:ChannelBufferWrapper.java

示例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);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:AbstractSequentialFile.java

示例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]);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:MessageImplTest.java

示例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);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:LargeMessageBufferTest.java


注:本文中的org.apache.activemq.artemis.api.core.ActiveMQBuffer.setIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。