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


Java ActiveMQBuffer.getBytes方法代码示例

本文整理汇总了Java中org.apache.activemq.artemis.api.core.ActiveMQBuffer.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQBuffer.getBytes方法的具体用法?Java ActiveMQBuffer.getBytes怎么用?Java ActiveMQBuffer.getBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.artemis.api.core.ActiveMQBuffer的用法示例。


在下文中一共展示了ActiveMQBuffer.getBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: broadcastConnectors

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
@Override
public synchronized void broadcastConnectors() throws Exception {
   ActiveMQBuffer buff = ActiveMQBuffers.dynamicBuffer(4096);

   buff.writeString(nodeManager.getNodeId().toString());

   buff.writeString(uniqueID);

   buff.writeInt(connectors.size());

   for (TransportConfiguration tcConfig : connectors) {
      tcConfig.encode(buff);
   }

   // Only send as many bytes as we need.
   byte[] data = new byte[buff.readableBytes()];
   buff.getBytes(buff.readerIndex(), data);

   endpoint.broadcast(data);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:BroadcastGroupImpl.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: checkData

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void checkData(JDBCSequentialFile file, ActiveMQBuffer expectedData) throws SQLException {
   expectedData.resetReaderIndex();

   byte[] resultingBytes = new byte[expectedData.readableBytes()];
   ByteBuffer byteBuffer = ByteBuffer.allocate(expectedData.readableBytes());

   file.read(byteBuffer, null);
   expectedData.getBytes(0, resultingBytes);

   assertArrayEquals(resultingBytes, byteBuffer.array());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:JDBCSequentialFileFactoryTest.java

示例4: testValidateUTFWithChars

import org.apache.activemq.artemis.api.core.ActiveMQBuffer; //导入方法依赖的package包/类
private void testValidateUTFWithChars(final int size, final char c) {
   final char[] chars = new char[size];
   Arrays.fill(chars, c);
   final String expectedUtf8String = new String(chars);
   final ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(4 * chars.length);
   UTF8Util.saveUTF(buffer.byteBuf(), expectedUtf8String);
   final byte[] expectedBytes = expectedUtf8String.getBytes(StandardCharsets.UTF_8);
   final int encodedSize = buffer.readUnsignedShort();
   final byte[] realEncodedBytes = new byte[encodedSize];
   buffer.getBytes(buffer.readerIndex(), realEncodedBytes);
   Assert.assertArrayEquals(expectedBytes, realEncodedBytes);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:13,代码来源:UTF8Test.java

示例5: 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.getBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。