Author: timfox
Date: 2009-11-23 18:27:50 -0500 (Mon, 23 Nov 2009)
New Revision: 8387
Added:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ResetLimitWrappedHornetQBuffer.java
Removed:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/buffers/
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/ByteBufferWrapperTest.java
Modified:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffers.java
branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java
branches/20-optimisation/src/main/org/hornetq/core/client/ClientSession.java
branches/20-optimisation/src/main/org/hornetq/core/client/LargeMessageBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageInternal.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/DelegatingSession.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/FailoverManagerImpl.java
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java
branches/20-optimisation/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java
branches/20-optimisation/src/main/org/hornetq/core/config/TransportConfiguration.java
branches/20-optimisation/src/main/org/hornetq/core/journal/EncodingSupport.java
branches/20-optimisation/src/main/org/hornetq/core/journal/SequentialFile.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalCompactor.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalTransaction.java
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
branches/20-optimisation/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
branches/20-optimisation/src/main/org/hornetq/core/message/BodyEncoder.java
branches/20-optimisation/src/main/org/hornetq/core/message/Message.java
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageTransactionInfoImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/BatchingIDGenerator.java
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/Packet.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/RemotingConnection.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/AbstractBufferHandler.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateQueueMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateReplicationSessionMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/HornetQExceptionMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketsConfirmedMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddTXMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCommitMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCompareDataMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteTXMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageBeingMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageWriteMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargemessageEndMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageEventMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageWriteMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPrepareMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/RollbackMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerCloseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerFlowCreditMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionContinuationMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionExpiredMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionForceConsumerDelivery.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionProducerCreditsMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveContinuationMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveLargeMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionRequestProducerCreditsMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendContinuationMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendLargeMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXACommitMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAEndMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAForgetMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAJoinMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAPrepareMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResumeMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXARollbackMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAStartMessage.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/XidCodecSupport.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/BufferHandler.java
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/Connection.java
branches/20-optimisation/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/RemoteQueueBindingImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQFrameDecoder.java
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java
branches/20-optimisation/src/main/org/hornetq/utils/TypedProperties.java
branches/20-optimisation/src/main/org/hornetq/utils/UTF8Util.java
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/InterceptorTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AckBatchSizeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/TemporaryQueueTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/DummyInterceptor.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/NettyHttpTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/mock/MockConnector.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementServiceImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/LargeJournalStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/timing/util/UTF8Test.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/filter/impl/FilterTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/SimpleEncoding.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/HornetQBufferTestBase.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapper2Test.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapperTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java
branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/UTF8Test.java
branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
optimisation
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQAbstractChannelBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,804 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.buffers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.GatheringByteChannel;
-import java.nio.channels.ScatteringByteChannel;
-
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.utils.DataConstants;
-import org.hornetq.utils.SimpleString;
-import org.hornetq.utils.UTF8Util;
-
-/**
- * A skeletal implementation of a buffer.
- *
- * @author The Netty Project (netty-dev(a)lists.jboss.org)
- * @author Trustin Lee (tlee(a)redhat.com)
- *
- * @version $Rev: 303 $, $Date: 2008-09-24 18:48:32 +0900 (Wed, 24 Sep 2008) $
- */
-public abstract class HornetQAbstractChannelBuffer implements HornetQChannelBuffer
-{
- private static final Logger log =
Logger.getLogger(HornetQAbstractChannelBuffer.class);
-
-
- private int readerIndex;
-
- private int writerIndex;
-
- private int markedReaderIndex;
-
- private int markedWriterIndex;
-
- public int readerIndex()
- {
- return readerIndex;
- }
-
- public void readerIndex(final int readerIndex)
- {
- if (readerIndex < 0 || readerIndex > writerIndex)
- {
- throw new IndexOutOfBoundsException();
- }
- this.readerIndex = readerIndex;
- }
-
- public int writerIndex()
- {
- return writerIndex;
- }
-
- public void writerIndex(final int writerIndex)
- {
- if (writerIndex < readerIndex || writerIndex > capacity())
- {
- throw new IndexOutOfBoundsException();
- }
- this.writerIndex = writerIndex;
- }
-
- public void setIndex(final int readerIndex, final int writerIndex)
- {
- if (readerIndex < 0 || readerIndex > writerIndex || writerIndex >
capacity())
- {
- throw new IndexOutOfBoundsException();
- }
- this.readerIndex = readerIndex;
- this.writerIndex = writerIndex;
- }
-
- public void clear()
- {
- readerIndex = writerIndex = 0;
- }
-
- public boolean readable()
- {
- return readableBytes() > 0;
- }
-
- public boolean writable()
- {
- return writableBytes() > 0;
- }
-
- public int readableBytes()
- {
- return writerIndex - readerIndex;
- }
-
- public int writableBytes()
- {
- return capacity() - writerIndex;
- }
-
- public void markReaderIndex()
- {
- markedReaderIndex = readerIndex;
- }
-
- public void resetReaderIndex()
- {
- readerIndex(markedReaderIndex);
- }
-
- public void markWriterIndex()
- {
- markedWriterIndex = writerIndex;
- }
-
- public void resetWriterIndex()
- {
- writerIndex = markedWriterIndex;
- }
-
- public void discardReadBytes()
- {
- if (readerIndex == 0)
- {
- return;
- }
- setBytes(0, this, readerIndex, writerIndex - readerIndex);
- writerIndex -= readerIndex;
- markedReaderIndex = Math.max(markedReaderIndex - readerIndex, 0);
- markedWriterIndex = Math.max(markedWriterIndex - readerIndex, 0);
- readerIndex = 0;
- }
-
- public short getUnsignedByte(final int index)
- {
- return (short)(getByte(index) & 0xFF);
- }
-
- public int getUnsignedShort(final int index)
- {
- return getShort(index) & 0xFFFF;
- }
-
- public int getMedium(final int index)
- {
- int value = getUnsignedMedium(index);
- if ((value & 0x800000) != 0)
- {
- value |= 0xff000000;
- }
- return value;
- }
-
- public long getUnsignedInt(final int index)
- {
- return getInt(index) & 0xFFFFFFFFL;
- }
-
- public void getBytes(final int index, final byte[] dst)
- {
- getBytes(index, dst, 0, dst.length);
- }
-
- public void getBytes(final int index, final HornetQChannelBuffer dst)
- {
- getBytes(index, dst, dst.writableBytes());
- }
-
- public void getBytes(final int index, final HornetQChannelBuffer dst, final int
length)
- {
- if (length > dst.writableBytes())
- {
- throw new IndexOutOfBoundsException();
- }
- getBytes(index, dst, dst.writerIndex(), length);
- dst.writerIndex(dst.writerIndex() + length);
- }
-
- public void setBytes(final int index, final byte[] src)
- {
- setBytes(index, src, 0, src.length);
- }
-
- public void setBytes(final int index, final HornetQChannelBuffer src)
- {
- setBytes(index, src, src.readableBytes());
- }
-
- public void setBytes(final int index, final HornetQChannelBuffer src, final int
length)
- {
- if (length > src.readableBytes())
- {
- throw new IndexOutOfBoundsException();
- }
- setBytes(index, src, src.readerIndex(), length);
- src.readerIndex(src.readerIndex() + length);
- }
-
- public void setZero(int index, final int length)
- {
- if (length == 0)
- {
- return;
- }
- if (length < 0)
- {
- throw new IllegalArgumentException("length must be 0 or greater than
0.");
- }
-
- int nLong = length >>> 3;
- int nBytes = length & 7;
- for (int i = nLong; i > 0; i--)
- {
- setLong(index, 0);
- index += 8;
- }
- if (nBytes == 4)
- {
- setInt(index, 0);
- }
- else if (nBytes < 4)
- {
- for (int i = nBytes; i > 0; i--)
- {
- setByte(index, (byte)0);
- index++;
- }
- }
- else
- {
- setInt(index, 0);
- index += 4;
- for (int i = nBytes - 4; i > 0; i--)
- {
- setByte(index, (byte)0);
- index++;
- }
- }
- }
-
- public byte readByte()
- {
- if (readerIndex == writerIndex)
- {
- throw new IndexOutOfBoundsException();
- }
- return getByte(readerIndex++);
- }
-
- public short readUnsignedByte()
- {
- return (short)(readByte() & 0xFF);
- }
-
- public short readShort()
- {
- checkReadableBytes(2);
- short v = getShort(readerIndex);
- readerIndex += 2;
- return v;
- }
-
- public int readUnsignedShort()
- {
- return readShort() & 0xFFFF;
- }
-
- public int readMedium()
- {
- int value = readUnsignedMedium();
- if ((value & 0x800000) != 0)
- {
- value |= 0xff000000;
- }
- return value;
- }
-
- public int readUnsignedMedium()
- {
- checkReadableBytes(3);
- int v = getUnsignedMedium(readerIndex);
- readerIndex += 3;
- return v;
- }
-
- public int readInt()
- {
- checkReadableBytes(4);
- int v = getInt(readerIndex);
- readerIndex += 4;
- return v;
- }
-
- public int readInt(final int pos)
- {
- checkReadableBytes(4);
- int v = getInt(pos);
- return v;
- }
-
- public long readUnsignedInt()
- {
- return readInt() & 0xFFFFFFFFL;
- }
-
- public long readLong()
- {
- checkReadableBytes(8);
- long v = getLong(readerIndex);
- readerIndex += 8;
- return v;
- }
-
- public void readBytes(final byte[] dst, final int dstIndex, final int length)
- {
- checkReadableBytes(length);
- getBytes(readerIndex, dst, dstIndex, length);
- readerIndex += length;
- }
-
- public void readBytes(final byte[] dst)
- {
- readBytes(dst, 0, dst.length);
- }
-
- public void readBytes(final HornetQChannelBuffer dst)
- {
- readBytes(dst, dst.writableBytes());
- }
-
- public void readBytes(final HornetQChannelBuffer dst, final int length)
- {
- if (length > dst.writableBytes())
- {
- throw new IndexOutOfBoundsException();
- }
- readBytes(dst, dst.writerIndex(), length);
- dst.writerIndex(dst.writerIndex() + length);
- }
-
- public void readBytes(final HornetQChannelBuffer dst, final int dstIndex, final int
length)
- {
- checkReadableBytes(length);
- getBytes(readerIndex, dst, dstIndex, length);
- readerIndex += length;
- }
-
- public void readBytes(final ByteBuffer dst)
- {
- int length = dst.remaining();
- checkReadableBytes(length);
- getBytes(readerIndex, dst);
- readerIndex += length;
- }
-
- public int readBytes(final GatheringByteChannel out, final int length) throws
IOException
- {
- checkReadableBytes(length);
- int readBytes = getBytes(readerIndex, out, length);
- readerIndex += readBytes;
- return readBytes;
- }
-
- public void readBytes(final OutputStream out, final int length) throws IOException
- {
- checkReadableBytes(length);
- getBytes(readerIndex, out, length);
- readerIndex += length;
- }
-
- public void skipBytes(final int length)
- {
- int newReaderIndex = readerIndex + length;
- if (newReaderIndex > writerIndex)
- {
- throw new IndexOutOfBoundsException();
- }
- readerIndex = newReaderIndex;
- }
-
- public void writeByte(final byte value)
- {
- setByte(writerIndex++, value);
- }
-
- public void writeShort(final short value)
- {
- setShort(writerIndex, value);
- writerIndex += 2;
- }
-
- public void writeMedium(final int value)
- {
- setMedium(writerIndex, value);
- writerIndex += 3;
- }
-
- public void writeInt(final int value)
- {
- setInt(writerIndex, value);
- writerIndex += 4;
- }
-
- public void writeLong(final long value)
- {
- setLong(writerIndex, value);
- writerIndex += 8;
- }
-
- public void writeBytes(final byte[] src, final int srcIndex, final int length)
- {
- setBytes(writerIndex, src, srcIndex, length);
- writerIndex += length;
- }
-
- public void writeBytes(final byte[] src)
- {
- writeBytes(src, 0, src.length);
- }
-
- public void writeBytes(final HornetQChannelBuffer src)
- {
- writeBytes(src, src.readableBytes());
- }
-
- public void writeBytes(final HornetQChannelBuffer src, final int length)
- {
- if (length > src.readableBytes())
- {
- throw new IndexOutOfBoundsException();
- }
- writeBytes(src, src.readerIndex(), length);
- src.readerIndex(src.readerIndex() + length);
- }
-
- public void writeBytes(final HornetQChannelBuffer src, final int srcIndex, final int
length)
- {
- setBytes(writerIndex, src, srcIndex, length);
- writerIndex += length;
- }
-
-
- public void writeBytes(final HornetQBuffer src, final int srcIndex, final int length)
- {
- if (src instanceof HornetQChannelBuffer)
- {
- writeBytes((HornetQChannelBuffer)src, srcIndex, length);
- }
- else
- {
- //There is a bug in Netty readBytes() which doesn't let us to do this, so we
workaround it
-// byte[] bytes = new byte[length];
-//
-// src.readBytes(bytes, srcIndex, length);
-//
-// writeBytes(bytes);
-
- byte[] bytes = src.array();
-
- writeBytes(bytes, srcIndex, length);
- }
- }
-
- public void writeBytes(final ByteBuffer src)
- {
- int length = src.remaining();
- setBytes(writerIndex, src);
- writerIndex += length;
- }
-
- public void writeBytes(final InputStream in, final int length) throws IOException
- {
- setBytes(writerIndex, in, length);
- writerIndex += length;
- }
-
- public int writeBytes(final ScatteringByteChannel in, final int length) throws
IOException
- {
- int writtenBytes = setBytes(writerIndex, in, length);
- if (writtenBytes > 0)
- {
- writerIndex += writtenBytes;
- }
- return writtenBytes;
- }
-
- public void writeZero(final int length)
- {
- if (length == 0)
- {
- return;
- }
- if (length < 0)
- {
- throw new IllegalArgumentException("length must be 0 or greater than
0.");
- }
- int nLong = length >>> 3;
- int nBytes = length & 7;
- for (int i = nLong; i > 0; i--)
- {
- writeLong(0);
- }
- if (nBytes == 4)
- {
- writeInt(0);
- }
- else if (nBytes < 4)
- {
- for (int i = nBytes; i > 0; i--)
- {
- writeByte((byte)0);
- }
- }
- else
- {
- writeInt(0);
- for (int i = nBytes - 4; i > 0; i--)
- {
- writeByte((byte)0);
- }
- }
- }
-
- public ByteBuffer toByteBuffer()
- {
- return toByteBuffer(readerIndex, readableBytes());
- }
-
- public ByteBuffer[] toByteBuffers()
- {
- return toByteBuffers(readerIndex, readableBytes());
- }
-
- public ByteBuffer[] toByteBuffers(final int index, final int length)
- {
- return new ByteBuffer[] { toByteBuffer(index, length) };
- }
-
- public String toString(final String charsetName)
- {
- return toString(readerIndex, readableBytes(), charsetName);
- }
-
- @Override
- public int hashCode()
- {
- return HornetQChannelBuffers.hashCode(this);
- }
-
- @Override
- public boolean equals(final Object o)
- {
- if (!(o instanceof HornetQChannelBuffer))
- {
- return false;
- }
- return HornetQChannelBuffers.equals(this, (HornetQChannelBuffer)o);
- }
-
- public int compareTo(final HornetQChannelBuffer that)
- {
- return HornetQChannelBuffers.compare(this, that);
- }
-
- @Override
- public String toString()
- {
- return getClass().getSimpleName() + '(' +
- "ridx=" +
- readerIndex +
- ", " +
- "widx=" +
- writerIndex +
- ", " +
- "cap=" +
- capacity() +
- ')';
- }
-
- /**
- * Throws an {@link IndexOutOfBoundsException} if the current
- * {@linkplain #readableBytes() readable bytes} of this buffer is less
- * than the specified value.
- */
- protected void checkReadableBytes(final int minimumReadableBytes)
- {
- if (readableBytes() < minimumReadableBytes)
- {
- throw new IndexOutOfBoundsException();
- }
- }
-
- public Object getUnderlyingBuffer()
- {
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readBoolean()
- */
- public boolean readBoolean()
- {
- return readByte() != 0;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readChar()
- */
- public char readChar()
- {
- return (char)readShort();
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readDouble()
- */
- public double readDouble()
- {
- return Double.longBitsToDouble(readLong());
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readFloat()
- */
- public float readFloat()
- {
- return Float.intBitsToFloat(readInt());
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readNullableSimpleString()
- */
- public SimpleString readNullableSimpleString()
- {
- int b = readByte();
- if (b == DataConstants.NULL)
- {
- return null;
- }
- else
- {
- return readSimpleString();
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readNullableString()
- */
- public String readNullableString()
- {
- int b = readByte();
- if (b == DataConstants.NULL)
- {
- return null;
- }
- else
- {
- return readString();
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readSimpleString()
- */
- public SimpleString readSimpleString()
- {
- int len = readInt();
- byte[] data = new byte[len];
- readBytes(data);
- return new SimpleString(data);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readString()
- */
- public String readString()
- {
- int len = readInt();
-
- char[] chars = new char[len];
- for (int i = 0; i < len; i++)
- {
- chars[i] = readChar();
- }
- return new String(chars);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readUTF()
- */
- public String readUTF() throws Exception
- {
- return UTF8Util.readUTF(this);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeBoolean(boolean)
- */
- public void writeBoolean(final boolean val)
- {
- writeByte((byte)(val ? -1 : 0));
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeChar(char)
- */
- public void writeChar(final char val)
- {
- writeShort((short)val);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeDouble(double)
- */
- public void writeDouble(final double val)
- {
- writeLong(Double.doubleToLongBits(val));
-
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeFloat(float)
- */
- public void writeFloat(final float val)
- {
- writeInt(Float.floatToIntBits(val));
-
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.remoting.spi.HornetQBuffer#writeNullableSimpleString(org.hornetq.util.SimpleString)
- */
- public void writeNullableSimpleString(final SimpleString val)
- {
- if (val == null)
- {
- writeByte(DataConstants.NULL);
- }
- else
- {
- writeByte(DataConstants.NOT_NULL);
- writeSimpleString(val);
- }
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.remoting.spi.HornetQBuffer#writeNullableString(java.lang.String)
- */
- public void writeNullableString(final String val)
- {
- if (val == null)
- {
- writeByte(DataConstants.NULL);
- }
- else
- {
- writeByte(DataConstants.NOT_NULL);
- writeString(val);
- }
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.remoting.spi.HornetQBuffer#writeSimpleString(org.hornetq.util.SimpleString)
- */
- public void writeSimpleString(final SimpleString val)
- {
- byte[] data = val.getData();
- writeInt(data.length);
- writeBytes(data);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeString(java.lang.String)
- */
- public void writeString(final String val)
- {
- writeInt(val.length());
- for (int i = 0; i < val.length(); i++)
- {
- writeShort((short)val.charAt(i));
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeUTF(java.lang.String)
- */
- public void writeUTF(final String utf) throws Exception
- {
- UTF8Util.saveUTF(this, utf);
- }
-
-}
Copied: branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQBuffer.java
(from rev 8367,
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java)
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQBuffer.java
(rev 0)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.buffers;
+
+import java.nio.ByteBuffer;
+
+import org.hornetq.utils.SimpleString;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ *
+ * A HornetQBuffer
+ *
+ * Much of it derived from Netty ChannelBuffer by Trustin Lee
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ *
+ */
+public interface HornetQBuffer
+{
+ ChannelBuffer channelBuffer();
+
+ int capacity();
+
+ int readerIndex();
+
+ void readerIndex(int readerIndex);
+
+ int writerIndex();
+
+ void writerIndex(int writerIndex);
+
+ void setIndex(int readerIndex, int writerIndex);
+
+ int readableBytes();
+
+ int writableBytes();
+
+ boolean readable();
+
+ boolean writable();
+
+ void clear();
+
+ void markReaderIndex();
+
+ void resetReaderIndex();
+
+ void markWriterIndex();
+
+ void resetWriterIndex();
+
+ void discardReadBytes();
+
+ byte getByte(int index);
+
+ short getUnsignedByte(int index);
+
+ short getShort(int index);
+
+ int getUnsignedShort(int index);
+
+ int getInt(int index);
+
+ long getUnsignedInt(int index);
+
+ long getLong(int index);
+
+ void getBytes(int index, HornetQBuffer dst);
+
+ void getBytes(int index, HornetQBuffer dst, int length);
+
+ void getBytes(int index, HornetQBuffer dst, int dstIndex, int length);
+
+ void getBytes(int index, byte[] dst);
+
+ void getBytes(int index, byte[] dst, int dstIndex, int length);
+
+ void getBytes(int index, ByteBuffer dst);
+
+ char getChar(int index);
+
+ float getFloat(int index);
+
+ double getDouble(int index);
+
+ void setByte(int index, byte value);
+
+ void setShort(int index, short value);
+
+ void setInt(int index, int value);
+
+ void setLong(int index, long value);
+
+ void setBytes(int index, HornetQBuffer src);
+
+ void setBytes(int index, HornetQBuffer src, int length);
+
+ void setBytes(int index, HornetQBuffer src, int srcIndex, int length);
+
+ void setBytes(int index, byte[] src);
+
+ void setBytes(int index, byte[] src, int srcIndex, int length);
+
+ void setBytes(int index, ByteBuffer src);
+
+ void setChar(int index, char value);
+
+ void setFloat(int index, float value);
+
+ void setDouble(int index, double value);
+
+ byte readByte();
+
+ short readUnsignedByte();
+
+ short readShort();
+
+ int readUnsignedShort();
+
+ int readInt();
+
+ long readUnsignedInt();
+
+ long readLong();
+
+ char readChar();
+
+ float readFloat();
+
+ double readDouble();
+
+ HornetQBuffer readBytes(int length);
+
+ HornetQBuffer readSlice(int length);
+
+ void readBytes(HornetQBuffer dst);
+
+ void readBytes(HornetQBuffer dst, int length);
+
+ void readBytes(HornetQBuffer dst, int dstIndex, int length);
+
+ void readBytes(byte[] dst);
+
+ void readBytes(byte[] dst, int dstIndex, int length);
+
+ void readBytes(ByteBuffer dst);
+
+ void skipBytes(int length);
+
+ void writeByte(byte value);
+
+ void writeShort(short value);
+
+ void writeInt(int value);
+
+ void writeLong(long value);
+
+ void writeChar(char chr);
+
+ void writeFloat(float value);
+
+ void writeDouble(double value);
+
+ void writeBytes(HornetQBuffer src, int length);
+
+ void writeBytes(HornetQBuffer src, int srcIndex, int length);
+
+ void writeBytes(byte[] src);
+
+ void writeBytes(byte[] src, int srcIndex, int length);
+
+ void writeBytes(ByteBuffer src);
+
+ HornetQBuffer copy();
+
+ HornetQBuffer copy(int index, int length);
+
+ HornetQBuffer slice();
+
+ HornetQBuffer slice(int index, int length);
+
+ HornetQBuffer duplicate();
+
+ ByteBuffer toByteBuffer();
+
+ ByteBuffer toByteBuffer(int index, int length);
+
+ boolean readBoolean();
+
+ SimpleString readNullableSimpleString();
+
+ String readNullableString();
+
+ SimpleString readSimpleString();
+
+ String readString();
+
+ String readUTF() throws Exception;
+
+ void writeBoolean(boolean val);
+
+ void writeNullableSimpleString(SimpleString val);
+
+ void writeNullableString(String val);
+
+ void writeSimpleString(SimpleString val);
+
+ void writeString(String val);
+
+ void writeUTF(String utf) throws Exception;
+}
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQByteBufferBackedChannelBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,400 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.buffers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.GatheringByteChannel;
-import java.nio.channels.ScatteringByteChannel;
-import java.nio.charset.UnsupportedCharsetException;
-
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-
-/**
- * A NIO {@link ByteBuffer} based buffer. It is recommended to use {@link
HornetQChannelBuffers#directBuffer(int)}
- * and {@link HornetQChannelBuffers#wrappedBuffer(ByteBuffer)} instead of calling the
- * constructor explicitly.
- *
- * @author The Netty Project (netty-dev(a)lists.jboss.org)
- * @author Trustin Lee (tlee(a)redhat.com)
- *
- * @version $Rev: 486 $, $Date: 2008-11-16 22:52:47 +0900 (Sun, 16 Nov 2008) $
- *
- */
-public class HornetQByteBufferBackedChannelBuffer extends HornetQAbstractChannelBuffer
-{
-
- private final ByteBuffer buffer;
-
- private final int capacity;
-
- /**
- * Creates a new buffer which wraps the specified buffer's slice.
- */
- HornetQByteBufferBackedChannelBuffer(final ByteBuffer buffer)
- {
- if (buffer == null)
- {
- throw new NullPointerException("buffer");
- }
-
- this.buffer = buffer;
- capacity = buffer.remaining();
- }
-
- public int capacity()
- {
- return capacity;
- }
-
- public byte getByte(final int index)
- {
- return buffer.get(index);
- }
-
- public short getShort(final int index)
- {
- return buffer.getShort(index);
- }
-
- public int getUnsignedMedium(final int index)
- {
- return (getByte(index) & 0xff) << 16 | (getByte(index + 1) & 0xff)
<< 8 | (getByte(index + 2) & 0xff) << 0;
- }
-
- public int getInt(final int index)
- {
- return buffer.getInt(index);
- }
-
- public long getLong(final int index)
- {
- return buffer.getLong(index);
- }
-
- public void getBytes(final int index, final HornetQChannelBuffer dst, final int
dstIndex, final int length)
- {
- if (dst instanceof HornetQByteBufferBackedChannelBuffer)
- {
- HornetQByteBufferBackedChannelBuffer bbdst =
(HornetQByteBufferBackedChannelBuffer)dst;
- ByteBuffer data = bbdst.buffer.duplicate();
-
- data.limit(dstIndex + length).position(dstIndex);
- getBytes(index, data);
- }
- else if (buffer.hasArray())
- {
- dst.setBytes(dstIndex, buffer.array(), index + buffer.arrayOffset(), length);
- }
- else
- {
- dst.setBytes(dstIndex, this, index, length);
- }
- }
-
- public void getBytes(final int index, final byte[] dst, final int dstIndex, final int
length)
- {
- ByteBuffer data = buffer.duplicate();
- try
- {
- data.limit(index + length).position(index);
- }
- catch (IllegalArgumentException e)
- {
- throw new IndexOutOfBoundsException();
- }
- data.get(dst, dstIndex, length);
- }
-
- public void getBytes(final int index, final ByteBuffer dst)
- {
- ByteBuffer data = buffer.duplicate();
- int bytesToCopy = Math.min(capacity() - index, dst.remaining());
- try
- {
- data.limit(index + bytesToCopy).position(index);
- }
- catch (IllegalArgumentException e)
- {
- throw new IndexOutOfBoundsException();
- }
- dst.put(data);
- }
-
- public void setByte(final int index, final byte value)
- {
- buffer.put(index, value);
- }
-
- public void setShort(final int index, final short value)
- {
- buffer.putShort(index, value);
- }
-
- public void setMedium(final int index, final int value)
- {
- setByte(index, (byte)(value >>> 16));
- setByte(index + 1, (byte)(value >>> 8));
- setByte(index + 2, (byte)(value >>> 0));
- }
-
- public void setInt(final int index, final int value)
- {
- buffer.putInt(index, value);
- }
-
- public void setLong(final int index, final long value)
- {
- buffer.putLong(index, value);
- }
-
- public void setBytes(final int index, final HornetQChannelBuffer src, final int
srcIndex, final int length)
- {
- if (src instanceof HornetQByteBufferBackedChannelBuffer)
- {
- HornetQByteBufferBackedChannelBuffer bbsrc =
(HornetQByteBufferBackedChannelBuffer)src;
- ByteBuffer data = bbsrc.buffer.duplicate();
-
- data.limit(srcIndex + length).position(srcIndex);
- setBytes(index, data);
- }
- else if (buffer.hasArray())
- {
- src.getBytes(srcIndex, buffer.array(), index + buffer.arrayOffset(), length);
- }
- else
- {
- src.getBytes(srcIndex, this, index, length);
- }
- }
-
- public void setBytes(final int index, final byte[] src, final int srcIndex, final int
length)
- {
- ByteBuffer data = buffer.duplicate();
- data.limit(index + length).position(index);
- data.put(src, srcIndex, length);
- }
-
- public void setBytes(final int index, final ByteBuffer src)
- {
- ByteBuffer data = buffer.duplicate();
- data.limit(index + src.remaining()).position(index);
- data.put(src);
- }
-
- public void getBytes(final int index, final OutputStream out, final int length) throws
IOException
- {
- if (length == 0)
- {
- return;
- }
-
- if (!buffer.isReadOnly() && buffer.hasArray())
- {
- out.write(buffer.array(), index + buffer.arrayOffset(), length);
- }
- else
- {
- byte[] tmp = new byte[length];
- ((ByteBuffer)buffer.duplicate().position(index)).get(tmp);
- out.write(tmp);
- }
- }
-
- public int getBytes(final int index, final GatheringByteChannel out, final int length)
throws IOException
- {
- if (length == 0)
- {
- return 0;
- }
-
- return out.write((ByteBuffer)buffer.duplicate().position(index).limit(index +
length));
- }
-
- public int setBytes(int index, final InputStream in, int length) throws IOException
- {
-
- int readBytes = 0;
-
- if (!buffer.isReadOnly() && buffer.hasArray())
- {
- index += buffer.arrayOffset();
- do
- {
- int localReadBytes = in.read(buffer.array(), index, length);
- if (localReadBytes < 0)
- {
- if (readBytes == 0)
- {
- return -1;
- }
- else
- {
- break;
- }
- }
- readBytes += localReadBytes;
- index += localReadBytes;
- length -= localReadBytes;
- }
- while (length > 0);
- }
- else
- {
- byte[] tmp = new byte[length];
- int i = 0;
- do
- {
- int localReadBytes = in.read(tmp, i, tmp.length - i);
- if (localReadBytes < 0)
- {
- if (readBytes == 0)
- {
- return -1;
- }
- else
- {
- break;
- }
- }
- readBytes += localReadBytes;
- i += readBytes;
- }
- while (i < tmp.length);
- ((ByteBuffer)buffer.duplicate().position(index)).put(tmp);
- }
-
- return readBytes;
- }
-
- public int setBytes(final int index, final ScatteringByteChannel in, final int length)
throws IOException
- {
-
- ByteBuffer slice = (ByteBuffer)buffer.duplicate().limit(index +
length).position(index);
- int readBytes = 0;
-
- while (readBytes < length)
- {
- int localReadBytes;
- try
- {
- localReadBytes = in.read(slice);
- }
- catch (ClosedChannelException e)
- {
- localReadBytes = -1;
- }
- if (localReadBytes < 0)
- {
- if (readBytes == 0)
- {
- return -1;
- }
- else
- {
- return readBytes;
- }
- }
- else if (localReadBytes == 0)
- {
- break;
- }
- readBytes += localReadBytes;
- }
-
- return readBytes;
- }
-
- public ByteBuffer toByteBuffer(final int index, final int length)
- {
- if (index == 0 && length == capacity())
- {
- return buffer.duplicate();
- }
- else
- {
- return ((ByteBuffer)buffer.duplicate().position(index).limit(index +
length)).slice();
- }
- }
-
- @Override
- public ByteBuffer toByteBuffer()
- {
- return buffer;
- }
-
- public String toString(final int index, final int length, final String charsetName)
- {
- if (!buffer.isReadOnly() && buffer.hasArray())
- {
- try
- {
- return new String(buffer.array(), index + buffer.arrayOffset(), length,
charsetName);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new UnsupportedCharsetException(charsetName);
- }
- }
- else
- {
- byte[] tmp = new byte[length];
- ((ByteBuffer)buffer.duplicate().position(index)).get(tmp);
- try
- {
- return new String(tmp, charsetName);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new UnsupportedCharsetException(charsetName);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.buffers.ChannelBuffer#array()
- */
- public byte[] array()
- {
- return buffer.array();
- }
-
- public HornetQBuffer copy()
- {
- ByteBuffer newBuffer = ByteBuffer.allocate(buffer.remaining());
- newBuffer.put(buffer);
- newBuffer.flip();
- return new HornetQByteBufferBackedChannelBuffer(newBuffer);
- }
-
- public HornetQBuffer slice(int index, int length)
- {
- int currentPos = buffer.position();
- int currentLimit = buffer.limit();
-
- buffer.position(index);
- buffer.limit(length);
-
- ByteBuffer sliced = buffer.slice();
-
- buffer.position(currentPos);
- buffer.limit(currentLimit);
-
- return new HornetQByteBufferBackedChannelBuffer(sliced);
- }
-}
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,1256 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.buffers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.GatheringByteChannel;
-import java.nio.channels.ScatteringByteChannel;
-import java.nio.charset.UnsupportedCharsetException;
-
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-
-/**
- * A random and sequential accessible sequence of zero or more bytes (octets).
- * This interface provides an abstract view for one or more primitive byte
- * arrays ({@code byte[]}) and {@linkplain ByteBuffer NIO buffers}.
- *
- * <h3>Creation of a buffer</h3>
- *
- * It is recommended to create a new buffer using the helper methods in
- * {@link HornetQChannelBuffers} rather than calling an individual implementation's
- * constructor.
- *
- * <h3>Random Access Indexing</h3>
- *
- * Just like an ordinary primitive byte array, {@link HornetQChannelBuffer} uses
- * <a
href="http://en.wikipedia.org/wiki/Index_(information_technology)#Ar...
indexing</a>.
- * It means the index of the first byte is always {@code 0} and the index of
- * the last byte is always {@link #capacity() capacity - 1}. For example, to
- * iterate all bytes of a buffer, you can do the following, regardless of
- * its internal implementation:
- *
- * <pre>
- * ChannelBuffer buffer = ...;
- * for (int i = 0; i < buffer.capacity(); i ++</strong>) {
- * byte b = array.getByte(i);
- * System.out.println((char) b);
- * }
- * </pre>
- *
- * <h3>Sequential Access Indexing</h3>
- *
- * {@link HornetQChannelBuffer} provides two pointer variables to support sequential
- * read and write operations - {@link #readerIndex() readerIndex} for a read
- * operation and {@link #writerIndex() writerIndex} for a write operation
- * respectively. The following diagram shows how a buffer is segmented into
- * three areas by the two pointers:
- *
- * <pre>
- * +-------------------+------------------+------------------+
- * | discardable bytes | readable bytes | writable bytes |
- * | | (CONTENT) | |
- * +-------------------+------------------+------------------+
- * | | | |
- * 0 <= readerIndex <= writerIndex <= capacity
- * </pre>
- *
- * <h4>Readable bytes (the actual content)</h4>
- *
- * This segment is where the actual data is stored. Any operation whose name
- * starts with {@code read} or {@code skip} will get or skip the data at the
- * current {@link #readerIndex() readerIndex} and increase it by the number of
- * read bytes. If the argument of the read operation is also a
- * {@link HornetQChannelBuffer} and no start index is specified, the specified
- * buffer's {@link #readerIndex() readerIndex} is increased together.
- * <p>
- * If there's not enough content left, {@link IndexOutOfBoundsException} is
- * raised. The default value of newly allocated, wrapped or copied buffer's
- * {@link #readerIndex() readerIndex} is {@code 0}.
- *
- * <pre>
- * // Iterates the readable bytes of a buffer.
- * ChannelBuffer buffer = ...;
- * while (buffer.readable()) {
- * System.out.println(buffer.readByte());
- * }
- * </pre>
- *
- * <h4>Writable bytes</h4>
- *
- * This segment is a undefined space which needs to be filled. Any operation
- * whose name ends with {@code write} will write the data at the current
- * {@link #writerIndex() writerIndex} and increase it by the number of written
- * bytes. If the argument of the write operation is also a {@link
HornetQChannelBuffer},
- * and no start index is specified, the specified buffer's
- * {@link #readerIndex() readerIndex} is increased together.
- * <p>
- * If there's not enough writable bytes left, {@link IndexOutOfBoundsException}
- * is raised. The default value of newly allocated buffer's
- * {@link #writerIndex() writerIndex} is {@code 0}. The default value of
- * wrapped or copied buffer's {@link #writerIndex() writerIndex} is the
- * {@link #capacity() capacity} of the buffer.
- *
- * <pre>
- * // Fills the writable bytes of a buffer with random integers.
- * ChannelBuffer buffer = ...;
- * while (buffer.writableBytes() >= 4) {
- * buffer.writeInt(random.nextInt());
- * }
- * </pre>
- *
- * <h4>Discardable bytes</h4>
- *
- * This segment contains the bytes which were read already by a read operation.
- * Initially, the size of this segment is {@code 0}, but its size increases up
- * to the {@link #writerIndex() writerIndex} as read operations are executed.
- * The read bytes can be discarded by calling {@link #discardReadBytes()} to
- * reclaim unused area as depicted by the following diagram:
- *
- * <pre>
- * BEFORE discardReadBytes()
- *
- * +-------------------+------------------+------------------+
- * | discardable bytes | readable bytes | writable bytes |
- * +-------------------+------------------+------------------+
- * | | | |
- * 0 <= readerIndex <= writerIndex <= capacity
- *
- *
- * AFTER discardReadBytes()
- *
- * +------------------+--------------------------------------+
- * | readable bytes | writable bytes (got more space) |
- * +------------------+--------------------------------------+
- * | | |
- * readerIndex (0) <= writerIndex (decreased) <= capacity
- * </pre>
- *
- * <h4>Clearing the buffer indexes</h4>
- *
- * You can set both {@link #readerIndex() readerIndex} and
- * {@link #writerIndex() writerIndex} to {@code 0} by calling {@link #clear()}.
- * It does not clear the buffer content (e.g. filling with {@code 0}) but just
- * clears the two pointers. Please also note that the semantic of this
- * operation is different from {@link ByteBuffer#clear()}.
- *
- * <pre>
- * BEFORE clear()
- *
- * +-------------------+------------------+------------------+
- * | discardable bytes | readable bytes | writable bytes |
- * +-------------------+------------------+------------------+
- * | | | |
- * 0 <= readerIndex <= writerIndex <= capacity
- *
- *
- * AFTER clear()
- *
- * +---------------------------------------------------------+
- * | writable bytes (got more space) |
- * +---------------------------------------------------------+
- * | |
- * 0 = readerIndex = writerIndex <= capacity
- * </pre>
- *
- * <h3>Search operations</h3>
- *
- * Various {@code indexOf()} methods help you locate an index of a value which
- * meets a certain criteria. Complicated dynamic sequential search can be done
- * with {@link ChannelBufferIndexFinder} as well as simple static single byte
- * search.
- *
- * <h3>Mark and reset</h3>
- *
- * There are two marker indexes in every buffer. One is for storing
- * {@link #readerIndex() readerIndex} and the other is for storing
- * {@link #writerIndex() writerIndex}. You can always reposition one of the
- * two indexes by calling a reset method. It works in a similar fashion to
- * the mark and reset methods in {@link InputStream} except that there's no
- * {@code readlimit}.
- *
- * <h3>Derived buffers</h3>
- *
- * You can create a view of an existing buffer by calling either
- * {@link #duplicate()}, {@link #slice()} or {@link #slice(int, int)}.
- * A derived buffer will have an independent {@link #readerIndex() readerIndex},
- * {@link #writerIndex() writerIndex} and marker indexes, while it shares
- * other internal data representation, just like a NIO buffer does.
- * <p>
- * In case a completely fresh copy of an existing buffer is required, please
- * call {@link #copy()} method instead.
- *
- * <h3>Conversion to existing JDK types</h3>
- *
- * <h4>NIO Buffers</h4>
- *
- * Various {@link #toByteBuffer()} and {@link #toByteBuffers()} methods convert
- * a {@link HornetQChannelBuffer} into one or more NIO buffers. These methods avoid
- * buffer allocation and memory copy whenever possible, but there's no
- * guarantee that memory copy will not be involved or that an explicit memory
- * copy will be involved.
- *
- * <h4>Strings</h4>
- *
- * Various {@link #toString(String)} methods convert a {@link HornetQChannelBuffer}
- * into a {@link String}. Plesae note that {@link #toString()} is not a
- * conversion method.
- *
- * <h4>I/O Streams</h4>
- *
- * Please refer to {@link ChannelBufferInputStream} and
- * {@link ChannelBufferOutputStream}.
- *
- * @author The Netty Project (netty-dev(a)lists.jboss.org)
- * @author Trustin Lee (tlee(a)redhat.com)
- *
- * @version $Rev: 472 $, $Date: 2008-11-14 16:45:53 +0900 (Fri, 14 Nov 2008) $
- *
- * @apiviz.landmark
- */
-public interface HornetQChannelBuffer extends Comparable<HornetQChannelBuffer>,
HornetQBuffer
-{
-
- /**
- * Returns the number of bytes (octets) this buffer can contain.
- */
- int capacity();
-
- byte[] array();
-
- /**
- * Returns the {@code readerIndex} of this buffer.
- */
- int readerIndex();
-
- /**
- * Sets the {@code readerIndex} of this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code readerIndex} is
- * less than {@code 0} or
- * greater than {@code this.writerIndex}
- */
- void readerIndex(int readerIndex);
-
- /**
- * Returns the {@code writerIndex} of this buffer.
- */
- int writerIndex();
-
- /**
- * Sets the {@code writerIndex} of this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code writerIndex} is
- * less than {@code this.readerIndex} or
- * greater than {@code this.capacity}
- */
- void writerIndex(int writerIndex);
-
- /**
- * Sets the {@code readerIndex} and {@code writerIndex} of this buffer
- * in one shot. This method is useful when you have to worry about the
- * invocation order of {@link #readerIndex(int)} and {@link #writerIndex(int)}
- * methods. For example, the following code will fail:
- *
- * <pre>
- * // Create a buffer whose readerIndex, writerIndex and capacity are
- * // 0, 0 and 8 respectively.
- * ChannelBuffer buf = ChannelBuffers.buffer(8);
- *
- * // IndexOutOfBoundsException is thrown because the specified
- * // readerIndex (2) cannot be greater than the current writerIndex (0).
- * buf.readerIndex(2);
- * buf.writerIndex(4);
- * </pre>
- *
- * The following code will also fail:
- *
- * <pre>
- * // Create a buffer whose readerIndex, writerIndex and capacity are
- * // 0, 8 and 8 respectively.
- * ChannelBuffer buf = ChannelBuffers.wrappedBuffer(new byte[8]);
- *
- * // readerIndex becomes 8.
- * buf.readLong();
- *
- * // IndexOutOfBoundsException is thrown because the specified
- * // writerIndex (4) cannot be less than the current readerIndex (8).
- * buf.writerIndex(4);
- * buf.readerIndex(2);
- * </pre>
- *
- * By contrast, {@link #setIndex(int, int)} guarantees that it never
- * throws an {@link IndexOutOfBoundsException} as long as the specified
- * indexes meet basic constraints, regardless what the current index
- * values of the buffer are:
- *
- * <pre>
- * // No matter what the current state of the buffer is, the following
- * // call always succeeds as long as the capacity of the buffer is not
- * // less than 4.
- * buf.setIndex(2, 4);
- * </pre>
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code readerIndex} is less than 0,
- * if the specified {@code writerIndex} is less than the specified
- * {@code readerIndex} or if the specified {@code writerIndex} is
- * greater than {@code this.capacity}
- */
- void setIndex(int readerIndex, int writerIndex);
-
- /**
- * Returns the number of readable bytes which is equal to
- * {@code (this.writerIndex - this.readerIndex)}.
- */
- int readableBytes();
-
- /**
- * Returns the number of writable bytes which is equal to
- * {@code (this.capacity - this.writerIndex)}.
- */
- int writableBytes();
-
- /**
- * Returns {@code true}
- * if and only if {@code (this.writerIndex - this.readerIndex)} is greater
- * than {@code 0}.
- */
- boolean readable();
-
- /**
- * Returns {@code true}
- * if and only if {@code (this.capacity - this.writerIndex)} is greater
- * than {@code 0}.
- */
- boolean writable();
-
- /**
- * Sets the {@code readerIndex} and {@code writerIndex} of this buffer to
- * {@code 0}.
- * This method is identical to {@link #setIndex(int, int) setIndex(0, 0)}.
- * <p>
- * Please note that the behavior of this method is different
- * from that of NIO buffer, which sets the {@code limit} to
- * the {@code capacity} of the buffer.
- */
- void clear();
-
- /**
- * Marks the current {@code readerIndex} in this buffer. You can
- * reposition the current {@code readerIndex} to the marked
- * {@code readerIndex} by calling {@link #resetReaderIndex()}.
- * The initial value of the marked {@code readerIndex} is {@code 0}.
- */
- void markReaderIndex();
-
- /**
- * Repositions the current {@code readerIndex} to the marked
- * {@code readerIndex} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the current {@code writerIndex} is less than the marked
- * {@code readerIndex}
- */
- void resetReaderIndex();
-
- /**
- * Marks the current {@code writerIndex} in this buffer. You can
- * reposition the current {@code writerIndex} to the marked
- * {@code writerIndex} by calling {@link #resetWriterIndex()}.
- * The initial value of the marked {@code writerIndex} is {@code 0}.
- */
- void markWriterIndex();
-
- /**
- * Repositions the current {@code writerIndex} to the marked
- * {@code writerIndex} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the current {@code readerIndex} is greater than the marked
- * {@code writerIndex}
- */
- void resetWriterIndex();
-
- /**
- * Discards the bytes between the 0th index and {@code readerIndex}.
- * It moves the bytes between {@code readerIndex} and {@code writerIndex}
- * to the 0th index, and sets {@code readerIndex} and {@code writerIndex}
- * to {@code 0} and {@code oldWriterIndex - oldReaderIndex} respectively.
- * <p>
- * Please refer to the class documentation for more detailed explanation.
- */
- void discardReadBytes();
-
- /**
- * Gets a byte at the specified absolute {@code index} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 1} is greater than {@code this.capacity}
- */
- byte getByte(int index);
-
- /**
- * Gets an unsigned byte at the specified absolute {@code index} in this
- * buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 1} is greater than {@code this.capacity}
- */
- short getUnsignedByte(int index);
-
- /**
- * Gets a 16-bit short integer at the specified absolute {@code index} in
- * this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
- */
- short getShort(int index);
-
- /**
- * Gets an unsigned 16-bit short integer at the specified absolute
- * {@code index} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
- */
- int getUnsignedShort(int index);
-
- /**
- * Gets a 24-bit medium integer at the specified absolute {@code index} in
- * this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 3} is greater than {@code this.capacity}
- */
- int getMedium(int index);
-
- /**
- * Gets an unsigned 24-bit medium integer at the specified absolute
- * {@code index} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 3} is greater than {@code this.capacity}
- */
- int getUnsignedMedium(int index);
-
- /**
- * Gets a 32-bit integer at the specified absolute {@code index} in
- * this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
- */
- int getInt(int index);
-
- /**
- * Gets an unsigned 32-bit integer at the specified absolute {@code index}
- * in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
- */
- long getUnsignedInt(int index);
-
- /**
- * Gets a 64-bit long integer at the specified absolute {@code index} in
- * this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 8} is greater than {@code this.capacity}
- */
- long getLong(int index);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the specified absolute {@code index} until the destination becomes
- * non-writable. This method is basically same with
- * {@link #getBytes(int, HornetQChannelBuffer, int, int)}, except that this
- * method increases the {@code writerIndex} of the destination by the
- * number of the transferred bytes while
- * {@link #getBytes(int, HornetQChannelBuffer, int, int)} does not.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + dst.writableBytes} is greater than
- * {@code this.capacity}
- */
- void getBytes(int index, HornetQChannelBuffer dst);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the specified absolute {@code index}. This method is basically same
- * with {@link #getBytes(int, HornetQChannelBuffer, int, int)}, except that this
- * method increases the {@code writerIndex} of the destination by the
- * number of the transferred bytes while
- * {@link #getBytes(int, HornetQChannelBuffer, int, int)} does not.
- *
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code length} is greater than {@code dst.writableBytes}
- */
- void getBytes(int index, HornetQChannelBuffer dst, int length);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the specified absolute {@code index}.
- *
- * @param dstIndex the first index of the destination
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code dstIndex + length} is greater than
- * {@code dst.capacity}
- */
- void getBytes(int index, HornetQChannelBuffer dst, int dstIndex, int length);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the specified absolute {@code index}.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + dst.length} is greater than
- * {@code this.capacity}
- */
- void getBytes(int index, byte[] dst);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the specified absolute {@code index}.
- *
- * @param dstIndex the first index of the destination
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code dstIndex + length} is greater than
- * {@code dst.length}
- */
- void getBytes(int index, byte[] dst, int dstIndex, int length);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the specified absolute {@code index} until the destination's position
- * reaches its limit.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + dst.remaining()} is greater than
- * {@code this.capacity}
- */
- void getBytes(int index, ByteBuffer dst);
-
- /**
- * Transfers this buffer's data to the specified stream starting at the
- * specified absolute {@code index}.
- *
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + length} is greater than
- * {@code this.capacity}
- * @throws IOException
- * if the specified stream threw an exception during I/O
- */
- void getBytes(int index, OutputStream out, int length) throws IOException;
-
- /**
- * Transfers this buffer's data to the specified channel starting at the
- * specified absolute {@code index}.
- *
- * @param length the maximum number of bytes to transfer
- *
- * @return the actual number of bytes written out to the specified channel
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + length} is greater than
- * {@code this.capacity}
- * @throws IOException
- * if the specified channel threw an exception during I/O
- */
- int getBytes(int index, GatheringByteChannel out, int length) throws IOException;
-
- /**
- * Sets the specified byte at the specified absolute {@code index} in this
- * buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 1} is greater than {@code this.capacity}
- */
- void setByte(int index, byte value);
-
- /**
- * Sets the specified 16-bit short integer at the specified absolute
- * {@code index} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
- */
- void setShort(int index, short value);
-
- /**
- * Sets the specified 24-bit medium integer at the specified absolute
- * {@code index} in this buffer. Please note that the most significant
- * byte is ignored in the specified value.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 3} is greater than {@code this.capacity}
- */
- void setMedium(int index, int value);
-
- /**
- * Sets the specified 32-bit integer at the specified absolute
- * {@code index} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
- */
- void setInt(int index, int value);
-
- /**
- * Sets the specified 64-bit long integer at the specified absolute
- * {@code index} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 8} is greater than {@code this.capacity}
- */
- void setLong(int index, long value);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the specified absolute {@code index} until the destination becomes
- * unreadable. This method is basically same with
- * {@link #setBytes(int, HornetQChannelBuffer, int, int)}, except that this
- * method increases the {@code readerIndex} of the source buffer by
- * the number of the transferred bytes while
- * {@link #getBytes(int, HornetQChannelBuffer, int, int)} does not.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + src.readableBytes} is greater than
- * {@code this.capacity}
- */
- void setBytes(int index, HornetQChannelBuffer src);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the specified absolute {@code index}. This method is basically same
- * with {@link #setBytes(int, HornetQChannelBuffer, int, int)}, except that this
- * method increases the {@code readerIndex} of the source buffer by
- * the number of the transferred bytes while
- * {@link #getBytes(int, HornetQChannelBuffer, int, int)} does not.
- *
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code length} is greater than {@code src.readableBytes}
- */
- void setBytes(int index, HornetQChannelBuffer src, int length);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the specified absolute {@code index}.
- *
- * @param srcIndex the first index of the source
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code srcIndex + length} is greater than
- * {@code src.capacity}
- */
- void setBytes(int index, HornetQChannelBuffer src, int srcIndex, int length);
-
- /**
- * Transfers the specified source array's data to this buffer starting at
- * the specified absolute {@code index}.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + src.length} is greater than
- * {@code this.capacity}
- */
- void setBytes(int index, byte[] src);
-
- /**
- * Transfers the specified source array's data to this buffer starting at
- * the specified absolute {@code index}.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code srcIndex + length} is greater than {@code src.length}
- */
- void setBytes(int index, byte[] src, int srcIndex, int length);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the specified absolute {@code index} until the source buffer's position
- * reaches its limit.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + src.remaining()} is greater than
- * {@code this.capacity}
- */
- void setBytes(int index, ByteBuffer src);
-
- /**
- * Transfers the content of the specified source stream to this buffer
- * starting at the specified absolute {@code index}.
- *
- * @param length the number of bytes to transfer
- *
- * @return the actual number of bytes read in from the specified channel.
- * {@code -1} if the specified channel is closed.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + length} is greater than {@code this.capacity}
- * @throws IOException
- * if the specified stream threw an exception during I/O
- */
- int setBytes(int index, InputStream in, int length) throws IOException;
-
- /**
- * Transfers the content of the specified source channel to this buffer
- * starting at the specified absolute {@code index}.
- *
- * @param length the maximum number of bytes to transfer
- *
- * @return the actual number of bytes read in from the specified channel.
- * {@code -1} if the specified channel is closed.
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + length} is greater than {@code this.capacity}
- * @throws IOException
- * if the specified channel threw an exception during I/O
- */
- int setBytes(int index, ScatteringByteChannel in, int length) throws IOException;
-
- /**
- * Fills this buffer with <tt>NUL (0x00)</tt> starting at the specified
- * absolute {@code index}.
- *
- * @param length the number of <tt>NUL</tt>s to write to the buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + length} is greater than {@code this.capacity}
- */
- void setZero(int index, int length);
-
- /**
- * Gets a byte at the current {@code readerIndex} and increases
- * the {@code readerIndex} by {@code 1} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 1}
- */
- byte readByte();
-
- /**
- * Gets an unsigned byte at the current {@code readerIndex} and increases
- * the {@code readerIndex} by {@code 1} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 1}
- */
- short readUnsignedByte();
-
- /**
- * Gets a 16-bit short integer at the current {@code readerIndex}
- * and increases the {@code readerIndex} by {@code 2} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 2}
- */
- short readShort();
-
- /**
- * Gets an unsigned 16-bit short integer at the current {@code readerIndex}
- * and increases the {@code readerIndex} by {@code 2} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 2}
- */
- int readUnsignedShort();
-
- /**
- * Gets a 24-bit medium integer at the current {@code readerIndex}
- * and increases the {@code readerIndex} by {@code 3} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 3}
- */
- int readMedium();
-
- /**
- * Gets an unsigned 24-bit medium integer at the current {@code readerIndex}
- * and increases the {@code readerIndex} by {@code 3} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 3}
- */
- int readUnsignedMedium();
-
- /**
- * Gets a 32-bit integer at the current {@code readerIndex}
- * and increases the {@code readerIndex} by {@code 4} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 4}
- */
- int readInt();
-
- /**
- * Gets an unsigned 32-bit integer at the current {@code readerIndex}
- * and increases the {@code readerIndex} by {@code 4} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 4}
- */
- long readUnsignedInt();
-
- /**
- * Gets a 64-bit integer at the current {@code readerIndex}
- * and increases the {@code readerIndex} by {@code 8} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 8}
- */
- long readLong();
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the current {@code readerIndex} until the destination becomes
- * non-writable, and increases the {@code readerIndex} by the number of the
- * transferred bytes. This method is basically same with
- * {@link #readBytes(HornetQChannelBuffer, int, int)}, except that this method
- * increases the {@code writerIndex} of the destination by the number of
- * the transferred bytes while {@link #readBytes(HornetQChannelBuffer, int, int)}
- * does not.
- *
- * @throws IndexOutOfBoundsException
- * if {@code dst.writableBytes} is greater than
- * {@code this.readableBytes}
- */
- void readBytes(HornetQChannelBuffer dst);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the current {@code readerIndex} and increases the {@code readerIndex}
- * by the number of the transferred bytes (= {@code length}). This method
- * is basically same with {@link #readBytes(HornetQChannelBuffer, int, int)},
- * except that this method increases the {@code writerIndex} of the
- * destination by the number of the transferred bytes (= {@code length})
- * while {@link #readBytes(HornetQChannelBuffer, int, int)} does not.
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes} or
- * if {@code length} is greater than {@code dst.writableBytes}
- */
- void readBytes(HornetQChannelBuffer dst, int length);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the current {@code readerIndex} and increases the {@code readerIndex}
- * by the number of the transferred bytes (= {@code length}).
- *
- * @param dstIndex the first index of the destination
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code length} is greater than {@code this.readableBytes}, or
- * if {@code dstIndex + length} is greater than
- * {@code dst.capacity}
- */
- void readBytes(HornetQChannelBuffer dst, int dstIndex, int length);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the current {@code readerIndex} and increases the {@code readerIndex}
- * by the number of the transferred bytes (= {@code dst.length}).
- *
- * @throws IndexOutOfBoundsException
- * if {@code dst.length} is greater than {@code this.readableBytes}
- */
- void readBytes(byte[] dst);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the current {@code readerIndex} and increases the {@code readerIndex}
- * by the number of the transferred bytes (= {@code length}).
- *
- * @param dstIndex the first index of the destination
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code length} is greater than {@code this.readableBytes}, or
- * if {@code dstIndex + length} is greater than {@code dst.length}
- */
- void readBytes(byte[] dst, int dstIndex, int length);
-
- /**
- * Transfers this buffer's data to the specified destination starting at
- * the current {@code readerIndex} until the destination's position
- * reaches its limit, and increases the {@code readerIndex} by the
- * number of the transferred bytes.
- *
- * @throws IndexOutOfBoundsException
- * if {@code dst.remaining()} is greater than
- * {@code this.readableBytes}
- */
- void readBytes(ByteBuffer dst);
-
- /**
- * Transfers this buffer's data to the specified stream starting at the
- * current {@code readerIndex}.
- *
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes}
- * @throws IOException
- * if the specified stream threw an exception during I/O
- */
- void readBytes(OutputStream out, int length) throws IOException;
-
- /**
- * Transfers this buffer's data to the specified stream starting at the
- * current {@code readerIndex}.
- *
- * @param length the maximum number of bytes to transfer
- *
- * @return the actual number of bytes written out to the specified channel
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes}
- * @throws IOException
- * if the specified channel threw an exception during I/O
- */
- int readBytes(GatheringByteChannel out, int length) throws IOException;
-
- /**
- * Increases the current {@code readerIndex} by the specified
- * {@code length} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes}
- */
- void skipBytes(int length);
-
- /**
- * Sets the specified byte at the current {@code writerIndex}
- * and increases the {@code writerIndex} by {@code 1} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 1}
- */
- void writeByte(byte value);
-
- /**
- * Sets the specified 16-bit short integer at the current
- * {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
- * in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 2}
- */
- void writeShort(short value);
-
- /**
- * Sets the specified 24-bit medium integer at the current
- * {@code writerIndex} and increases the {@code writerIndex} by {@code 3}
- * in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 3}
- */
- void writeMedium(int value);
-
- /**
- * Sets the specified 32-bit integer at the current {@code writerIndex}
- * and increases the {@code writerIndex} by {@code 4} in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 4}
- */
- void writeInt(int value);
-
- /**
- * Sets the specified 64-bit long integer at the current
- * {@code writerIndex} and increases the {@code writerIndex} by {@code 8}
- * in this buffer.
- *
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 8}
- */
- void writeLong(long value);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the current {@code writerIndex} until the source buffer becomes
- * unreadable, and increases the {@code writerIndex} by the number of
- * the transferred bytes. This method is basically same with
- * {@link #writeBytes(HornetQChannelBuffer, int, int)}, except that this method
- * increases the {@code readerIndex} of the source buffer by the number of
- * the transferred bytes while {@link #writeBytes(HornetQChannelBuffer, int, int)}
- * does not.
- *
- * @throws IndexOutOfBoundsException
- * if {@code src.readableBytes} is greater than
- * {@code this.writableBytes}
- *
- */
- void writeBytes(HornetQChannelBuffer src);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the current {@code writerIndex} and increases the {@code writerIndex}
- * by the number of the transferred bytes (= {@code length}). This method
- * is basically same with {@link #writeBytes(HornetQChannelBuffer, int, int)},
- * except that this method increases the {@code readerIndex} of the source
- * buffer by the number of the transferred bytes (= {@code length}) while
- * {@link #writeBytes(HornetQChannelBuffer, int, int)} does not.
- *
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.writableBytes} or
- * if {@code length} is greater then {@code src.readableBytes}
- */
- void writeBytes(HornetQChannelBuffer src, int length);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the current {@code writerIndex} and increases the {@code writerIndex}
- * by the number of the transferred bytes (= {@code length}).
- *
- * @param srcIndex the first index of the source
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code srcIndex + length} is greater than
- * {@code src.capacity}, or
- * if {@code length} is greater than {@code this.writableBytes}
- */
- void writeBytes(HornetQChannelBuffer src, int srcIndex, int length);
-
- /**
- * Transfers the specified source array's data to this buffer starting at
- * the current {@code writerIndex} and increases the {@code writerIndex}
- * by the number of the transferred bytes (= {@code src.length}).
- *
- * @throws IndexOutOfBoundsException
- * if {@code src.length} is greater than {@code this.writableBytes}
- */
- void writeBytes(byte[] src);
-
- /**
- * Transfers the specified source array's data to this buffer starting at
- * the current {@code writerIndex} and increases the {@code writerIndex}
- * by the number of the transferred bytes (= {@code length}).
- *
- * @param srcIndex the first index of the source
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code srcIndex + length} is greater than
- * {@code src.length}, or
- * if {@code length} is greater than {@code this.writableBytes}
- */
- void writeBytes(byte[] src, int srcIndex, int length);
-
- /**
- * Transfers the specified source buffer's data to this buffer starting at
- * the current {@code writerIndex} until the source buffer's position
- * reaches its limit, and increases the {@code writerIndex} by the
- * number of the transferred bytes.
- *
- * @throws IndexOutOfBoundsException
- * if {@code src.remaining()} is greater than
- * {@code this.writableBytes}
- */
- void writeBytes(ByteBuffer src);
-
- /**
- * Transfers the content of the specified stream to this buffer
- * starting at the current {@code writerIndex} and increases the
- * {@code writerIndex} by the number of the transferred bytes.
- *
- * @param length the number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.writableBytes}
- * @throws IOException
- * if the specified stream threw an exception during I/O
- */
- void writeBytes(InputStream in, int length) throws IOException;
-
- /**
- * Transfers the content of the specified channel to this buffer
- * starting at the current {@code writerIndex} and increases the
- * {@code writerIndex} by the number of the transferred bytes.
- *
- * @param length the maximum number of bytes to transfer
- *
- * @return the actual number of bytes read in from the specified channel
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.writableBytes}
- * @throws IOException
- * if the specified channel threw an exception during I/O
- */
- int writeBytes(ScatteringByteChannel in, int length) throws IOException;
-
- /**
- * Fills this buffer with <tt>NUL (0x00)</tt> starting at the current
- * {@code writerIndex} and increases the {@code writerIndex} by the
- * specified {@code length}.
- *
- * @param length the number of <tt>NUL</tt>s to write to the buffer
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.writableBytes}
- */
- void writeZero(int length);
-
- /**
- * Converts this buffer's readable bytes into a NIO buffer. The returned
- * buffer might or might not share the content with this buffer, while
- * they have separate indexes and marks. This method is identical to
- * {@code buf.toByteBuffer(buf.readerIndex(), buf.readableBytes())}.
- */
- ByteBuffer toByteBuffer();
-
- /**
- * Converts this buffer's sub-region into a NIO buffer. The returned
- * buffer might or might not share the content with this buffer, while
- * they have separate indexes and marks.
- */
- ByteBuffer toByteBuffer(int index, int length);
-
- /**
- * Converts this buffer's sub-region into an array of NIO buffers.
- * The returned buffers might or might not share the content with this
- * buffer, while they have separate indexes and marks.
- */
- ByteBuffer[] toByteBuffers(int index, int length);
-
- /**
- * Decodes this buffer's readable bytes into a string with the specified
- * character set name. This method is identical to
- * {@code buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName)}.
- *
- * @throws UnsupportedCharsetException
- * if the specified character set name is not supported by the
- * current VM
- */
- String toString(String charsetName);
-
- /**
- * Decodes this buffer's sub-region into a string with the specified
- * character set name.
- *
- * @throws UnsupportedCharsetException
- * if the specified character set name is not supported by the
- * current VM
- */
- String toString(int index, int length, String charsetName);
-
- /**
- * Returns a hash code which was calculated from the content of this
- * buffer. If there's a byte array which is
- * {@linkplain #equals(Object) equal to} this array, both arrays should
- * return the same value.
- */
- int hashCode();
-
- /**
- * Determines if the content of the specified buffer is identical to the
- * content of this array. 'Identical' here means:
- * <ul>
- * <li>the size of the contents of the two buffers are same and</li>
- * <li>every single byte of the content of the two buffers are same.</li>
- * </ul>
- * Please note that it does not compare {@link #readerIndex()} nor
- * {@link #writerIndex()}. This method also returns {@code false} for
- * {@code null} and an object which is not an instance of
- * {@link HornetQChannelBuffer} type.
- */
- boolean equals(Object obj);
-
- /**
- * Compares the content of the specified buffer to the content of this
- * buffer. Comparison is performed in the same manner with the string
- * comparison functions of various languages such as {@code strcmp},
- * {@code memcmp} and {@link String#compareTo(String)}.
- */
- int compareTo(HornetQChannelBuffer buffer);
-
- /**
- * Returns the string representation of this buffer. This method does not
- * necessarily return the whole content of the buffer but returns
- * the values of the key properties such as {@link #readerIndex()},
- * {@link #writerIndex()} and {@link #capacity()}.
- */
- String toString();
-}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffers.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffers.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQChannelBuffers.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,455 +15,47 @@
import java.nio.ByteBuffer;
+import org.hornetq.core.buffers.impl.ChannelBufferWrapper;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+
+
/**
- * Creates a new {@link HornetQChannelBuffer} by allocating new space or by wrapping
- * or copying existing byte arrays, byte buffers and a string.
+ *
+ * A HornetQChannelBuffers
*
- * <h3>Use static import</h3>
- * This classes is intended to be used with Java 5 static import statement:
+ * @author tim
*
- * <pre>
- * import static org.jboss.netty.buffer.ChannelBuffers.*;
*
- * ChannelBuffer heapBuffer = buffer(128);
- * ChannelBuffer directBuffer = directBuffer(256);
- * ChannelBuffer dynamicBuffer = dynamicBuffer(512);
- * ChannelBuffer wrappedBuffer = wrappedBuffer(new byte[128], new byte[256]);
- * ChannelBuffer copiedBuffer = copiedBuffer(ByteBuffer.allocate(128));
- * </pre>
- *
- * <h3>Allocating a new buffer</h3>
- *
- * Three buffer types are provided out of the box.
- *
- * <ul>
- * <li>{@link #buffer(int)} allocates a new fixed-capacity heap buffer.</li>
- * <li>{@link #directBuffer(int)} allocates a new fixed-capacity direct
buffer.</li>
- * <li>{@link #dynamicBuffer(int)} allocates a new dynamic-capacity heap
- * buffer, whose capacity increases automatically as needed by a write
- * operation.</li>
- * </ul>
- *
- * <h3>Creating a wrapped buffer</h3>
- *
- * Wrapped buffer is a buffer which is a view of one or more existing
- * byte arrays and byte buffers. Any changes in the content of the original
- * array or buffer will be reflected in the wrapped buffer. Various wrapper
- * methods are provided and their name is all {@code wrappedBuffer()}.
- * You might want to take a look at this method closely if you want to create
- * a buffer which is composed of more than one array to reduce the number of
- * memory copy.
- *
- * <h3>Creating a copied buffer</h3>
- *
- * Copied buffer is a deep copy of one or more existing byte arrays, byte
- * buffers or a string. Unlike a wrapped buffer, there's no shared data
- * between the original data and the copied buffer. Various copy methods are
- * provided and their name is all {@code copiedBuffer()}. It is also convenient
- * to use this operation to merge multiple buffers into one buffer.
- *
- * <h3>Miscellaneous utility methods</h3>
- *
- * This class also provides various utility methods to help implementation
- * of a new buffer type, generation of hex dump and swapping an integer's
- * byte order.
- *
- * @author The Netty Project (netty-dev(a)lists.jboss.org)
- * @author Trustin Lee (tlee(a)redhat.com)
- *
- * @version $Rev: 472 $, $Date: 2008-11-14 16:45:53 +0900 (Fri, 14 Nov 2008) $
- *
- * @apiviz.landmark
*/
public class HornetQChannelBuffers
{
-
- /**
- * A buffer whose capacity is {@code 0}.
- */
- public static final HornetQHeapChannelBuffer EMPTY_BUFFER = new
HornetQHeapChannelBuffer(0);
-
- private static final char[] HEXDUMP_TABLE = new char[65536 * 4];
-
- static
+ public static HornetQBuffer dynamicBuffer(int estimatedLength)
{
- final char[] DIGITS = "0123456789abcdef".toCharArray();
- for (int i = 0; i < 65536; i++)
- {
- HEXDUMP_TABLE[(i << 2) + 0] = DIGITS[i >>> 12 & 0x0F];
- HEXDUMP_TABLE[(i << 2) + 1] = DIGITS[i >>> 8 & 0x0F];
- HEXDUMP_TABLE[(i << 2) + 2] = DIGITS[i >>> 4 & 0x0F];
- HEXDUMP_TABLE[(i << 2) + 3] = DIGITS[i >>> 0 & 0x0F];
- }
+ return new ChannelBufferWrapper(ChannelBuffers.dynamicBuffer(estimatedLength));
}
-
- /**
- * Creates a new Java heap buffer with the specified {@code endianness}
- * and {@code capacity}. The new buffer's {@code readerIndex} and
- * {@code writerIndex} are {@code 0}.
- */
- public static HornetQChannelBuffer buffer(final int capacity)
+
+ public static HornetQBuffer dynamicBuffer(byte[] bytes)
{
- if (capacity == 0)
- {
- return EMPTY_BUFFER;
- }
- else
- {
- return new HornetQHeapChannelBuffer(capacity);
- }
+ ChannelBuffer buff = ChannelBuffers.dynamicBuffer(bytes.length);
+
+ buff.writeBytes(bytes);
+
+ return new ChannelBufferWrapper(buff);
}
- /**
- * Reuses the initialBuffer on the creation of the DynamicBuffer.
- * This avoids a copy, but you should only call this method if the buffer is not being
modified after the call of this method.
- *
- * @author Clebert
- */
- public static HornetQChannelBuffer dynamicBuffer(final byte[] initialBuffer)
+ public static HornetQBuffer wrappedBuffer(ByteBuffer underlying)
{
- return new HornetQDynamicChannelBuffer(initialBuffer);
+ return new ChannelBufferWrapper(ChannelBuffers.wrappedBuffer(underlying));
}
-
- /**
- * Creates a new dynamic buffer with the specified endianness and
- * the specified estimated data length. More accurate estimation yields
- * less unexpected reallocation overhead. The new buffer's
- * {@code readerIndex} and {@code writerIndex} are {@code 0}.
- */
- public static HornetQChannelBuffer dynamicBuffer(final int estimatedLength)
+
+ public static HornetQBuffer wrappedBuffer(byte[] underlying)
{
- return new HornetQDynamicChannelBuffer(estimatedLength);
+ return new ChannelBufferWrapper(ChannelBuffers.wrappedBuffer(underlying));
}
-
- /**
- * Creates a new buffer which wraps the specified {@code array} with the
- * specified {@code endianness}. A modification on the specified array's
- * content will be visible to the returned buffer.
- */
- public static HornetQChannelBuffer wrappedBuffer(final byte[] array)
- {
- return new HornetQHeapChannelBuffer(array);
- }
- /**
- * Creates a new buffer which wraps the specified NIO buffer's current
- * slice. A modification on the specified buffer's content and endianness
- * will be visible to the returned buffer.
- * The new buffer's {@code readerIndex}
- * and {@code writerIndex} are {@code 0} and {@code buffer.remaining}
- * respectively.
- *
- * Note: This method differs from the Original Netty version.
- *
- * @author Clebert
- */
- public static HornetQChannelBuffer wrappedBuffer(final ByteBuffer buffer)
+ public static HornetQBuffer fixedBuffer(int size)
{
-
- HornetQChannelBuffer newbuffer = new HornetQByteBufferBackedChannelBuffer(buffer);
- newbuffer.clear();
- return newbuffer;
+ return new ChannelBufferWrapper(ChannelBuffers.buffer(size));
}
-
- /**
- * Creates a new buffer with the specified {@code endianness} whose
- * content is a copy of the specified {@code array}. The new buffer's
- * {@code readerIndex} and {@code writerIndex} are {@code 0} and
- * {@code array.length} respectively.
- */
-// public static HornetQChannelBuffer copiedBuffer(final byte[] array)
-// {
-// if (array.length == 0)
-// {
-// return EMPTY_BUFFER;
-// }
-// else
-// {
-// return new HornetQHeapChannelBuffer(array.clone());
-// }
-// }
-//
-// /**
-// * Creates a new buffer whose content is a copy of the specified
-// * {@code buffer}'s current slice. The new buffer's {@code readerIndex}
-// * and {@code writerIndex} are {@code 0} and {@code buffer.remaining}
-// * respectively.
-// */
-// public static HornetQChannelBuffer copiedBuffer(final ByteBuffer buffer)
-// {
-// int length = buffer.remaining();
-// if (length == 0)
-// {
-// return EMPTY_BUFFER;
-// }
-// byte[] copy = new byte[length];
-// int position = buffer.position();
-// try
-// {
-// buffer.get(copy);
-// }
-// finally
-// {
-// buffer.position(position);
-// }
-// return wrappedBuffer(copy);
-// }
-//
-// /**
-// * Returns a <a
href="http://en.wikipedia.org/wiki/Hex_dump">hex
dump</a>
-// * of the specified buffer's readable bytes.
-// */
-// public static String hexDump(final HornetQChannelBuffer buffer)
-// {
-// return hexDump(buffer, buffer.readerIndex(), buffer.readableBytes());
-// }
-//
-// /**
-// * Returns a <a
href="http://en.wikipedia.org/wiki/Hex_dump">hex
dump</a>
-// * of the specified buffer's sub-region.
-// */
-// public static String hexDump(final HornetQChannelBuffer buffer, final int fromIndex,
final int length)
-// {
-// if (length < 0)
-// {
-// throw new IllegalArgumentException("length: " + length);
-// }
-// if (length == 0)
-// {
-// return "";
-// }
-//
-// int endIndex = fromIndex + (length >>> 1 << 1);
-// boolean oddLength = length % 2 != 0;
-// char[] buf = new char[length << 1];
-//
-// int srcIdx = fromIndex;
-// int dstIdx = 0;
-// for (; srcIdx < endIndex; srcIdx += 2, dstIdx += 4)
-// {
-// System.arraycopy(HEXDUMP_TABLE, buffer.getUnsignedShort(srcIdx) << 2,
buf, dstIdx, 4);
-// }
-//
-// if (oddLength)
-// {
-// System.arraycopy(HEXDUMP_TABLE, (buffer.getUnsignedByte(srcIdx) << 2) +
2, buf, dstIdx, 2);
-// }
-//
-// return new String(buf);
-// }
-//
- /**
- * Calculates the hash code of the specified buffer. This method is
- * useful when implementing a new buffer type.
- */
- public static int hashCode(final HornetQChannelBuffer buffer)
- {
- final int aLen = buffer.readableBytes();
- final int intCount = aLen >>> 2;
- final int byteCount = aLen & 3;
-
- int hashCode = 1;
- int arrayIndex = buffer.readerIndex();
- for (int i = intCount; i > 0; i--)
- {
- hashCode = 31 * hashCode + buffer.getInt(arrayIndex);
- arrayIndex += 4;
- }
-
- for (int i = byteCount; i > 0; i--)
- {
- hashCode = 31 * hashCode + buffer.getByte(arrayIndex++);
- }
-
- if (hashCode == 0)
- {
- hashCode = 1;
- }
-
- return hashCode;
- }
-
- /**
- * Returns {@code true} if and only if the two specified buffers are
- * identical to each other as described in {@code ChannelBuffer#equals(Object)}.
- * This method is useful when implementing a new buffer type.
- */
- public static boolean equals(final HornetQChannelBuffer bufferA, final
HornetQChannelBuffer bufferB)
- {
- final int aLen = bufferA.readableBytes();
- if (aLen != bufferB.readableBytes())
- {
- return false;
- }
-
- final int longCount = aLen >>> 3;
- final int byteCount = aLen & 7;
-
- int aIndex = bufferA.readerIndex();
- int bIndex = bufferB.readerIndex();
-
- for (int i = longCount; i > 0; i--)
- {
- if (bufferA.getLong(aIndex) != bufferB.getLong(bIndex))
- {
- return false;
- }
- aIndex += 8;
- bIndex += 8;
- }
-
- for (int i = byteCount; i > 0; i--)
- {
- if (bufferA.getByte(aIndex) != bufferB.getByte(bIndex))
- {
- return false;
- }
- aIndex++;
- bIndex++;
- }
-
- return true;
- }
-
- /**
- * Compares the two specified buffers as described in {@link
HornetQChannelBuffer#compareTo(HornetQChannelBuffer)}.
- * This method is useful when implementing a new buffer type.
- */
- public static int compare(final HornetQChannelBuffer bufferA, final
HornetQChannelBuffer bufferB)
- {
- final int aLen = bufferA.readableBytes();
- final int bLen = bufferB.readableBytes();
- final int minLength = Math.min(aLen, bLen);
- final int uintCount = minLength >>> 2;
- final int byteCount = minLength & 3;
-
- int aIndex = bufferA.readerIndex();
- int bIndex = bufferB.readerIndex();
-
- for (int i = uintCount; i > 0; i--)
- {
- long va = bufferA.getUnsignedInt(aIndex);
- long vb = bufferB.getUnsignedInt(bIndex);
- if (va > vb)
- {
- return 1;
- }
- else if (va < vb)
- {
- return -1;
- }
- aIndex += 4;
- bIndex += 4;
- }
-
- for (int i = byteCount; i > 0; i--)
- {
- byte va = bufferA.getByte(aIndex);
- byte vb = bufferB.getByte(bIndex);
- if (va > vb)
- {
- return 1;
- }
- else if (va < vb)
- {
- return -1;
- }
- aIndex++;
- bIndex++;
- }
-
- return aLen - bLen;
- }
-//
-// /**
-// * The default implementation of {@link HornetQChannelBuffer#indexOf(int, int,
byte)}.
-// * This method is useful when implementing a new buffer type.
-// */
-// public static int indexOf(final HornetQChannelBuffer buffer, final int fromIndex,
final int toIndex, final byte value)
-// {
-// if (fromIndex <= toIndex)
-// {
-// return firstIndexOf(buffer, fromIndex, toIndex, value);
-// }
-// else
-// {
-// return lastIndexOf(buffer, fromIndex, toIndex, value);
-// }
-// }
-//
-// /**
-// * Toggles the endianness of the specified 16-bit short integer.
-// */
-// public static short swapShort(final short value)
-// {
-// return (short)(value << 8 | value >>> 8 & 0xff);
-// }
-//
-// /**
-// * Toggles the endianness of the specified 24-bit medium integer.
-// */
-// public static int swapMedium(final int value)
-// {
-// return value << 16 & 0xff0000 | value & 0xff00 | value >>>
16 & 0xff;
-// }
-//
-// /**
-// * Toggles the endianness of the specified 32-bit integer.
-// */
-// public static int swapInt(final int value)
-// {
-// return swapShort((short)value) << 16 | swapShort((short)(value >>>
16)) & 0xffff;
-// }
-//
-// /**
-// * Toggles the endianness of the specified 64-bit long integer.
-// */
-// public static long swapLong(final long value)
-// {
-// return (long)swapInt((int)value) << 32 | swapInt((int)(value >>>
32)) & 0xffffffffL;
-// }
-//
-// private static int firstIndexOf(final HornetQChannelBuffer buffer, int fromIndex,
final int toIndex, final byte value)
-// {
-// fromIndex = Math.max(fromIndex, 0);
-// if (fromIndex >= toIndex || buffer.capacity() == 0)
-// {
-// return -1;
-// }
-//
-// for (int i = fromIndex; i < toIndex; i++)
-// {
-// if (buffer.getByte(i) == value)
-// {
-// return i;
-// }
-// }
-//
-// return -1;
-// }
-//
-// private static int lastIndexOf(final HornetQChannelBuffer buffer, int fromIndex,
final int toIndex, final byte value)
-// {
-// fromIndex = Math.min(fromIndex, buffer.capacity());
-// if (fromIndex < 0 || buffer.capacity() == 0)
-// {
-// return -1;
-// }
-//
-// for (int i = fromIndex - 1; i >= toIndex; i--)
-// {
-// if (buffer.getByte(i) == value)
-// {
-// return i;
-// }
-// }
-//
-// return -1;
-// }
-
- private HornetQChannelBuffers()
- {
- // Unused
- }
}
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQDynamicChannelBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,290 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.buffers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.GatheringByteChannel;
-import java.nio.channels.ScatteringByteChannel;
-
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-
-/**
- * A dynamic capacity buffer which increases its capacity as needed. It is
- * recommended to use {@link HornetQChannelBuffers#dynamicBuffer(int)} instead of
- * calling the constructor explicitly.
- *
- * @author The Netty Project (netty-dev(a)lists.jboss.org)
- * @author Trustin Lee (tlee(a)redhat.com)
- *
- * @version $Rev: 237 $, $Date: 2008-09-04 20:53:44 +0900 (Thu, 04 Sep 2008) $
- *
- */
-public class HornetQDynamicChannelBuffer extends HornetQAbstractChannelBuffer
-{
- private static final Logger log =
Logger.getLogger(HornetQDynamicChannelBuffer.class);
-
- private final int initialCapacity;
-
- private HornetQChannelBuffer buffer = HornetQChannelBuffers.EMPTY_BUFFER;
-
- HornetQDynamicChannelBuffer(final int estimatedLength)
- {
- if (estimatedLength < 0)
- {
- throw new IllegalArgumentException("estimatedLength: " +
estimatedLength);
- }
- initialCapacity = estimatedLength;
- }
-
- HornetQDynamicChannelBuffer(final byte[] initialBuffer)
- {
- initialCapacity = initialBuffer.length;
-
- buffer = new HornetQHeapChannelBuffer(initialBuffer);
-
- writerIndex(initialBuffer.length);
- }
-
- public int capacity()
- {
- return buffer.capacity();
- }
-
- public byte getByte(final int index)
- {
- return buffer.getByte(index);
- }
-
- public short getShort(final int index)
- {
- return buffer.getShort(index);
- }
-
- public int getUnsignedMedium(final int index)
- {
- return buffer.getUnsignedMedium(index);
- }
-
- public int getInt(final int index)
- {
- return buffer.getInt(index);
- }
-
- public long getLong(final int index)
- {
- return buffer.getLong(index);
- }
-
- public void getBytes(final int index, final byte[] dst, final int dstIndex, final int
length)
- {
- buffer.getBytes(index, dst, dstIndex, length);
- }
-
- public void getBytes(final int index, final HornetQChannelBuffer dst, final int
dstIndex, final int length)
- {
- buffer.getBytes(index, dst, dstIndex, length);
- }
-
- public void getBytes(final int index, final ByteBuffer dst)
- {
- buffer.getBytes(index, dst);
- }
-
- public int getBytes(final int index, final GatheringByteChannel out, final int length)
throws IOException
- {
- return buffer.getBytes(index, out, length);
- }
-
- public void getBytes(final int index, final OutputStream out, final int length) throws
IOException
- {
- buffer.getBytes(index, out, length);
- }
-
- public void setByte(final int index, final byte value)
- {
- buffer.setByte(index, value);
- }
-
- public void setShort(final int index, final short value)
- {
- buffer.setShort(index, value);
- }
-
- public void setMedium(final int index, final int value)
- {
- buffer.setMedium(index, value);
- }
-
- public void setInt(final int index, final int value)
- {
- buffer.setInt(index, value);
- }
-
- public void setLong(final int index, final long value)
- {
- buffer.setLong(index, value);
- }
-
- public void setBytes(final int index, final byte[] src, final int srcIndex, final int
length)
- {
- buffer.setBytes(index, src, srcIndex, length);
- }
-
- public void setBytes(final int index, final HornetQChannelBuffer src, final int
srcIndex, final int length)
- {
- buffer.setBytes(index, src, srcIndex, length);
- }
-
- public void setBytes(final int index, final ByteBuffer src)
- {
- buffer.setBytes(index, src);
- }
-
- public int setBytes(final int index, final InputStream in, final int length) throws
IOException
- {
- return buffer.setBytes(index, in, length);
- }
-
- public int setBytes(final int index, final ScatteringByteChannel in, final int length)
throws IOException
- {
- return buffer.setBytes(index, in, length);
- }
-
- @Override
- public void writeByte(final byte value)
- {
- ensureWritableBytes(1);
- super.writeByte(value);
- }
-
- @Override
- public void writeShort(final short value)
- {
- ensureWritableBytes(2);
- super.writeShort(value);
- }
-
- @Override
- public void writeMedium(final int value)
- {
- ensureWritableBytes(3);
- super.writeMedium(value);
- }
-
- @Override
- public void writeInt(final int value)
- {
- ensureWritableBytes(4);
- super.writeInt(value);
- }
-
- @Override
- public void writeLong(final long value)
- {
- ensureWritableBytes(8);
- super.writeLong(value);
- }
-
- @Override
- public void writeBytes(final byte[] src, final int srcIndex, final int length)
- {
- ensureWritableBytes(length);
- super.writeBytes(src, srcIndex, length);
- }
-
- @Override
- public void writeBytes(final HornetQChannelBuffer src, final int srcIndex, final int
length)
- {
- ensureWritableBytes(length);
- super.writeBytes(src, srcIndex, length);
- }
-
- @Override
- public void writeBytes(final ByteBuffer src)
- {
- ensureWritableBytes(src.remaining());
- super.writeBytes(src);
- }
-
- @Override
- public void writeZero(final int length)
- {
- ensureWritableBytes(length);
- super.writeZero(length);
- }
-
- public ByteBuffer toByteBuffer(final int index, final int length)
- {
- return buffer.toByteBuffer(index, length);
- }
-
- public String toString(final int index, final int length, final String charsetName)
- {
- return buffer.toString(index, length, charsetName);
- }
-
- private void ensureWritableBytes(final int requestedBytes)
- {
- if (requestedBytes <= writableBytes())
- {
- return;
- }
-
- int newCapacity;
- if (capacity() == 0)
- {
- newCapacity = initialCapacity;
- if (newCapacity == 0)
- {
- newCapacity = 1;
- }
- }
- else
- {
- newCapacity = capacity();
- }
- int minNewCapacity = writerIndex() + requestedBytes;
- while (newCapacity < minNewCapacity)
- {
- newCapacity <<= 1;
- }
-
- HornetQChannelBuffer newBuffer = HornetQChannelBuffers.buffer(newCapacity);
- newBuffer.writeBytes(buffer, 0, writerIndex());
- buffer = newBuffer;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.buffers.AbstractChannelBuffer#array()
- */
- public byte[] array()
- {
- return buffer.array();
- }
-
- public HornetQBuffer copy()
- {
- return new HornetQDynamicChannelBuffer(buffer.copy().array());
- }
-
- public HornetQBuffer slice(int index, int length)
- {
- return buffer.slice(index, length);
- }
-
-}
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/HornetQHeapChannelBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,331 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.buffers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.GatheringByteChannel;
-import java.nio.channels.ScatteringByteChannel;
-import java.nio.charset.UnsupportedCharsetException;
-
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-
-/**
- * A skeletal implementation for Java heap buffers.
- *
- * @author The Netty Project (netty-dev(a)lists.jboss.org)
- * @author Trustin Lee (tlee(a)redhat.com)
- *
- * @version $Rev: 486 $, $Date: 2008-11-16 22:52:47 +0900 (Sun, 16 Nov 2008) $
- */
-public class HornetQHeapChannelBuffer extends HornetQAbstractChannelBuffer
-{
-
- /**
- * The underlying heap byte array that this buffer is wrapping.
- */
- protected final byte[] array;
-
- /**
- * Creates a new heap buffer with a newly allocated byte array.
- *
- * @param length the length of the new byte array
- */
- HornetQHeapChannelBuffer(final int length)
- {
- this(new byte[length], 0, 0);
- }
-
- /**
- * Creates a new heap buffer with an existing byte array.
- *
- * @param array the byte array to wrap
- */
- HornetQHeapChannelBuffer(final byte[] array)
- {
- this(array, 0, array.length);
- }
-
- /**
- * Creates a new heap buffer with an existing byte array.
- *
- * @param array the byte array to wrap
- * @param readerIndex the initial reader index of this buffer
- * @param writerIndex the initial writer index of this buffer
- */
- protected HornetQHeapChannelBuffer(final byte[] array, final int readerIndex, final
int writerIndex)
- {
- if (array == null)
- {
- throw new NullPointerException("array");
- }
- this.array = array;
- setIndex(readerIndex, writerIndex);
- }
-
- public int capacity()
- {
- return array.length;
- }
-
- public byte getByte(final int index)
- {
- return array[index];
- }
-
- public void getBytes(final int index, final HornetQChannelBuffer dst, final int
dstIndex, final int length)
- {
- if (dst instanceof HornetQHeapChannelBuffer)
- {
- getBytes(index, ((HornetQHeapChannelBuffer)dst).array, dstIndex, length);
- }
- else
- {
- dst.setBytes(dstIndex, array, index, length);
- }
- }
-
- public void getBytes(final int index, final byte[] dst, final int dstIndex, final int
length)
- {
- System.arraycopy(array, index, dst, dstIndex, length);
- }
-
- public void getBytes(final int index, final ByteBuffer dst)
- {
- dst.put(array, index, Math.min(capacity() - index, dst.remaining()));
- }
-
- public void getBytes(final int index, final OutputStream out, final int length) throws
IOException
- {
- out.write(array, index, length);
- }
-
- public int getBytes(final int index, final GatheringByteChannel out, final int length)
throws IOException
- {
- return out.write(ByteBuffer.wrap(array, index, length));
- }
-
- public void setByte(final int index, final byte value)
- {
- array[index] = value;
- }
-
- public void setBytes(final int index, final HornetQChannelBuffer src, final int
srcIndex, final int length)
- {
- if (src instanceof HornetQHeapChannelBuffer)
- {
- setBytes(index, ((HornetQHeapChannelBuffer)src).array, srcIndex, length);
- }
- else
- {
- src.getBytes(srcIndex, array, index, length);
- }
- }
-
- public void setBytes(final int index, final byte[] src, final int srcIndex, final int
length)
- {
- System.arraycopy(src, srcIndex, array, index, length);
- }
-
- public void setBytes(final int index, final ByteBuffer src)
- {
- src.get(array, index, src.remaining());
- }
-
- public int setBytes(int index, final InputStream in, int length) throws IOException
- {
- int readBytes = 0;
- do
- {
- int localReadBytes = in.read(array, index, length);
- if (localReadBytes < 0)
- {
- if (readBytes == 0)
- {
- return -1;
- }
- else
- {
- break;
- }
- }
- readBytes += localReadBytes;
- index += localReadBytes;
- length -= localReadBytes;
- }
- while (length > 0);
-
- return readBytes;
- }
-
- public int setBytes(final int index, final ScatteringByteChannel in, final int length)
throws IOException
- {
- ByteBuffer buf = ByteBuffer.wrap(array, index, length);
- int readBytes = 0;
-
- do
- {
- int localReadBytes;
- try
- {
- localReadBytes = in.read(buf);
- }
- catch (ClosedChannelException e)
- {
- localReadBytes = -1;
- }
- if (localReadBytes < 0)
- {
- if (readBytes == 0)
- {
- return -1;
- }
- else
- {
- break;
- }
- }
- else if (localReadBytes == 0)
- {
- break;
- }
- readBytes += localReadBytes;
- }
- while (readBytes < length);
-
- return readBytes;
- }
-
- public short getShort(final int index)
- {
- return (short)(array[index] << 8 | array[index + 1] & 0xFF);
- }
-
- public int getUnsignedMedium(final int index)
- {
- return (array[index] & 0xff) << 16 | (array[index + 1] & 0xff)
<< 8 | (array[index + 2] & 0xff) << 0;
- }
-
- public int getInt(final int index)
- {
- return (array[index] & 0xff) << 24 | (array[index + 1] & 0xff)
<< 16 |
- (array[index + 2] & 0xff) << 8 |
- (array[index + 3] & 0xff) << 0;
- }
-
- public long getLong(final int index)
- {
- return ((long)array[index] & 0xff) << 56 | ((long)array[index + 1] &
0xff) << 48 |
- ((long)array[index + 2] & 0xff) << 40 |
- ((long)array[index + 3] & 0xff) << 32 |
- ((long)array[index + 4] & 0xff) << 24 |
- ((long)array[index + 5] & 0xff) << 16 |
- ((long)array[index + 6] & 0xff) << 8 |
- ((long)array[index + 7] & 0xff) << 0;
- }
-
- public void setShort(final int index, final short value)
- {
- array[index] = (byte)(value >>> 8);
- array[index + 1] = (byte)(value >>> 0);
- }
-
- public void setMedium(final int index, final int value)
- {
- array[index] = (byte)(value >>> 16);
- array[index + 1] = (byte)(value >>> 8);
- array[index + 2] = (byte)(value >>> 0);
- }
-
- public void setInt(final int index, final int value)
- {
- array[index] = (byte)(value >>> 24);
- array[index + 1] = (byte)(value >>> 16);
- array[index + 2] = (byte)(value >>> 8);
- array[index + 3] = (byte)(value >>> 0);
- }
-
- public void setLong(final int index, final long value)
- {
- array[index] = (byte)(value >>> 56);
- array[index + 1] = (byte)(value >>> 48);
- array[index + 2] = (byte)(value >>> 40);
- array[index + 3] = (byte)(value >>> 32);
- array[index + 4] = (byte)(value >>> 24);
- array[index + 5] = (byte)(value >>> 16);
- array[index + 6] = (byte)(value >>> 8);
- array[index + 7] = (byte)(value >>> 0);
- }
-
- public HornetQChannelBuffer copy(final int index, final int length)
- {
- if (index < 0 || length < 0 || index + length > array.length)
- {
- throw new IndexOutOfBoundsException();
- }
-
- byte[] copiedArray = new byte[length];
- System.arraycopy(array, index, copiedArray, 0, length);
- return new HornetQHeapChannelBuffer(copiedArray);
- }
-
- public ByteBuffer toByteBuffer(final int index, final int length)
- {
- return ByteBuffer.wrap(array, index, length);
- }
-
- public String toString(final int index, final int length, final String charsetName)
- {
- try
- {
- return new String(array, index, length, charsetName);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new UnsupportedCharsetException(charsetName);
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#array()
- */
- public byte[] array()
- {
- return array;
- }
-
- public HornetQBuffer copy()
- {
- return new HornetQHeapChannelBuffer(array.clone());
- }
-
- public HornetQBuffer slice(int index, int length)
- {
- //FIXME - this is currently very inefficient since we just copy the underlying
array
- //We should really get rid of these versions of the Netty classes and just use the
real
- //Netty classes, since these don't have all the functionality and fixes.
- //However this will introduce a dependency on Netty on core
-
- byte[] copied = new byte[length];
-
- System.arraycopy(array, index, copied, 0, length);
-
- return new HornetQHeapChannelBuffer(copied);
- }
-
-}
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,327 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.buffers;
-
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.utils.SimpleString;
-
-/**
- * A ResetLimitWrappedHornetQBuffer
- *
- * @author Tim Fox
- *
- */
-public class ResetLimitWrappedHornetQBuffer implements HornetQBuffer
-{
- private static final Logger log =
Logger.getLogger(ResetLimitWrappedHornetQBuffer.class);
-
- private final int limit;
-
- private HornetQBuffer buffer;
-
- public ResetLimitWrappedHornetQBuffer(final int limit, final HornetQBuffer buffer)
- {
- this.limit = limit;
-
- this.buffer = buffer;
-
- this.resetReaderIndex();
- }
-
- public void setBuffer(HornetQBuffer buffer)
- {
- this.buffer = buffer;
- }
-
- public byte[] array()
- {
- return buffer.array();
- }
-
- public int capacity()
- {
- return buffer.capacity();
- }
-
- public void clear()
- {
- buffer.clear();
-
- buffer.setIndex(limit, limit);
- }
-
- public HornetQBuffer copy()
- {
- return buffer.copy();
- }
-
- public Object getUnderlyingBuffer()
- {
- return buffer.getUnderlyingBuffer();
- }
-
- public boolean readable()
- {
- return buffer.readable();
- }
-
- public int readableBytes()
- {
- return buffer.readableBytes();
- }
-
- public boolean readBoolean()
- {
- return buffer.readBoolean();
- }
-
- public byte readByte()
- {
- return buffer.readByte();
- }
-
- public void readBytes(byte[] bytes, int offset, int length)
- {
- buffer.readBytes(bytes, offset, length);
- }
-
- public void readBytes(byte[] bytes)
- {
- buffer.readBytes(bytes);
- }
-
- public char readChar()
- {
- return buffer.readChar();
- }
-
- public double readDouble()
- {
- return buffer.readDouble();
- }
-
- public int readerIndex()
- {
- return buffer.readerIndex();
- }
-
- public void readerIndex(int readerIndex)
- {
- if (readerIndex < limit)
- {
- readerIndex = limit;
- }
-
- buffer.readerIndex(readerIndex);
- }
-
- public float readFloat()
- {
- return buffer.readFloat();
- }
-
- public int readInt()
- {
- return buffer.readInt();
- }
-
- public int readInt(int pos)
- {
- return buffer.readInt(pos);
- }
-
- public long readLong()
- {
- return buffer.readLong();
- }
-
- public SimpleString readNullableSimpleString()
- {
- return buffer.readNullableSimpleString();
- }
-
- public String readNullableString()
- {
- return buffer.readNullableString();
- }
-
- public short readShort()
- {
- return buffer.readShort();
- }
-
- public SimpleString readSimpleString()
- {
- return buffer.readSimpleString();
- }
-
- public String readString()
- {
- return buffer.readString();
- }
-
- public short readUnsignedByte()
- {
- return buffer.readUnsignedByte();
- }
-
- public int readUnsignedShort()
- {
- return buffer.readUnsignedShort();
- }
-
- public String readUTF() throws Exception
- {
- return buffer.readUTF();
- }
-
- public void resetReaderIndex()
- {
- buffer.readerIndex(limit);
- }
-
- public void resetWriterIndex()
- {
- buffer.writerIndex(limit);
- }
-
- public void setIndex(int readerIndex, int writerIndex)
- {
- if (readerIndex < limit)
- {
- readerIndex = limit;
- }
- if (writerIndex < limit)
- {
- writerIndex = limit;
- }
- buffer.setIndex(readerIndex, writerIndex);
- }
-
- public void setInt(int pos, int val)
- {
- buffer.setInt(pos, val);
- }
-
- public HornetQBuffer slice(int index, int length)
- {
- return buffer.slice(index, length);
- }
-
- public boolean writable()
- {
- return buffer.writable();
- }
-
- public int writableBytes()
- {
- return buffer.writableBytes();
- }
-
- public void writeBoolean(boolean val)
- {
- buffer.writeBoolean(val);
- }
-
- public void writeByte(byte val)
- {
- buffer.writeByte(val);
- }
-
- public void writeBytes(byte[] bytes, int offset, int length)
- {
- buffer.writeBytes(bytes, offset, length);
- }
-
- public void writeBytes(byte[] bytes)
- {
- buffer.writeBytes(bytes);
- }
-
- public void writeBytes(HornetQBuffer src, int srcIndex, int length)
- {
- buffer.writeBytes(src, srcIndex, length);
- }
-
- public void writeChar(char val)
- {
- buffer.writeChar(val);
- }
-
- public void writeDouble(double val)
- {
- buffer.writeDouble(val);
- }
-
- public void writeFloat(float val)
- {
- buffer.writeFloat(val);
- }
-
- public void writeInt(int val)
- {
- buffer.writeInt(val);
- }
-
- public void writeLong(long val)
- {
- buffer.writeLong(val);
- }
-
- public void writeNullableSimpleString(SimpleString val)
- {
- buffer.writeNullableSimpleString(val);
- }
-
- public void writeNullableString(String val)
- {
- buffer.writeNullableString(val);
- }
-
- public int writerIndex()
- {
- return buffer.writerIndex();
- }
-
- public void writerIndex(int writerIndex)
- {
- if (writerIndex < limit)
- {
- writerIndex = limit;
- }
- buffer.writerIndex(writerIndex);
- }
-
- public void writeShort(short val)
- {
- buffer.writeShort(val);
- }
-
- public void writeSimpleString(SimpleString val)
- {
- buffer.writeSimpleString(val);
- }
-
- public void writeString(String val)
- {
- buffer.writeString(val);
- }
-
- public void writeUTF(String utf) throws Exception
- {
- buffer.writeUTF(utf);
- }
-
-}
Copied:
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java
(from rev 8367,
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java)
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java
(rev 0)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -0,0 +1,573 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.buffers.impl;
+
+import java.nio.ByteBuffer;
+
+import org.hornetq.core.buffers.HornetQBuffer;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.utils.DataConstants;
+import org.hornetq.utils.SimpleString;
+import org.hornetq.utils.UTF8Util;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ *
+ * A ChannelBufferWrapper
+ *
+ * @author Tim Fox
+ *
+ *
+ */
+public class ChannelBufferWrapper implements HornetQBuffer
+{
+ private static final Logger log = Logger.getLogger(ChannelBufferWrapper.class);
+
+ protected ChannelBuffer buffer;
+
+ public ChannelBufferWrapper(final ChannelBuffer buffer)
+ {
+ this.buffer = buffer;
+ }
+
+ public boolean readBoolean()
+ {
+ return readByte() != 0;
+ }
+
+ public SimpleString readNullableSimpleString()
+ {
+ int b = readByte();
+ if (b == DataConstants.NULL)
+ {
+ return null;
+ }
+ else
+ {
+ return readSimpleString();
+ }
+ }
+
+ public String readNullableString()
+ {
+ int b = readByte();
+ if (b == DataConstants.NULL)
+ {
+ return null;
+ }
+ else
+ {
+ return readString();
+ }
+ }
+
+ public SimpleString readSimpleString()
+ {
+ int len = readInt();
+ byte[] data = new byte[len];
+ readBytes(data);
+ return new SimpleString(data);
+ }
+
+ public String readString()
+ {
+ int len = readInt();
+ char[] chars = new char[len];
+ for (int i = 0; i < len; i++)
+ {
+ chars[i] = (char)readShort();
+ }
+ return new String(chars);
+ }
+
+ public String readUTF() throws Exception
+ {
+ return UTF8Util.readUTF(this);
+ }
+
+ public void writeBoolean(final boolean val)
+ {
+ writeByte((byte)(val ? -1 : 0));
+ }
+
+ public void writeNullableSimpleString(final SimpleString val)
+ {
+ if (val == null)
+ {
+ writeByte(DataConstants.NULL);
+ }
+ else
+ {
+ writeByte(DataConstants.NOT_NULL);
+ writeSimpleString(val);
+ }
+ }
+
+ public void writeNullableString(final String val)
+ {
+ if (val == null)
+ {
+ writeByte(DataConstants.NULL);
+ }
+ else
+ {
+ writeByte(DataConstants.NOT_NULL);
+ writeString(val);
+ }
+ }
+
+ public void writeSimpleString(final SimpleString val)
+ {
+ byte[] data = val.getData();
+ writeInt(data.length);
+ writeBytes(data);
+ }
+
+ public void writeString(final String val)
+ {
+ writeInt(val.length());
+ for (int i = 0; i < val.length(); i++)
+ {
+ writeShort((short)val.charAt(i));
+ }
+ }
+
+ public void writeUTF(final String utf) throws Exception
+ {
+ UTF8Util.saveUTF(this, utf);
+ }
+
+
+ public int capacity()
+ {
+ return buffer.capacity();
+ }
+
+
+ public ChannelBuffer channelBuffer()
+ {
+ return buffer;
+ }
+
+ public void clear()
+ {
+ buffer.clear();
+ }
+
+ public HornetQBuffer copy()
+ {
+ return new ChannelBufferWrapper(buffer.copy());
+ }
+
+ public HornetQBuffer copy(int index, int length)
+ {
+ return new ChannelBufferWrapper(buffer.copy(index, length));
+ }
+
+ public void discardReadBytes()
+ {
+ buffer.discardReadBytes();
+ }
+
+ public HornetQBuffer duplicate()
+ {
+ return new ChannelBufferWrapper(buffer.duplicate());
+ }
+
+ public byte getByte(int index)
+ {
+ return buffer.getByte(index);
+ }
+
+ public void getBytes(int index, byte[] dst, int dstIndex, int length)
+ {
+ buffer.getBytes(index, dst, dstIndex, length);
+ }
+
+ public void getBytes(int index, byte[] dst)
+ {
+ buffer.getBytes(index, dst);
+ }
+
+ public void getBytes(int index, ByteBuffer dst)
+ {
+ buffer.getBytes(index, dst);
+ }
+
+ public void getBytes(int index, HornetQBuffer dst, int dstIndex, int length)
+ {
+ buffer.getBytes(index, dst.channelBuffer(), dstIndex, length);
+ }
+
+ public void getBytes(int index, HornetQBuffer dst, int length)
+ {
+ buffer.getBytes(index, dst.channelBuffer(), length);
+ }
+
+ public void getBytes(int index, HornetQBuffer dst)
+ {
+ buffer.getBytes(index, dst.channelBuffer());
+ }
+
+ public char getChar(int index)
+ {
+ return (char)buffer.getShort(index);
+ }
+
+ public double getDouble(int index)
+ {
+ return Double.longBitsToDouble(buffer.getLong(index));
+ }
+
+ public float getFloat(int index)
+ {
+ return Float.intBitsToFloat(buffer.getInt(index));
+ }
+
+ public int getInt(int index)
+ {
+ return buffer.getInt(index);
+ }
+
+ public long getLong(int index)
+ {
+ return buffer.getLong(index);
+ }
+
+ public short getShort(int index)
+ {
+ return buffer.getShort(index);
+ }
+
+ public short getUnsignedByte(int index)
+ {
+ return buffer.getUnsignedByte(index);
+ }
+
+ public long getUnsignedInt(int index)
+ {
+ return buffer.getUnsignedInt(index);
+ }
+
+ public int getUnsignedShort(int index)
+ {
+ return buffer.getUnsignedShort(index);
+ }
+
+ public void markReaderIndex()
+ {
+ buffer.markReaderIndex();
+ }
+
+ public void markWriterIndex()
+ {
+ buffer.markWriterIndex();
+ }
+
+ public boolean readable()
+ {
+ return buffer.readable();
+ }
+
+ public int readableBytes()
+ {
+ return buffer.readableBytes();
+ }
+
+ public byte readByte()
+ {
+ return buffer.readByte();
+ }
+
+ public void readBytes(byte[] dst, int dstIndex, int length)
+ {
+ buffer.readBytes(dst, dstIndex, length);
+ }
+
+ public void readBytes(byte[] dst)
+ {
+ buffer.readBytes(dst);
+ }
+
+ public void readBytes(ByteBuffer dst)
+ {
+ buffer.readBytes(dst);
+ }
+
+ public void readBytes(HornetQBuffer dst, int dstIndex, int length)
+ {
+ buffer.readBytes(dst.channelBuffer(), dstIndex, length);
+ }
+
+ public void readBytes(HornetQBuffer dst, int length)
+ {
+ buffer.readBytes(dst.channelBuffer(), length);
+ }
+
+ public void readBytes(HornetQBuffer dst)
+ {
+ buffer.readBytes(dst.channelBuffer());
+ }
+
+ public HornetQBuffer readBytes(int length)
+ {
+ return new ChannelBufferWrapper(buffer.readBytes(length));
+ }
+
+ public char readChar()
+ {
+ return (char)buffer.readShort();
+ }
+
+ public double readDouble()
+ {
+ return Double.longBitsToDouble(buffer.readLong());
+ }
+
+ public int readerIndex()
+ {
+ return buffer.readerIndex();
+ }
+
+ public void readerIndex(int readerIndex)
+ {
+ buffer.readerIndex(readerIndex);
+ }
+
+ public float readFloat()
+ {
+ return Float.intBitsToFloat(buffer.readInt());
+ }
+
+ public int readInt()
+ {
+ return buffer.readInt();
+ }
+
+ public long readLong()
+ {
+ return buffer.readLong();
+ }
+
+ public short readShort()
+ {
+ return buffer.readShort();
+ }
+
+ public HornetQBuffer readSlice(int length)
+ {
+ return new ChannelBufferWrapper(buffer.readSlice(length));
+ }
+
+ public short readUnsignedByte()
+ {
+ return buffer.readUnsignedByte();
+ }
+
+ public long readUnsignedInt()
+ {
+ return buffer.readUnsignedInt();
+ }
+
+ public int readUnsignedShort()
+ {
+ return buffer.readUnsignedShort();
+ }
+
+ public void resetReaderIndex()
+ {
+ buffer.resetReaderIndex();
+ }
+
+ public void resetWriterIndex()
+ {
+ buffer.resetWriterIndex();
+ }
+
+ public void setByte(int index, byte value)
+ {
+ buffer.setByte(index, value);
+ }
+
+ public void setBytes(int index, byte[] src, int srcIndex, int length)
+ {
+ buffer.setBytes(index, src, srcIndex, length);
+ }
+
+ public void setBytes(int index, byte[] src)
+ {
+ buffer.setBytes(index, src);
+ }
+
+ public void setBytes(int index, ByteBuffer src)
+ {
+ buffer.setBytes(index, src);
+ }
+
+ public void setBytes(int index, HornetQBuffer src, int srcIndex, int length)
+ {
+ buffer.setBytes(index, src.channelBuffer(), srcIndex, length);
+ }
+
+ public void setBytes(int index, HornetQBuffer src, int length)
+ {
+ buffer.setBytes(index, src.channelBuffer(), length);
+ }
+
+ public void setBytes(int index, HornetQBuffer src)
+ {
+ buffer.setBytes(index, src.channelBuffer());
+ }
+
+ public void setChar(int index, char value)
+ {
+ buffer.setShort(index, (short)value);
+ }
+
+ public void setDouble(int index, double value)
+ {
+ buffer.setLong(index, Double.doubleToLongBits(value));
+ }
+
+ public void setFloat(int index, float value)
+ {
+ buffer.setInt(index, Float.floatToIntBits(value));
+ }
+
+ public void setIndex(int readerIndex, int writerIndex)
+ {
+ buffer.setIndex(readerIndex, writerIndex);
+ }
+
+ public void setInt(int index, int value)
+ {
+ buffer.setInt(index, value);
+ }
+
+ public void setLong(int index, long value)
+ {
+ buffer.setLong(index, value);
+ }
+
+ public void setShort(int index, short value)
+ {
+ buffer.setShort(index, value);
+ }
+
+ public void skipBytes(int length)
+ {
+ buffer.skipBytes(length);
+ }
+
+ public HornetQBuffer slice()
+ {
+ return new ChannelBufferWrapper(buffer.slice());
+ }
+
+ public HornetQBuffer slice(int index, int length)
+ {
+ return new ChannelBufferWrapper(buffer.slice(index, length));
+ }
+
+ public ByteBuffer toByteBuffer()
+ {
+ return buffer.toByteBuffer();
+ }
+
+ public ByteBuffer toByteBuffer(int index, int length)
+ {
+ return buffer.toByteBuffer(index, length);
+ }
+
+ public boolean writable()
+ {
+ return buffer.writable();
+ }
+
+ public int writableBytes()
+ {
+ return buffer.writableBytes();
+ }
+
+ public void writeByte(byte value)
+ {
+ buffer.writeByte(value);
+ }
+
+ public void writeBytes(byte[] src, int srcIndex, int length)
+ {
+ buffer.writeBytes(src, srcIndex, length);
+ }
+
+ public void writeBytes(byte[] src)
+ {
+ buffer.writeBytes(src);
+ }
+
+ public void writeBytes(ByteBuffer src)
+ {
+ buffer.writeBytes(src);
+ }
+
+ public void writeBytes(HornetQBuffer src, int srcIndex, int length)
+ {
+ buffer.writeBytes(src.channelBuffer(), srcIndex, length);
+ }
+
+ public void writeBytes(HornetQBuffer src, int length)
+ {
+ buffer.writeBytes(src.channelBuffer(), length);
+ }
+
+ public void writeChar(char chr)
+ {
+ buffer.writeShort((short)chr);
+ }
+
+ public void writeDouble(double value)
+ {
+ buffer.writeLong(Double.doubleToLongBits(value));
+ }
+
+ public void writeFloat(float value)
+ {
+ buffer.writeInt(Float.floatToIntBits(value));
+ }
+
+ public void writeInt(int value)
+ {
+ buffer.writeInt(value);
+ }
+
+ public void writeLong(long value)
+ {
+ buffer.writeLong(value);
+ }
+
+ public int writerIndex()
+ {
+ return buffer.writerIndex();
+ }
+
+ public void writerIndex(int writerIndex)
+ {
+ buffer.writerIndex(writerIndex);
+ }
+
+ public void writeShort(short value)
+ {
+ buffer.writeShort(value);
+ }
+
+}
Copied:
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ResetLimitWrappedHornetQBuffer.java
(from rev 8368,
branches/20-optimisation/src/main/org/hornetq/core/buffers/ResetLimitWrappedHornetQBuffer.java)
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ResetLimitWrappedHornetQBuffer.java
(rev 0)
+++
branches/20-optimisation/src/main/org/hornetq/core/buffers/impl/ResetLimitWrappedHornetQBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.buffers.impl;
+
+import org.hornetq.core.buffers.HornetQBuffer;
+import org.hornetq.core.logging.Logger;
+
+/**
+ * A ResetLimitWrappedHornetQBuffer
+ *
+ * @author Tim Fox
+ *
+ */
+public class ResetLimitWrappedHornetQBuffer extends ChannelBufferWrapper
+{
+ private static final Logger log =
Logger.getLogger(ResetLimitWrappedHornetQBuffer.class);
+
+ private final int limit;
+
+ public ResetLimitWrappedHornetQBuffer(final int limit, final HornetQBuffer buffer)
+ {
+ super(buffer.channelBuffer());
+
+ this.limit = limit;
+
+ if (writerIndex() < limit)
+ {
+ writerIndex(limit);
+ }
+
+ readerIndex(limit);
+ }
+
+ public void setBuffer(HornetQBuffer buffer)
+ {
+ this.buffer = buffer.channelBuffer();
+ }
+
+ public void clear()
+ {
+ buffer.clear();
+
+ buffer.setIndex(limit, limit);
+ }
+
+ public void readerIndex(int readerIndex)
+ {
+ if (readerIndex < limit)
+ {
+ readerIndex = limit;
+ }
+
+ buffer.readerIndex(readerIndex);
+ }
+
+ public void resetReaderIndex()
+ {
+ buffer.readerIndex(limit);
+ }
+
+ public void resetWriterIndex()
+ {
+ buffer.writerIndex(limit);
+ }
+
+ public void setIndex(int readerIndex, int writerIndex)
+ {
+ if (readerIndex < limit)
+ {
+ readerIndex = limit;
+ }
+ if (writerIndex < limit)
+ {
+ writerIndex = limit;
+ }
+ buffer.setIndex(readerIndex, writerIndex);
+ }
+
+ public void writerIndex(int writerIndex)
+ {
+ if (writerIndex < limit)
+ {
+ writerIndex = limit;
+ }
+ buffer.writerIndex(writerIndex);
+ }
+}
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/ClientMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -34,9 +34,12 @@
void setDeliveryCount(int deliveryCount);
void acknowledge() throws HornetQException;
-
- //FIXME - the following are only used for large messages - they should be put
somewhere else:
+ int getBodySize();
+
+ //FIXME - these are only used for large messages - they should be moved elsewhere
+
+
/** Sets the OutputStream that will receive the content of a message received in a non
blocking way
* @throws HornetQException */
void setOutputStream(OutputStream out) throws HornetQException;
@@ -53,6 +56,5 @@
boolean waitOutputStreamCompletion(long timeMilliseconds) throws HornetQException;
void setBodyInputStream(InputStream bodyInputStream);
-
- int getBodySize();
+
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/client/ClientSession.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/ClientSession.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/ClientSession.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,11 +15,11 @@
import javax.transaction.xa.XAResource;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.FailureListener;
import org.hornetq.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.SimpleString;
/*
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/LargeMessageBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/LargeMessageBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/LargeMessageBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,8 +15,8 @@
import java.io.OutputStream;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A LargeMessageBufferImpl
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -17,13 +17,13 @@
import java.io.InputStream;
import java.io.OutputStream;
-import org.hornetq.core.buffers.ResetLimitWrappedHornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
+import org.hornetq.core.buffers.impl.ResetLimitWrappedHornetQBuffer;
import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
@@ -68,11 +68,9 @@
final long expiration,
final long timestamp,
final byte priority,
- final HornetQBuffer buffer)
+ final int initialMessageBufferSize)
{
- super(type, durable, expiration, timestamp, priority, buffer);
-
- this.resetBuffer();
+ super(type, durable, expiration, timestamp, priority, initialMessageBufferSize);
}
public void onReceipt(final ClientConsumerInternal consumer)
@@ -174,7 +172,7 @@
{
try
{
- out.write(this.getWholeBuffer().array());
+ out.write(this.getWholeBuffer().toByteBuffer().array());
}
catch (IOException e)
{
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageInternal.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageInternal.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientMessageInternal.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.core.client.impl;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A ClientMessageInternal
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerCreditsImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -64,8 +64,6 @@
{
// credits += offset;
- // log.info("trying to acquire " + credits);
-
checkCredits(credits);
semaphore.acquire(credits);
@@ -73,8 +71,6 @@
public void receiveCredits(final int credits, final int offset)
{
- // log.info("receiving credits " + credits);
-
synchronized (this)
{
arriving -= credits;
@@ -120,8 +116,7 @@
}
if (toRequest != -1)
- {
- //log.info("sending request for credits " + toRequest);
+ {
requestCredits(toRequest);
}
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientProducerImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.io.InputStream;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
@@ -28,7 +29,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionSendContinuationMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionSendLargeMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionSendMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TokenBucketLimiter;
import org.hornetq.utils.UUIDGenerator;
@@ -308,11 +308,11 @@
msg.getWholeBuffer().readerIndex(0);
}
- HornetQBuffer headerBuffer = HornetQChannelBuffers.buffer(headerSize);
+ HornetQBuffer headerBuffer = HornetQChannelBuffers.fixedBuffer(headerSize);
msg.encodeHeadersAndProperties(headerBuffer);
- SessionSendLargeMessage initialChunk = new
SessionSendLargeMessage(headerBuffer.array());
+ SessionSendLargeMessage initialChunk = new
SessionSendLargeMessage(headerBuffer.toByteBuffer().array());
channel.send(initialChunk);
@@ -359,7 +359,7 @@
final int chunkLength = Math.min((int)(bodySize - pos),
minLargeMessageSize);
- final HornetQBuffer bodyBuffer = HornetQChannelBuffers.buffer(chunkLength);
+ final HornetQBuffer bodyBuffer =
HornetQChannelBuffers.fixedBuffer(chunkLength);
context.encode(bodyBuffer, chunkLength);
@@ -367,7 +367,7 @@
lastChunk = pos >= bodySize;
- final SessionSendContinuationMessage chunk = new
SessionSendContinuationMessage(bodyBuffer.array(),
+ final SessionSendContinuationMessage chunk = new
SessionSendContinuationMessage(bodyBuffer.toByteBuffer().array(),
!lastChunk,
lastChunk && sendBlocking);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -26,6 +26,7 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientProducer;
@@ -74,7 +75,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXAStartMessage;
import org.hornetq.core.remoting.spi.Connection;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.ConcurrentHashSet;
import org.hornetq.utils.IDGenerator;
import org.hornetq.utils.SimpleIDGenerator;
@@ -518,9 +518,7 @@
final long timestamp,
final byte priority)
{
- HornetQBuffer body = remotingConnection.createBuffer(initialMessagePacketSize);
-
- return new ClientMessageImpl(type, durable, expiration, timestamp, priority,
body);
+ return new ClientMessageImpl(type, durable, expiration, timestamp, priority,
initialMessagePacketSize);
}
public ClientMessage createClientMessage(final byte type, final boolean durable)
@@ -690,7 +688,7 @@
if (consumer != null)
{
- ClientMessageInternal clMessage = message.getClientMessage();
+ ClientMessageInternal clMessage = (ClientMessageInternal)message.getMessage();
if (trace)
{
@@ -699,7 +697,7 @@
clMessage.setFlowControlSize(message.getPacketSize());
- consumer.handleMessage(message.getClientMessage());
+ consumer.handleMessage(clMessage);
}
}
@@ -948,7 +946,7 @@
{
SessionSendMessage ssm = (SessionSendMessage)packet;
- sendAckHandler.sendAcknowledged(ssm.getClientMessage());
+ sendAckHandler.sendAcknowledged(ssm.getMessage());
}
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/DelegatingSession.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/DelegatingSession.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/DelegatingSession.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -19,6 +19,7 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientProducer;
@@ -32,7 +33,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveLargeMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.ConcurrentHashSet;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/FailoverManagerImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/FailoverManagerImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/FailoverManagerImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -25,6 +25,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
import org.hornetq.core.client.SessionFailureListener;
@@ -47,7 +48,6 @@
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
import org.hornetq.core.remoting.spi.Connector;
import org.hornetq.core.remoting.spi.ConnectorFactory;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.version.Version;
import org.hornetq.utils.ConcurrentHashSet;
import org.hornetq.utils.ConfigurationHelper;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/client/impl/LargeMessageBufferImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -26,15 +26,15 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import org.hornetq.core.buffers.HornetQChannelBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.UTF8Util;
+import org.jboss.netty.buffer.ChannelBuffer;
/**
* This class aggregates several SessionReceiveContinuationMessages as it was being
handled by a single buffer.
@@ -44,7 +44,7 @@
*
*
*/
-public class LargeMessageBufferImpl implements HornetQChannelBuffer, LargeMessageBuffer
+public class LargeMessageBufferImpl implements LargeMessageBuffer
{
// Constants -----------------------------------------------------
@@ -359,7 +359,7 @@
/* (non-Javadoc)
* @see org.hornetq.core.buffers.ChannelBuffer#getBytes(int,
org.hornetq.core.buffers.ChannelBuffer, int, int)
*/
- public void getBytes(final int index, final HornetQChannelBuffer dst, final int
dstIndex, final int length)
+ public void getBytes(final int index, final HornetQBuffer dst, final int dstIndex,
final int length)
{
byte[] destBytes = new byte[length];
getBytes(index, destBytes);
@@ -369,7 +369,7 @@
/* (non-Javadoc)
* @see org.hornetq.core.buffers.ChannelBuffer#getBytes(int,
org.hornetq.core.buffers.ChannelBuffer, int, int)
*/
- public void getBytes(final long index, final HornetQChannelBuffer dst, final int
dstIndex, final int length)
+ public void getBytes(final long index, final HornetQBuffer dst, final int dstIndex,
final int length)
{
byte[] destBytes = new byte[length];
getBytes(index, destBytes);
@@ -520,7 +520,7 @@
/* (non-Javadoc)
* @see org.hornetq.core.buffers.ChannelBuffer#setBytes(int,
org.hornetq.core.buffers.ChannelBuffer, int, int)
*/
- public void setBytes(final int index, final HornetQChannelBuffer src, final int
srcIndex, final int length)
+ public void setBytes(final int index, final HornetQBuffer src, final int srcIndex,
final int length)
{
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
@@ -762,12 +762,12 @@
}
}
- public void getBytes(final int index, final HornetQChannelBuffer dst)
+ public void getBytes(final int index, final HornetQBuffer dst)
{
getBytes(index, dst, dst.writableBytes());
}
- public void getBytes(final int index, final HornetQChannelBuffer dst, final int
length)
+ public void getBytes(final int index, final HornetQBuffer dst, final int length)
{
if (length > dst.writableBytes())
{
@@ -782,12 +782,12 @@
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
- public void setBytes(final int index, final HornetQChannelBuffer src)
+ public void setBytes(final int index, final HornetQBuffer src)
{
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
- public void setBytes(final int index, final HornetQChannelBuffer src, final int
length)
+ public void setBytes(final int index, final HornetQBuffer src, final int length)
{
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
@@ -867,12 +867,12 @@
readBytes(dst, 0, dst.length);
}
- public void readBytes(final HornetQChannelBuffer dst)
+ public void readBytes(final HornetQBuffer dst)
{
readBytes(dst, dst.writableBytes());
}
- public void readBytes(final HornetQChannelBuffer dst, final int length)
+ public void readBytes(final HornetQBuffer dst, final int length)
{
if (length > dst.writableBytes())
{
@@ -882,7 +882,7 @@
dst.writerIndex(dst.writerIndex() + length);
}
- public void readBytes(final HornetQChannelBuffer dst, final int dstIndex, final int
length)
+ public void readBytes(final HornetQBuffer dst, final int dstIndex, final int length)
{
getBytes(readerIndex, dst, dstIndex, length);
readerIndex += length;
@@ -951,32 +951,22 @@
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
- public void writeBytes(final HornetQChannelBuffer src)
+ public void writeBytes(final HornetQBuffer src)
{
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
- public void writeBytes(final HornetQChannelBuffer src, final int length)
+ public void writeBytes(final HornetQBuffer src, final int length)
{
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
- public void writeBytes(final HornetQBuffer src, final int srcIndex, final int length)
- {
- throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
- }
-
- public void writeBytes(final HornetQChannelBuffer src, final int srcIndex, final int
length)
- {
- throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
- }
-
public void writeBytes(final ByteBuffer src)
{
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
- public void writeBytes(final InputStream in, final int length) throws IOException
+ public int writeBytes(final InputStream in, final int length) throws IOException
{
throw new IllegalAccessError(READ_ONLY_ERROR_MESSAGE);
}
@@ -1190,7 +1180,7 @@
/* (non-Javadoc)
* @see
org.hornetq.core.buffers.ChannelBuffer#compareTo(org.hornetq.core.buffers.ChannelBuffer)
*/
- public int compareTo(final HornetQChannelBuffer buffer)
+ public int compareTo(final HornetQBuffer buffer)
{
return -1;
}
@@ -1448,4 +1438,82 @@
}
+ public ChannelBuffer channelBuffer()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public HornetQBuffer copy(int index, int length)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public HornetQBuffer duplicate()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char getChar(int index)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public double getDouble(int index)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public float getFloat(int index)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public HornetQBuffer readBytes(int length)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public HornetQBuffer readSlice(int length)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setChar(int index, char value)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDouble(int index, double value)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setFloat(int index, float value)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public HornetQBuffer slice()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void writeBytes(HornetQBuffer src, int srcIndex, int length)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.cluster.DiscoveryEntry;
import org.hornetq.core.cluster.DiscoveryGroup;
@@ -32,7 +33,6 @@
import org.hornetq.core.management.Notification;
import org.hornetq.core.management.NotificationService;
import org.hornetq.core.management.NotificationType;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TypedProperties;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/config/TransportConfiguration.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/config/TransportConfiguration.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/config/TransportConfiguration.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -16,7 +16,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.UUIDGenerator;
/**
Modified: branches/20-optimisation/src/main/org/hornetq/core/journal/EncodingSupport.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/EncodingSupport.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/EncodingSupport.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.journal;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
*
Modified: branches/20-optimisation/src/main/org/hornetq/core/journal/SequentialFile.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/SequentialFile.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/SequentialFile.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,8 +15,8 @@
import java.nio.ByteBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.impl.TimedBuffer;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AIOSequentialFile.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -25,11 +25,11 @@
import org.hornetq.core.asyncio.AsynchronousFile;
import org.hornetq.core.asyncio.BufferCallback;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.IOCompletion;
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractJournalUpdateTask.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -18,12 +18,11 @@
import java.util.List;
import java.util.Set;
-import org.hornetq.core.buffers.HornetQChannelBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.ConcurrentHashSet;
import org.hornetq.utils.Pair;
@@ -57,7 +56,7 @@
protected int nextOrderingID;
- private HornetQChannelBuffer writingChannel;
+ private HornetQBuffer writingChannel;
private final Set<Long> recordsSnapshot = new ConcurrentHashSet<Long>();
@@ -98,7 +97,7 @@
{
controlFile.open(1);
- HornetQChannelBuffer renameBuffer = HornetQChannelBuffers.dynamicBuffer(1);
+ HornetQBuffer renameBuffer = HornetQChannelBuffers.dynamicBuffer(1);
renameBuffer.writeInt(-1);
renameBuffer.writeInt(-1);
@@ -155,13 +154,13 @@
JournalImpl.writeAddRecord(-1,
1,
(byte)0,
- new
JournalImpl.ByteArrayEncoding(filesToRename.array()),
- JournalImpl.SIZE_ADD_RECORD +
filesToRename.array().length,
+ new
JournalImpl.ByteArrayEncoding(filesToRename.toByteBuffer().array()),
+ JournalImpl.SIZE_ADD_RECORD +
filesToRename.toByteBuffer().array().length,
renameBuffer);
ByteBuffer writeBuffer = fileFactory.newBuffer(renameBuffer.writerIndex());
- writeBuffer.put(renameBuffer.array(), 0, renameBuffer.writerIndex());
+ writeBuffer.put(renameBuffer.toByteBuffer().array(), 0,
renameBuffer.writerIndex());
writeBuffer.rewind();
@@ -226,7 +225,7 @@
/**
* @return the writingChannel
*/
- protected HornetQChannelBuffer getWritingChannel()
+ protected HornetQBuffer getWritingChannel()
{
return writingChannel;
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/AbstractSequentialFile.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -18,11 +18,11 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.IOCompletion;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A AbstractSequentialFile
@@ -163,12 +163,12 @@
{
if (timedBuffer != null)
{
- timedBuffer.addBytes(bytes.array(), sync, callback);
+ timedBuffer.addBytes(bytes.toByteBuffer().array(), sync, callback);
}
else
{
ByteBuffer buffer = factory.newBuffer(bytes.capacity());
- buffer.put(bytes.array());
+ buffer.put(bytes.toByteBuffer().array());
buffer.rewind();
writeDirect(buffer, sync, callback);
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalCompactor.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalCompactor.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalCompactor.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,7 +21,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import org.hornetq.core.buffers.HornetQChannelBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.RecordInfo;
import org.hornetq.core.journal.SequentialFile;
@@ -83,7 +83,7 @@
}
else
{
- HornetQChannelBuffer input =
HornetQChannelBuffers.wrappedBuffer(records.get(0).data);
+ HornetQBuffer input =
HornetQChannelBuffers.wrappedBuffer(records.get(0).data);
int numberDataFiles = input.readInt();
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -41,7 +41,7 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.hornetq.core.buffers.HornetQChannelBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.EncodingSupport;
import org.hornetq.core.journal.IOCompletion;
@@ -54,7 +54,6 @@
import org.hornetq.core.journal.TestableJournal;
import org.hornetq.core.journal.TransactionFailureCallback;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.Pair;
import org.hornetq.utils.concurrent.LinkedBlockingDeque;
@@ -322,7 +321,7 @@
final EncodingSupport transactionData,
final int size,
final int numberOfRecords,
- final HornetQChannelBuffer bb) throws Exception
+ final HornetQBuffer bb) throws Exception
{
bb.writeByte(recordType);
bb.writeInt(fileID); // skip ID part
@@ -356,7 +355,7 @@
final byte recordType,
final EncodingSupport record,
final int size,
- final HornetQChannelBuffer bb)
+ final HornetQBuffer bb)
{
bb.writeByte(UPDATE_RECORD_TX);
bb.writeInt(fileID);
@@ -372,7 +371,7 @@
* @param txID
* @param bb
*/
- public static void writeRollback(final int fileID, final long txID,
HornetQChannelBuffer bb)
+ public static void writeRollback(final int fileID, final long txID, HornetQBuffer bb)
{
bb.writeByte(ROLLBACK_RECORD);
bb.writeInt(fileID);
@@ -392,7 +391,7 @@
final byte recordType,
final EncodingSupport record,
final int size,
- final HornetQChannelBuffer bb)
+ final HornetQBuffer bb)
{
bb.writeByte(UPDATE_RECORD);
bb.writeInt(fileId);
@@ -415,7 +414,7 @@
final byte recordType,
final EncodingSupport record,
final int size,
- final HornetQChannelBuffer bb)
+ final HornetQBuffer bb)
{
bb.writeByte(ADD_RECORD);
bb.writeInt(fileId);
@@ -431,7 +430,7 @@
* @param size
* @param bb
*/
- public static void writeDeleteRecord(final int fileId, final long id, int size,
HornetQChannelBuffer bb)
+ public static void writeDeleteRecord(final int fileId, final long id, int size,
HornetQBuffer bb)
{
bb.writeByte(DELETE_RECORD);
bb.writeInt(fileId);
@@ -451,7 +450,7 @@
final long id,
final EncodingSupport record,
final int size,
- final HornetQChannelBuffer bb)
+ final HornetQBuffer bb)
{
bb.writeByte(DELETE_RECORD_TX);
bb.writeInt(fileID);
@@ -480,7 +479,7 @@
final byte recordType,
final EncodingSupport record,
final int size,
- final HornetQChannelBuffer bb)
+ final HornetQBuffer bb)
{
bb.writeByte(ADD_RECORD_TX);
bb.writeInt(fileID);
@@ -858,7 +857,7 @@
{
int size = SIZE_ADD_RECORD + record.getEncodeSize();
- HornetQChannelBuffer bb = newBuffer(size);
+ HornetQBuffer bb = newBuffer(size);
writeAddRecord(-1, id, recordType, record, size, bb); // fileID will be filled
later
@@ -918,7 +917,7 @@
int size = SIZE_UPDATE_RECORD + record.getEncodeSize();
- HornetQChannelBuffer bb = newBuffer(size);
+ HornetQBuffer bb = newBuffer(size);
writeUpdateRecord(-1, id, recordType, record, size, bb);
@@ -982,7 +981,7 @@
int size = SIZE_DELETE_RECORD;
- HornetQChannelBuffer bb = newBuffer(size);
+ HornetQBuffer bb = newBuffer(size);
writeDeleteRecord(-1, id, size, bb);
@@ -1044,7 +1043,7 @@
int size = SIZE_ADD_RECORD_TX + record.getEncodeSize();
- HornetQChannelBuffer bb = newBuffer(size);
+ HornetQBuffer bb = newBuffer(size);
writeAddRecordTX(-1, txID, id, recordType, record, size, bb);
@@ -1093,7 +1092,7 @@
int size = SIZE_UPDATE_RECORD_TX + record.getEncodeSize();
- HornetQChannelBuffer bb = newBuffer(size);
+ HornetQBuffer bb = newBuffer(size);
writeUpdateRecordTX(-1, txID, id, recordType, record, size, bb);
@@ -1135,7 +1134,7 @@
{
int size = SIZE_DELETE_RECORD_TX + record.getEncodeSize();
- HornetQChannelBuffer bb = newBuffer(size);
+ HornetQBuffer bb = newBuffer(size);
writeDeleteRecordTransactional(-1, txID, id, record, size, bb);
@@ -1205,7 +1204,7 @@
{
int size = SIZE_COMPLETE_TRANSACTION_RECORD + transactionData.getEncodeSize() +
DataConstants.SIZE_INT;
- HornetQChannelBuffer bb = newBuffer(size);
+ HornetQBuffer bb = newBuffer(size);
writeTransaction(-1, PREPARE_RECORD, txID, transactionData, size, -1, bb);
@@ -1267,7 +1266,7 @@
throw new IllegalStateException("Cannot find tx with id " + txID);
}
- HornetQChannelBuffer bb = newBuffer(SIZE_COMPLETE_TRANSACTION_RECORD);
+ HornetQBuffer bb = newBuffer(SIZE_COMPLETE_TRANSACTION_RECORD);
writeTransaction(-1,
COMMIT_RECORD,
@@ -1322,7 +1321,7 @@
throw new IllegalStateException("Cannot find tx with id " + txID);
}
- HornetQChannelBuffer bb = newBuffer(SIZE_ROLLBACK_RECORD);
+ HornetQBuffer bb = newBuffer(SIZE_ROLLBACK_RECORD);
writeRollback(-1, txID, bb);
@@ -3330,9 +3329,9 @@
}
}
- private HornetQChannelBuffer newBuffer(final int size)
+ private HornetQBuffer newBuffer(final int size)
{
- return HornetQChannelBuffers.buffer(size);
+ return HornetQChannelBuffers.fixedBuffer(size);
}
// Inner classes
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalTransaction.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalTransaction.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/JournalTransaction.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,8 +21,8 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,10 +21,10 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.IOCompletion;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.VariableLatch;
/**
@@ -104,7 +104,7 @@
}
// Setting the interval for nano-sleeps
- buffer = HornetQChannelBuffers.buffer(bufferSize);
+ buffer = HornetQChannelBuffers.fixedBuffer(bufferSize);
buffer.clear();
bufferLimit = 0;
@@ -280,7 +280,7 @@
// Putting a byteArray on a native buffer is much faster, since it will do in a
single native call.
// Using directBuffer.put(buffer) would make several append calls for each byte
- directBuffer.put(buffer.array(), 0, pos);
+ directBuffer.put(buffer.toByteBuffer().array(), 0, pos);
bufferObserver.flushBuffer(directBuffer, pendingSync, callbacks);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -28,7 +28,6 @@
import javax.management.ObjectName;
import javax.management.StandardMBean;
-import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.management.impl.ManagementHelper;
import org.hornetq.core.cluster.DiscoveryGroup;
import org.hornetq.core.config.Configuration;
@@ -411,7 +410,7 @@
public ServerMessage handleMessage(final ServerMessage message) throws Exception
{
// a reply message is sent with the result stored in the message body.
- ServerMessage reply = new ServerMessageImpl(storageManager.generateUniqueID(),
HornetQChannelBuffers.dynamicBuffer(1500));
+ ServerMessage reply = new ServerMessageImpl(storageManager.generateUniqueID(),
512);
String resourceName =
message.getStringProperty(ManagementHelper.HDR_RESOURCE_NAME);
if (log.isDebugEnabled())
@@ -699,8 +698,9 @@
return;
}
- ServerMessage notificationMessage = new
ServerMessageImpl(storageManager.generateUniqueID(),
-
HornetQChannelBuffers.dynamicBuffer(1500));
+ long messageID = storageManager.generateUniqueID();
+
+ ServerMessage notificationMessage = new ServerMessageImpl(messageID,
512);
// Notification messages are always durable so the user can choose whether
to add a durable queue to
// consume
Modified: branches/20-optimisation/src/main/org/hornetq/core/message/BodyEncoder.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/message/BodyEncoder.java 2009-11-23
21:22:09 UTC (rev 8386)
+++ branches/20-optimisation/src/main/org/hornetq/core/message/BodyEncoder.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -14,8 +14,8 @@
package org.hornetq.core.message;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import java.nio.ByteBuffer;
Modified: branches/20-optimisation/src/main/org/hornetq/core/message/Message.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/message/Message.java 2009-11-23
21:22:09 UTC (rev 8386)
+++ branches/20-optimisation/src/main/org/hornetq/core/message/Message.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -14,10 +14,12 @@
package org.hornetq.core.message;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Map;
import java.util.Set;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
+import org.hornetq.core.exception.HornetQException;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TypedProperties;
@@ -67,7 +69,16 @@
HornetQBuffer getBodyBuffer();
-
+ void decodeFromBuffer(HornetQBuffer buffer);
+
+ HornetQBuffer encodeToBuffer();
+
+ int getEndOfMessagePosition();
+
+ int getEndOfBodyPosition();
+
+ void forceCopy();
+
// Properties
// ------------------------------------------------------------------
@@ -171,17 +182,17 @@
Map<String, Object> toMap();
+
// FIXME - All this stuff is only necessary here for large messages - it should be
refactored to be put in a better place
-
-
+
int getHeadersAndPropertiesEncodeSize();
HornetQBuffer getWholeBuffer();
- void setBuffer(HornetQBuffer buffer);
-
void encodeHeadersAndProperties(HornetQBuffer buffer);
+ void decodeHeadersAndProperties(HornetQBuffer buffer);
+
long getLargeBodySize();
BodyEncoder getBodyEncoder();
@@ -190,12 +201,5 @@
InputStream getBodyInputStream();
- // Sending stuff
-
- boolean isEncodedToBuffer();
- void decodeFromWire(HornetQBuffer buffer);
-
- void decodeHeadersAndProperties(HornetQBuffer buffer);
-
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -22,8 +22,9 @@
import java.util.Map;
import java.util.Set;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.buffers.ResetLimitWrappedHornetQBuffer;
+import org.hornetq.core.buffers.impl.ResetLimitWrappedHornetQBuffer;
import org.hornetq.core.client.LargeMessageBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
@@ -31,7 +32,6 @@
import org.hornetq.core.message.Message;
import org.hornetq.core.message.PropertyConversionException;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TypedProperties;
@@ -73,7 +73,7 @@
public static final SimpleString HDR_FROM_CLUSTER = new
SimpleString("_HQ_FROM_CLUSTER");
public static final SimpleString HDR_LAST_VALUE_NAME = new
SimpleString("_HQ_LVQ_NAME");
-
+
// Attributes ----------------------------------------------------
protected long messageID;
@@ -96,10 +96,7 @@
protected HornetQBuffer buffer;
private int encodeSize;
-
- //This means does the buffer contain an accurate encoding of the message?
- protected boolean encodedToBuffer;
-
+
// Constructors --------------------------------------------------
protected MessageImpl()
@@ -121,7 +118,7 @@
final long expiration,
final long timestamp,
final byte priority,
- final HornetQBuffer buffer)
+ final int initialMessageBufferSize)
{
this();
this.type = type;
@@ -129,14 +126,29 @@
this.expiration = expiration;
this.timestamp = timestamp;
this.priority = priority;
- this.buffer = buffer;
+ createBody(initialMessageBufferSize);
}
-
- protected MessageImpl(final long messageID)
+
+ protected MessageImpl(final long messageID, final int initialMessageBufferSize)
{
this();
this.messageID = messageID;
+ createBody(initialMessageBufferSize);
}
+
+ private void createBody(final int initialMessageBufferSize)
+ {
+ buffer = HornetQChannelBuffers.dynamicBuffer(initialMessageBufferSize);
+
+ //There's a bug in netty which means a dynamic buffer won't resize until
you write a byte
+ buffer.writeByte((byte)0);
+
+ int limit = PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT;
+
+ buffer.setIndex(limit, limit);
+
+ endOfBodyPosition = -1;
+ }
// Message implementation ----------------------------------------
@@ -146,7 +158,7 @@
}
public void encodeHeadersAndProperties(final HornetQBuffer buffer)
- {
+ {
buffer.writeLong(messageID);
buffer.writeSimpleString(destination);
buffer.writeByte(type);
@@ -158,20 +170,6 @@
encodeSize = buffer.writerIndex() - PacketImpl.PACKET_HEADERS_SIZE;
}
- public void decodeFromWire(final HornetQBuffer buffer)
- {
- decodeHeadersAndProperties(buffer);
-
- this.buffer = buffer;
-
- this.encodedToBuffer = true;
- }
-
- public boolean isEncodedToBuffer()
- {
- return this.encodedToBuffer;
- }
-
public void decodeHeadersAndProperties(final HornetQBuffer buffer)
{
messageID = buffer.readLong();
@@ -590,43 +588,13 @@
{
return new DecodingContext();
}
-
- private ResetLimitWrappedHornetQBuffer bodyBuffer;
-
- public HornetQBuffer getBodyBuffer()
- {
- if (bodyBuffer == null)
- {
- if (buffer instanceof LargeMessageBuffer == false)
- {
- bodyBuffer = new
ResetLimitWrappedHornetQBuffer(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT,
buffer);
- }
- else
- {
- return buffer;
- }
- }
- return bodyBuffer;
- }
-
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
- protected void resetBuffer()
- {
- // There is a bug in Netty which requires us to initially write a byte
- if (buffer.capacity() == 0)
- {
- buffer.writeByte((byte)0);
- }
-
- buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT);
- }
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
@@ -673,5 +641,139 @@
/* Priority */SIZE_BYTE +
/* PropertySize and Properties */properties.getEncodeSize();
}
+
+
+
+
+
+ private ResetLimitWrappedHornetQBuffer bodyBuffer;
+ public HornetQBuffer getBodyBuffer()
+ {
+ if (bodyBuffer == null)
+ {
+ if (buffer instanceof LargeMessageBuffer == false)
+ {
+ bodyBuffer = new
ResetLimitWrappedHornetQBuffer(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT,
buffer);
+ }
+ else
+ {
+ return buffer;
+ }
+ }
+
+ return bodyBuffer;
+ }
+
+
+
+ protected boolean bufferValid;
+
+ private int endOfBodyPosition;
+
+ private int endOfMessagePosition;
+
+ public void forceCopy()
+ {
+ // Must copy buffer before sending it
+ int wi = buffer.writerIndex();
+
+ this.buffer = buffer.copy(0, buffer.capacity());
+
+ this.buffer.setIndex(0, wi);
+ }
+
+ public int getEndOfMessagePosition()
+ {
+ return this.endOfMessagePosition;
+ }
+
+ public int getEndOfBodyPosition()
+ {
+ return this.endOfBodyPosition;
+ }
+
+ //Encode to journal or paging
+ public void encode(HornetQBuffer buff)
+ {
+ encodeToBuffer();
+
+ buff.writeBytes(buffer, PacketImpl.PACKET_HEADERS_SIZE, endOfMessagePosition -
PacketImpl.PACKET_HEADERS_SIZE);
+ }
+
+ //Decode from journal or paging
+ public void decode(HornetQBuffer buff)
+ {
+ int start = buff.readerIndex();
+
+ endOfBodyPosition = buff.readInt();
+
+ endOfMessagePosition = buff.getInt(endOfBodyPosition -
PacketImpl.PACKET_HEADERS_SIZE + start);
+
+ int endPos = endOfMessagePosition + start -
+ PacketImpl.PACKET_HEADERS_SIZE;
+
+ this.buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE);
+
+ buff.writeBytes(buffer, start, endPos - start);
+
+ decode();
+ }
+
+ public HornetQBuffer encodeToBuffer()
+ {
+ log.info("encoding msg to buffer, valid " + bufferValid);
+
+ if (!bufferValid)
+ {
+ if (endOfBodyPosition == -1)
+ {
+ //Means sending message for first time
+ endOfBodyPosition = buffer.writerIndex();
+
+ //write it
+ buffer.setInt(PacketImpl.PACKET_HEADERS_SIZE, endOfBodyPosition);
+
+ log.info("setting end of body pos as " + endOfBodyPosition);
+ }
+
+ // Position at end of body and skip past the message end position int
+ buffer.writerIndex(endOfBodyPosition + DataConstants.SIZE_INT);
+
+ encodeHeadersAndProperties(buffer);
+
+ // Write end of message position
+
+ this.endOfMessagePosition = buffer.writerIndex();
+
+ buffer.setInt(endOfBodyPosition, endOfMessagePosition);
+
+ this.bufferValid = true;
+ }
+
+ return buffer;
+ }
+
+ public void decode()
+ {
+ this.endOfBodyPosition = buffer.getInt(PacketImpl.PACKET_HEADERS_SIZE);
+
+ buffer.readerIndex(this.endOfBodyPosition + DataConstants.SIZE_INT);
+
+ this.decodeHeadersAndProperties(buffer);
+
+ this.endOfMessagePosition = buffer.readerIndex();
+
+ log.info("decoded end of body pos as " + this.endOfBodyPosition);
+
+ this.bufferValid = true;
+ }
+
+ public void decodeFromBuffer(HornetQBuffer buffer)
+ {
+ this.buffer = buffer;
+
+ decode();
+ }
+
}
Modified: branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,7 +21,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import org.hornetq.core.buffers.HornetQChannelBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.journal.SequentialFileFactory;
@@ -98,7 +98,7 @@
buffer2.rewind();
- HornetQChannelBuffer fileBuffer = HornetQChannelBuffers.wrappedBuffer(buffer2);
+ HornetQBuffer fileBuffer = HornetQChannelBuffers.wrappedBuffer(buffer2);
fileBuffer.writerIndex(fileBuffer.capacity());
while (fileBuffer.readable())
@@ -147,10 +147,15 @@
public void write(final PagedMessage message) throws Exception
{
+ log.info("encode size is " + message.getEncodeSize());
+
ByteBuffer buffer = fileFactory.newBuffer(message.getEncodeSize() + SIZE_RECORD);
- HornetQChannelBuffer wrap = HornetQChannelBuffers.wrappedBuffer(buffer);
+ HornetQBuffer wrap = HornetQChannelBuffers.wrappedBuffer(buffer);
+ wrap.clear();
+ log.info("wrapped " + wrap.channelBuffer());
+
wrap.writeByte(START_BYTE);
wrap.writeInt(0);
int startIndex = wrap.writerIndex();
@@ -167,6 +172,8 @@
size.addAndGet(buffer.limit());
storageManager.pageWrite(message, pageId);
+
+ log.info("wrote page");
}
public void sync() throws Exception
Modified:
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageTransactionInfoImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageTransactionInfoImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PageTransactionInfoImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -20,8 +20,8 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.paging.PageTransactionInfo;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
Modified:
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagedMessageImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -17,11 +17,11 @@
import static org.hornetq.utils.DataConstants.SIZE_INT;
import static org.hornetq.utils.DataConstants.SIZE_LONG;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.paging.PagedMessage;
import org.hornetq.core.persistence.StorageManager;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.impl.ServerMessageImpl;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -283,8 +283,6 @@
{
long size = message.getMemoryEstimate();
- //log.info((add ? "adding" : "subtracting") + " message
size " + size);
-
if (add)
{
checkReleaseProducerFlowControlCredits(size);
@@ -303,8 +301,6 @@
{
long size = MessageReferenceImpl.getMemoryEstimate();
- //log.info((add ? "adding" : "subtracting") + " reference
size " + size);
-
if (add)
{
checkReleaseProducerFlowControlCredits(size);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/BatchingIDGenerator.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/BatchingIDGenerator.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/BatchingIDGenerator.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,10 +15,10 @@
import java.util.concurrent.atomic.AtomicLong;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
import org.hornetq.core.journal.Journal;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.IDGenerator;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -32,6 +32,7 @@
import javax.transaction.xa.Xid;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.exception.HornetQException;
@@ -59,7 +60,6 @@
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.PostOffice;
import org.hornetq.core.remoting.impl.wireformat.XidCodecSupport;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.replication.ReplicationManager;
import org.hornetq.core.replication.impl.ReplicatedJournal;
import org.hornetq.core.server.JournalType;
@@ -739,7 +739,7 @@
}
case ADD_MESSAGE:
{
- ServerMessage message = new ServerMessageImpl(record.id);
+ ServerMessage message = new ServerMessageImpl(record.id, 50);
message.decode(buff);
@@ -1022,7 +1022,7 @@
}
case ADD_MESSAGE:
{
- ServerMessage message = new ServerMessageImpl(record.id);
+ ServerMessage message = new ServerMessageImpl(record.id, 50);
message.decode(buff);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/journal/LargeServerMessageImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -18,11 +18,11 @@
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicInteger;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.BodyEncoder;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.MessageReference;
import org.hornetq.core.server.ServerMessage;
@@ -103,7 +103,6 @@
public void encodeBody(final HornetQBuffer bufferOut, BodyEncoder context, int size)
{
- log.info("large server message, encodebody");
try
{
// This could maybe be optimized (maybe reading directly into bufferOut)
Modified:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.core.persistence.impl.nullpm;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.impl.ServerMessageImpl;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -19,6 +19,7 @@
import javax.transaction.xa.Xid;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.JournalLoadInformation;
import org.hornetq.core.paging.PageTransactionInfo;
@@ -29,7 +30,6 @@
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.PostOffice;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.replication.ReplicationManager;
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.MessageReference;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/BindingsImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -236,7 +236,7 @@
}
if (!routed)
- {
+ {
if (message.containsProperty(MessageImpl.HDR_FROM_CLUSTER))
{
routeFromCluster(message, context);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -635,7 +635,6 @@
{
bindings.route(message, context);
}
-
if (context.getQueueCount() == 0)
{
// Send to DLA if appropriate
@@ -780,7 +779,7 @@
{
// First send a reset message
- ServerMessage message = new ServerMessageImpl(storageManager.generateUniqueID(),
HornetQChannelBuffers.dynamicBuffer(50));
+ ServerMessage message = new ServerMessageImpl(storageManager.generateUniqueID(),
50);
message.setDestination(queueName);
message.putBooleanProperty(HDR_RESET_QUEUE_DATA, true);
@@ -885,7 +884,7 @@
}
Iterator<Queue> iter = context.getDurableQueues().iterator();
-
+
while (iter.hasNext())
{
Queue queue = iter.next();
@@ -980,7 +979,7 @@
private void addReferences(final List<MessageReference> refs)
{
for (MessageReference ref : refs)
- {
+ {
ref.getQueue().addLast(ref);
}
}
@@ -999,7 +998,7 @@
private ServerMessage createQueueInfoMessage(final NotificationType type, final
SimpleString queueName)
{
- ServerMessage message = new ServerMessageImpl(storageManager.generateUniqueID(),
HornetQChannelBuffers.dynamicBuffer(100));
+ ServerMessage message = new ServerMessageImpl(storageManager.generateUniqueID(),
50);
message.setDestination(queueName);
// message.setDurable(true);
Modified: branches/20-optimisation/src/main/org/hornetq/core/remoting/Packet.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/core/remoting/Packet.java 2009-11-23
21:22:09 UTC (rev 8386)
+++ branches/20-optimisation/src/main/org/hornetq/core/remoting/Packet.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
*
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/RemotingConnection.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/RemotingConnection.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/RemotingConnection.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,10 +15,10 @@
import java.util.List;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A RemotingConnection
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/AbstractBufferHandler.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/AbstractBufferHandler.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/AbstractBufferHandler.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -12,9 +12,9 @@
*/
package org.hornetq.core.remoting.impl;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.BufferHandler;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/ChannelImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,6 +21,7 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.Channel;
@@ -31,7 +32,6 @@
import org.hornetq.core.remoting.impl.wireformat.HornetQExceptionMessage;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
import org.hornetq.core.remoting.impl.wireformat.PacketsConfirmedMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A ChannelImpl
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/PacketDecoder.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -79,6 +79,7 @@
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_XA_START;
import static org.hornetq.core.remoting.impl.wireformat.PacketImpl.SESS_XA_SUSPEND;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.impl.wireformat.CreateQueueMessage;
@@ -140,7 +141,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionXAStartMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A PacketDecoder
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,6 +21,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.Channel;
@@ -31,7 +32,6 @@
import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
import org.hornetq.core.remoting.spi.Connection;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.SimpleIDGenerator;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/invm/InVMConnection.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,13 +15,13 @@
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.UUIDGenerator;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateQueueMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateQueueMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateQueueMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateReplicationSessionMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateReplicationSessionMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateReplicationSessionMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/CreateSessionResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/HornetQExceptionMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/HornetQExceptionMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/HornetQExceptionMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,9 +13,9 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,10 +13,10 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.RemotingConnection;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketsConfirmedMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketsConfirmedMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/PacketsConfirmedMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/Ping.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReattachSessionResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,9 +13,9 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.utils.DataConstants;
+import org.hornetq.core.logging.Logger;
/**
* A ReplicationAddMessage
@@ -28,7 +28,10 @@
{
// Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(ReplicationAddMessage.class);
+
// Attributes ----------------------------------------------------
private long id;
@@ -76,6 +79,7 @@
buffer.writeBoolean(isUpdate);
buffer.writeLong(id);
buffer.writeByte(recordType);
+ log.info("encode size is " + encodingData.getEncodeSize());
buffer.writeInt(encodingData.getEncodeSize());
encodingData.encode(buffer);
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddTXMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddTXMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationAddTXMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCommitMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCommitMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCommitMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCompareDataMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCompareDataMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationCompareDataMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.JournalLoadInformation;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteTXMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteTXMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationDeleteTXMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageBeingMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageBeingMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageBeingMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageWriteMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageWriteMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargeMessageWriteMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargemessageEndMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargemessageEndMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationLargemessageEndMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageEventMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageEventMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageEventMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageWriteMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageWriteMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPageWriteMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,9 +13,9 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.paging.PagedMessage;
import org.hornetq.core.paging.impl.PagedMessageImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPrepareMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPrepareMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationPrepareMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/ReplicationSyncContextMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
* Message sent when a Replication Context is complete without any persistence
replicated.
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/RollbackMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/RollbackMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/RollbackMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.SimpleString;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -16,7 +16,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerCloseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerCloseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerCloseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerFlowCreditMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerFlowCreditMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionConsumerFlowCreditMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionContinuationMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionContinuationMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionContinuationMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.SimpleString;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionExpiredMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionExpiredMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionExpiredMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionForceConsumerDelivery.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionForceConsumerDelivery.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionForceConsumerDelivery.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionProducerCreditsMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionProducerCreditsMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionProducerCreditsMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveContinuationMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveContinuationMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveContinuationMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveLargeMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveLargeMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveLargeMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionReceiveMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,22 +13,17 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.impl.ClientMessageImpl;
-import org.hornetq.core.client.impl.ClientMessageInternal;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.RemotingConnection;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.ServerMessage;
+import org.hornetq.core.message.Message;
import org.hornetq.utils.DataConstants;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu@feodorov.com">Ovidiu
Feodorov</a>
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
+ *
*/
-public class SessionReceiveMessage extends PacketImpl
+public class SessionReceiveMessage extends MessagePacket
{
// Constants -----------------------------------------------------
@@ -38,28 +33,22 @@
private long consumerID;
- private ClientMessageInternal clientMessage;
-
- private ServerMessage serverMessage;
-
private int deliveryCount;
- public SessionReceiveMessage(final long consumerID, final ServerMessage message, final
int deliveryCount)
+ public SessionReceiveMessage(final long consumerID, final Message message, final int
deliveryCount)
{
- super(SESS_RECEIVE_MSG);
-
+ super(SESS_RECEIVE_MSG, message);
+
this.consumerID = consumerID;
- this.serverMessage = message;
-
- this.clientMessage = null;
-
this.deliveryCount = deliveryCount;
+
+ message.forceCopy();
}
public SessionReceiveMessage()
{
- super(SESS_RECEIVE_MSG);
+ super(SESS_RECEIVE_MSG, new ClientMessageImpl());
}
// Public --------------------------------------------------------
@@ -68,129 +57,41 @@
{
return consumerID;
}
-
- public ClientMessageInternal getClientMessage()
+
+ public int getDeliveryCount()
{
- return clientMessage;
+ return deliveryCount;
}
- public ServerMessage getServerMessage()
- {
- return serverMessage;
- }
+ // Package protected ---------------------------------------------
- public int getDeliveryCount()
+ // Protected -----------------------------------------------------
+
+ protected void encodeExtraData(HornetQBuffer buffer)
{
- return deliveryCount;
- }
-
- @Override
- public HornetQBuffer encode(final RemotingConnection connection)
- {
- //We re-use the same packet buffer - but we need to change the extra data
-
- //Since many consumers could be delivering the same message concurrently, we must
copy the buffer before sending
- //since otherwise they will all write different consumer ids and delivering counts
on the same buffer concurrently
- //and indexes will get screwed up
-
- //TODO - optimise this
- HornetQBuffer origBuffer = serverMessage.getWholeBuffer();
-
- HornetQBuffer buffer = origBuffer.copy();
-
- buffer.setIndex(origBuffer.readerIndex(), origBuffer.writerIndex());
-
- if (serverMessage.isEncodedToBuffer())
- {
- //It's already encoded - we just need to change the extra data at the end
- //so we need to jump to the after body position
-
- buffer.setIndex(0, serverMessage.getEndMessagePosition());
- }
- else
- {
- int afterBody = buffer.writerIndex();
-
- //Message hasn't been encoded yet - probably it's something like a
notification message generated on the server
-
- //End of message position
- buffer.writeInt(0);
-
- // We now write the message headers and properties
- serverMessage.encodeHeadersAndProperties(buffer);
-
- int endMessage = buffer.writerIndex();
-
- buffer.setInt(afterBody, endMessage);
-
- serverMessage.setEndMessagePosition(endMessage);
-
- //Now we need to fill in the afterBody
- buffer.setInt(PacketImpl.PACKET_HEADERS_SIZE, afterBody);
- }
-
buffer.writeLong(consumerID);
buffer.writeInt(deliveryCount);
-
- // Calculate the new packet size
- size = buffer.writerIndex();
-
- buffer.setIndex(0, 0);
-
- // Fill in the standard header fields
-
- int len = size - DataConstants.SIZE_INT;
- buffer.writeInt(len);
- buffer.writeByte(type);
- buffer.writeLong(channelID);
-
- buffer.writerIndex(size);
-
- return buffer;
}
-
- @Override
- public void decode(final HornetQBuffer buffer)
+
+ protected void decodeExtraData(HornetQBuffer buffer)
{
- channelID = buffer.readLong();
-
- clientMessage = new ClientMessageImpl();
-
- // We read the position of the end of the body - this is where the message headers
and properties are stored
- int afterBody = buffer.readInt();
-
- //At this point standard headers have been decoded and we are positioned at the
beginning of the body
- int bodyStart = buffer.readerIndex();
-
- // We now read message headers/properties
-
- buffer.readerIndex(afterBody);
-
- int endMessage = buffer.readInt();
-
- clientMessage.decodeFromWire(buffer);
-
- // And read the extra data
-
consumerID = buffer.readLong();
-
deliveryCount = buffer.readInt();
+ }
+ @Override
+ public void decodeRest(HornetQBuffer buffer)
+ {
+ //Buffer comes in after having read standard headers and positioned at Beginning of
body part
- clientMessage.setDeliveryCount(deliveryCount);
+ message.decodeFromBuffer(buffer);
- size = buffer.readerIndex();
-
- // Set reader index back to beginning of body
-
- buffer.setIndex(bodyStart, afterBody);
+ decodeExtraData(buffer);
- clientMessage.setBuffer(buffer);
+ //Need to position buffer for reading
+
+ buffer.setIndex(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT,
message.getEndOfBodyPosition());
}
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionRequestProducerCreditsMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionRequestProducerCreditsMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionRequestProducerCreditsMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendContinuationMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendContinuationMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendContinuationMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendLargeMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendLargeMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendLargeMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionSendMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,22 +13,17 @@
package org.hornetq.core.remoting.impl.wireformat;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.Message;
-import org.hornetq.core.remoting.RemotingConnection;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.impl.ServerMessageImpl;
-import org.hornetq.utils.DataConstants;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- * @author <a href="mailto:csuconic@redhat.com">Clebert
Suconic</a>
- *
+ *
* @version <tt>$Revision$</tt>
*/
-public class SessionSendMessage extends PacketImpl
+public class SessionSendMessage extends MessagePacket
{
// Constants -----------------------------------------------------
@@ -36,10 +31,6 @@
// Attributes ----------------------------------------------------
- private Message sentMessage;
-
- private ServerMessage receivedMessage;
-
private boolean requiresResponse;
// Static --------------------------------------------------------
@@ -48,163 +39,39 @@
public SessionSendMessage(final Message message, final boolean requiresResponse)
{
- super(SESS_SEND);
-
- sentMessage = message;
-
+ super(SESS_SEND, message);
+
this.requiresResponse = requiresResponse;
+
+ message.forceCopy();
}
-
+
public SessionSendMessage()
{
- super(SESS_SEND);
+ super(SESS_SEND, new ServerMessageImpl());
}
// Public --------------------------------------------------------
- public Message getClientMessage()
- {
- return sentMessage;
- }
-
- public ServerMessage getServerMessage()
- {
- return receivedMessage;
- }
-
public boolean isRequiresResponse()
{
return requiresResponse;
}
- @Override
- public HornetQBuffer encode(final RemotingConnection connection)
- {
- /*
- * We write the message to the buffer in the following structure:
- *
- * First the standard packet headers - all packets have these
- *
- * length:int
- * packet type:byte
- * channelID:long
- *
- * Then the message body:
- *
- * position of end of body: int
- * body:byte[]
- *
- * {Note we store the message body before the message headers/properties since this
allows the user to
- * construct a message, add stuff to the body buffer, and send it without us having
to copy the body into a new
- * buffer before sending it, this minmises buffer copying}
- *
- * position of end of encoded message headers/properties: int
- *
- * Then followed by the message headers and properties:
- *
- * messageID:long
- * destination:SimpleString
- * message type: byte
- * durable: boolean
- * expiration: long
- * timestamp: long
- * priority: byte
- *
- * properties: byte[]
- *
- *
- */
+ // Package protected ---------------------------------------------
- HornetQBuffer buffer = sentMessage.getWholeBuffer();
-
- // The body will already be written (if any) at this point, so we take note of the
position of the end of the
- // body
-
- int afterBody = buffer.writerIndex();
-
- //The next int is the position of after the encoded message headers/properties, so
we skip this for now
- buffer.writeInt(0);
-
- // We now write the message headers and properties
- sentMessage.encodeHeadersAndProperties(buffer);
-
- //Write the position of the end of the message
-
- int endMessage = buffer.writerIndex();
-
- buffer.setInt(afterBody, endMessage);
-
- // We now write the extra data for the packet
+ // Protected -----------------------------------------------------
+
+ protected void encodeExtraData(HornetQBuffer buffer)
+ {
buffer.writeBoolean(requiresResponse);
-
- // We take note of the overall size of the packet
- size = buffer.writerIndex();
-
- // We now set the standard packet headers at the beginning of the buffer
-
- buffer.clear();
-
- int len = size - DataConstants.SIZE_INT;
- buffer.writeInt(len);
- buffer.writeByte(type);
- buffer.writeLong(channelID);
-
- // This last byte we write marks the position of the end of the message body
- buffer.writeInt(afterBody);
-
- // And we set the indexes back for reading and writing
- buffer.setIndex(0, size);
-
- //We must make a copy of the buffer, since the message might get sent again, and
the body might get read or written
- //this might occur while the same send is in operatio since netty send is asynch
- //this could cause incorrect data to be send and/or reader/writer positions to
become corrupted
-
- HornetQBuffer newBuffer = buffer.copy();
-
- newBuffer.setIndex(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT,
afterBody);
-
- this.sentMessage.setBuffer(newBuffer);
-
- return buffer;
}
-
- @Override
- public void decodeRest(final HornetQBuffer buffer)
+
+ protected void decodeExtraData(HornetQBuffer buffer)
{
- receivedMessage = new ServerMessageImpl();
-
- sentMessage = receivedMessage;
-
- // At this point, the standard packet headers will already have been read
-
- // We read the position of the end of the body - this is where the message headers
and properties are stored
- int afterBody = buffer.readInt();
-
- buffer.setIndex(afterBody, buffer.writerIndex());
-
- int endMessage = buffer.readInt();
-
- receivedMessage.setEndMessagePosition(endMessage);
-
- // We now read message headers/properties
-
- receivedMessage.decodeFromWire(buffer);
-
- //We store the position of the end of the encoded message, where the extra data
starts - this
- //will be needed if we re-deliver this packet, since we need to reset to there to
rewrite the extra data
- //for the different packet
- //receivedMessage.setEndMessagePosition(endMessage);
-
- // And we read extra data in the packet
-
requiresResponse = buffer.readBoolean();
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXACommitMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXACommitMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXACommitMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAEndMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAEndMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAEndMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAForgetMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAForgetMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAForgetMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -18,7 +18,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAJoinMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAJoinMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAJoinMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAPrepareMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAPrepareMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAPrepareMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResumeMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResumeMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAResumeMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXARollbackMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXARollbackMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXARollbackMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,7 +13,7 @@
package org.hornetq.core.remoting.impl.wireformat;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAStartMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAStartMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/SessionXAStartMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/XidCodecSupport.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/XidCodecSupport.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/impl/wireformat/XidCodecSupport.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,7 +15,7 @@
import javax.transaction.xa.Xid;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.transaction.impl.XidImpl;
import org.hornetq.utils.DataConstants;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -25,6 +25,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.TransportConfiguration;
@@ -48,7 +49,6 @@
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.impl.HornetQPacketHandler;
import org.hornetq.utils.ConfigurationHelper;
Modified:
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/BufferHandler.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/BufferHandler.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/BufferHandler.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -12,6 +12,8 @@
*/
package org.hornetq.core.remoting.spi;
+import org.hornetq.core.buffers.HornetQBuffer;
+
/**
* A BufferHandler
*
Modified: branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/Connection.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/Connection.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/Connection.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,6 +13,7 @@
package org.hornetq.core.remoting.spi;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
/**
Deleted:
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/remoting/spi/HornetQBuffer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,130 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.remoting.spi;
-
-import org.hornetq.utils.SimpleString;
-
-/**
- *
- * A HornetQBuffer
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public interface HornetQBuffer
-{
- void writeByte(byte val);
-
- void writeBytes(byte[] bytes);
-
- void writeBytes(byte[] bytes, int offset, int length);
-
- void writeBytes(HornetQBuffer src, int srcIndex, int length);
-
- void writeInt(int val);
-
- void setInt(int pos, int val);
-
- void writeLong(long val);
-
- void writeShort(short val);
-
- void writeDouble(double val);
-
- void writeFloat(float val);
-
- void writeBoolean(boolean val);
-
- void writeChar(char val);
-
- void writeNullableString(String val);
-
- void writeString(String val);
-
- void writeSimpleString(SimpleString val);
-
- void writeNullableSimpleString(SimpleString val);
-
- void writeUTF(String utf) throws Exception;
-
- byte readByte();
-
- short readUnsignedByte();
-
- void readBytes(byte[] bytes);
-
- void readBytes(byte[] bytes, int offset, int length);
-
- int readInt();
-
- int readInt(int pos);
-
- long readLong();
-
- short readShort();
-
- int readUnsignedShort();
-
- double readDouble();
-
- float readFloat();
-
- boolean readBoolean();
-
- char readChar();
-
- String readString();
-
- String readNullableString();
-
- SimpleString readSimpleString();
-
- SimpleString readNullableSimpleString();
-
- String readUTF() throws Exception;
-
- int capacity();
-
- int readerIndex();
-
- void readerIndex(int readerIndex);
-
- int writerIndex();
-
- void writerIndex(int writerIndex);
-
- void setIndex(int readerIndex, int writerIndex);
-
- int readableBytes();
-
- int writableBytes();
-
- boolean readable();
-
- boolean writable();
-
- void clear();
-
- void resetReaderIndex();
-
- void resetWriterIndex();
-
- Object getUnderlyingBuffer();
-
- byte[] array();
-
- HornetQBuffer copy();
-
- HornetQBuffer slice(int index, int length);
-}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/replication/impl/ReplicationManagerImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -17,6 +17,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.SessionFailureListener;
import org.hornetq.core.client.impl.FailoverManager;
import org.hornetq.core.exception.HornetQException;
@@ -43,7 +44,6 @@
import org.hornetq.core.remoting.impl.wireformat.ReplicationPageEventMessage;
import org.hornetq.core.remoting.impl.wireformat.ReplicationPageWriteMessage;
import org.hornetq.core.remoting.impl.wireformat.ReplicationPrepareMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.replication.ReplicationContext;
import org.hornetq.core.replication.ReplicationManager;
import org.hornetq.utils.ConcurrentHashSet;
Modified: branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/ServerMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -60,13 +60,6 @@
boolean page(long transactionID, boolean duplicateDetection) throws Exception;
boolean storeIsPaging();
-
- void setNeedsEncoding();
-
-
- void setEndMessagePosition(int pos);
-
- int getEndMessagePosition();
-
- void encodeMessageIDToBuffer();;
+
+ void encodeMessageIDToBuffer();
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -20,13 +20,13 @@
import java.util.List;
import java.util.concurrent.ScheduledFuture;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.config.TransportConfiguration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.management.Notification;
import org.hornetq.core.management.NotificationService;
import org.hornetq.core.management.NotificationType;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.cluster.BroadcastGroup;
import org.hornetq.utils.Pair;
import org.hornetq.utils.SimpleString;
@@ -227,7 +227,7 @@
}
}
- byte[] data = buff.array();
+ byte[] data = buff.toByteBuffer().array();
DatagramPacket packet = new DatagramPacket(data, data.length, groupAddress,
groupPort);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/RemoteQueueBindingImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/RemoteQueueBindingImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/cluster/impl/RemoteQueueBindingImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -204,7 +204,7 @@
{
//There can be many remote bindings for the same node, we only want to add the
message once to
//the s & f queue for that node
- context.getDurableQueues().add(storeAndForwardQueue);
+ context.addQueue(storeAndForwardQueue);
}
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1504,7 +1504,7 @@
for (int i = 0; i < numMessages; i++)
{
- ServerMessage msg = new ServerMessageImpl(storageManager.generateUniqueID(),
HornetQChannelBuffers.wrappedBuffer(body));
+ ServerMessage msg = new ServerMessageImpl(storageManager.generateUniqueID(),
1500);
msg.setDestination(address);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,6 +21,7 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.impl.ClientConsumerImpl;
import org.hornetq.core.client.management.impl.ManagementHelper;
@@ -38,7 +39,6 @@
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveContinuationMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveLargeMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionReceiveMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HandleStatus;
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.MessageReference;
@@ -347,7 +347,7 @@
promptDelivery(false);
ServerMessage forcedDeliveryMessage = new
ServerMessageImpl(storageManager.generateUniqueID(),
-
HornetQChannelBuffers.dynamicBuffer(100));
+ 50);
forcedDeliveryMessage.putLongProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE,
sequence);
forcedDeliveryMessage.setDestination(messageQueue.getName());
@@ -668,12 +668,12 @@
if (!sentInitialPacket)
{
- HornetQBuffer headerBuffer =
HornetQChannelBuffers.buffer(largeMessage.getHeadersAndPropertiesEncodeSize());
+ HornetQBuffer headerBuffer =
HornetQChannelBuffers.fixedBuffer(largeMessage.getHeadersAndPropertiesEncodeSize());
largeMessage.encodeHeadersAndProperties(headerBuffer);
SessionReceiveLargeMessage initialPacket = new
SessionReceiveLargeMessage(id,
-
headerBuffer.array(),
+
headerBuffer.toByteBuffer().array(),
largeMessage.getLargeBodySize(),
ref.getDeliveryCount());
@@ -796,12 +796,12 @@
localChunkLen = (int)Math.min(sizePendingLargeMessage -
positionPendingLargeMessage, minLargeMessageSize);
- HornetQBuffer bodyBuffer = HornetQChannelBuffers.buffer(localChunkLen);
+ HornetQBuffer bodyBuffer = HornetQChannelBuffers.fixedBuffer(localChunkLen);
context.encode(bodyBuffer, localChunkLen);
chunk = new SessionReceiveContinuationMessage(id,
- bodyBuffer.array(),
+
bodyBuffer.toByteBuffer().array(),
positionPendingLargeMessage +
localChunkLen < sizePendingLargeMessage,
false);
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -16,13 +16,11 @@
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger;
-import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.message.Message;
+import org.hornetq.core.message.PropertyConversionException;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.paging.PagingStore;
import org.hornetq.core.remoting.impl.wireformat.PacketImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.MessageReference;
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.ServerMessage;
@@ -61,30 +59,17 @@
}
/*
- * Construct a MessageImpl from storage
+ * Construct a MessageImpl from storage, or notification
*/
- public ServerMessageImpl(final long messageID)
+ public ServerMessageImpl(final long messageID, final int initialMessageBufferSize)
{
- super(messageID);
+ super(messageID, initialMessageBufferSize);
}
/*
- * Constructor when creating a ServerMessage for sending - e.g. notification
- */
- public ServerMessageImpl(final long messageID, final HornetQBuffer buffer)
- {
- super(messageID);
-
- this.buffer = buffer;
-
- // Must align the body after the packet headers
- resetBuffer();
- }
-
- /*
* Copy constructor
*/
- protected ServerMessageImpl(final Message other)
+ protected ServerMessageImpl(final ServerMessageImpl other)
{
this();
messageID = other.getMessageID();
@@ -95,7 +80,8 @@
timestamp = other.getTimestamp();
priority = other.getPriority();
properties = new TypedProperties(other.getProperties());
- buffer = other.getWholeBuffer();
+ //Note, this is a shallow copy - does not copy the buffer
+ buffer = other.buffer;
}
public void setMessageID(final long id)
@@ -246,7 +232,7 @@
putLongProperty(HDR_ACTUAL_EXPIRY_TIME, actualExpiryTime);
}
- setNeedsEncoding();
+ bufferValid = false;
}
public void setPagingStore(final PagingStore pagingStore)
@@ -320,100 +306,223 @@
// Encoding stuff
- public void setNeedsEncoding()
+ public void encodeMessageIDToBuffer()
{
- // This wil force the message to be re-encoded if it gets sent to a client
- // Typically this is called after properties or headers are changed on the server
side
- this.encodedToBuffer = false;
+ // We first set the message id - this needs to be set on the buffer since this
buffer will be re-used
+
+ //log.info(System.identityHashCode(this) + " encoded message id " +
messageID + " etb " + this.encodedToBuffer);
+
+ buffer.setLong(buffer.getInt(PacketImpl.PACKET_HEADERS_SIZE) +
DataConstants.SIZE_INT, messageID);
}
- private int endMessagePosition;
+ @Override
+ public void putBooleanProperty(SimpleString key, boolean value)
+ {
+ super.putBooleanProperty(key, value);
+
+ bufferValid = false;
+ }
- public void setEndMessagePosition(int pos)
- {
- this.endMessagePosition = pos;
+ @Override
+ public void putBooleanProperty(String key, boolean value)
+ {
+ super.putBooleanProperty(key, value);
+
+ bufferValid = false;;
}
- public int getEndMessagePosition()
- {
- return this.endMessagePosition;
+ @Override
+ public void putByteProperty(SimpleString key, byte value)
+ {
+ super.putByteProperty(key, value);
+
+ bufferValid = false;
}
- public void encodeToWire()
- {
+ @Override
+ public void putByteProperty(String key, byte value)
+ {
+ super.putByteProperty(key, value);
+
+ bufferValid = false;
}
- // EncodingSupport implementation
+ @Override
+ public void putBytesProperty(SimpleString key, byte[] value)
+ {
+ super.putBytesProperty(key, value);
+
+ bufferValid = false;
+ }
- // Used when storing to/from journal
+ @Override
+ public void putBytesProperty(String key, byte[] value)
+ {
+ super.putBytesProperty(key, value);
+
+ bufferValid = false;
+ }
- public void encode(final HornetQBuffer buffer)
- {
- // Encode the message to a buffer for storage in the journal
+ @Override
+ public void putDoubleProperty(SimpleString key, double value)
+ {
+ super.putDoubleProperty(key, value);
+
+ bufferValid = false;
+ }
- if (this.encodedToBuffer)
- {
- // The body starts after the standard packet headers
- int bodyStart = PacketImpl.PACKET_HEADERS_SIZE;
+ @Override
+ public void putDoubleProperty(String key, double value)
+ {
+ super.putDoubleProperty(key, value);
+
+ bufferValid = false;
+ }
- int end = this.endMessagePosition;
-
- buffer.writeBytes(this.buffer, bodyStart, end - bodyStart);
- }
- else
- {
- // encodeToBuffer();
+ @Override
+ public void putFloatProperty(SimpleString key, float value)
+ {
+ super.putFloatProperty(key, value);
+
+ bufferValid = false;
+ }
- throw new IllegalStateException("Not encoded to buffer and storing to
journal");
- }
+ @Override
+ public void putFloatProperty(String key, float value)
+ {
+ super.putFloatProperty(key, value);
+
+ bufferValid = false;
}
- public void decode(final HornetQBuffer buffer)
- {
- // TODO optimise
+ @Override
+ public void putIntProperty(SimpleString key, int value)
+ {
+ super.putIntProperty(key, value);
+
+ bufferValid = false;
+ }
- int start = buffer.readerIndex();
+ @Override
+ public void putIntProperty(String key, int value)
+ {
+ super.putIntProperty(key, value);
+
+ bufferValid = false;
+ }
- int bodyEndPos = buffer.readInt();
+ @Override
+ public void putLongProperty(SimpleString key, long value)
+ {
+ super.putLongProperty(key, value);
- this.endMessagePosition = buffer.readInt(bodyEndPos -
PacketImpl.PACKET_HEADERS_SIZE + start);
+ bufferValid = false;
+ }
+
+ @Override
+ public void putLongProperty(String key, long value)
+ {
+ super.putLongProperty(key, value);
- int endPos = endMessagePosition + start -
- PacketImpl.PACKET_HEADERS_SIZE;
+ bufferValid = false;
+ }
- this.buffer = HornetQChannelBuffers.dynamicBuffer(1500);
+ @Override
+ public void putObjectProperty(SimpleString key, Object value) throws
PropertyConversionException
+ {
+ super.putObjectProperty(key, value);
+
+ bufferValid = false;
+ }
- // work around Netty bug
- this.buffer.writeByte((byte)0);
+ @Override
+ public void putObjectProperty(String key, Object value) throws
PropertyConversionException
+ {
+ super.putObjectProperty(key, value);
+
+ bufferValid = false;
+ }
- this.buffer.setIndex(0, PacketImpl.PACKET_HEADERS_SIZE);
+ @Override
+ public void putShortProperty(SimpleString key, short value)
+ {
+ super.putShortProperty(key, value);
+
+ bufferValid = false;
+ }
- this.buffer.writeBytes(buffer, start, endPos - start);
+ @Override
+ public void putShortProperty(String key, short value)
+ {
+ super.putShortProperty(key, value);
- // Position to beginning of encoded message headers/properties
+ bufferValid = false;
+ }
- this.buffer.readerIndex(0);
-
- //Position to beginning of encoded message headers/properties
+ @Override
+ public void putStringProperty(SimpleString key, SimpleString value)
+ {
+ super.putStringProperty(key, value);
- this.buffer.readerIndex(bodyEndPos + DataConstants.SIZE_INT);
+ bufferValid = false;
+ }
- this.decodeHeadersAndProperties(this.buffer);
+ @Override
+ public void putStringProperty(String key, String value)
+ {
+ super.putStringProperty(key, value);
- buffer.setIndex(endPos, buffer.capacity());
+ bufferValid = false;
+ }
+
+ @Override
+ public void putTypedProperties(TypedProperties otherProps)
+ {
+ super.putTypedProperties(otherProps);
- this.encodedToBuffer = true;
+ bufferValid = false;
}
- public void encodeMessageIDToBuffer()
- {
- // We first set the message id - this needs to be set on the buffer since this
buffer will be re-used
+ @Override
+ public void setDestination(SimpleString destination)
+ {
+ super.setDestination(destination);
+
+ bufferValid = false;
+ }
- buffer.readerIndex(0);
+ @Override
+ public void setDurable(boolean durable)
+ {
+ super.setDurable(durable);
+
+ bufferValid = false;
+ }
- buffer.writerIndex(buffer.readInt(PacketImpl.PACKET_HEADERS_SIZE) +
DataConstants.SIZE_INT);
+ @Override
+ public void setExpiration(long expiration)
+ {
+ super.setExpiration(expiration);
+
+ bufferValid = false;
+ }
- buffer.writeLong(messageID);
+ @Override
+ public void setPriority(byte priority)
+ {
+ super.setPriority(priority);
+
+ bufferValid = false;
}
+ @Override
+ public void setTimestamp(long timestamp)
+ {
+ super.setTimestamp(timestamp);
+
+ bufferValid = false;
+ }
+
+
+
}
Modified:
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -28,7 +28,6 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
-import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.impl.ClientMessageImpl;
import org.hornetq.core.client.management.impl.ManagementHelper;
import org.hornetq.core.exception.HornetQException;
@@ -1435,8 +1434,7 @@
public void handleSendLargeMessage(final SessionSendLargeMessage packet)
{
- log.info("Got large message on server");
-
+
// need to create the LargeMessage before continue
long id = storageManager.generateUniqueID();
@@ -1456,10 +1454,10 @@
}
public void handleSend(final SessionSendMessage packet)
- {
+ {
Packet response = null;
- ServerMessage message = packet.getServerMessage();
+ ServerMessage message = (ServerMessage)packet.getMessage();
try
{
@@ -1597,8 +1595,6 @@
}
});
- //log.info("session requesting " + credits + " got " +
gotCredits);
-
if (gotCredits > 0)
{
sendProducerCredits(holder, gotCredits, address);
@@ -1904,8 +1900,6 @@
*/
private void releaseOutStanding(final ServerMessage message, final int credits) throws
Exception
{
- //log.info("releasing outstanding credits " + credits);
-
CreditManagerHolder holder = getCreditManagerHolder(message);
holder.outstandingCredits -= credits;
@@ -1949,8 +1943,6 @@
{
holder.outstandingCredits += credits;
- // log.info("sending producer credits " + credits);
-
Packet packet = new SessionProducerCreditsMessage(credits, address, -1);
channel.send(packet);
Deleted:
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/ChannelBufferWrapper.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,418 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.integration.transports.netty;
-
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.utils.DataConstants;
-import org.hornetq.utils.SimpleString;
-import org.hornetq.utils.UTF8Util;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- *
- * @author <a href="mailto:tlee@redhat.com">Trustin Lee</a>
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic@jboss.com">Clebert
Suconic</a>
- *
- * @version $Rev$, $Date$
- */
-public class ChannelBufferWrapper implements HornetQBuffer
-{
- private static final Logger log = Logger.getLogger(ChannelBufferWrapper.class);
-
- private final ChannelBuffer buffer;
-
- /**
- * @param buffer
- */
- public ChannelBufferWrapper(final ChannelBuffer buffer)
- {
- super();
- this.buffer = buffer;
- }
-
- public int capacity()
- {
- return buffer.capacity();
- }
-
- public void clear()
- {
- buffer.clear();
- }
-
- public boolean readable()
- {
- return buffer.readable();
- }
-
- public int readableBytes()
- {
- return buffer.readableBytes();
- }
-
- public byte readByte()
- {
- return buffer.readByte();
- }
-
- public void readBytes(final byte[] dst, final int dstIndex, final int length)
- {
- buffer.readBytes(dst, dstIndex, length);
- }
-
- public void readBytes(final byte[] dst)
- {
- buffer.readBytes(dst);
- }
-
- public int readerIndex()
- {
- return buffer.readerIndex();
- }
-
- public void readerIndex(final int readerIndex)
- {
- buffer.readerIndex(readerIndex);
- }
-
- public int readInt()
- {
- return buffer.readInt();
- }
-
- public int readInt(final int pos)
- {
- return buffer.getInt(pos);
- }
-
- public long readLong()
- {
- return buffer.readLong();
- }
-
- public short readShort()
- {
- return buffer.readShort();
- }
-
- public short readUnsignedByte()
- {
- return buffer.readUnsignedByte();
- }
-
- public int readUnsignedShort()
- {
- return buffer.readUnsignedShort();
- }
-
- public void resetReaderIndex()
- {
- buffer.resetReaderIndex();
- }
-
- public void resetWriterIndex()
- {
- buffer.resetWriterIndex();
- }
-
- public void setIndex(final int readerIndex, final int writerIndex)
- {
- buffer.setIndex(readerIndex, writerIndex);
- }
-
- public void setInt(final int index, final int value)
- {
- buffer.setInt(index, value);
- }
-
- public boolean writable()
- {
- return buffer.writable();
- }
-
- public int writableBytes()
- {
- return buffer.writableBytes();
- }
-
- public void writeByte(final byte value)
- {
- buffer.writeByte(value);
- }
-
- public void writeBytes(final byte[] src, final int srcIndex, final int length)
- {
- buffer.writeBytes(src, srcIndex, length);
- }
-
- public void writeBytes(final HornetQBuffer src, final int srcIndex, final int length)
- {
- byte bytes[] = new byte[length];
- src.readBytes(bytes, srcIndex, length);
- this.writeBytes(bytes);
- }
-
- public void writeBytes(final byte[] src)
- {
- buffer.writeBytes(src);
- }
-
- public void writeInt(final int value)
- {
- buffer.writeInt(value);
- }
-
- public void writeLong(final long value)
- {
- buffer.writeLong(value);
- }
-
- public int writerIndex()
- {
- return buffer.writerIndex();
- }
-
- public void writerIndex(final int writerIndex)
- {
- buffer.writerIndex(writerIndex);
- }
-
- public void writeShort(final short value)
- {
- buffer.writeShort(value);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#array()
- */
- public byte[] array()
- {
- return buffer.toByteBuffer().array();
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readBoolean()
- */
- public boolean readBoolean()
- {
- return readByte() != 0;
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readChar()
- */
- public char readChar()
- {
- return (char)readShort();
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readDouble()
- */
- public double readDouble()
- {
- return Double.longBitsToDouble(readLong());
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readFloat()
- */
- public float readFloat()
- {
- return Float.intBitsToFloat(readInt());
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readNullableSimpleString()
- */
- public SimpleString readNullableSimpleString()
- {
- int b = readByte();
- if (b == DataConstants.NULL)
- {
- return null;
- }
- else
- {
- return readSimpleString();
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readNullableString()
- */
- public String readNullableString()
- {
- int b = readByte();
- if (b == DataConstants.NULL)
- {
- return null;
- }
- else
- {
- return readString();
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readSimpleString()
- */
- public SimpleString readSimpleString()
- {
- int len = readInt();
- byte[] data = new byte[len];
- readBytes(data);
- return new SimpleString(data);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readString()
- */
- public String readString()
- {
- int len = readInt();
- char[] chars = new char[len];
- for (int i = 0; i < len; i++)
- {
- chars[i] = readChar();
- }
- return new String(chars);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#readUTF()
- */
- public String readUTF() throws Exception
- {
- return UTF8Util.readUTF(this);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeBoolean(boolean)
- */
- public void writeBoolean(final boolean val)
- {
- writeByte((byte)(val ? -1 : 0));
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeChar(char)
- */
- public void writeChar(final char val)
- {
- writeShort((short)val);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeDouble(double)
- */
- public void writeDouble(final double val)
- {
- writeLong(Double.doubleToLongBits(val));
-
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeFloat(float)
- */
- public void writeFloat(final float val)
- {
- writeInt(Float.floatToIntBits(val));
-
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.remoting.spi.HornetQBuffer#writeNullableSimpleString(org.hornetq.util.SimpleString)
- */
- public void writeNullableSimpleString(final SimpleString val)
- {
- if (val == null)
- {
- writeByte(DataConstants.NULL);
- }
- else
- {
- writeByte(DataConstants.NOT_NULL);
- writeSimpleString(val);
- }
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.remoting.spi.HornetQBuffer#writeNullableString(java.lang.String)
- */
- public void writeNullableString(final String val)
- {
- if (val == null)
- {
- writeByte(DataConstants.NULL);
- }
- else
- {
- writeByte(DataConstants.NOT_NULL);
- writeString(val);
- }
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.remoting.spi.HornetQBuffer#writeSimpleString(org.hornetq.util.SimpleString)
- */
- public void writeSimpleString(final SimpleString val)
- {
- byte[] data = val.getData();
- writeInt(data.length);
- writeBytes(data);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeString(java.lang.String)
- */
- public void writeString(final String val)
- {
- writeInt(val.length());
- for (int i = 0; i < val.length(); i++)
- {
- writeShort((short)val.charAt(i));
- }
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#writeUTF(java.lang.String)
- */
- public void writeUTF(final String utf) throws Exception
- {
- UTF8Util.saveUTF(this, utf);
- }
-
- /* (non-Javadoc)
- * @see org.hornetq.core.remoting.spi.HornetQBuffer#getUnderlyingBuffer()
- */
- public Object getUnderlyingBuffer()
- {
- return buffer;
- }
-
- public HornetQBuffer copy()
- {
- return new ChannelBufferWrapper(buffer.copy(0, buffer.capacity()));
- }
-
- public HornetQBuffer slice(int index, int length)
- {
- return new ChannelBufferWrapper(buffer.slice(index, length));
- }
-
-}
Modified:
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -12,6 +12,7 @@
*/
package org.hornetq.integration.transports.netty;
+import org.hornetq.core.buffers.impl.ChannelBufferWrapper;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.BufferHandler;
Modified:
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQFrameDecoder.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQFrameDecoder.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/HornetQFrameDecoder.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,6 +15,7 @@
import static org.hornetq.utils.DataConstants.SIZE_INT;
+import org.hornetq.core.buffers.impl.ChannelBufferWrapper;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.utils.DataConstants;
Modified:
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/integration/transports/netty/NettyConnection.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,12 +13,12 @@
package org.hornetq.integration.transports.netty;
-import org.hornetq.core.buffers.HornetQChannelBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
+import org.hornetq.core.buffers.impl.ChannelBufferWrapper;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
@@ -102,11 +102,7 @@
public HornetQBuffer createBuffer(final int size)
{
- ChannelBuffer cb = org.jboss.netty.buffer.ChannelBuffers.dynamicBuffer(size);
-
- HornetQBuffer buff = new ChannelBufferWrapper(cb);
-
- return buff;
+ return new ChannelBufferWrapper(ChannelBuffers.dynamicBuffer(size));
}
public Object getID()
@@ -121,24 +117,7 @@
public void write(HornetQBuffer buffer, final boolean flush)
{
- Object underlying = buffer.getUnderlyingBuffer();
-
- if (underlying instanceof ChannelBuffer == false)
- {
- //Need to copy it
-
- //TODO we can avoid this if we use Netty buffers everywhere!!
-
- HornetQBuffer hq = (HornetQBuffer)underlying;
-
- ChannelBuffer cb = ChannelBuffers.copiedBuffer(hq.array());
-
- cb.setIndex(hq.readerIndex(), hq.writerIndex());
-
- underlying = cb;
- }
-
- ChannelFuture future = channel.write(underlying);
+ ChannelFuture future = channel.write(buffer.channelBuffer());
if (flush)
{
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQBytesMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -19,10 +19,10 @@
import javax.jms.MessageEOFException;
import javax.jms.MessageFormatException;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* This class implements javax.jms.BytesMessage.
@@ -157,7 +157,7 @@
checkRead();
try
{
- return getBuffer().readChar();
+ return (char)getBuffer().readShort();
}
catch (IndexOutOfBoundsException e)
{
@@ -196,7 +196,7 @@
checkRead();
try
{
- return getBuffer().readFloat();
+ return Float.intBitsToFloat(getBuffer().readInt());
}
catch (IndexOutOfBoundsException e)
{
@@ -209,7 +209,7 @@
checkRead();
try
{
- return getBuffer().readDouble();
+ return Double.longBitsToDouble(getBuffer().readLong());
}
catch (IndexOutOfBoundsException e)
{
@@ -279,7 +279,7 @@
public void writeChar(final char value) throws JMSException
{
checkWrite();
- getBuffer().writeChar(value);
+ getBuffer().writeShort((short)value);
}
public void writeInt(final int value) throws JMSException
@@ -297,13 +297,13 @@
public void writeFloat(final float value) throws JMSException
{
checkWrite();
- getBuffer().writeFloat(value);
+ getBuffer().writeInt(Float.floatToIntBits(value));
}
public void writeDouble(final double value) throws JMSException
{
checkWrite();
- getBuffer().writeDouble(value);
+ getBuffer().writeLong(Double.doubleToLongBits(value));
}
public void writeUTF(final String value) throws JMSException
Modified: branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -33,6 +33,7 @@
import javax.jms.MessageNotReadableException;
import javax.jms.MessageNotWriteableException;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientSession;
@@ -41,7 +42,6 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.PropertyConversionException;
import org.hornetq.core.message.impl.MessageImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.jms.HornetQDestination;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQStreamMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -18,10 +18,12 @@
import javax.jms.MessageFormatException;
import javax.jms.StreamMessage;
+import org.hornetq.core.buffers.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientSession;
+import org.hornetq.core.client.impl.ClientMessageImpl;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.DataConstants;
/**
@@ -84,9 +86,11 @@
// Ignore
}
}
-
+
+ // For testing only
public HornetQStreamMessage()
{
+ this.message = new ClientMessageImpl((byte)0, false, 0, 0, (byte)4, 1500);
}
// Public --------------------------------------------------------
@@ -180,7 +184,7 @@
switch (type)
{
case DataConstants.CHAR:
- return getBuffer().readChar();
+ return (char)getBuffer().readShort();
default:
throw new MessageFormatException("Invalid conversion");
}
@@ -256,7 +260,7 @@
switch (type)
{
case DataConstants.FLOAT:
- return getBuffer().readFloat();
+ return Float.intBitsToFloat(getBuffer().readInt());
case DataConstants.STRING:
String s = getBuffer().readNullableString();
return Float.parseFloat(s);
@@ -279,9 +283,9 @@
switch (type)
{
case DataConstants.FLOAT:
- return getBuffer().readFloat();
+ return Float.intBitsToFloat(getBuffer().readInt());
case DataConstants.DOUBLE:
- return getBuffer().readDouble();
+ return Double.longBitsToDouble(getBuffer().readLong());
case DataConstants.STRING:
String s = getBuffer().readNullableString();
return Double.parseDouble(s);
@@ -310,15 +314,15 @@
case DataConstants.SHORT:
return String.valueOf(getBuffer().readShort());
case DataConstants.CHAR:
- return String.valueOf(getBuffer().readChar());
+ return String.valueOf((char)getBuffer().readShort());
case
DataConstants.INT:
return String.valueOf(getBuffer().readInt());
case DataConstants.LONG:
return String.valueOf(getBuffer().readLong());
case DataConstants.FLOAT:
- return String.valueOf(getBuffer().readFloat());
+ return String.valueOf(Float.intBitsToFloat(getBuffer().readInt()));
case DataConstants.DOUBLE:
- return String.valueOf(getBuffer().readDouble());
+ return String.valueOf(Double.longBitsToDouble(getBuffer().readLong()));
case DataConstants.STRING:
return getBuffer().readNullableString();
default:
@@ -380,15 +384,15 @@
case DataConstants.SHORT:
return getBuffer().readShort();
case DataConstants.CHAR:
- return getBuffer().readChar();
+ return (char)getBuffer().readShort();
case
DataConstants.INT:
return getBuffer().readInt();
case DataConstants.LONG:
return getBuffer().readLong();
case DataConstants.FLOAT:
- return getBuffer().readFloat();
+ return Float.intBitsToFloat(getBuffer().readInt());
case DataConstants.DOUBLE:
- return getBuffer().readDouble();
+ return Double.longBitsToDouble(getBuffer().readLong());
case DataConstants.STRING:
return getBuffer().readNullableString();
case DataConstants.BYTES:
@@ -426,7 +430,7 @@
{
checkWrite();
getBuffer().writeByte(DataConstants.CHAR);
- getBuffer().writeChar(value);
+ getBuffer().writeShort((short)value);
}
public void writeInt(final int value) throws JMSException
@@ -447,14 +451,14 @@
{
checkWrite();
getBuffer().writeByte(DataConstants.FLOAT);
- getBuffer().writeFloat(value);
+ getBuffer().writeInt(Float.floatToIntBits(value));
}
public void writeDouble(final double value) throws JMSException
{
checkWrite();
getBuffer().writeByte(DataConstants.DOUBLE);
- getBuffer().writeDouble(value);
+ getBuffer().writeLong(Double.doubleToLongBits(value));
}
public void writeString(final String value) throws JMSException
@@ -562,7 +566,7 @@
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
-
+
private HornetQBuffer getBuffer()
{
return message.getBodyBuffer();
Modified:
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java
===================================================================
---
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/src/main/org/hornetq/jms/client/HornetQTextMessage.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -18,10 +18,10 @@
import javax.jms.JMSException;
import javax.jms.TextMessage;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.utils.SimpleString;
/**
Modified: branches/20-optimisation/src/main/org/hornetq/utils/TypedProperties.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/utils/TypedProperties.java 2009-11-23
21:22:09 UTC (rev 8386)
+++ branches/20-optimisation/src/main/org/hornetq/utils/TypedProperties.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -40,9 +40,9 @@
import java.util.Set;
import java.util.Map.Entry;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.PropertyConversionException;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
@@ -896,7 +896,7 @@
public FloatValue(final HornetQBuffer buffer)
{
- val = buffer.readFloat();
+ val = Float.intBitsToFloat(buffer.readInt());
}
public Object getValue()
@@ -907,7 +907,7 @@
public void write(final HornetQBuffer buffer)
{
buffer.writeByte(FLOAT);
- buffer.writeFloat(val);
+ buffer.writeInt(Float.floatToIntBits(val));
}
public int encodeSize()
@@ -928,7 +928,7 @@
public DoubleValue(final HornetQBuffer buffer)
{
- val = buffer.readDouble();
+ val = Double.longBitsToDouble(buffer.readLong());
}
public Object getValue()
@@ -939,7 +939,7 @@
public void write(final HornetQBuffer buffer)
{
buffer.writeByte(DOUBLE);
- buffer.writeDouble(val);
+ buffer.writeLong(Double.doubleToLongBits(val));
}
public int encodeSize()
@@ -959,7 +959,7 @@
public CharValue(final HornetQBuffer buffer)
{
- val = buffer.readChar();
+ val = (char)buffer.readShort();
}
public Object getValue()
@@ -970,7 +970,7 @@
public void write(final HornetQBuffer buffer)
{
buffer.writeByte(CHAR);
- buffer.writeChar(val);
+ buffer.writeShort((short)val);
}
public int encodeSize()
Modified: branches/20-optimisation/src/main/org/hornetq/utils/UTF8Util.java
===================================================================
--- branches/20-optimisation/src/main/org/hornetq/utils/UTF8Util.java 2009-11-23 21:22:09
UTC (rev 8386)
+++ branches/20-optimisation/src/main/org/hornetq/utils/UTF8Util.java 2009-11-23 23:27:50
UTC (rev 8387)
@@ -16,8 +16,8 @@
import java.io.IOException;
import java.lang.ref.SoftReference;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
Modified:
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
===================================================================
---
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -33,7 +33,7 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
-import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientProducer;
@@ -45,7 +45,6 @@
import org.hornetq.core.remoting.FailureListener;
import org.hornetq.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
import org.hornetq.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.jms.client.HornetQBytesMessage;
import org.hornetq.jms.client.HornetQMapMessage;
import org.hornetq.jms.client.HornetQMessage;
@@ -672,8 +671,7 @@
public void testCopyOnJBossMessage() throws JMSException
{
- HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
- ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
+ ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, 1000);
ClientSession session = new FakeSession(clientMessage);
HornetQMessage jbossMessage = HornetQMessage.createMessage(clientMessage,
session);
jbossMessage.clearProperties();
@@ -688,8 +686,7 @@
public void testCopyOnForeignMessage() throws JMSException
{
- HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
- ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
+ ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, 1000);
ClientSession session = new FakeSession(clientMessage);
Message foreignMessage = new SimpleJMSMessage();
@@ -702,8 +699,7 @@
public void testCopyOnForeignBytesMessage() throws JMSException
{
- HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
- ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
+ ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, 1000);
ClientSession session = new FakeSession(clientMessage);
BytesMessage foreignBytesMessage = new SimpleJMSBytesMessage();
@@ -722,8 +718,7 @@
public void testCopyOnForeignMapMessage() throws JMSException
{
- HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
- ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
+ ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, 1000);
ClientSession session = new FakeSession(clientMessage);
MapMessage foreignMapMessage = new SimpleJMSMapMessage();
foreignMapMessage.setInt("int", 1);
@@ -736,9 +731,8 @@
public void testCopyOnForeignObjectMessage() throws JMSException
- {
- HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
- ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
+ {
+ ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, 1000);
ClientSession session = new FakeSession(clientMessage);
ObjectMessage foreignObjectMessage = new SimpleJMSObjectMessage();
@@ -751,8 +745,7 @@
public void testCopyOnForeignStreamMessage() throws JMSException
{
- HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
- ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
+ ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, 1000);
ClientSession session = new FakeSession(clientMessage);
StreamMessage foreignStreamMessage = new SimpleJMSStreamMessage();
@@ -768,8 +761,7 @@
public void testCopyOnForeignTextMessage() throws JMSException
{
- HornetQBuffer body = HornetQChannelBuffers.buffer(1024);
- ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, body);
+ ClientMessage clientMessage = new ClientMessageImpl(HornetQTextMessage.TYPE, true,
0, System.currentTimeMillis(), (byte)4, 1000);
ClientSession session = new FakeSession(clientMessage);
TextMessage foreignTextMessage = new SimpleJMSTextMessage();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/InterceptorTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/InterceptorTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/InterceptorTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -77,7 +77,7 @@
{
SessionSendMessage p = (SessionSendMessage)packet;
- ServerMessage sm = p.getServerMessage();
+ ServerMessage sm = (ServerMessage)p.getMessage();
sm.putStringProperty(key, "orange");
}
@@ -109,7 +109,7 @@
{
SessionReceiveMessage p = (SessionReceiveMessage)packet;
- ClientMessage cm = p.getClientMessage();
+ ClientMessage cm = (ClientMessage)p.getMessage();
cm.putStringProperty(key, "orange");
}
@@ -171,7 +171,7 @@
{
SessionSendMessage p = (SessionSendMessage)packet;
- ServerMessage sm = p.getServerMessage();
+ ServerMessage sm = (ServerMessage)p.getMessage();
sm.putIntProperty(key, num);
@@ -224,7 +224,7 @@
{
SessionReceiveMessage p = (SessionReceiveMessage)packet;
- Message sm = p.getClientMessage();
+ Message sm = p.getMessage();
sm.putIntProperty(key, num);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AckBatchSizeTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AckBatchSizeTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/AckBatchSizeTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -92,7 +92,7 @@
ClientMessage m = consumer.receive(5000);
Queue q = (Queue)server.getPostOffice().getBinding(queueA).getBindable();
- assertEquals(numMessages, q.getDeliveringCount());
+ assertEquals(1, q.getDeliveringCount());
m.acknowledge();
assertEquals(0, q.getDeliveringCount());
sendSession.close();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/CoreClientTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,6 +13,7 @@
package org.hornetq.tests.integration.client;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientProducer;
@@ -23,7 +24,6 @@
import org.hornetq.core.config.TransportConfiguration;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQ;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.jms.client.HornetQTextMessage;
@@ -79,7 +79,7 @@
ClientProducer producer = session.createProducer(QUEUE);
- final int numMessages = 10;
+ final int numMessages = 1000;
for (int i = 0; i < numMessages; i++)
{
@@ -117,8 +117,6 @@
assertEquals("testINVMCoreClient", buffer.readString());
message2.acknowledge();
-
- log.info("got message " + i);
}
session.close();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/InVMNonPersistentMessageBufferTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -63,7 +63,18 @@
assertEquals(body, received.getBodyBuffer().readString());
}
+
+ public void testSimpleSendReceiveWithEmptyBody() throws Exception
+ {
+ ClientMessage message = session.createClientMessage(false);
+
+ ClientMessage received = sendAndReceive(message);
+ assertNotNull(received);
+
+ assertEquals(0, received.getBodySize());
+ }
+
public void testSendSameMessageMultipleTimes() throws Exception
{
ClientMessage message = session.createClientMessage(false);
@@ -74,8 +85,12 @@
int bodySize = message.getBodySize();
+ log.info("body size is " + bodySize);
+
for (int i = 0; i < 10; i++)
{
+ log.info("sending " + i);
+
ClientMessage received = sendAndReceive(message);
assertNotNull(received);
@@ -94,6 +109,7 @@
for (int i = 0; i < 10; i++)
{
+ log.info("iteration " + i);
final String body = RandomUtil.randomString();
message.getBodyBuffer().writeString(body);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/LargeMessageTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -19,7 +19,10 @@
import javax.transaction.xa.Xid;
import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
@@ -31,9 +34,8 @@
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.Message;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.persistence.impl.journal.LargeServerMessageImpl;
-import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressSettings;
@@ -53,6 +55,13 @@
*/
public class LargeMessageTest extends LargeMessageTestBase
{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite();
+
+ return suite;
+ }
+
// Constants -----------------------------------------------------
final static int RECEIVE_WAIT_TIME = 60000;
@@ -304,9 +313,9 @@
assertNotNull(msg);
msg.acknowledge();
assertEquals(1, msg.getDeliveryCount());
-
+
log.info("body buffer is " + msg.getBodyBuffer());
-
+
for (int i = 0; i < messageSize; i++)
{
assertEquals(getSamplebyte(i), msg.getBodyBuffer().readByte());
@@ -2202,29 +2211,24 @@
ClientProducer producer = session.createProducer(ADDRESS);
- // printBuffer("body to be sent : " , body);
-
ClientMessage message = null;
HornetQBuffer body = null;
for (int i = 0; i < 100; i++)
{
- HornetQBuffer bodyLocal = HornetQChannelBuffers.buffer(DataConstants.SIZE_INT
* numberOfBytes);
-
+ message = session.createClientMessage(true);
+
for (int j = 1; j <= numberOfBytes; j++)
{
- bodyLocal.writeInt(j);
+ message.getBodyBuffer().writeInt(j);
}
if (i == 0)
{
- body = bodyLocal;
+ body = message.getBodyBuffer();
}
-
- message = session.createClientMessage(true);
- message.setBuffer(bodyLocal);
-
+
producer.send(message);
}
@@ -2262,12 +2266,13 @@
try
{
- assertEqualsByteArrays(body.writerIndex(), body.array(),
message2.getBodyBuffer().array());
+ assertEqualsByteArrays(body.writerIndex(), body.toByteBuffer().array(),
message2.getBodyBuffer().toByteBuffer().
+ array());
}
catch (AssertionFailedError e)
{
- log.info("Expected buffer:" + dumbBytesHex(body.array(), 40));
- log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().array(), 40));
+ log.info("Expected buffer:" +
dumbBytesHex(body.toByteBuffer().array(), 40));
+ log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40));
throw e;
}
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -19,6 +19,7 @@
import junit.framework.AssertionFailedError;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
@@ -29,7 +30,6 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.paging.impl.TestSupportPageStore;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
@@ -130,6 +130,8 @@
producer.send(message);
}
+
+ log.info("** sent messages");
session.close();
@@ -175,7 +177,7 @@
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body, 40));
- log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().array(), 40));
+ log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40));
throw e;
}
}
@@ -455,7 +457,7 @@
catch (AssertionFailedError e)
{
log.info("Expected buffer:" + dumbBytesHex(body, 40));
- log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().array(), 40));
+ log.info("Arriving buffer:" +
dumbBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40));
throw e;
}
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/SelfExpandingBufferTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,13 +13,13 @@
package org.hornetq.tests.integration.client;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientProducer;
import org.hornetq.core.client.ClientSession;
import org.hornetq.core.client.ClientSessionFactory;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/TemporaryQueueTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/TemporaryQueueTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/client/TemporaryQueueTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -72,7 +72,9 @@
session.createTemporaryQueue(address, queue);
ClientProducer producer = session.createProducer(address);
- producer.send(session.createClientMessage(false));
+ ClientMessage msg = session.createClientMessage(false);
+
+ producer.send(msg);
session.start();
ClientConsumer consumer = session.createConsumer(queue);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/DummyInterceptor.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/DummyInterceptor.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/clientcrash/DummyInterceptor.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -57,8 +57,8 @@
if (packet instanceof SessionReceiveMessage)
{
SessionReceiveMessage deliver = (SessionReceiveMessage)packet;
- log.debug("msg = " +
deliver.getServerMessage().getClass().getName());
- deliver.getServerMessage().putStringProperty(new
SimpleString("DummyInterceptor"), new SimpleString("was here"));
+ log.debug("msg = " + deliver.getMessage().getClass().getName());
+ deliver.getMessage().putStringProperty(new
SimpleString("DummyInterceptor"), new SimpleString("was here"));
}
}
return true;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/BridgeTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -666,8 +666,6 @@
{
ClientMessage message = session0.createClientMessage(false);
- message.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
-
message.putIntProperty(propKey, i);
producer0.send(message);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/bridge/SimpleTransformer.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -14,8 +14,8 @@
package org.hornetq.tests.integration.cluster.bridge;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.cluster.Transformer;
import org.hornetq.utils.SimpleString;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -823,7 +823,7 @@
message.acknowledge();
}
- // log.info("consumer " + consumerIDs[i] +" returns "
+ count);
+ log.info("consumer " + consumerIDs[i] +" returns " +
count);
}
else
{
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -166,24 +166,33 @@
setupCluster();
startServers();
+
+ log.info("*** started servers");
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
setupSessionFactory(2, isNetty());
setupSessionFactory(3, isNetty());
setupSessionFactory(4, isNetty());
+
+ log.info("** created session factories");
createQueue(0, "queues.testaddress", "queue0", null, false);
+
createQueue(1, "queues.testaddress", "queue0", null, false);
createQueue(2, "queues.testaddress", "queue0", null, false);
createQueue(3, "queues.testaddress", "queue0", null, false);
createQueue(4, "queues.testaddress", "queue0", null, false);
+
+ log.info("**** created queues");
addConsumer(0, 0, "queue0", null);
addConsumer(1, 1, "queue0", null);
addConsumer(2, 2, "queue0", null);
addConsumer(3, 3, "queue0", null);
addConsumer(4, 4, "queue0", null);
+
+ log.info("*** created consumers");
waitForBindings(0, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 1, true);
@@ -197,7 +206,13 @@
waitForBindings(3, "queues.testaddress", 4, 4, false);
waitForBindings(4, "queues.testaddress", 4, 4, false);
+ log.info("** sending messages");
+
send(0, "queues.testaddress", 10, false, null);
+
+ log.info("** sent messages");
+
+ // this.checkReceive(0, 1, 2, 3, 4);
verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2, 3, 4);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -15,9 +15,9 @@
import junit.framework.TestSuite;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A LargeMessageFailoverTest
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/PagingFailoverTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -114,7 +114,6 @@
session.commit();
}
ClientMessage msg = session.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.buffer(1024));
msg.putIntProperty(new SimpleString("key"), i);
prod.send(msg);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -16,7 +16,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientProducer;
@@ -78,8 +77,6 @@
{
ClientMessage msg = sessionOne.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
-
msg.putIntProperty(new SimpleString("key"), i);
producer.send(msg);
@@ -181,8 +178,7 @@
for (int i = 0; i < 100; i++)
{
- ClientMessage msg = sessionOne.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+ ClientMessage msg = sessionOne.createClientMessage(true);
msg.putIntProperty(new SimpleString("key"), i);
producer.send(msg);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/NettyHttpTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/NettyHttpTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/http/NettyHttpTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -20,13 +20,13 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.impl.AbstractBufferHandler;
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.integration.transports.netty.NettyAcceptor;
import org.hornetq.integration.transports.netty.NettyConnector;
import org.hornetq.integration.transports.netty.TransportConstants;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -24,6 +24,7 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientMessage;
@@ -34,7 +35,6 @@
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.tests.util.ServiceTestBase;
@@ -590,7 +590,7 @@
protected HornetQBuffer createLargeBuffer(final int numberOfIntegers)
{
- HornetQBuffer body = HornetQChannelBuffers.buffer(DataConstants.SIZE_INT *
numberOfIntegers);
+ HornetQBuffer body = HornetQChannelBuffers.fixedBuffer(DataConstants.SIZE_INT *
numberOfIntegers);
for (int i = 0; i < numberOfIntegers; i++)
{
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/mock/MockConnector.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/mock/MockConnector.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/largemessage/mock/MockConnector.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -17,12 +17,12 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.remoting.impl.invm.InVMConnection;
import org.hornetq.core.remoting.impl.invm.InVMConnector;
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* A MockConnector
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementHelperTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -149,7 +149,6 @@
Object[] params = new Object[] { i, s, d, b, l, map, strArray, maps };
Message msg = new ClientMessageImpl();
- msg.setBuffer(HornetQChannelBuffers.dynamicBuffer(1024));
ManagementHelper.putOperationInvocation(msg, resource, operationName, params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
@@ -215,8 +214,7 @@
Object[] params = new Object[] { "hello", map };
- Message msg = new ClientMessageImpl();
- msg.setBuffer(HornetQChannelBuffers.dynamicBuffer(1024));
+ Message msg = new ClientMessageImpl();
ManagementHelper.putOperationInvocation(msg, resource, operationName, params);
Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementServiceImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementServiceImplTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/management/ManagementServiceImplTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -16,6 +16,7 @@
import static org.hornetq.tests.util.RandomUtil.randomSimpleString;
import static org.hornetq.tests.util.RandomUtil.randomString;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.management.impl.ManagementHelper;
import org.hornetq.core.config.Configuration;
@@ -25,7 +26,6 @@
import org.hornetq.core.management.QueueControl;
import org.hornetq.core.management.ResourceNames;
import org.hornetq.core.management.impl.ManagementServiceImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.HornetQ;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
@@ -67,9 +67,7 @@
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl();
- HornetQBuffer body = HornetQChannelBuffers.buffer(2048);
- message.setBuffer(body);
+ ServerMessage message = new ServerMessageImpl(1, 100);
ManagementHelper.putOperationInvocation(message,
ResourceNames.CORE_SERVER,
"createQueue",
@@ -92,9 +90,7 @@
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl();
- HornetQBuffer body = HornetQChannelBuffers.buffer(2048);
- message.setBuffer(body);
+ ServerMessage message = new ServerMessageImpl(1, 100);
ManagementHelper.putOperationInvocation(message,
ResourceNames.CORE_SERVER,
"thereIsNoSuchOperation");
@@ -116,9 +112,7 @@
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl();
- HornetQBuffer body = HornetQChannelBuffers.buffer(2048);
- message.setBuffer(body);
+ ServerMessage message = new ServerMessageImpl(1, 100);
ManagementHelper.putOperationInvocation(message,
"Resouce.Does.Not.Exist",
"toString");
@@ -140,9 +134,8 @@
server.start();
// invoke attribute and operation on the server
- ServerMessage message = new ServerMessageImpl();
- HornetQBuffer body = HornetQChannelBuffers.buffer(2048);
- message.setBuffer(body);
+ ServerMessage message = new ServerMessageImpl(1, 100);
+
ManagementHelper.putAttribute(message, ResourceNames.CORE_SERVER,
"attribute.Does.Not.Exist");
ServerMessage reply = server.getManagementService().handleMessage(message);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/integration/replication/ReplicationTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -27,6 +27,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientSessionFactory;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
@@ -54,7 +55,6 @@
import org.hornetq.core.remoting.Packet;
import org.hornetq.core.remoting.RemotingConnection;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.replication.impl.ReplicatedJournal;
import org.hornetq.core.replication.impl.ReplicationManagerImpl;
import org.hornetq.core.server.HornetQServer;
@@ -288,12 +288,11 @@
assertEquals(0, manager.getActiveTokens().size());
- ServerMessage msg = new ServerMessageImpl();
+ ServerMessage msg = new ServerMessageImpl(1, 10);
SimpleString dummy = new SimpleString("dummy");
msg.setDestination(dummy);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[10]));
-
+
replicatedJournal.appendAddRecordTransactional(23, 24, (byte)1, new
FakeData());
PagedMessage pgmsg = new PagedMessageImpl(msg, -1);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/CompactingStressTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -186,7 +186,7 @@
byte[] buffer = new byte[10 * 1024];
ClientMessage msg = session.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(buffer));
+
for (int i = 0; i < TOT_AD3; i++)
{
producer.send(msg);
@@ -246,7 +246,7 @@
slowProd.send(session.createClientMessage(true));
}
ClientMessage msg = session.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+
prod.send(msg);
}
sessionSlow.commit();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/LargeJournalStressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/LargeJournalStressTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/LargeJournalStressTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -116,8 +116,7 @@
}
slowProd.send(session.createClientMessage(true));
}
- ClientMessage msg = session.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+ ClientMessage msg = session.createClientMessage(true);
prod.send(msg);
}
sessionSlow.commit();
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/MultiThreadConsumerStressTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -248,8 +248,7 @@
{
System.out.println(Thread.currentThread().getName() + "::received
#" + i);
}
- ClientMessage msg = session.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+ ClientMessage msg = session.createClientMessage(true);
prod.send(msg);
}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/stress/journal/NIOMultiThreadCompactorStressTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -455,7 +455,7 @@
// System.out.println(Thread.currentThread().getName() + "::sent
#" + i);
}
ClientMessage msg = session.createClientMessage(true);
- msg.setBuffer(HornetQChannelBuffers.wrappedBuffer(new byte[1024]));
+
prod.send(msg);
}
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/timing/util/UTF8Test.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/timing/util/UTF8Test.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/timing/util/UTF8Test.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.tests.timing.util;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.UTF8Util;
@@ -47,7 +47,7 @@
public void testWriteUTF() throws Exception
{
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(10 * 1024);
+ HornetQBuffer buffer = HornetQChannelBuffers.fixedBuffer(10 * 1024);
long start = System.currentTimeMillis();
@@ -72,7 +72,7 @@
public void testReadUTF() throws Exception
{
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(10 * 1024);
+ HornetQBuffer buffer = HornetQChannelBuffers.fixedBuffer(10 * 1024);
buffer.writeUTF(str);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/client/impl/LargeMessageBufferTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -25,7 +25,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import org.hornetq.core.buffers.HornetQChannelBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.MessageHandler;
@@ -114,7 +114,7 @@
{
LargeMessageBufferImpl buffer = create15BytesSample();
- HornetQChannelBuffer dstBuffer = HornetQChannelBuffers.buffer(20);
+ HornetQBuffer dstBuffer = HornetQChannelBuffers.fixedBuffer(20);
dstBuffer.setIndex(0, 5);
@@ -168,7 +168,7 @@
public void testReadData() throws Exception
{
- HornetQChannelBuffer dynamic = HornetQChannelBuffers.dynamicBuffer(1);
+ HornetQBuffer dynamic = HornetQChannelBuffers.dynamicBuffer(1);
String str1 = RandomUtil.randomString();
String str2 = RandomUtil.randomString();
@@ -180,7 +180,7 @@
dynamic.writeDouble(d1);
dynamic.writeFloat(f1);
- LargeMessageBufferImpl readBuffer = splitBuffer(3, dynamic.array());
+ LargeMessageBufferImpl readBuffer = splitBuffer(3,
dynamic.toByteBuffer().array());
assertEquals(str1, readBuffer.readUTF());
assertEquals(str2, readBuffer.readString());
@@ -197,7 +197,7 @@
{
clearData();
- HornetQChannelBuffer dynamic = HornetQChannelBuffers.dynamicBuffer(1);
+ HornetQBuffer dynamic = HornetQChannelBuffers.dynamicBuffer(1);
String str1 = RandomUtil.randomString();
String str2 = RandomUtil.randomString();
@@ -209,7 +209,7 @@
dynamic.writeDouble(d1);
dynamic.writeFloat(f1);
- LargeMessageBufferImpl readBuffer = splitBuffer(3, dynamic.array(),
getTestFile());
+ LargeMessageBufferImpl readBuffer = splitBuffer(3, dynamic.toByteBuffer().array(),
getTestFile());
assertEquals(str1, readBuffer.readUTF());
assertEquals(str2, readBuffer.readString());
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/filter/impl/FilterTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/filter/impl/FilterTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/filter/impl/FilterTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -102,16 +102,14 @@
public void testHQSize() throws Exception
{
message.setDestination(RandomUtil.randomSimpleString());
- message.setBuffer(HornetQChannelBuffers.wrappedBuffer(RandomUtil.randomBytes(1)));
+
assertTrue(message.getEncodeSize() < 1024);
-
+
Filter moreThan128 = FilterImpl.createFilter(new SimpleString("HQSize >
128"));
Filter lessThan1024 = FilterImpl.createFilter(new SimpleString("HQSize <
1024"));
assertFalse(moreThan128.match(message));
assertTrue(lessThan1024.match(message));
-
-
message.setBuffer(HornetQChannelBuffers.wrappedBuffer(RandomUtil.randomBytes(1024)));
assertTrue(moreThan128.match(message));
assertFalse(lessThan1024.match(message));
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -20,12 +20,12 @@
import java.util.concurrent.ConcurrentHashMap;
import org.hornetq.core.asyncio.BufferCallback;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.IOCompletion;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.journal.impl.TimedBuffer;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
*
@@ -607,7 +607,7 @@
*/
public void write(HornetQBuffer bytes, boolean sync, IOCompletion callback) throws
Exception
{
- writeDirect(ByteBuffer.wrap(bytes.array()), sync, callback);
+ writeDirect(bytes.toByteBuffer(), sync, callback);
}
@@ -616,7 +616,7 @@
*/
public void write(HornetQBuffer bytes, boolean sync) throws Exception
{
- writeDirect(ByteBuffer.wrap(bytes.array()), sync);
+ writeDirect(bytes.toByteBuffer(), sync);
}
/* (non-Javadoc)
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/SimpleEncoding.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/SimpleEncoding.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/journal/impl/fakes/SimpleEncoding.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.tests.unit.core.journal.impl.fakes;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.EncodingSupport;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
* Provides a SimpleEncoding with a Fake Payload
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/message/impl/MessageImplTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -25,13 +25,9 @@
import java.util.Set;
-import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.client.impl.ClientMessageImpl;
-import org.hornetq.core.journal.EncodingSupport;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.Message;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.impl.ServerMessageImpl;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.SimpleString;
@@ -53,14 +49,13 @@
{
bytes[i] = randomByte();
}
- HornetQBuffer body = HornetQChannelBuffers.wrappedBuffer(bytes);
-
+
final byte type = randomByte();
final boolean durable = randomBoolean();
final long expiration = randomLong();
final long timestamp = randomLong();
final byte priority = randomByte();
- Message message1 = new ClientMessageImpl(type, durable, expiration, timestamp,
priority, body);
+ Message message1 = new ClientMessageImpl(type, durable, expiration, timestamp,
priority, 100);
Message message = message1;
@@ -90,9 +85,7 @@
message.setPriority(priority2);
assertEquals(priority2, message.getPriority());
-
- message.setBuffer(body);
- assertTrue(body == message.getBodyBuffer());
+
}
}
@@ -254,7 +247,7 @@
assertEquals(msg1.getType(), msg2.getType());
- assertEqualsByteArrays(msg1.getBodyBuffer().array(), msg2.getBodyBuffer().array());
+ assertEqualsByteArrays(msg1.getBodyBuffer().toByteBuffer().array(),
msg2.getBodyBuffer().toByteBuffer().array());
assertEquals(msg1.getDestination(), msg2.getDestination());
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PageImplTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -17,7 +17,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.hornetq.core.buffers.HornetQChannelBuffers;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.journal.SequentialFile;
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
@@ -25,7 +25,6 @@
import org.hornetq.core.paging.impl.PageImpl;
import org.hornetq.core.paging.impl.PagedMessageImpl;
import org.hornetq.core.persistence.impl.nullpm.NullStorageManager;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.impl.ServerMessageImpl;
import org.hornetq.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
@@ -109,7 +108,7 @@
assertEquals(simpleDestination,
(msgs.get(i).getMessage(null)).getDestination());
- assertEqualsByteArrays(buffers.get(i).array(),
(msgs.get(i).getMessage(null)).getBodyBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(),
(msgs.get(i).getMessage(null)).getBodyBuffer().toByteBuffer().array());
}
impl.delete();
@@ -182,7 +181,7 @@
assertEquals(simpleDestination,
(msgs.get(i).getMessage(null)).getDestination());
- assertEqualsByteArrays(buffers.get(i).array(),
(msgs.get(i).getMessage(null)).getBodyBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(),
(msgs.get(i).getMessage(null)).getBodyBuffer().toByteBuffer().array());
}
impl.delete();
@@ -208,20 +207,15 @@
for (int i = 0; i < numberOfElements; i++)
{
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(10);
+ ServerMessage msg = new ServerMessageImpl(i, 1000);
- for (int j = 0; j < buffer.capacity(); j++)
- {
- //buffer.writeByte(RandomUtil.randomByte());
- buffer.writeByte((byte)'b');
+ for (int j = 0; j < msg.getBodyBuffer().capacity(); j++)
+ {
+ msg.getBodyBuffer().writeByte((byte)'b');
}
- buffers.add(buffer);
+ buffers.add(msg.getBodyBuffer());
- ServerMessage msg = new ServerMessageImpl();
-
- msg.setMessageID(i);
-
msg.setDestination(simpleDestination);
page.write(new PagedMessageImpl(msg));
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingManagerImplTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -90,7 +90,7 @@
assertEquals(1, msgs.size());
- assertEqualsByteArrays(msg.getBodyBuffer().array(),
(msgs.get(0).getMessage(null)).getBodyBuffer().array());
+ assertEqualsByteArrays(msg.getBodyBuffer().toByteBuffer().array(),
(msgs.get(0).getMessage(null)).getBodyBuffer().toByteBuffer().array());
assertTrue(store.isPaging());
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -28,6 +28,7 @@
import javax.transaction.xa.Xid;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.JournalLoadInformation;
import org.hornetq.core.journal.SequentialFile;
@@ -47,7 +48,6 @@
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.PostOffice;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.replication.ReplicationManager;
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.MessageReference;
@@ -107,7 +107,7 @@
assertEquals(nr1, trans.getNumberOfMessages());
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(trans.getEncodeSize());
+ HornetQBuffer buffer = HornetQChannelBuffers.fixedBuffer(trans.getEncodeSize());
trans.encode(buffer);
@@ -295,7 +295,7 @@
for (int i = 0; i < 10; i++)
{
assertEquals(0, msg.get(i).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(i).array(),
msg.get(i).getMessage(null).getBodyBuffer().array());
+ assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(),
msg.get(i).getMessage(null).getBodyBuffer().toByteBuffer().array());
}
}
@@ -366,7 +366,7 @@
for (int i = 0; i < 5; i++)
{
assertEquals(0, msg.get(i).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(pageNr * 5 + i).array(),
msg.get(i).getMessage(null).getBodyBuffer().array());
+ assertEqualsByteArrays(buffers.get(pageNr * 5 + i).toByteBuffer().array(),
msg.get(i).getMessage(null).getBodyBuffer().toByteBuffer().array());
}
}
@@ -410,7 +410,7 @@
assertEquals(0l, msgs.get(0).getMessage(null).getMessageID());
- assertEqualsByteArrays(buffers.get(0).array(),
msgs.get(0).getMessage(null).getBodyBuffer().array());
+ assertEqualsByteArrays(buffers.get(0).toByteBuffer().array(),
msgs.get(0).getMessage(null).getBodyBuffer().toByteBuffer().array());
assertEquals(1, storeImpl.getNumberOfPages());
@@ -596,7 +596,7 @@
buffers2.put(id, msg.getMessage(null));
assertNotNull(msgWritten);
assertEquals(msg.getMessage(null).getDestination(),
msgWritten.getDestination());
- assertEqualsByteArrays(msgWritten.getBodyBuffer().array(),
msg.getMessage(null).getBodyBuffer().array());
+ assertEqualsByteArrays(msgWritten.getBodyBuffer().toByteBuffer().array(),
msg.getMessage(null).getBodyBuffer().toByteBuffer().array());
}
}
@@ -666,7 +666,7 @@
ServerMessage msgWritten = buffers2.remove(id);
assertNotNull(msgWritten);
assertEquals(msg.getMessage(null).getDestination(),
msgWritten.getDestination());
- assertEqualsByteArrays(msgWritten.getBodyBuffer().array(),
msg.getMessage(null).getBodyBuffer().array());
+ assertEqualsByteArrays(msgWritten.getBodyBuffer().toByteBuffer().array(),
msg.getMessage(null).getBodyBuffer().toByteBuffer().array());
}
}
@@ -677,7 +677,7 @@
lastMessages.get(0).getMessage(null).getBodyBuffer().resetReaderIndex();
assertEquals(lastMessages.get(0).getMessage(null).getBodyBuffer().readLong(),
lastMessageId);
-
assertEqualsByteArrays(lastMessages.get(0).getMessage(null).getBodyBuffer().array(),
lastMsg.getBodyBuffer().array());
+
assertEqualsByteArrays(lastMessages.get(0).getMessage(null).getBodyBuffer().toByteBuffer().array(),
lastMsg.getBodyBuffer().toByteBuffer().array());
assertEquals(0, buffers2.size());
@@ -717,7 +717,7 @@
private HornetQBuffer createRandomBuffer(final long id, final int size)
{
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(size + 8);
+ HornetQBuffer buffer = HornetQChannelBuffers.fixedBuffer(size + 8);
buffer.writeLong(id);
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -16,6 +16,7 @@
import java.io.File;
import java.util.ArrayList;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.journal.Journal;
import org.hornetq.core.journal.PreparedTransactionInfo;
@@ -24,7 +25,6 @@
import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
import org.hornetq.core.persistence.impl.journal.BatchingIDGenerator;
import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.tests.util.UnitTestCase;
/**
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -14,12 +14,14 @@
package org.hornetq.tests.unit.core.postoffice.impl;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import javax.transaction.xa.Xid;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.filter.Filter;
import org.hornetq.core.message.BodyEncoder;
@@ -28,7 +30,6 @@
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.BindingType;
import org.hornetq.core.postoffice.impl.BindingsImpl;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.core.server.Bindable;
import org.hornetq.core.server.MessageReference;
import org.hornetq.core.server.Queue;
@@ -891,7 +892,79 @@
}
+ public void setEncodedToBuffer(boolean encoded)
+ {
+ // TODO Auto-generated method stub
+
+ }
+ public void decodeFromBuffer(HornetQBuffer buffer)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public HornetQBuffer encodeToBuffer()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getBodySize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getEndOfMessagePosition()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void saveToOutputStream(OutputStream out) throws HornetQException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setBodyInputStream(InputStream bodyInputStream)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setOutputStream(OutputStream out) throws HornetQException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean waitOutputStreamCompletion(long timeMilliseconds) throws
HornetQException
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void beforeDeliver()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void beforeSend()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void forceCopy()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
}
class FakeFilter implements Filter
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/HornetQBufferTestBase.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/HornetQBufferTestBase.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/HornetQBufferTestBase.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -21,7 +21,7 @@
import static org.hornetq.tests.util.RandomUtil.randomLong;
import static org.hornetq.tests.util.RandomUtil.randomString;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.SimpleString;
@@ -269,9 +269,9 @@
byte[] bytes = randomBytes(128);
wrapper.writeBytes(bytes);
- byte[] array = wrapper.array();
+ byte[] array = wrapper.toByteBuffer().array();
assertEquals(wrapper.capacity(), array.length);
- assertEqualsByteArrays(128, bytes, wrapper.array());
+ assertEqualsByteArrays(128, bytes, wrapper.toByteBuffer().array());
}
public void testRewind() throws Exception
Deleted:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/ByteBufferWrapperTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/ByteBufferWrapperTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/ByteBufferWrapperTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.unit.core.remoting.impl;
-
-import java.nio.ByteBuffer;
-
-import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.tests.unit.core.remoting.HornetQBufferTestBase;
-
-/**
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class ByteBufferWrapperTest extends HornetQBufferTestBase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // HornetQBufferTestBase overrides -----------------------------
-
- @Override
- protected HornetQBuffer createBuffer()
- {
- return HornetQChannelBuffers.wrappedBuffer(ByteBuffer.allocate(512));
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapper2Test.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapper2Test.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapper2Test.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.tests.unit.core.remoting.impl.netty;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.tests.unit.core.remoting.HornetQBufferTestBase;
/**
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapperTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapperTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/ChannelBufferWrapperTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -13,8 +13,8 @@
package org.hornetq.tests.unit.core.remoting.impl.netty;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.integration.transports.netty.ChannelBufferWrapper;
+import org.hornetq.core.buffers.HornetQBuffer;
+import org.hornetq.core.buffers.impl.ChannelBufferWrapper;
import org.hornetq.tests.unit.core.remoting.HornetQBufferTestBase;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -16,6 +16,7 @@
import java.util.Map;
import java.util.concurrent.Executors;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.impl.AbstractBufferHandler;
@@ -23,7 +24,6 @@
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.integration.transports.netty.NettyAcceptor;
import org.hornetq.integration.transports.netty.NettyAcceptorFactory;
import org.hornetq.tests.util.UnitTestCase;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -17,13 +17,13 @@
import java.util.Map;
import java.util.concurrent.Executors;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.impl.AbstractBufferHandler;
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.integration.transports.netty.NettyAcceptor;
import org.hornetq.integration.transports.netty.TransportConstants;
import org.hornetq.tests.util.UnitTestCase;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -19,11 +19,11 @@
import java.util.LinkedList;
import java.util.List;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.integration.transports.netty.NettyConnection;
import org.hornetq.tests.util.UnitTestCase;
import org.jboss.netty.channel.Channel;
@@ -60,8 +60,7 @@
NettyConnection conn = new NettyConnection(channel, new MyListener());
conn.write(buff);
- assertEquals(1, channel.getWritten().size());
- assertEquals(buff.getUnderlyingBuffer(), channel.getWritten().get(0));
+ assertEquals(1, channel.getWritten().size());
}
public void testCreateBuffer() throws Exception
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -17,12 +17,12 @@
import java.util.Map;
import java.util.concurrent.Executors;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.exception.HornetQException;
import org.hornetq.core.remoting.impl.AbstractBufferHandler;
import org.hornetq.core.remoting.spi.BufferHandler;
import org.hornetq.core.remoting.spi.Connection;
import org.hornetq.core.remoting.spi.ConnectionLifeCycleListener;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.integration.transports.netty.NettyConnector;
import org.hornetq.tests.util.UnitTestCase;
Modified:
branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -26,8 +26,8 @@
import java.util.Iterator;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TypedProperties;
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/UTF8Test.java
===================================================================
---
branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/UTF8Test.java 2009-11-23
21:22:09 UTC (rev 8386)
+++
branches/20-optimisation/tests/src/org/hornetq/tests/unit/util/UTF8Test.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -19,8 +19,8 @@
import java.io.DataOutputStream;
import java.nio.ByteBuffer;
+import org.hornetq.core.buffers.HornetQBuffer;
import org.hornetq.core.buffers.HornetQChannelBuffers;
-import org.hornetq.core.remoting.spi.HornetQBuffer;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.DataConstants;
@@ -41,7 +41,7 @@
public void testValidateUTF() throws Exception
{
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(60 * 1024);
+ HornetQBuffer buffer = HornetQChannelBuffers.fixedBuffer(60 * 1024);
byte[] bytes = new byte[20000];
@@ -75,7 +75,7 @@
testValidateUTFOnDataInputStream(str,
HornetQChannelBuffers.dynamicBuffer(100));
- testValidateUTFOnDataInputStream(str, HornetQChannelBuffers.buffer(100 *
1024));
+ testValidateUTFOnDataInputStream(str, HornetQChannelBuffers.fixedBuffer(100 *
1024));
}
}
@@ -83,7 +83,7 @@
{
UTF8Util.saveUTF(wrap, str);
- DataInputStream data = new DataInputStream(new
ByteArrayInputStream(wrap.array()));
+ DataInputStream data = new DataInputStream(new
ByteArrayInputStream(wrap.toByteBuffer().array()));
String newStr = data.readUTF();
@@ -113,7 +113,7 @@
String str = new String(chars);
- HornetQBuffer buffer = HornetQChannelBuffers.buffer(0xffff + 4);
+ HornetQBuffer buffer = HornetQChannelBuffers.fixedBuffer(0xffff + 4);
try
{
Modified: branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-23
21:22:09 UTC (rev 8386)
+++ branches/20-optimisation/tests/src/org/hornetq/tests/util/UnitTestCase.java 2009-11-23
23:27:50 UTC (rev 8387)
@@ -833,7 +833,7 @@
protected ServerMessage generateMessage(long id)
{
- ServerMessage message = new ServerMessageImpl();
+ ServerMessage message = new ServerMessageImpl(id, 1000);
message.setMessageID(id);