[jboss-cvs] JBoss Messaging SVN: r3897 - in trunk: src/main/org/jboss/messaging/core and 42 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 20 12:43:19 EDT 2008
Author: timfox
Date: 2008-03-20 12:43:19 -0400 (Thu, 20 Mar 2008)
New Revision: 3897
Added:
trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/
trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddDestinationMessageCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveDestinationMessageCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java
trunk/src/main/org/jboss/messaging/core/server/JournalType.java
Removed:
trunk/src/main/org/jboss/messaging/core/bindingmanager/
trunk/src/main/org/jboss/messaging/core/persistence/PersistenceManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/bdbje/
trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullPersistenceManager.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddAddressMessageCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveAddressMessageCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddAddressMessage.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveAddressMessage.java
trunk/tests/src/org/jboss/messaging/core/persistence/impl/bdbje/integration/
trunk/tests/src/org/jboss/messaging/core/persistence/impl/bdbje/test/
Modified:
trunk/src/etc/server/default/deploy/jbm-beans.xml
trunk/src/etc/server/default/deploy/jbm-configuration.xml
trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
trunk/src/main/org/jboss/messaging/core/journal/Journal.java
trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java
trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java
trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
trunk/src/main/org/jboss/messaging/core/message/Message.java
trunk/src/main/org/jboss/messaging/core/message/MessageReference.java
trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
trunk/src/main/org/jboss/messaging/core/message/impl/MessageReferenceImpl.java
trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java
trunk/src/main/org/jboss/messaging/core/server/Configuration.java
trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
trunk/src/main/org/jboss/messaging/core/server/Queue.java
trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java
trunk/src/main/org/jboss/messaging/core/server/ServerSession.java
trunk/src/main/org/jboss/messaging/core/server/impl/DeliveryImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java
trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java
trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java
trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
trunk/src/main/org/jboss/messaging/util/ConcurrentHashSet.java
trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestBase.java
trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/fakes/FakeSequentialFileFactory.java
trunk/tests/src/org/jboss/messaging/core/message/impl/test/unit/MessageTest.java
trunk/tests/src/org/jboss/messaging/core/postoffice/impl/test/unit/PostOfficeTest.java
trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java
trunk/tests/src/org/jboss/messaging/core/server/impl/test/timing/QueueTest.java
trunk/tests/src/org/jboss/messaging/core/server/impl/test/unit/QueueTest.java
trunk/tests/src/org/jboss/messaging/core/transaction/impl/test/unit/TransactionTest.java
trunk/tests/src/org/jboss/messaging/test/unit/UnitTestCase.java
trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java
trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
Log:
New journal!!
Modified: trunk/src/etc/server/default/deploy/jbm-beans.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-beans.xml 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/etc/server/default/deploy/jbm-beans.xml 2008-03-20 16:43:19 UTC (rev 3897)
@@ -14,8 +14,8 @@
</bean>
<bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
- <property name="persistenceManager">
- <inject bean="PersistenceManager"/>
+ <property name="storageManager">
+ <inject bean="StorageManager"/>
</property>
<property name="remotingService">
<inject bean="RemotingService"/>
@@ -28,42 +28,22 @@
</property>
</bean>
- <bean name="PersistenceManager" class="org.jboss.messaging.core.persistence.impl.bdbje.BDBJEPersistenceManager">
-
- <property name="largeMessageRepository">${user.home}/bdbje/large</property>
-
- <property name="minLargeMessageSize">1000000</property>
-
- <property name="environment">
- <inject bean="BDBJEEnvironment"/>
- </property>
-
+ <bean name="StorageManager" class="org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ </constructor>
</bean>
-
- <bean name="BDBJEEnvironment" class="org.jboss.messaging.core.persistence.impl.bdbje.integration.RealBDBJEEnvironment">
-
- <property name="environmentPath">${user.home}/bdbje/env</property>
- <property name="createEnvironment">true</property>
-
- <property name="syncVM">true</property>
-
- <property name="syncOS">true</property>
-
- <!-- We set the BDB cache low. We don't really use BDB for caching, and setting it large will increase
- memory footprint since messages will be in memory twice - once in the queue and once in the cache -->
- <property name="memoryCacheSize">1048576</property>
-
- </bean>
-
<bean name="RemotingService" class="org.jboss.messaging.core.remoting.impl.mina.MinaService">
<constructor>
<parameter>
<inject bean="Configuration"/>
</parameter>
</constructor>
- </bean>
-
+ </bean>
+
<bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.messaging:service=JMSServerManager", exposedInterface=org.jboss.messaging.jms.server.JMSServerManager.class)</annotation>
<property name="messagingServerManagement">
Modified: trunk/src/etc/server/default/deploy/jbm-configuration.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-configuration.xml 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/etc/server/default/deploy/jbm-configuration.xml 2008-03-20 16:43:19 UTC (rev 3897)
@@ -20,6 +20,8 @@
<clustered>false</clustered>
<scheduled-executor-max-pool-size>30</scheduled-executor-max-pool-size>
+
+ <require-destinations>true</require-destinations>
<!-- one of: TCP, INVM -->
<!-- INVM: the server is accessible only by clients in the same VM (no sockets are opened) -->
@@ -43,8 +45,30 @@
<remoting-ssl-truststore-path>messaging.truststore</remoting-ssl-truststore-path>
- <remoting-ssl-truststore-password>secureexample</remoting-ssl-truststore-password>
-
+ <remoting-ssl-truststore-password>secureexample</remoting-ssl-truststore-password>
+
+ <!-- Storage configuration -->
+
+ <bindings-directory>/tmp/jbm-test/data/bindings</bindings-directory>
+
+ <create-bindings-dir>true</create-bindings-dir>
+
+ <journal-directory>/tmp/jbm-test/data/journal</journal-directory>
+
+ <create-journal-dir>true</create-journal-dir>
+
+ <journal-type>nio</journal-type>
+
+ <journal-sync>true</journal-sync>
+
+ <journal-file-size>10485760</journal-file-size>
+
+ <journal-min-files>10</journal-min-files>
+
+ <journal-min-available-files>10</journal-min-available-files>
+
+ <journal-task-period>5000</journal-task-period>
+
</configuration>
</deployment>
\ No newline at end of file
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -25,9 +25,9 @@
void deleteQueue(String queueName) throws MessagingException;
- void addAddress(String address) throws MessagingException;
+ void addDestination(String address, boolean temporary) throws MessagingException;
- void removeAddress(String address) throws MessagingException;
+ void removeDestination(String address, boolean temporary) throws MessagingException;
SessionQueueQueryResponseMessage queueQuery(String queueName) throws MessagingException;
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -74,8 +74,6 @@
final RemotingConnection remotingConnection, final int windowSize,
final int maxRate)
{
- log.info("Creating producer with window size " + windowSize + " and max rate " + maxRate);
-
this.session = session;
this.id = id;
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -42,7 +42,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.CloseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.ConsumerFlowTokenMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddAddressMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCancelMessage;
@@ -57,7 +57,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveAddressMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRollbackMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
@@ -244,20 +244,20 @@
return response;
}
- public void addAddress(final String address) throws MessagingException
+ public void addDestination(final String address, final boolean temporary) throws MessagingException
{
checkClosed();
- SessionAddAddressMessage request = new SessionAddAddressMessage(address);
+ SessionAddDestinationMessage request = new SessionAddDestinationMessage(address, temporary);
remotingConnection.send(id, request);
}
- public void removeAddress(final String address) throws MessagingException
+ public void removeDestination(final String address, final boolean temporary) throws MessagingException
{
checkClosed();
- SessionRemoveAddressMessage request = new SessionRemoveAddressMessage(address);
+ SessionRemoveDestinationMessage request = new SessionRemoveDestinationMessage(address, temporary);
remotingConnection.send(id, request);
}
@@ -371,7 +371,7 @@
public void rollback() throws MessagingException
{
checkClosed();
-
+
//We tell each consumer to clear it's buffers and ignore any deliveries with
//delivery id > last delivery id, until it gets delivery id = lastID again
@@ -388,10 +388,10 @@
//We flush any remaining acks
acknowledgeInternal(false);
-
+
toAckCount = 0;
- remotingConnection.send(id, new SessionRollbackMessage());
+ remotingConnection.send(id, new SessionRollbackMessage());
}
public void acknowledge() throws MessagingException
@@ -406,7 +406,7 @@
toAckCount++;
acked = false;
-
+
if (deliveryExpired)
{
remotingConnection.send(id, new SessionCancelMessage(lastID, true), true);
@@ -503,11 +503,6 @@
this.deliveryExpired = expired;
}
- public void flushAcks() throws MessagingException
- {
- acknowledgeInternal(false);
- }
-
public void removeConsumer(final ClientConsumerInternal consumer) throws MessagingException
{
consumers.remove(consumer.getID());
@@ -805,7 +800,7 @@
}
SessionAcknowledgeMessage message = new SessionAcknowledgeMessage(lastID, !broken);
-
+
remotingConnection.send(id, message, !block);
acked = true;
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -25,8 +25,6 @@
void delivered(long deliveryID, boolean expired);
- void flushAcks() throws MessagingException;
-
void removeConsumer(ClientConsumerInternal consumer) throws MessagingException;
void removeProducer(ClientProducerInternal producer);
Modified: trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -30,6 +30,7 @@
import org.jboss.messaging.core.remoting.TransportType;
import org.jboss.messaging.core.remoting.impl.RemotingConfigurationImpl;
import org.jboss.messaging.core.server.Configuration;
+import org.jboss.messaging.core.server.JournalType;
import org.jboss.messaging.util.XMLUtil;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -88,6 +89,49 @@
this.remotingConfig = remotingConf;
+ requireDestinations = getBoolean(e, "require-destinations", requireDestinations);
+
+ //Persistence config
+
+ this.bindingsDirectory = getString(e, "bindings-directory", bindingsDirectory);
+
+ this.createBindingsDir = getBoolean(e, "create-bindings-dir", createBindingsDir);
+
+ this.journalDirectory = getString(e, "journal-directory", journalDirectory);
+
+ this.createJournalDir = getBoolean(e, "create-journal-dir", createJournalDir);
+
+ String s = getString(e, "journal-type", "nio");
+
+ if (s == null || (!s.equals("nio") && !s.equals("asyncio") && !s.equals("jdbc")))
+ {
+ throw new IllegalArgumentException("Invalid journal type " + s);
+ }
+
+ if (s.equals("nio"))
+ {
+ journalType = JournalType.NIO;
+ }
+ else if (s.equals("asyncio"))
+ {
+ journalType = JournalType.ASYNCIO;
+ }
+ else if (s.equals("jdbc"))
+ {
+ journalType = JournalType.JDBC;
+ }
+
+ this.journalSync = getBoolean(e, "journal-sync", true);
+
+ this.journalFileSize = getInteger(e, "journal-file-size", 10 * 1024 * 1024);
+
+ this.journalMinFiles = getInteger(e, "journal-min-files", 10);
+
+ this.journalMinAvailableFiles = getInteger(e, "journal-min-available-files", 10);
+
+ this.journalTaskPeriod = getLong(e, "journal-task-period", 5000L);
+
+
NodeList defaultInterceptors = e.getElementsByTagName("default-interceptors-config");
ArrayList<String> interceptorList = new ArrayList<String>();
Modified: trunk/src/main/org/jboss/messaging/core/journal/Journal.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/Journal.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/journal/Journal.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -44,25 +44,20 @@
// Transactional operations
- void appendAddRecordTransactional(long txID, long id, byte[] record, boolean done) throws Exception;
+ long getTransactionID();
- void appendUpdateRecordTransactional(long txID, long id, byte[] record, boolean done) throws Exception;
+ void appendAddRecordTransactional(long txID, long id, byte[] record) throws Exception;
- void appendDeleteRecordTransactional(long txID, long id, boolean done) throws Exception;
+ void appendUpdateRecordTransactional(long txID, long id, byte[] record) throws Exception;
- //XA operations
+ void appendDeleteRecordTransactional(long txID, long id) throws Exception;
- void appendAddRecordPrepare(long txID, long id, byte[] record, boolean done) throws Exception;
+ void appendCommitRecord(long txID) throws Exception;
- void appendUpdateRecordPrepare(long txID, long id, byte[] record, boolean done) throws Exception;
+ void appendPrepareRecord(long txID) throws Exception;
- void appendDeleteRecordPrepare(long txID, long id, boolean done) throws Exception;
-
- void appendXACommitRecord(long txID) throws Exception;
-
- void appendXARollbackRecord(long txID) throws Exception;
-
-
+ void appendRollbackRecord(long txID) throws Exception;
+
// Load
void load(List<RecordInfo> committedRecords,
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalFile.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -67,9 +67,9 @@
return orderingID;
}
- public void resetOffset()
+ public void setOffset(final int offset)
{
- offset = 0;
+ this.offset = offset;
}
public SequentialFile getFile()
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -35,6 +35,7 @@
import java.util.TimerTask;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicLong;
import org.jboss.messaging.core.journal.Journal;
import org.jboss.messaging.core.journal.PreparedTransactionInfo;
@@ -79,35 +80,21 @@
public static final byte UPDATE_RECORD = 12;
public static final byte DELETE_RECORD = 13;
-
+
public static final byte ADD_RECORD_TX = 14;
public static final byte UPDATE_RECORD_TX = 15;
public static final byte DELETE_RECORD_TX = 16;
- public static final byte ADD_RECORD_PREPARE = 17;
+ public static final byte PREPARE_RECORD = 17;
+
+ public static final byte COMMIT_RECORD = 18;
- public static final byte UPDATE_RECORD_PREPARE = 18;
+ public static final byte ROLLBACK_RECORD = 19;
- public static final byte DELETE_RECORD_PREPARE = 19;
+ public static final byte DONE = 20;
- public static final byte XA_COMMIT_RECORD = 20;
-
- public static final byte XA_ROLLBACK_RECORD = 21;
-
- //End markers - they must all be unique
-
- public static final byte DONE = 31;
-
- public static final byte TX_CONTINUE = 32;
-
- public static final byte TX_DONE = 33;
-
- public static final byte XA_CONTINUE = 34;
-
- public static final byte XA_DONE = 35;
-
public static final byte FILL_CHARACTER = 74; // Letter 'J'
@@ -151,6 +138,7 @@
private TimerTask availableFilesTask;
+ private final AtomicLong transactionIDSequence = new AtomicLong(0);
public JournalImpl(final int fileSize, final int minFiles, final int minAvailableFiles,
final boolean sync, final SequentialFileFactory fileFactory, final long taskPeriod,
@@ -224,22 +212,10 @@
bb.putLong(id);
bb.putInt(record.length);
bb.put(record);
- bb.put(DONE);
-
+ bb.put(DONE);
bb.flip();
-
- lock.acquire();
- try
- {
- checkFile(size);
- currentFile.getFile().write(bb, true);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, true);
}
public void appendUpdateRecord(final long id, final byte[] record) throws Exception
@@ -248,9 +224,7 @@
{
throw new IllegalStateException("Journal must be loaded first");
}
-
- //TODO optimise to avoid creating a new byte buffer
-
+
int size = SIZE_BYTE + SIZE_LONG + SIZE_INT + record.length + SIZE_BYTE;
ByteBuffer bb = ByteBuffer.wrap(new byte[size]);
@@ -259,22 +233,10 @@
bb.putLong(id);
bb.putInt(record.length);
bb.put(record);
- bb.put(DONE);
-
+ bb.put(DONE);
bb.flip();
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(bb, true);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, true);
}
public void appendDeleteRecord(long id) throws Exception
@@ -286,30 +248,23 @@
int size = SIZE_BYTE + SIZE_LONG + SIZE_BYTE;
- ByteBuffer buffer = ByteBuffer.wrap(new byte[size]);
+ ByteBuffer bb = ByteBuffer.wrap(new byte[size]);
- buffer.put(DELETE_RECORD);
- buffer.putLong(id);
- buffer.put(DONE);
-
- buffer.flip();
+ bb.put(DELETE_RECORD);
+ bb.putLong(id);
+ bb.put(DONE);
+ bb.flip();
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(buffer, true);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, true);
}
+
+ public long getTransactionID()
+ {
+ return transactionIDSequence.getAndIncrement();
+ }
public void appendAddRecordTransactional(final long txID, final long id,
- final byte[] record, final boolean done) throws Exception
+ final byte[] record) throws Exception
{
if (state != STATE_LOADED)
{
@@ -325,34 +280,14 @@
bb.putLong(id);
bb.putInt(record.length);
bb.put(record);
-
- if (done)
- {
- bb.put(TX_DONE);
- }
- else
- {
- bb.put(TX_CONTINUE);
- }
-
+ bb.put(DONE);
bb.flip();
-
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(bb, done);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+
+ appendRecord(bb, false);
}
-
+
public void appendUpdateRecordTransactional(final long txID, final long id,
- final byte[] record, final boolean done) throws Exception
+ final byte[] record) throws Exception
{
if (state != STATE_LOADED)
{
@@ -367,34 +302,14 @@
bb.putLong(txID);
bb.putLong(id);
bb.putInt(record.length);
- bb.put(record);
-
- if (done)
- {
- bb.put(TX_DONE);
- }
- else
- {
- bb.put(TX_CONTINUE);
- }
-
+ bb.put(record);
+ bb.put(DONE);
bb.flip();
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(bb, done);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, false);
}
- public void appendDeleteRecordTransactional(final long txID, final long id, final boolean done) throws Exception
+ public void appendDeleteRecordTransactional(final long txID, final long id) throws Exception
{
if (state != STATE_LOADED)
{
@@ -403,194 +318,57 @@
int size = SIZE_BYTE + SIZE_LONG + SIZE_LONG + SIZE_BYTE;
- ByteBuffer buffer = ByteBuffer.wrap(new byte[size]);
+ ByteBuffer bb = ByteBuffer.wrap(new byte[size]);
- buffer.put(DELETE_RECORD_TX);
- buffer.putLong(txID);
- buffer.putLong(id);
-
- if (done)
- {
- buffer.put(TX_DONE);
- }
- else
- {
- buffer.put(TX_CONTINUE);
- }
-
- buffer.flip();
+ bb.put(DELETE_RECORD_TX);
+ bb.putLong(txID);
+ bb.putLong(id);
+ bb.put(DONE);
+ bb.flip();
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(buffer, done);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, false);
}
-
- public void appendAddRecordPrepare(final long txID, final long id, final byte[] record, final boolean done) throws Exception
+
+ public void appendPrepareRecord(final long txID) throws Exception
{
if (state != STATE_LOADED)
{
throw new IllegalStateException("Journal must be loaded first");
}
-
- int size = SIZE_BYTE + SIZE_LONG + SIZE_LONG + SIZE_INT + record.length + SIZE_BYTE;
-
- ByteBuffer bb = ByteBuffer.wrap(new byte[size]);
-
- bb.put(ADD_RECORD_PREPARE);
- bb.putLong(txID);
- bb.putLong(id);
- bb.putInt(record.length);
- bb.put(record);
-
- if (done)
- {
- bb.put(XA_DONE);
- }
- else
- {
- bb.put(XA_CONTINUE);
- }
-
- bb.flip();
-
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(bb, done);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
- }
-
- public void appendUpdateRecordPrepare(final long txID, final long id, final byte[] record, final boolean done) throws Exception
- {
- if (state != STATE_LOADED)
- {
- throw new IllegalStateException("Journal must be loaded first");
- }
- int size = SIZE_BYTE + SIZE_LONG + SIZE_LONG + SIZE_INT + record.length + SIZE_BYTE;
+ int size = SIZE_BYTE + SIZE_LONG + SIZE_BYTE;
ByteBuffer bb = ByteBuffer.wrap(new byte[size]);
- bb.put(UPDATE_RECORD_PREPARE);
+ bb.put(PREPARE_RECORD);
bb.putLong(txID);
- bb.putLong(id);
- bb.putInt(record.length);
- bb.put(record);
-
- if (done)
- {
- bb.put(XA_DONE);
- }
- else
- {
- bb.put(XA_CONTINUE);
- }
-
+ bb.put(DONE);
bb.flip();
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(bb, done);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, true);
}
- public void appendDeleteRecordPrepare(final long txID, final long id, final boolean done) throws Exception
+ public void appendCommitRecord(final long txID) throws Exception
{
if (state != STATE_LOADED)
{
throw new IllegalStateException("Journal must be loaded first");
}
- int size = SIZE_BYTE + SIZE_LONG + SIZE_LONG + SIZE_BYTE;
-
- ByteBuffer buffer = ByteBuffer.wrap(new byte[size]);
-
- buffer.put(DELETE_RECORD_PREPARE);
- buffer.putLong(txID);
- buffer.putLong(id);
-
- if (done)
- {
- buffer.put(XA_DONE);
- }
- else
- {
- buffer.put(XA_CONTINUE);
- }
-
- buffer.flip();
-
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(buffer, done);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
- }
-
- public void appendXACommitRecord(final long txID) throws Exception
- {
- if (state != STATE_LOADED)
- {
- throw new IllegalStateException("Journal must be loaded first");
- }
-
int size = SIZE_BYTE + SIZE_LONG + SIZE_BYTE;
- ByteBuffer buffer = ByteBuffer.wrap(new byte[size]);
+ ByteBuffer bb = ByteBuffer.wrap(new byte[size]);
- buffer.put(XA_COMMIT_RECORD);
- buffer.putLong(txID);
- buffer.put(XA_DONE);
+ bb.put(COMMIT_RECORD);
+ bb.putLong(txID);
+ bb.put(DONE);
+ bb.flip();
- buffer.flip();
-
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(buffer, true);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, true);
}
- public void appendXARollbackRecord(final long txID) throws Exception
+ public void appendRollbackRecord(final long txID) throws Exception
{
if (state != STATE_LOADED)
{
@@ -599,26 +377,14 @@
int size = SIZE_BYTE + SIZE_LONG + SIZE_BYTE;
- ByteBuffer buffer = ByteBuffer.wrap(new byte[size]);
+ ByteBuffer bb = ByteBuffer.wrap(new byte[size]);
- buffer.put(XA_ROLLBACK_RECORD);
- buffer.putLong(txID);
- buffer.put(XA_DONE);
-
- buffer.flip();
+ bb.put(ROLLBACK_RECORD);
+ bb.putLong(txID);
+ bb.put(DONE);
+ bb.flip();
- lock.acquire();
-
- try
- {
- checkFile(size);
- currentFile.getFile().write(buffer, true);
- currentFile.extendOffset(size);
- }
- finally
- {
- lock.release();
- }
+ appendRecord(bb, true);
}
public void load(final List<RecordInfo> committedRecords,
@@ -687,6 +453,8 @@
int lastDataPos = -1;
+ long maxTransactionID = -1;
+
for (JournalFile file: orderedFiles)
{
ByteBuffer bb = ByteBuffer.wrap(new byte[fileSize]);
@@ -712,22 +480,18 @@
while (bb.hasRemaining())
{
- byte recordType = bb.get();
-
int pos = bb.position();
+ byte recordType = bb.get();
+
switch(recordType)
{
case ADD_RECORD:
{
- long id = bb.getLong();
-
- int size = bb.getInt();
-
- byte[] record = new byte[size];
-
- bb.get(record);
-
+ long id = bb.getLong();
+ int size = bb.getInt();
+ byte[] record = new byte[size];
+ bb.get(record);
byte end = bb.get();
if (end != DONE)
@@ -737,7 +501,6 @@
else
{
records.add(new RecordInfo(id, record, false));
-
hasData = true;
}
@@ -745,14 +508,10 @@
}
case UPDATE_RECORD:
{
- long id = bb.getLong();
-
- int size = bb.getInt();
-
- byte[] record = new byte[size];
-
- bb.get(record);
-
+ long id = bb.getLong();
+ int size = bb.getInt();
+ byte[] record = new byte[size];
+ bb.get(record);
byte end = bb.get();
if (end != DONE)
@@ -761,8 +520,7 @@
}
else
{
- records.add(new RecordInfo(id, record, true));
-
+ records.add(new RecordInfo(id, record, true));
hasData = true;
}
@@ -770,8 +528,7 @@
}
case DELETE_RECORD:
{
- long id = bb.getLong();
-
+ long id = bb.getLong();
byte end = bb.get();
if (end != DONE)
@@ -780,8 +537,7 @@
}
else
{
- recordsToDelete.add(id);
-
+ recordsToDelete.add(id);
hasData = true;
}
@@ -789,19 +545,15 @@
}
case ADD_RECORD_TX:
{
- long txID = bb.getLong();
-
- long id = bb.getLong();
-
- int size = bb.getInt();
-
- byte[] record = new byte[size];
-
- bb.get(record);
-
+ long txID = bb.getLong();
+ maxTransactionID = Math.max(maxTransactionID, txID);
+ long id = bb.getLong();
+ int size = bb.getInt();
+ byte[] record = new byte[size];
+ bb.get(record);
byte end = bb.get();
- if (end != TX_CONTINUE && end != TX_DONE)
+ if (end != DONE)
{
repairFrom(pos, file);
}
@@ -811,20 +563,11 @@
if (tx == null)
{
- tx = new TransactionHolder(txID);
-
+ tx = new TransactionHolder(txID);
transactions.put(txID, tx);
}
- tx.recordInfos.add(new RecordInfo(id, record, false));
-
- if (end == TX_DONE)
- {
- transactions.remove(txID);
-
- records.addAll(tx.recordInfos);
- }
-
+ tx.recordInfos.add(new RecordInfo(id, record, false));
hasData = true;
}
@@ -832,19 +575,15 @@
}
case UPDATE_RECORD_TX:
{
- long txID = bb.getLong();
-
- long id = bb.getLong();
-
- int size = bb.getInt();
-
- byte[] record = new byte[size];
-
- bb.get(record);
-
+ long txID = bb.getLong();
+ maxTransactionID = Math.max(maxTransactionID, txID);
+ long id = bb.getLong();
+ int size = bb.getInt();
+ byte[] record = new byte[size];
+ bb.get(record);
byte end = bb.get();
- if (end != TX_CONTINUE && end != TX_DONE)
+ if (end != DONE)
{
repairFrom(pos, file);
}
@@ -854,18 +593,12 @@
if (tx == null)
{
- throw new IllegalStateException("Cannot find tx with id " + txID);
+ tx = new TransactionHolder(txID);
+ transactions.put(txID, tx);
}
tx.recordInfos.add(new RecordInfo(id, record, true));
-
- if (end == TX_DONE)
- {
- transactions.remove(txID);
-
- records.addAll(tx.recordInfos);
- }
-
+
hasData = true;
}
@@ -873,13 +606,12 @@
}
case DELETE_RECORD_TX:
{
- long txID = bb.getLong();
-
- long id = bb.getLong();
-
+ long txID = bb.getLong();
+ maxTransactionID = Math.max(maxTransactionID, txID);
+ long id = bb.getLong();
byte end = bb.get();
- if (end != TX_CONTINUE && end != TX_DONE)
+ if (end != DONE)
{
repairFrom(pos, file);
}
@@ -889,145 +621,47 @@
if (tx == null)
{
- throw new IllegalStateException("Cannot find tx with id " + txID);
+ tx = new TransactionHolder(txID);
+ transactions.put(txID, tx);
}
- tx.recordsToDelete.add(id);
-
- if (end == TX_DONE)
- {
- transactions.remove(txID);
-
- records.addAll(tx.recordInfos);
-
- recordsToDelete.addAll(tx.recordsToDelete);
- }
-
+ tx.recordsToDelete.add(id);
hasData = true;
}
break;
}
- case ADD_RECORD_PREPARE:
+ case PREPARE_RECORD:
{
- long txID = bb.getLong();
-
- long id = bb.getLong();
-
- int size = bb.getInt();
-
- byte[] record = new byte[size];
-
- bb.get(record);
-
+ long txID = bb.getLong();
+ maxTransactionID = Math.max(maxTransactionID, txID);
byte end = bb.get();
- if (end != XA_DONE && end != XA_CONTINUE)
+ if (end != DONE)
{
repairFrom(pos, file);
}
else
- {
- TransactionHolder tx = transactions.get(txID);
-
- if (tx == null)
- {
- tx = new TransactionHolder(txID);
-
- transactions.put(txID, tx);
- }
-
- tx.recordInfos.add(new RecordInfo(id, record, false));
-
- if (end == XA_DONE)
- {
- tx.prepared = true;
- }
-
- hasData = true;
- }
-
- break;
- }
- case UPDATE_RECORD_PREPARE:
- {
- long txID = bb.getLong();
-
- long id = bb.getLong();
-
- int size = bb.getInt();
-
- byte[] record = new byte[size];
-
- bb.get(record);
-
- byte end = bb.get();
-
- if (end != XA_CONTINUE && end != XA_DONE)
{
- repairFrom(pos, file);
- }
- else
- {
TransactionHolder tx = transactions.get(txID);
if (tx == null)
{
throw new IllegalStateException("Cannot find tx with id " + txID);
}
-
- tx.recordInfos.add(new RecordInfo(id, record, true));
-
- if (end == XA_DONE)
- {
- tx.prepared = true;
- }
-
- hasData = true;
+
+ tx.prepared = true;
}
-
- break;
- }
- case DELETE_RECORD_PREPARE:
- {
- long txID = bb.getLong();
- long id = bb.getLong();
-
- byte end = bb.get();
-
- if (end != XA_CONTINUE && end != XA_DONE)
- {
- repairFrom(pos, file);
- }
- else
- {
- TransactionHolder tx = transactions.get(txID);
-
- if (tx == null)
- {
- throw new IllegalStateException("Cannot find tx with id " + txID);
- }
-
- tx.recordsToDelete.add(id);
-
- if (end == XA_DONE)
- {
- tx.prepared = true;
- }
-
- hasData = true;
- }
-
break;
}
- case XA_COMMIT_RECORD:
+ case COMMIT_RECORD:
{
- long txID = bb.getLong();
-
+ long txID = bb.getLong();
+ maxTransactionID = Math.max(maxTransactionID, txID);
byte end = bb.get();
- if (end != XA_DONE)
+ if (end != DONE)
{
repairFrom(pos, file);
}
@@ -1040,25 +674,19 @@
throw new IllegalStateException("Cannot find tx with id " + txID);
}
- if (!tx.prepared)
- {
- throw new IllegalStateException("Can't commit transaction - it is not prepared " + txID);
- }
-
- records.addAll(tx.recordInfos);
-
- recordsToDelete.addAll(tx.recordsToDelete);
+ records.addAll(tx.recordInfos);
+ recordsToDelete.addAll(tx.recordsToDelete);
}
break;
}
- case XA_ROLLBACK_RECORD:
+ case ROLLBACK_RECORD:
{
- long txID = bb.getLong();
-
+ long txID = bb.getLong();
+ maxTransactionID = Math.max(maxTransactionID, txID);
byte end = bb.get();
- if (end != XA_DONE)
+ if (end != DONE)
{
repairFrom(pos, file);
}
@@ -1069,18 +697,13 @@
if (tx == null)
{
throw new IllegalStateException("Cannot find tx with id " + txID);
- }
-
- if (!tx.prepared)
- {
- throw new IllegalStateException("Can't roll back transaction - it is not prepared " + txID);
- }
+ }
}
break;
}
case FILL_CHARACTER:
- {
+ {
//End of records in file - we check the file only contains fill characters from this point
while (bb.hasRemaining())
{
@@ -1104,7 +727,7 @@
if (recordType != FILL_CHARACTER)
{
- lastDataPos = pos;
+ lastDataPos = bb.position();
}
}
@@ -1125,6 +748,8 @@
file.getFile().position(SIZE_LONG);
}
}
+
+ transactionIDSequence.set(maxTransactionID + 1);
//Now it's possible that some of the files are no longer needed
@@ -1144,6 +769,8 @@
currentFile.getFile().open();
currentFile.getFile().position(lastDataPos);
+
+ currentFile.setOffset(lastDataPos);
}
else
{
@@ -1184,16 +811,13 @@
}
public void checkAndCreateAvailableFiles() throws Exception
- {
- //log.info("min available " + minAvailableFiles + " avail: " + availableFiles.size() + " files: " + files.size());
+ {
int filesToCreate = minAvailableFiles - availableFiles.size();
for (int i = 0; i < filesToCreate; i++)
{
JournalFile file = createFile();
-
- //log.info("Creating new file");
-
+
availableFiles.add(file);
}
}
@@ -1248,11 +872,11 @@
public void startTasks()
{
- reclaimerTask = new ReclaimerTask();
- timer.schedule(reclaimerTask, taskPeriod, taskPeriod);
-
- availableFilesTask = new AvailableFilesTask();
- timer.schedule(availableFilesTask, taskPeriod, taskPeriod);
+// reclaimerTask = new ReclaimerTask();
+// timer.schedule(reclaimerTask, taskPeriod, taskPeriod);
+//
+// availableFilesTask = new AvailableFilesTask();
+// timer.schedule(availableFilesTask, taskPeriod, taskPeriod);
}
// Public -----------------------------------------------------------------------------
@@ -1297,10 +921,8 @@
sf.position(SIZE_LONG);
- jf.resetOffset();
+ jf.setOffset(SIZE_LONG);
- jf.extendOffset(SIZE_LONG);
-
availableFiles.add(jf);
}
}
@@ -1308,6 +930,24 @@
// Private -----------------------------------------------------------------------------
+ private void appendRecord(ByteBuffer bb, boolean sync) throws Exception
+ {
+ lock.acquire();
+
+ int size = bb.capacity();
+
+ try
+ {
+ checkFile(size);
+ currentFile.getFile().write(bb, false);
+ currentFile.extendOffset(size);
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+
private void repairFrom(int pos, JournalFile file) throws Exception
{
log.warn("Corruption has been detected in file: " + file.getFile().getFileName() +
@@ -1410,8 +1050,7 @@
cancel();
}
- }
-
+ }
}
private class AvailableFilesTask extends TimerTask
@@ -1435,8 +1074,6 @@
cancel();
}
- }
-
- }
-
+ }
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFile.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -73,8 +73,6 @@
rfile = new RandomAccessFile(file, "rw");
channel = rfile.getChannel();
-
- //log.info("Opened file");
}
public void fill(final int position, final int size, final byte fillCharacter) throws Exception
@@ -108,8 +106,6 @@
rfile = null;
file = null;
-
- //log.info("Closed file");
}
public void delete() throws Exception
@@ -121,12 +117,8 @@
public int read(ByteBuffer bytes) throws Exception
{
- //log.info("reading, position is " + channel.position());
-
int bytesRead = channel.read(bytes);
- //log.info("Read " + bytesRead + " bytes");
-
return bytesRead;
}
@@ -144,7 +136,6 @@
public void position(final int pos) throws Exception
{
- //log.info("Positioning to " + pos);
channel.position(pos);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/NIOSequentialFileFactory.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -23,6 +23,7 @@
import java.io.File;
import java.io.FilenameFilter;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
@@ -64,6 +65,11 @@
String[] fileNames = dir.list(fnf);
+ if (fileNames == null)
+ {
+ throw new IOException("Failed to list: " + journalDir);
+ }
+
return Arrays.asList(fileNames);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -67,7 +67,7 @@
* @return true if the address was added
* @throws Exception if a problem occurred
*/
- boolean addAddress(String address) throws Exception;
+ boolean addDestination(String address) throws Exception;
/**
* remove an address from the post office
@@ -75,7 +75,7 @@
* @return true if the address was removed
* @throws Exception if a problem occurred
*/
- boolean removeAddress(String address) throws Exception;
+ boolean removeDestination(String address) throws Exception;
/**
* returns all the queues for a specific address
@@ -126,7 +126,7 @@
* @param filter the filter
* @throws Exception if a problem occurred
*/
- void removeMessageForBinding(String binding, Filter filter) throws Exception;
+ /// void removeMessageForBinding(String binding, Filter filter) throws Exception;
/**
* remove the messages for a specific address that match the specified filter
@@ -134,7 +134,7 @@
* @param filter the filter
* @throws Exception if a problem occurred
*/
- void removeMessageForAddress(String address, Filter filter) throws Exception;
+ // void removeMessageForAddress(String address, Filter filter) throws Exception;
/**
* count the number of messages in a queue
@@ -243,7 +243,7 @@
* @param filter the filter to use
* @throws Exception if a problem occurred
*/
- void moveMessages(String toQueue, String fromQueue, String filter) throws Exception;
+ //void moveMessages(String toQueue, String fromQueue, String filter) throws Exception;
/**
* expire a set of messages for a specific queue
@@ -260,7 +260,7 @@
* @param priority the priority to change to
* @throws Exception if a problem occurred
*/
- void changeMessagePriority(String queue, String filter, int priority) throws Exception;
+ //void changeMessagePriority(String queue, String filter, int priority) throws Exception;
/**
* list all available addresses
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -30,9 +30,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import java.lang.management.ManagementFactory;
-import org.jboss.aop.microcontainer.aspects.jmx.JMX;
import org.jboss.messaging.core.client.ClientConnectionFactory;
import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.exception.MessagingException;
@@ -48,10 +46,6 @@
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.ServerConnection;
-import javax.management.StandardMBean;
-import javax.management.ObjectName;
-import javax.management.MBeanServer;
-
/**
* This interface describes the properties and operations that comprise the management interface of the
* Messaging Server.
@@ -80,18 +74,6 @@
this.messagingServer = messagingServer;
}
-// public String getServerVersion()
-// {
-// return messagingServer.getVersion().getProviderVersion();
-// }
-//
-// public Configuration getConfiguration()
-// {
-// return messagingServer.getConfiguration();
-// }
-
- //
-
public boolean isStarted()
{
return messagingServer.isStarted();
@@ -103,51 +85,30 @@
{
messagingServer.getPostOffice().addBinding(address, name, null, true, false);
}
-
- if (!messagingServer.getPostOffice().containsAllowableAddress(address))
- {
- messagingServer.getPostOffice().addAllowableAddress(address);
- }
}
public void destroyQueue(String name) throws Exception
{
Binding binding = messagingServer.getPostOffice().getBinding(name);
- boolean destroyed = false;
-
if (binding != null)
{
Queue queue = binding.getQueue();
- messagingServer.getPersistenceManager().deleteAllReferences(queue);
-
- queue.removeAllReferences();
-
+ queue.deleteAllReferences(messagingServer.getStorageManager());
+
messagingServer.getPostOffice().removeBinding(queue.getName());
-
- destroyed = true;
}
}
- public boolean addAddress(String address) throws Exception
+ public boolean addDestination(String address) throws Exception
{
- if (!messagingServer.getPostOffice().containsAllowableAddress(address))
- {
- messagingServer.getPostOffice().addAllowableAddress(address);
- return true;
- }
- return false;
+ return messagingServer.getPostOffice().addDestination(address, false);
}
- public boolean removeAddress(String address) throws Exception
+ public boolean removeDestination(String address) throws Exception
{
- if (messagingServer.getPostOffice().containsAllowableAddress(address))
- {
- messagingServer.getPostOffice().removeAllowableAddress(address);
- return true;
- }
- return false;
+ return messagingServer.getPostOffice().removeDestination(address, false);
}
public ClientConnectionFactory createClientConnectionFactory(boolean strictTck,
@@ -170,12 +131,7 @@
{
Queue queue = binding.getQueue();
- if (queue.isDurable())
- {
- messagingServer.getPersistenceManager().deleteAllReferences(queue);
- }
-
- queue.removeAllReferences();
+ queue.deleteAllReferences(messagingServer.getStorageManager());
}
}
@@ -186,9 +142,7 @@
{
Queue queue = binding.getQueue();
- messagingServer.getPersistenceManager().deleteAllReferences(queue);
-
- queue.removeAllReferences();
+ queue.deleteAllReferences(messagingServer.getStorageManager());
}
}
@@ -207,29 +161,29 @@
return msgs;
}
- public void removeMessageForBinding(String name, Filter filter) throws Exception
- {
- Binding binding = messagingServer.getPostOffice().getBinding(name);
- if (binding != null)
- {
- Queue queue = binding.getQueue();
- List<MessageReference> allRefs = queue.list(filter);
- for (MessageReference messageReference : allRefs)
- {
- messagingServer.getPersistenceManager().deleteReference(messageReference);
- queue.removeReference(messageReference);
- }
- }
- }
+// public void removeMessageForBinding(String name, Filter filter) throws Exception
+// {
+// Binding binding = messagingServer.getPostOffice().getBinding(name);
+// if (binding != null)
+// {
+// Queue queue = binding.getQueue();
+// List<MessageReference> allRefs = queue.list(filter);
+// for (MessageReference messageReference : allRefs)
+// {
+// messagingServer.getPersistenceManager().deleteReference(messageReference);
+// queue.removeReference(messageReference);
+// }
+// }
+// }
- public void removeMessageForAddress(String binding, Filter filter) throws Exception
- {
- List<Binding> bindings = messagingServer.getPostOffice().getBindingsForAddress(binding);
- for (Binding binding1 : bindings)
- {
- removeMessageForBinding(binding1.getQueue().getName(), filter);
- }
- }
+// public void removeMessageForAddress(String binding, Filter filter) throws Exception
+// {
+// List<Binding> bindings = messagingServer.getPostOffice().getBindingsForAddress(binding);
+// for (Binding binding1 : bindings)
+// {
+// removeMessageForBinding(binding1.getQueue().getName(), filter);
+// }
+// }
public List<Queue> getQueuesForAddress(String address) throws Exception
{
@@ -421,19 +375,19 @@
return messagingServer.getConnectionManager().getActiveConnections();
}
- public void moveMessages(String fromQueue, String toQueue, String filter) throws Exception
- {
- Filter actFilter = new FilterImpl(filter);
- Queue from = getQueue(fromQueue);
- Queue to = getQueue(toQueue);
- List<MessageReference> messageReferences = from.list(actFilter);
- for (MessageReference messageReference : messageReferences)
- {
- from.move(messageReference, to, messagingServer.getPersistenceManager());
- }
+// public void moveMessages(String fromQueue, String toQueue, String filter) throws Exception
+// {
+// Filter actFilter = new FilterImpl(filter);
+// Queue from = getQueue(fromQueue);
+// Queue to = getQueue(toQueue);
+// List<MessageReference> messageReferences = from.list(actFilter);
+// for (MessageReference messageReference : messageReferences)
+// {
+// from.move(messageReference, to, messagingServer.getPersistenceManager());
+// }
+//
+// }
- }
-
public void expireMessages(String queue, String filter) throws Exception
{
Filter actFilter = new FilterImpl(filter);
@@ -444,25 +398,25 @@
}
}
- public void changeMessagePriority(String queue, String filter, int priority) throws Exception
- {
- Filter actFilter = new FilterImpl(filter);
- List<MessageReference> allRefs = getQueue(queue).list(actFilter);
- for (MessageReference messageReference : allRefs)
- {
- List<MessageReference> allRefsForMessage = messageReference.getMessage().getReferences();
- for (MessageReference reference : allRefsForMessage)
- {
- reference.getQueue().changePriority(reference, priority);
- }
- messageReference.getMessage().setPriority((byte) priority);
- }
+// public void changeMessagePriority(String queue, String filter, int priority) throws Exception
+// {
+// Filter actFilter = new FilterImpl(filter);
+// List<MessageReference> allRefs = getQueue(queue).list(actFilter);
+// for (MessageReference messageReference : allRefs)
+// {
+// List<MessageReference> allRefsForMessage = messageReference.getMessage().getReferences();
+// for (MessageReference reference : allRefsForMessage)
+// {
+// reference.getQueue().changePriority(reference, priority);
+// }
+// messageReference.getMessage().setPriority((byte) priority);
+// }
+//
+// }
- }
-
public Set<String> listAvailableAddresses()
{
- return messagingServer.getPostOffice().listAvailableAddresses();
+ return messagingServer.getPostOffice().listAllDestinations();
}
//
Modified: trunk/src/main/org/jboss/messaging/core/message/Message.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/Message.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/message/Message.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -203,41 +203,26 @@
MessageReference createReference(Queue queue);
/**
- *
- * @return List of persisted references for this message
+ * Decrement the durable ref count
*/
- List<MessageReference> getReferences();
+ void decrementDurableRefCount();
/**
- *
- * @return The number of durable references for this message
+ * Increment the durable ref count
*/
- int getNumDurableReferences();
+ void incrementDurableRefCount();
/**
- *
- * @param reference durable from the specified position
- * @param pos
+ * Get the current durable reference count
+ * @return
*/
- void removeDurableReference(MessageReference reference, int pos) throws Exception;
+ int getDurableRefCount();
/**
- *
- * @param reference
- * @return The position of the reference over all durable references
- */
- int getDurableReferencePos(MessageReference reference);
-
- void addBackDurableReference(MessageReference ref);
-
-
- /**
* Make a copy of the message
*
* @return The copy
*/
Message copy();
-
- void send() throws Exception;
-
+
}
Modified: trunk/src/main/org/jboss/messaging/core/message/MessageReference.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/MessageReference.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/message/MessageReference.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -21,7 +21,8 @@
*/
package org.jboss.messaging.core.message;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
@@ -31,8 +32,6 @@
*
* Channels store message references rather than the messages themselves.
*
- * If many channels have contain the same reference this makes a lot of sense
- *
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 3020 $</tt>
@@ -54,9 +53,7 @@
void setScheduledDeliveryTime(long scheduledDeliveryTime);
- /**
- * @return the number of times delivery has been attempted for this routable
- */
+
int getDeliveryCount();
void setDeliveryCount(int deliveryCount);
@@ -65,14 +62,12 @@
Queue getQueue();
- void acknowledge(PersistenceManager persistenceManager) throws Exception;
+ boolean cancel(StorageManager persistenceManager, PostOffice postOffice,
+ HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
- boolean cancel(PersistenceManager persistenceManager, HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
-
- void expire(PersistenceManager persistenceManager, HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
+ void expire(StorageManager persistenceManager, PostOffice postOffice,
+ HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
- void moveMessage(Queue destinationQueue,
- PersistenceManager persistenceManager) throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -25,16 +25,13 @@
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.server.HandleStatus;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.util.StreamUtils;
@@ -77,22 +74,12 @@
//The payload of MessageImpl instances is opaque
private byte[] payload;
- //We keep track of the persisted references for this message
- private final List<MessageReference> references = new ArrayList<MessageReference>();
-
private String connectionID;
- private volatile int numDurableReferences;
+ private final AtomicInteger durableRefCount = new AtomicInteger(0);
private int deliveryCount;
- /*
- * We use a semaphore of size 1, i.e. a mutex to synchronize access to the refs rather than
- * use the synchronized keyword since java.util.Semaphore uses compareAndSet to maintain the semaphore
- * i.e. no locking which should give better performance under high contention
- */
- private Semaphore refsLock = new Semaphore(1);
-
// Constructors --------------------------------------------------
/*
@@ -306,95 +293,36 @@
{
MessageReference ref = new MessageReferenceImpl(this, queue);
- references.add(ref);
+ //references.add(ref);
if (durable && queue.isDurable())
{
- numDurableReferences++;
+ durableRefCount.incrementAndGet();
}
return ref;
}
- public int getNumDurableReferences()
+ public int getDurableRefCount()
{
- return numDurableReferences;
+ return durableRefCount.get();
}
- public List<MessageReference> getReferences()
+ public void decrementDurableRefCount()
{
- return references;
+ durableRefCount.decrementAndGet();
}
- public void removeDurableReference(final MessageReference reference, final int pos) throws Exception
+ public void incrementDurableRefCount()
{
- refsLock.acquire();
-
- try
- {
- references.remove(pos);
-
- numDurableReferences--;
- }
- finally
- {
- refsLock.release();
- }
+ durableRefCount.incrementAndGet();
}
- //TODO optimise to avoid scan
- public int getDurableReferencePos(final MessageReference reference)
- {
- int pos = 0;
-
- for (MessageReference ref: references)
- {
- if (ref == reference)
- {
- break;
- }
-
- if (ref.getQueue().isDurable())
- {
- pos++;
- }
- }
-
- return pos;
- }
-
- public void addBackDurableReference(final MessageReference reference)
- {
- references.add(reference);
-
- numDurableReferences++;
- }
-
public Message copy()
{
return new MessageImpl(this);
}
- public void send() throws Exception
- {
- refsLock.acquire();
-
- try
- {
- for (MessageReference ref: references)
- {
- if (ref.getQueue().addLast(ref) == HandleStatus.BUSY)
- {
- log.warn("Message not added to queue " + ref.getQueue().getName() + " since it is full");
- }
- }
- }
- finally
- {
- refsLock.release();
- }
- }
-
// Public --------------------------------------------------------
public boolean equals(Object o)
Modified: trunk/src/main/org/jboss/messaging/core/message/impl/MessageReferenceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/impl/MessageReferenceImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/message/impl/MessageReferenceImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -24,10 +24,13 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.core.transaction.Transaction;
import org.jboss.messaging.core.transaction.impl.TransactionImpl;
/**
@@ -120,22 +123,12 @@
return queue;
}
- public void acknowledge(final PersistenceManager persistenceManager) throws Exception
- {
- if (message.isDurable())
- {
- persistenceManager.deleteReference(this);
- }
-
- queue.referenceAcknowledged();
- }
-
- public boolean cancel(final PersistenceManager persistenceManager,
+ public boolean cancel(final StorageManager persistenceManager, final PostOffice postOffice,
final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
{
if (message.isDurable() && queue.isDurable())
{
- persistenceManager.updateDeliveryCount(queue, this);
+ persistenceManager.updateDeliveryCount(this);
}
queue.referenceCancelled();
@@ -146,11 +139,22 @@
{
Queue DLQ = queueSettingsRepository.getMatch(queue.getName()).getDLQ();
+ Transaction tx = new TransactionImpl(persistenceManager, postOffice);
+
if (DLQ != null)
{
+ Binding binding = postOffice.getBinding(DLQ.getName());
+
+ if (binding == null)
+ {
+ throw new IllegalStateException("Cannot find binding for DLQ: " + DLQ.getName());
+ }
+
Message copyMessage = makeCopyForDLQOrExpiry(false, persistenceManager);
- moveInTransaction(DLQ, copyMessage, persistenceManager);
+ tx.addMessage(binding.getAddress(), copyMessage);
+
+ tx.addAcknowledgement(this);
}
else
{
@@ -158,7 +162,7 @@
log.warn("Message has reached maximum delivery attempts, no DLQ is configured so dropping it");
- acknowledge(persistenceManager);
+ tx.addAcknowledgement(this);
}
return false;
@@ -169,39 +173,38 @@
}
}
- public void expire(final PersistenceManager persistenceManager,
+ public void expire(final StorageManager persistenceManager, final PostOffice postOffice,
final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
{
Queue expiryQueue = queueSettingsRepository.getMatch(queue.getName()).getExpiryQueue();
+ Transaction tx = new TransactionImpl(persistenceManager, postOffice);
+
if (expiryQueue != null)
{
+ Binding binding = postOffice.getBinding(expiryQueue.getName());
+
+ if (binding == null)
+ {
+ throw new IllegalStateException("Cannot find binding for expiry queue: " + expiryQueue.getName());
+ }
+
Message copyMessage = makeCopyForDLQOrExpiry(false, persistenceManager);
- moveInTransaction(expiryQueue, copyMessage, persistenceManager);
+ tx.addMessage(binding.getAddress(), copyMessage);
+
+ tx.addAcknowledgement(this);
}
else
{
log.warn("Message has expired, no expiry queue is configured so dropping it");
- acknowledge(persistenceManager);
+ tx.addAcknowledgement(this);
}
+
+ tx.commit();
}
- public void moveMessage(final Queue destinationQueue,
- final PersistenceManager persistenceManager) throws Exception
- {
- TransactionImpl tx = new TransactionImpl();
-
- message.createReference(destinationQueue);
-
- tx.addMessage(message);
-
- tx.addAcknowledgement(this);
-
- tx.commit(true, persistenceManager);
- }
-
// Public --------------------------------------------------------
public String toString()
@@ -215,22 +218,8 @@
// Private -------------------------------------------------------
- private void moveInTransaction(final Queue destinationQueue, final Message copyMessage,
- final PersistenceManager persistenceManager) throws Exception
+ private Message makeCopyForDLQOrExpiry(final boolean expiry, final StorageManager pm) throws Exception
{
- copyMessage.createReference(destinationQueue);
-
- TransactionImpl tx = new TransactionImpl();
-
- tx.addMessage(copyMessage);
-
- tx.addAcknowledgement(this);
-
- tx.commit(true, persistenceManager);
- }
-
- private Message makeCopyForDLQOrExpiry(final boolean expiry, final PersistenceManager pm) throws Exception
- {
/*
We copy the message and send that to the dlq/expiry queue - this is
because otherwise we may end up with a ref with the same message id in the
Deleted: trunk/src/main/org/jboss/messaging/core/persistence/PersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/PersistenceManager.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/persistence/PersistenceManager.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.persistence;
-
-import java.util.List;
-
-import javax.transaction.xa.Xid;
-
-import org.jboss.messaging.core.message.Message;
-import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.postoffice.Binding;
-import org.jboss.messaging.core.server.MessagingComponent;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
-
-/**
- *
- * A PersistenceManager
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface PersistenceManager extends MessagingComponent
-{
- // Operations for maintaining message state
- // ========================================
-
- /**
- * Generate a new message id - unique per store
- * @return The new message id
- */
- public long generateMessageID();
-
- /**
- * A single message, possible with many message references needs to be added to storage
- * This would occur when a single reliable messages arrives on the server and needs to be routed
- * to 1 or more queues.
- * @param message
- */
- public void addMessage(Message message) throws Exception;
-
- /**
- * Delete a single reference. This would also delete the message if it is no longer referenced by any other
- * references.
- * This would occur on acknowledgement of a single reference
- * @param message
- */
- void deleteReference(MessageReference reference) throws Exception;
-
- /**
- * Commit a transaction containing messages to add and references to remove
- * @param messagesToAdd List of messages to add, or null if none
- * @param referencesToRemove List of references to remove, or null if none
- * @throws Exception
- */
- public void commitTransaction(List<Message> messagesToAdd, List<MessageReference> referencesToRemove) throws Exception;
-
- /**
- * Prepare a transaction containing messages to add and references to remove
- * @param xid The Xid of the XA transaction
- * @param messagesToAdd List of messages to add, or null if none
- * @param referencesToRemove List of references to remove, or null if none
- * @throws Exception
- */
- public void prepareTransaction(Xid xid, List<Message> messagesToAdd,
- List<MessageReference> referencesToRemove) throws Exception;
-
- /**
- * Commit a prepared transaction
- *
- * @param xid
- * @throws Exception
- */
- public void commitPreparedTransaction(Xid xid) throws Exception;
-
-
- /**
- * Unprepare a transaction containing messages to add and references to remove
- * @param xid The Xid of the XA transaction
- * @param messagesToAdd List of messages to add, or null if none
- * @param referencesToRemove List of references to remove, or null if none
- * @throws Exception
- */
- public void unprepareTransaction(Xid xid, List<Message> messagesToAdd,
- List<MessageReference> referencesToRemove) throws Exception;
-
-
- /**
- * Update the delivery count of a reference
- * @param queue
- * @param ref
- * @throws Exception
- */
- void updateDeliveryCount(Queue queue, MessageReference ref) throws Exception;
-
- /**
- * Deletes all references from storage for the specifie Queue
- * @param queue
- * @throws Exception
- */
- void deleteAllReferences(Queue queue) throws Exception;
-
-
- // Recovery related operations
- // ===========================
-
- /**
- * Get a list of in doubt (prepared) transaction ids
- * Can only be called in recovery mode
- * @return the list of ids
- */
- List<Xid> getInDoubtXids() throws Exception;
-
- /**
- *
- * @return true if the PersistenceManager is in recovery mode
- */
- boolean isInRecoveryMode() throws Exception;
-
- /**
- *
- * @param recoveryMode Set the PersistenceManager in recovery mode
- */
- void setInRecoveryMode(boolean recoveryMode);
-
- // Operations for maintaining post office state
- // ============================================
-
- /**
- * Load the bindings from the store to populate the post office at startup
- * @param QueueFactory The factory used to create the queues
- * @return List of bindings
- * @throws Exception
- */
- List<Binding> loadBindings(QueueFactory queueFactory) throws Exception;
-
- /**
- * Add a binding into the store
- * @param binding The binding to add
- * @throws Exception
- */
- void addBinding(Binding binding) throws Exception;
-
- /**
- * Delete a binding from the store
- * @param binding The binding to delete
- * @throws Exception
- */
- void deleteBinding(Binding binding) throws Exception;
-
-}
Copied: trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java (from rev 3883, trunk/src/main/org/jboss/messaging/core/persistence/PersistenceManager.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.persistence;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.message.MessageReference;
+import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.MessagingComponent;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.QueueFactory;
+
+/**
+ *
+ * A StorageManager
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface StorageManager extends MessagingComponent
+{
+
+ // Message related operations
+
+ long generateMessageID();
+
+ long generateTransactionID();
+
+
+ void storeMessage(String address, Message message) throws Exception;
+
+ void storeAcknowledge(long queueID, long messageID) throws Exception;
+
+ void storeDelete(long messageID) throws Exception;
+
+
+ void storeMessageTransactional(long txID, String address, Message message) throws Exception;
+
+ void storeAcknowledgeTransactional(long txID, long queueID, long messageiD) throws Exception;
+
+ void storeDeleteTransactional(long txID, long messageID) throws Exception;
+
+
+ void prepare(long txID) throws Exception;
+
+ void commit(long txID) throws Exception;
+
+ void rollback(long txID) throws Exception;
+
+
+ void updateDeliveryCount(MessageReference ref) throws Exception;
+
+ void loadMessages(PostOffice postOffice, Map<Long, Queue> queues) throws Exception;
+
+
+ // Bindings related operations
+
+ void addBinding(Binding binding) throws Exception;
+
+ void deleteBinding(Binding binding) throws Exception;
+
+ boolean addDestination(String destination) throws Exception;
+
+ boolean deleteDestination(String destination) throws Exception;
+
+
+ void loadBindings(QueueFactory queueFactory, List<Binding> bindings,
+ List<String> destinations) throws Exception;
+
+}
Added: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,624 @@
+package org.jboss.messaging.core.persistence.impl.journal;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.filter.impl.FilterImpl;
+import org.jboss.messaging.core.journal.Journal;
+import org.jboss.messaging.core.journal.PreparedTransactionInfo;
+import org.jboss.messaging.core.journal.RecordInfo;
+import org.jboss.messaging.core.journal.SequentialFileFactory;
+import org.jboss.messaging.core.journal.impl.JournalImpl;
+import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.message.MessageReference;
+import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.postoffice.impl.BindingImpl;
+import org.jboss.messaging.core.server.Configuration;
+import org.jboss.messaging.core.server.JournalType;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.QueueFactory;
+
+/**
+ *
+ * A JournalStorageManager
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class JournalStorageManager implements StorageManager
+{
+ private static final Logger log = Logger.getLogger(JournalStorageManager.class);
+
+ private static final int SIZE_LONG = 8;
+
+ private static final int SIZE_INT = 4;
+
+ private static final int SIZE_BYTE = 1;
+
+ // Bindings journal record type
+
+ private static final byte BINDING_RECORD = 1;
+
+ private static final byte DESTINATION_RECORD = 2;
+
+ // type + expiration + timestamp + priority
+ public static final int SIZE_FIELDS = SIZE_INT + SIZE_LONG + SIZE_LONG + SIZE_BYTE;
+
+ // Message journal record types
+
+ public static final byte ADD_MESSAGE = 1;
+
+ public static final byte ACKNOWLEDGE_REF = 2;
+
+ public static final byte UPDATE_DELIVERY_COUNT = 3;
+
+ public static final byte SET_SCHEDULED_DELIVERY_TIME = 4;
+
+ private final AtomicLong messageIDSequence = new AtomicLong(0);
+
+ private final AtomicLong bindingIDSequence = new AtomicLong(0);
+
+ private final Journal messageJournal;
+
+ private final Journal bindingsJournal;
+
+ private final ConcurrentMap<String, Long> destinationIDMap = new ConcurrentHashMap<String, Long>();
+
+ private volatile boolean started;
+
+ public JournalStorageManager(Configuration config)
+ {
+ if (config.getJournalType() != JournalType.NIO)
+ {
+ throw new IllegalArgumentException("Only support NIO journal");
+ }
+
+ String bindingsDir = config.getBindingsDirectory();
+
+ if (bindingsDir == null)
+ {
+ throw new NullPointerException("bindings-dir is null");
+ }
+
+ checkAndCreateDir(bindingsDir, config.isCreateBindingsDir());
+
+ SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir);
+
+ bindingsJournal = new JournalImpl(1024 * 1024, 2, 2, true, bindingsFF, 30000, "jbm-bindings", "bindings");
+
+ String journalDir = config.getJournalDirectory();
+
+ if (journalDir == null)
+ {
+ throw new NullPointerException("journal-dir is null");
+ }
+
+ checkAndCreateDir(journalDir, config.isCreateBindingsDir());
+
+ SequentialFileFactory journalFF = new NIOSequentialFileFactory(journalDir);
+
+ messageJournal = new JournalImpl(config.getJournalFileSize(), config.getJournalMinFiles(),
+ config.getJournalMinAvailableFiles(), config.isJournalSync(), journalFF,
+ config.getJournalTaskPeriod(), "jbm-data", "jbm");
+ }
+
+ public long generateMessageID()
+ {
+ return messageIDSequence.getAndIncrement();
+ }
+
+ public long generateTransactionID()
+ {
+ return messageJournal.getTransactionID();
+ }
+
+ // Non transactional operations
+
+ public void storeMessage(final String address, final Message message) throws Exception
+ {
+ byte[] bytes = messageBytes(address, message);
+
+ messageJournal.appendAddRecord(message.getMessageID(), bytes);
+ }
+
+ public void storeAcknowledge(final long queueID, final long messageID) throws Exception
+ {
+ byte[] record = ackBytes(queueID, messageID);
+
+ messageJournal.appendUpdateRecord(messageID, record);
+ }
+
+ public void storeDelete(final long messageID) throws Exception
+ {
+ messageJournal.appendDeleteRecord(messageID);
+ }
+
+ // Transactional operations
+
+ public void storeMessageTransactional(long txID, String address, Message message) throws Exception
+ {
+ byte[] bytes = messageBytes(address, message);
+
+ messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), bytes);
+ }
+
+ public void storeAcknowledgeTransactional(long txID, long queueID, long messageID) throws Exception
+ {
+ byte[] record = ackBytes(queueID, messageID);
+
+ messageJournal.appendUpdateRecordTransactional(txID, messageID, record);
+ }
+
+ public void storeDeleteTransactional(long txID, long messageID) throws Exception
+ {
+ messageJournal.appendDeleteRecordTransactional(txID, messageID);
+ }
+
+ public void prepare(long txID) throws Exception
+ {
+ messageJournal.appendPrepareRecord(txID);
+ }
+
+ public void commit(long txID) throws Exception
+ {
+ messageJournal.appendCommitRecord(txID);
+ }
+
+ public void rollback(long txID) throws Exception
+ {
+ messageJournal.appendRollbackRecord(txID);
+ }
+
+ // Other operations
+
+ public void updateDeliveryCount(final MessageReference ref) throws Exception
+ {
+ byte[] bytes = new byte[SIZE_BYTE + SIZE_LONG + SIZE_LONG + SIZE_INT];
+
+ ByteBuffer bb = ByteBuffer.wrap(bytes);
+
+ bb.put(UPDATE_DELIVERY_COUNT);
+
+ bb.putLong(ref.getQueue().getPersistenceID());
+
+ bb.putLong(ref.getMessage().getMessageID());
+
+ bb.putInt(ref.getDeliveryCount());
+
+ messageJournal.appendUpdateRecord(ref.getMessage().getMessageID(), bytes);
+ }
+
+ public void loadMessages(final PostOffice postOffice, final Map<Long, Queue> queues) throws Exception
+ {
+ log.info("*** loading message data");
+
+ List<RecordInfo> records = new ArrayList<RecordInfo>();
+
+ List<PreparedTransactionInfo> preparedTransactions = new ArrayList<PreparedTransactionInfo>();
+
+ messageJournal.load(records, preparedTransactions);
+
+ long maxMessageID = -1;
+
+ for (RecordInfo record: records)
+ {
+ byte[] data = record.data;
+
+ ByteBuffer bb = ByteBuffer.wrap(data);
+
+ byte recordType = bb.get();
+
+ switch (recordType)
+ {
+ case ADD_MESSAGE:
+ {
+ int addressLength = bb.getInt();
+
+ byte[] addressBytes = new byte[addressLength];
+
+ bb.get(addressBytes);
+
+ String address = new String(addressBytes, "UTF-8");
+
+ maxMessageID = Math.max(maxMessageID, record.id);
+
+ int type = bb.getInt();
+
+ long expiration = bb.getLong();
+
+ long timestamp = bb.getLong();
+
+ byte priority = bb.get();
+
+ int headerSize = bb.getInt();
+
+ byte[] headers = new byte[headerSize];
+
+ bb.get(headers);
+
+ int payloadSize = bb.getInt();
+
+ byte[] payload = new byte[payloadSize];
+
+ bb.get(payload);
+
+ Message message = new MessageImpl(record.id, type, true, expiration, timestamp, priority,
+ headers, payload);
+
+ List<MessageReference> refs = postOffice.route(address, message);
+
+ for (MessageReference ref: refs)
+ {
+ ref.getQueue().addLast(ref);
+ }
+
+ break;
+ }
+ case ACKNOWLEDGE_REF:
+ {
+ long queueID = bb.getLong();
+
+ long messageID = bb.getLong();
+
+ Queue queue = queues.get(queueID);
+
+ if (queue == null)
+ {
+ throw new IllegalStateException("Cannot find queue with id " + queueID);
+ }
+
+ boolean removed = queue.removeReferenceWithID(messageID);
+
+ if (!removed)
+ {
+ throw new IllegalStateException("Failed to remove reference for " + messageID);
+ }
+
+ break;
+ }
+ case UPDATE_DELIVERY_COUNT:
+ {
+ long queueID = bb.getLong();
+
+ long messageID = bb.getLong();
+
+ int deliveryCount = bb.getInt();
+
+ Queue queue = queues.get(queueID);
+
+ if (queue == null)
+ {
+ throw new IllegalStateException("Cannot find queue with id " + queueID);
+ }
+
+ MessageReference reference = queue.getReference(messageID);
+
+ if (reference == null)
+ {
+ throw new IllegalStateException("Failed to find reference for " + messageID);
+ }
+
+ reference.setDeliveryCount(deliveryCount);
+
+ break;
+
+ }
+ case SET_SCHEDULED_DELIVERY_TIME:
+ {
+ //TODO
+ }
+ default:
+ {
+ throw new IllegalStateException("Invalid record type " + recordType);
+ }
+ }
+ }
+
+ messageIDSequence.set(maxMessageID + 1);
+
+ log.info("****** Loaded message data");
+ }
+
+ //Bindings operations
+
+ public void addBinding(Binding binding) throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ DataOutputStream daos = new DataOutputStream(baos);
+
+ /*
+ We store:
+ *
+ * Queue name
+ * Address string
+ * All nodes?
+ * Filter string
+ */
+
+ Queue queue = binding.getQueue();
+
+ //We generate the queue id here
+
+ long queueID = bindingIDSequence.getAndIncrement();
+
+ queue.setPersistenceID(queueID);
+
+ daos.writeByte(BINDING_RECORD);
+
+ daos.writeUTF(queue.getName());
+
+ daos.writeUTF(binding.getAddress());
+
+ Filter filter = queue.getFilter();
+
+ daos.writeBoolean(filter != null);
+
+ if (filter != null)
+ {
+ daos.writeUTF(filter.getFilterString());
+ }
+
+ daos.flush();
+
+ byte[] data = baos.toByteArray();
+
+ bindingsJournal.appendAddRecord(queueID, data);
+ }
+
+ public void deleteBinding(Binding binding) throws Exception
+ {
+ long id = binding.getQueue().getPersistenceID();
+
+ if (id == -1)
+ {
+ throw new IllegalArgumentException("Cannot delete binding, id is " + id);
+ }
+
+ bindingsJournal.appendDeleteRecord(id);
+ }
+
+ public boolean addDestination(final String destination) throws Exception
+ {
+ long destinationID = bindingIDSequence.getAndIncrement();
+
+ if (destinationIDMap.putIfAbsent(destination, destinationID) != null)
+ {
+ //Already exists
+ return false;
+ }
+ else
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ DataOutputStream daos = new DataOutputStream(baos);
+
+ daos.writeByte(DESTINATION_RECORD);
+
+ daos.writeUTF(destination);
+
+ daos.flush();
+
+ byte[] data = baos.toByteArray();
+
+ bindingsJournal.appendAddRecord(destinationID, data);
+
+ return true;
+ }
+ }
+
+ public boolean deleteDestination(final String destination) throws Exception
+ {
+ Long destinationID = destinationIDMap.remove(destination);
+
+ if (destinationID == null)
+ {
+ return false;
+ }
+ else
+ {
+ bindingsJournal.appendDeleteRecord(destinationID);
+
+ return true;
+ }
+ }
+
+ public void loadBindings(final QueueFactory queueFactory,
+ final List<Binding> bindings, final List<String> destinations) throws Exception
+ {
+ log.info("*** loading bindings");
+
+ List<RecordInfo> records = new ArrayList<RecordInfo>();
+
+ bindingsJournal.load(records, null);
+
+ long maxID = -1;
+
+ for (RecordInfo record: records)
+ {
+ long id = record.id;
+
+ maxID = Math.max(maxID, id);
+
+ byte[] data = record.data;
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+
+ DataInputStream dais = new DataInputStream(bais);
+
+ byte rec = dais.readByte();
+
+ if (rec == BINDING_RECORD)
+ {
+ String queueName = dais.readUTF();
+
+ String address = dais.readUTF();
+
+ Filter filter = null;
+
+ if (dais.readBoolean())
+ {
+ filter = new FilterImpl(dais.readUTF());
+ }
+
+ Queue queue = queueFactory.createQueue(id, queueName, filter, true, false);
+
+
+ Binding binding = new BindingImpl(0, address, queue);
+
+ bindings.add(binding);
+ }
+ else if (rec == DESTINATION_RECORD)
+ {
+ String destinationName = dais.readUTF();
+
+ destinationIDMap.put(destinationName, id);
+
+ destinations.add(destinationName);
+ }
+ else
+ {
+ throw new IllegalStateException("Invalid record type " + rec);
+ }
+ }
+
+ bindingIDSequence.set(maxID + 1);
+
+ log.info("Loaded bindings");
+ }
+
+ // MessagingComponent implementation ------------------------------------------------------
+
+ public synchronized void start() throws Exception
+ {
+ if (started)
+ {
+ throw new IllegalStateException("Already started");
+ }
+
+ bindingsJournal.start();
+
+ messageJournal.start();
+
+ started = true;
+ }
+
+ public synchronized void stop() throws Exception
+ {
+ if (!started)
+ {
+ throw new IllegalStateException("Already started");
+ }
+
+ bindingsJournal.stop();
+
+ messageJournal.stop();
+
+ started = false;
+ }
+
+ // Private ----------------------------------------------------------------------------------
+
+ private byte[] messageBytes(final String address, final Message message) throws Exception
+ {
+ //TODO optimise this
+
+ byte[] addressBytes = address.getBytes("UTF-8");
+
+ byte[] headers = message.getHeaderBytes();
+
+ int headersLength = headers.length;
+
+ byte[] payload = message.getPayload();
+
+ int payloadLength = payload == null ? 0 : payload.length;
+
+ byte[] bytes = new byte[SIZE_BYTE + SIZE_INT + addressBytes.length + SIZE_FIELDS + 2 * SIZE_INT + headersLength + payloadLength];
+
+ ByteBuffer buffer = ByteBuffer.wrap(bytes);
+
+ buffer.put(ADD_MESSAGE);
+
+ buffer.putInt(addressBytes.length);
+ buffer.put(addressBytes);
+
+ //Put the fields
+ buffer.putInt(message.getType());
+ buffer.putLong(message.getExpiration());
+ buffer.putLong(message.getTimestamp());
+ buffer.put(message.getPriority());
+
+ buffer.putInt(headersLength);
+ buffer.put(headers);
+
+ buffer.putInt(payloadLength);
+ if (payload != null)
+ {
+ buffer.put(payload);
+ }
+
+ return bytes;
+ }
+
+ private byte[] ackBytes(final long queueID, final long messageID)
+ {
+ byte[] record = new byte[SIZE_BYTE + SIZE_LONG + SIZE_LONG];
+
+ ByteBuffer bb = ByteBuffer.wrap(record);
+
+ bb.put(ACKNOWLEDGE_REF);
+
+ bb.putLong(queueID);
+
+ bb.putLong(messageID);
+
+ return record;
+ }
+
+ private void checkAndCreateDir(String dir, boolean create)
+ {
+ File f = new File(dir);
+
+ if (!f.exists())
+ {
+ log.info("Directory " + dir + " does not already exists");
+
+ if (create)
+ {
+ log.info("Creating it");
+
+ if (!f.mkdirs())
+ {
+ throw new IllegalStateException("Failed to create directory " + dir);
+ }
+ }
+ else
+ {
+ log.info("Not creating it");
+
+ throw new IllegalArgumentException("Directory " + dir + " does not exist and will not create it");
+ }
+ }
+ else
+ {
+ log.info("Directory " + dir + " already exists");
+ }
+ }
+
+}
Deleted: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullPersistenceManager.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullPersistenceManager.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.persistence.impl.nullpm;
-
-import javax.transaction.xa.Xid;
-
-import org.jboss.messaging.core.message.Message;
-import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
-import org.jboss.messaging.core.postoffice.Binding;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class NullPersistenceManager implements PersistenceManager
-{
- public long generateMessageID()
- {
- return 0;
- }
-
- public void addMessage(Message message) throws Exception
- {
-
- }
-
- public void deleteReference(MessageReference reference) throws Exception
- {
-
- }
-
- public void commitTransaction(List<Message> messagesToAdd, List<MessageReference> referencesToRemove) throws Exception
- {
-
- }
-
- public void prepareTransaction(Xid xid, List<Message> messagesToAdd, List<MessageReference> referencesToRemove) throws Exception
- {
-
- }
-
- public void commitPreparedTransaction(Xid xid) throws Exception
- {
-
- }
-
- public void unprepareTransaction(Xid xid, List<Message> messagesToAdd, List<MessageReference> referencesToRemove) throws Exception
- {
-
- }
-
- public void updateDeliveryCount(Queue queue, MessageReference ref) throws Exception
- {
-
- }
-
- public void deleteAllReferences(Queue queue) throws Exception
- {
-
- }
-
- public List<Xid> getInDoubtXids() throws Exception
- {
- return new ArrayList<Xid>();
- }
-
- public boolean isInRecoveryMode() throws Exception
- {
- return false;
- }
-
- public void setInRecoveryMode(boolean recoveryMode)
- {
-
- }
-
- public List<Binding> loadBindings(QueueFactory queueFactory) throws Exception
- {
- return new ArrayList<Binding>();
- }
-
- public void addBinding(Binding binding) throws Exception
- {
-
- }
-
- public void deleteBinding(Binding binding) throws Exception
- {
-
- }
-
- public void start() throws Exception
- {
-
- }
-
- public void stop() throws Exception
- {
-
- }
-}
Copied: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java (from rev 3883, trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullPersistenceManager.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.persistence.impl.nullpm;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.message.MessageReference;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.QueueFactory;
+
+/**
+ *
+ * A NullStorageManager
+ *
+ * @author <a href="mailto:ataylor at redhat.com">Andy Taylor</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class NullStorageManager implements StorageManager
+{
+ private final AtomicLong messageIDSequence = new AtomicLong(0);
+
+ private final AtomicLong transactionIDSequence = new AtomicLong(0);
+
+ private volatile boolean started;
+
+ public void addBinding(Binding binding) throws Exception
+ {
+ }
+
+ public boolean addDestination(String destination) throws Exception
+ {
+ return true;
+ }
+
+ public void commit(long txID) throws Exception
+ {
+ }
+
+ public void deleteBinding(Binding binding) throws Exception
+ {
+ }
+
+ public boolean deleteDestination(String destination) throws Exception
+ {
+ return true;
+ }
+
+ public void loadBindings(QueueFactory queueFactory, List<Binding> bindings,
+ List<String> destinations) throws Exception
+ {
+ }
+
+ public void loadMessages(PostOffice postOffice, Map<Long, Queue> queues)
+ throws Exception
+ {
+ }
+
+ public void prepare(long txID) throws Exception
+ {
+ }
+
+ public void rollback(long txID) throws Exception
+ {
+ }
+
+ public void storeAcknowledge(long queueID, long messageID) throws Exception
+ {
+ }
+
+ public void storeAcknowledgeTransactional(long txID, long queueID,
+ long messageiD) throws Exception
+ {
+ }
+
+ public void storeDelete(long messageID) throws Exception
+ {
+ }
+
+ public void storeDeleteTransactional(long txID, long messageID)
+ throws Exception
+ {
+ }
+
+ public void storeMessage(String address, Message message) throws Exception
+ {
+ }
+
+ public void storeMessageTransactional(long txID, String address,
+ Message message) throws Exception
+ {
+ }
+
+ public void updateDeliveryCount(MessageReference ref) throws Exception
+ {
+ }
+
+ public long generateMessageID()
+ {
+ return messageIDSequence.getAndIncrement();
+ }
+
+ public long generateTransactionID()
+ {
+ return transactionIDSequence.getAndIncrement();
+ }
+
+ public synchronized void start() throws Exception
+ {
+ if (started)
+ {
+ throw new IllegalStateException("Already started");
+ }
+
+ started = true;
+ }
+
+ public synchronized void stop() throws Exception
+ {
+ if (!started)
+ {
+ throw new IllegalStateException("Not started");
+ }
+
+ started = false;
+ }
+
+}
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -27,6 +27,7 @@
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.message.MessageReference;
import org.jboss.messaging.core.server.MessagingComponent;
/**
@@ -52,11 +53,11 @@
*/
public interface PostOffice extends MessagingComponent
{
- void addAllowableAddress(String address) throws Exception;
+ boolean addDestination(String address, boolean temporary) throws Exception;
- boolean removeAllowableAddress(String address) throws Exception;
+ boolean removeDestination(String address, boolean temporary) throws Exception;
- boolean containsAllowableAddress(String address);
+ boolean containsDestination(String address);
Binding addBinding(String address, String queueName, Filter filter,
boolean durable, boolean temporary) throws Exception;
@@ -67,7 +68,7 @@
Binding getBinding(String queueName) throws Exception;
- void route(String address, Message message) throws Exception;
+ List<MessageReference> route(String address, Message message) throws Exception;
void routeFromCluster(String address, Message message) throws Exception;
@@ -78,5 +79,5 @@
//For testing only
Map<String, List<Binding>> getMappings();
- Set<String> listAvailableAddresses();
+ Set<String> listAllDestinations();
}
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core.postoffice.impl;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -35,13 +36,14 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.FlowController;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.QueueFactory;
import org.jboss.messaging.util.ConcurrentHashSet;
+import org.jboss.messaging.util.ConcurrentSet;
/**
*
@@ -58,24 +60,24 @@
private final ConcurrentMap<String, List<Binding>> mappings = new ConcurrentHashMap<String, List<Binding>>();
- private final Set<String> allowableAddresses = new ConcurrentHashSet<String>();
+ private final ConcurrentSet<String> destinations = new ConcurrentHashSet<String>();
private final ConcurrentMap<String, Binding> nameMap = new ConcurrentHashMap<String, Binding>();
private final ConcurrentMap<String, FlowController> flowControllers = new ConcurrentHashMap<String, FlowController>();
- private final PersistenceManager persistenceManager;
-
private final QueueFactory queueFactory;
private final boolean checkAllowable;
+
+ private final StorageManager storageManager;
- public PostOfficeImpl(final int nodeID, final PersistenceManager persistenceManager,
+ public PostOfficeImpl(final int nodeID, final StorageManager storageManager,
final QueueFactory queueFactory, final boolean checkAllowable)
{
this.nodeID = nodeID;
- this.persistenceManager = persistenceManager;
+ this.storageManager = storageManager;
this.queueFactory = queueFactory;
@@ -93,38 +95,53 @@
{
mappings.clear();
- allowableAddresses.clear();
+ destinations.clear();
}
// PostOffice implementation -----------------------------------------------
- public void addAllowableAddress(final String address) throws Exception
+ public boolean addDestination(final String address, final boolean temporary) throws Exception
{
- allowableAddresses.add(address);
-
- flowControllers.put(address, new FlowControllerImpl(address, this));
+ boolean added = destinations.addIfAbsent(address);
+
+ if (added)
+ {
+ if (!temporary)
+ {
+ storageManager.addDestination(address);
+ }
+
+ flowControllers.put(address, new FlowControllerImpl(address, this));
+ }
+
+ return added;
}
- public boolean removeAllowableAddress(final String address) throws Exception
+ public boolean removeDestination(final String address, final boolean temporary) throws Exception
{
- boolean removed = allowableAddresses.remove(address);
+ boolean removed = destinations.remove(address);
if (removed)
{
flowControllers.remove(address);
+
+ if (!temporary)
+ {
+ storageManager.deleteDestination(address);
+ }
}
-
+
return removed;
}
- public boolean containsAllowableAddress(final String address)
+ public boolean containsDestination(final String address)
{
- return allowableAddresses.contains(address);
+ return destinations.contains(address);
}
- public Set<String> listAvailableAddresses()
+ public Set<String> listAllDestinations()
{
- return allowableAddresses;
+ return destinations;
}
public Binding addBinding(final String address, final String queueName, final Filter filter,
@@ -136,7 +153,7 @@
if (durable)
{
- persistenceManager.addBinding(binding);
+ storageManager.addBinding(binding);
}
return binding;
@@ -148,7 +165,7 @@
if (binding.getQueue().isDurable())
{
- persistenceManager.deleteBinding(binding);
+ storageManager.deleteBinding(binding);
}
return binding;
@@ -179,13 +196,11 @@
return nameMap.get(queueName);
}
- public void route(final String address, final Message message) throws Exception
+ public List<MessageReference> route(final String address, final Message message) throws Exception
{
- // boolean routeRemote = false;
-
if (checkAllowable)
{
- if (!allowableAddresses.contains(address))
+ if (!destinations.contains(address))
{
throw new MessagingException(MessagingException.ADDRESS_DOES_NOT_EXIST,
"Cannot route to address " + address);
@@ -194,6 +209,8 @@
List<Binding> bindings = mappings.get(address);
+ List<MessageReference> refs = new ArrayList<MessageReference>();
+
if (bindings != null)
{
for (Binding binding: bindings)
@@ -201,32 +218,15 @@
Queue queue = binding.getQueue();
if (queue.getFilter() == null || queue.getFilter().match(message))
- {
- if (binding.getNodeID() == nodeID)
- {
- //Local queue
-
- message.createReference(queue);
- }
- else
- {
-// if (!queue.isDurable())
-// {
-// //Remote queue - we never route to remote durable queues since we will lose atomicity in event
-// //of crash - for moving between durable queues we use message redistribution
-//
-// routeRemote = true;
-// }
- }
+ {
+ MessageReference reference = message.createReference(queue);
+
+ refs.add(reference);
}
}
}
-
-// if (routeRemote)
-// {
-// tx.addSynchronization(new CastMessageCallback(new MessageRequest(address, message)));
-// }
+ return refs;
}
public void routeFromCluster(final String address, final Message message) throws Exception
@@ -338,12 +338,24 @@
private void loadBindings() throws Exception
{
- List<Binding> bindings = persistenceManager.loadBindings(queueFactory);
+ List<Binding> bindings = new ArrayList<Binding>();
+ List<String> dests = new ArrayList<String>();
+
+ storageManager.loadBindings(queueFactory, bindings, dests);
+
+ Map<Long, Queue> queues = new HashMap<Long, Queue>();
+
for (Binding binding: bindings)
{
- addBindingInMemory(binding);
+ addBindingInMemory(binding);
+
+ queues.put(binding.getQueue().getPersistenceID(), binding.getQueue());
}
+
+ destinations.addAll(dests);
+
+ storageManager.loadMessages(this, queues);
}
}
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddAddressMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddAddressMessageCodec.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddAddressMessageCodec.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.impl.codec;
-
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_ADDRESS;
-
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddAddressMessage;
-
-/**
- *
- * A SessionAddAddressMessageCodec
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionAddAddressMessageCodec extends AbstractPacketCodec<SessionAddAddressMessage>
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public SessionAddAddressMessageCodec()
- {
- super(SESS_ADD_ADDRESS);
- }
-
- // Public --------------------------------------------------------
-
- // AbstractPacketCodec overrides ---------------------------------
-
- @Override
- protected void encodeBody(SessionAddAddressMessage message, RemotingBuffer out) throws Exception
- {
- String address = message.getAddress();
-
- int bodyLength = sizeof(address);
-
- out.putInt(bodyLength);
- out.putNullableString(address);
- }
-
- @Override
- protected SessionAddAddressMessage decodeBody(RemotingBuffer in)
- throws Exception
- {
- int bodyLength = in.getInt();
- if (in.remaining() < bodyLength)
- {
- return null;
- }
-
- String address = in.getNullableString();
-
- return new SessionAddAddressMessage(address);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private ----------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
-
Copied: trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddDestinationMessageCodec.java (from rev 3884, trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddAddressMessageCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddDestinationMessageCodec.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionAddDestinationMessageCodec.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.impl.codec;
+
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_DESTINATION;
+
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
+
+/**
+ *
+ * A SessionAddDestinationMessageCodec
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionAddDestinationMessageCodec extends AbstractPacketCodec<SessionAddDestinationMessage>
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SessionAddDestinationMessageCodec()
+ {
+ super(SESS_ADD_DESTINATION);
+ }
+
+ // Public --------------------------------------------------------
+
+ // AbstractPacketCodec overrides ---------------------------------
+
+ @Override
+ protected void encodeBody(SessionAddDestinationMessage message, RemotingBuffer out) throws Exception
+ {
+ String address = message.getAddress();
+
+ int bodyLength = sizeof(address);
+
+ out.putInt(bodyLength);
+ out.putNullableString(address);
+ out.putBoolean(message.isTemporary());
+ }
+
+ @Override
+ protected SessionAddDestinationMessage decodeBody(RemotingBuffer in)
+ throws Exception
+ {
+ int bodyLength = in.getInt();
+ if (in.remaining() < bodyLength)
+ {
+ return null;
+ }
+
+ String address = in.getNullableString();
+ boolean temp = in.getBoolean();
+
+ return new SessionAddDestinationMessage(address, temp);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private ----------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
+
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveAddressMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveAddressMessageCodec.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveAddressMessageCodec.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.impl.codec;
-
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_ADDRESS;
-
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveAddressMessage;
-
-/**
- *
- * A SessionRemoveAddressMessageCodec
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionRemoveAddressMessageCodec extends AbstractPacketCodec<SessionRemoveAddressMessage>
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public SessionRemoveAddressMessageCodec()
- {
- super(SESS_REMOVE_ADDRESS);
- }
-
- // Public --------------------------------------------------------
-
- // AbstractPacketCodec overrides ---------------------------------
-
- @Override
- protected void encodeBody(SessionRemoveAddressMessage message, RemotingBuffer out) throws Exception
- {
- String address = message.getAddress();
-
- int bodyLength = sizeof(address);
-
- out.putInt(bodyLength);
- out.putNullableString(address);
- }
-
- @Override
- protected SessionRemoveAddressMessage decodeBody(RemotingBuffer in)
- throws Exception
- {
- int bodyLength = in.getInt();
- if (in.remaining() < bodyLength)
- {
- return null;
- }
-
- String address = in.getNullableString();
-
- return new SessionRemoveAddressMessage(address);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private ----------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Copied: trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveDestinationMessageCodec.java (from rev 3884, trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveAddressMessageCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveDestinationMessageCodec.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/SessionRemoveDestinationMessageCodec.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.impl.codec;
+
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_DESTINATION;
+
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
+
+/**
+ *
+ * A SessionRemoveDestinationMessageCodec
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionRemoveDestinationMessageCodec extends AbstractPacketCodec<SessionRemoveDestinationMessage>
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SessionRemoveDestinationMessageCodec()
+ {
+ super(SESS_REMOVE_DESTINATION);
+ }
+
+ // Public --------------------------------------------------------
+
+ // AbstractPacketCodec overrides ---------------------------------
+
+ @Override
+ protected void encodeBody(SessionRemoveDestinationMessage message, RemotingBuffer out) throws Exception
+ {
+ String address = message.getAddress();
+
+ int bodyLength = sizeof(address);
+
+ out.putInt(bodyLength);
+ out.putNullableString(address);
+ out.putBoolean(message.isTemporary());
+ }
+
+ @Override
+ protected SessionRemoveDestinationMessage decodeBody(RemotingBuffer in)
+ throws Exception
+ {
+ int bodyLength = in.getInt();
+ if (in.remaining() < bodyLength)
+ {
+ return null;
+ }
+
+ String address = in.getNullableString();
+
+ return new SessionRemoveDestinationMessage(address, in.getBoolean());
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private ----------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -23,7 +23,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.PROD_RECEIVETOKENS;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.PROD_SEND;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ACKNOWLEDGE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_ADDRESS;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_DESTINATION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_BINDINGQUERY;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_BINDINGQUERY_RESP;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE;
@@ -46,7 +46,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_QUEUEQUERY;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_QUEUEQUERY_RESP;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_RECOVER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_ADDRESS;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_DESTINATION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ROLLBACK;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_COMMIT;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_END;
@@ -83,7 +83,7 @@
import org.jboss.messaging.core.remoting.impl.codec.ProducerSendMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.RemotingBuffer;
import org.jboss.messaging.core.remoting.impl.codec.SessionAcknowledgeMessageCodec;
-import org.jboss.messaging.core.remoting.impl.codec.SessionAddAddressMessageCodec;
+import org.jboss.messaging.core.remoting.impl.codec.SessionAddDestinationMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionBindingQueryMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionBindingQueryResponseMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionBrowserHasNextMessageResponseMessageCodec;
@@ -101,7 +101,7 @@
import org.jboss.messaging.core.remoting.impl.codec.SessionDeleteQueueMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionQueueQueryMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionQueueQueryResponseMessageCodec;
-import org.jboss.messaging.core.remoting.impl.codec.SessionRemoveAddressMessageCodec;
+import org.jboss.messaging.core.remoting.impl.codec.SessionRemoveDestinationMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionXACommitMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionXAEndMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionXAForgetMessageCodec;
@@ -297,8 +297,8 @@
addCodecForEmptyPacket(encoder, decoder, SESS_XA_SUSPEND,
SessionXASuspendMessage.class);
- addCodec(encoder, decoder, SESS_REMOVE_ADDRESS,
- new SessionRemoveAddressMessageCodec());
+ addCodec(encoder, decoder, SESS_REMOVE_DESTINATION,
+ new SessionRemoveDestinationMessageCodec());
addCodec(encoder, decoder, SESS_CREATEQUEUE,
new SessionCreateQueueMessageCodec());
@@ -309,8 +309,8 @@
addCodec(encoder, decoder, SESS_QUEUEQUERY_RESP,
new SessionQueueQueryResponseMessageCodec());
- addCodec(encoder, decoder, SESS_ADD_ADDRESS,
- new SessionAddAddressMessageCodec());
+ addCodec(encoder, decoder, SESS_ADD_DESTINATION,
+ new SessionAddDestinationMessageCodec());
addCodec(encoder, decoder, SESS_BINDINGQUERY,
new SessionBindingQueryMessageCodec());
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -50,8 +50,8 @@
SESS_QUEUEQUERY_RESP ((byte)52),
SESS_CREATEQUEUE ((byte)53),
SESS_DELETE_QUEUE ((byte)54),
- SESS_ADD_ADDRESS ((byte)55),
- SESS_REMOVE_ADDRESS ((byte)56),
+ SESS_ADD_DESTINATION ((byte)55),
+ SESS_REMOVE_DESTINATION ((byte)56),
SESS_BINDINGQUERY ((byte)57),
SESS_BINDINGQUERY_RESP ((byte)58),
SESS_BROWSER_RESET ((byte)59),
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddAddressMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddAddressMessage.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddAddressMessage.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.impl.wireformat;
-
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_ADDRESS;
-
-
-/**
- *
- * A SessionAddAddressMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionAddAddressMessage extends AbstractPacket
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private final String address;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public SessionAddAddressMessage(final String address)
- {
- super(SESS_ADD_ADDRESS);
-
- this.address = address;
- }
-
- // Public --------------------------------------------------------
-
- public String getAddress()
- {
- return address;
- }
-
- @Override
- public String toString()
- {
- return getParentString() + ", address=" + address + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
-
Copied: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java (from rev 3884, trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddAddressMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.impl.wireformat;
+
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_DESTINATION;
+
+
+/**
+ *
+ * A SessionAddDestinationMessage
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionAddDestinationMessage extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final String address;
+
+ private final boolean temporary;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SessionAddDestinationMessage(final String address, final boolean temp)
+ {
+ super(SESS_ADD_DESTINATION);
+
+ this.address = address;
+
+ this.temporary = temp;
+ }
+
+ // Public --------------------------------------------------------
+
+ public String getAddress()
+ {
+ return address;
+ }
+
+ public boolean isTemporary()
+ {
+ return temporary;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getParentString() + ", address=" + address + ", temp=" + temporary +"]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
+
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveAddressMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveAddressMessage.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveAddressMessage.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.impl.wireformat;
-
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_ADDRESS;
-
-
-/**
- *
- * A SessionRemoveAddressMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionRemoveAddressMessage extends AbstractPacket
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private final String address;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public SessionRemoveAddressMessage(final String address)
- {
- super(SESS_REMOVE_ADDRESS);
-
- this.address = address;
- }
-
- // Public --------------------------------------------------------
-
- public String getAddress()
- {
- return address;
- }
-
- @Override
- public String toString()
- {
- return getParentString() + ", address=" + address + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
-
-
Copied: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java (from rev 3884, trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveAddressMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.impl.wireformat;
+
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_DESTINATION;
+
+
+/**
+ *
+ * A SessionRemoveDestinationMessage
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionRemoveDestinationMessage extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final String address;
+
+ private final boolean temporary;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SessionRemoveDestinationMessage(final String address, final boolean temporary)
+ {
+ super(SESS_REMOVE_DESTINATION);
+
+ this.address = address;
+
+ this.temporary = temporary;
+ }
+
+ // Public --------------------------------------------------------
+
+ public String getAddress()
+ {
+ return address;
+ }
+
+ public boolean isTemporary()
+ {
+ return temporary;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getParentString() + ", address=" + address + ", temp=" + temporary + "]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
+
+
Modified: trunk/src/main/org/jboss/messaging/core/server/Configuration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Configuration.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/Configuration.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -64,6 +64,30 @@
protected long securityInvalidationInterval = 10000;
protected RemotingConfigurationImpl remotingConfig;
+
+ protected boolean requireDestinations;
+
+ //Persistence config
+
+ protected String bindingsDirectory;
+
+ protected boolean createBindingsDir;
+
+ protected String journalDirectory;
+
+ protected boolean createJournalDir;
+
+ protected JournalType journalType;
+
+ protected boolean journalSync;
+
+ protected int journalFileSize;
+
+ protected int journalMinFiles;
+
+ protected int journalMinAvailableFiles;
+
+ protected long journalTaskPeriod;
public void addPropertyChangeListener(PropertyChangeListener listener)
{
@@ -251,7 +275,117 @@
return remotingConfig.getURI();
}
+ public String getBindingsDirectory()
+ {
+ return bindingsDirectory;
+ }
+ public void setBindingsDirectory(String bindingsDirectory)
+ {
+ this.bindingsDirectory = bindingsDirectory;
+ }
+
+ public String getJournalDirectory()
+ {
+ return journalDirectory;
+ }
+
+ public void setJournalDirectory(String journalDirectory)
+ {
+ this.journalDirectory = journalDirectory;
+ }
+
+ public JournalType getJournalType()
+ {
+ return journalType;
+ }
+
+ public void setJournalType(JournalType journalType)
+ {
+ this.journalType = journalType;
+ }
+
+ public boolean isJournalSync()
+ {
+ return journalSync;
+ }
+
+ public void setJournalSync(boolean journalSync)
+ {
+ this.journalSync = journalSync;
+ }
+
+ public int getJournalFileSize()
+ {
+ return journalFileSize;
+ }
+
+ public void setJournalFileSize(int journalFileSize)
+ {
+ this.journalFileSize = journalFileSize;
+ }
+
+ public int getJournalMinFiles()
+ {
+ return journalMinFiles;
+ }
+
+ public void setJournalMinFiles(int journalMinFiles)
+ {
+ this.journalMinFiles = journalMinFiles;
+ }
+
+ public int getJournalMinAvailableFiles()
+ {
+ return journalMinAvailableFiles;
+ }
+
+ public void setJournalMinAvailableFiles(int journalMinAvailableFiles)
+ {
+ this.journalMinAvailableFiles = journalMinAvailableFiles;
+ }
+
+ public long getJournalTaskPeriod()
+ {
+ return journalTaskPeriod;
+ }
+
+ public void setJournalTaskPeriod(long journalTaskPeriod)
+ {
+ this.journalTaskPeriod = journalTaskPeriod;
+ }
+
+ public boolean isCreateBindingsDir()
+ {
+ return createBindingsDir;
+ }
+
+ public void setCreateBindingsDir(boolean createBindingsDir)
+ {
+ this.createBindingsDir = createBindingsDir;
+ }
+
+ public boolean isCreateJournalDir()
+ {
+ return createJournalDir;
+ }
+
+ public void setCreateJournalDir(boolean createJournalDir)
+ {
+ this.createJournalDir = createJournalDir;
+ }
+
+ public boolean isRequireDestinations()
+ {
+ return requireDestinations;
+ }
+
+ public void setRequireDestinations(boolean requireDestinations)
+ {
+ this.requireDestinations = requireDestinations;
+ }
+
+
// /**
// * If the system property <code>jbm.remoting.disable.invm</code> is set, its boolean value is used
Added: trunk/src/main/org/jboss/messaging/core/server/JournalType.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/JournalType.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/JournalType.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.server;
+
+/**
+ *
+ * A JournalType
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public enum JournalType
+{
+ NIO, ASYNCIO, JDBC;
+}
Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -23,7 +23,8 @@
import java.util.HashSet;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.deployers.DeploymentManager;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.remoting.RemotingService;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
@@ -32,8 +33,6 @@
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.version.Version;
-import org.jboss.messaging.core.deployers.DeploymentManager;
-import org.jboss.messaging.core.filter.Filter;
/**
* This interface defines the internal interface of the Messaging Server exposed
@@ -70,10 +69,10 @@
ConnectionManager getConnectionManager();
- PersistenceManager getPersistenceManager();
+ StorageManager getStorageManager();
- void setPersistenceManager(PersistenceManager persistenceManager);
-
+ void setStorageManager(StorageManager storageManager);
+
PostOffice getPostOffice();
HierarchicalRepository<HashSet<Role>> getSecurityRepository();
Modified: trunk/src/main/org/jboss/messaging/core/server/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -27,7 +27,7 @@
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.message.MessageReference;
import org.jboss.messaging.core.postoffice.FlowController;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
/**
@@ -63,12 +63,6 @@
List<MessageReference> list(Filter filter);
- void removeAllReferences();
-
- void removeReference(MessageReference messageReference);
-
- void changePriority(final MessageReference messageReference, int priority);
-
long getPersistenceID();
void setPersistenceID(long id);
@@ -108,6 +102,10 @@
FlowController getFlowController();
void setFlowController(FlowController flowController);
-
- void move(MessageReference messageReference, Queue queue, PersistenceManager persistenceManager) throws Exception;
+
+ boolean removeReferenceWithID(long id);
+
+ MessageReference getReference(long id);
+
+ void deleteAllReferences(StorageManager storageManager) throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -60,6 +60,10 @@
void removeTemporaryQueue(Queue queue);
+ void addTemporaryDestination(String destination);
+
+ void removeTemporaryDestination(String destination);
+
boolean isStarted();
long getCreatedTime();
Modified: trunk/src/main/org/jboss/messaging/core/server/ServerSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -95,9 +95,9 @@
boolean setXATimeout(int timeoutSeconds);
- void addAddress(String address) throws Exception;
+ void addDestination(String address, boolean temporary) throws Exception;
- void removeAddress(String address) throws Exception;
+ void removeDestination(String address, boolean temporary) throws Exception;
void createQueue(String address, String queueName, String filterString, boolean durable, boolean temporary) throws Exception;
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/DeliveryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/DeliveryImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/DeliveryImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -24,6 +24,7 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.remoting.PacketSender;
import org.jboss.messaging.core.remoting.impl.wireformat.ConsumerDeliverMessage;
import org.jboss.messaging.core.server.Delivery;
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -33,8 +33,8 @@
import org.jboss.messaging.core.deployers.impl.SecurityDeployer;
import org.jboss.messaging.core.memory.MemoryManager;
import org.jboss.messaging.core.memory.impl.SimpleMemoryManager;
-import org.jboss.messaging.core.persistence.PersistenceManager;
-import org.jboss.messaging.core.persistence.impl.nullpm.NullPersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.persistence.impl.nullpm.NullStorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
import org.jboss.messaging.core.remoting.Interceptor;
@@ -99,9 +99,8 @@
// plugins
- private PersistenceManager persistenceManager = new NullPersistenceManager();
+ private StorageManager storageManager = new NullStorageManager();
-
private RemotingService remotingService;
private boolean createTransport = false;
@@ -167,7 +166,7 @@
connectionManager = new ConnectionManagerImpl();
memoryManager = new SimpleMemoryManager();
postOffice = new PostOfficeImpl(configuration.getMessagingServerID(),
- persistenceManager, queueFactory, configuration.isStrictTck());
+ storageManager, queueFactory, configuration.isRequireDestinations());
queueSettingsDeployer = new QueueSettingsDeployer(postOffice, queueSettingsRepository);
if (createTransport)
@@ -180,6 +179,7 @@
remotingService.addFailureListener(connectionManager);
memoryManager.start();
postOffice.start();
+
deploymentManager.start();
deploymentManager.registerDeployer(securityDeployer);
deploymentManager.registerDeployer(queueSettingsDeployer);
@@ -199,7 +199,7 @@
log.warn("Error instantiating interceptor \"" + interceptorClass + "\"", e);
}
}
-
+
started = true;
}
@@ -269,37 +269,22 @@
{
return deploymentManager;
}
-
-
-
- public void createQueue(String address, String name) throws Exception
- {
- if (postOffice.getBinding(name) == null)
- {
- postOffice.addBinding(address, name, null, true, false);
- }
-
- if (!postOffice.containsAllowableAddress(address))
- {
- postOffice.addAllowableAddress(address);
- }
- }
-
+
public ConnectionManager getConnectionManager()
{
return connectionManager;
}
- public PersistenceManager getPersistenceManager()
+ public StorageManager getStorageManager()
{
- return persistenceManager;
+ return storageManager;
}
- public void setPersistenceManager(PersistenceManager persistenceManager)
+ public void setStorageManager(StorageManager storageManager)
{
- this.persistenceManager = persistenceManager;
+ this.storageManager = storageManager;
}
-
+
public PostOffice getPostOffice()
{
return postOffice;
@@ -352,7 +337,7 @@
final ServerConnection connection =
new ServerConnectionImpl(username, password,
remotingClientSessionID, clientVMID, clientAddress,
- remotingService.getDispatcher(), resourceManager, persistenceManager,
+ remotingService.getDispatcher(), resourceManager, storageManager,
queueSettingsRepository,
postOffice, securityStore, connectionManager);
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -22,7 +22,7 @@
package org.jboss.messaging.core.server.impl;
import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -37,14 +37,14 @@
import org.jboss.messaging.core.list.impl.PriorityLinkedListImpl;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.FlowController;
import org.jboss.messaging.core.server.Consumer;
import org.jboss.messaging.core.server.DistributionPolicy;
import org.jboss.messaging.core.server.HandleStatus;
import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.transaction.Transaction;
import org.jboss.messaging.core.transaction.impl.TransactionImpl;
-import org.jboss.messaging.core.persistence.PersistenceManager;
/**
*
@@ -82,7 +82,7 @@
private final List<Consumer> consumers = new ArrayList<Consumer>();
- private final Set<ScheduledDeliveryRunnable> scheduledRunnables = new HashSet<ScheduledDeliveryRunnable>();
+ private final Set<ScheduledDeliveryRunnable> scheduledRunnables = new LinkedHashSet<ScheduledDeliveryRunnable>();
private volatile DistributionPolicy distributionPolicy = new RoundRobinDistributionPolicy();
@@ -233,18 +233,6 @@
}
}
- public void move(MessageReference messageReference, Queue queue, PersistenceManager persistenceManager) throws Exception
- {
- Message newMessage = messageReference.getMessage().copy();
- MessageReference newRef = newMessage.createReference(queue);
- queue.addLast(newRef);
- messageReferences.remove(messageReference , messageReference.getMessage().getPriority());
- TransactionImpl tx = new TransactionImpl();
- tx.addMessage(newMessage);
- tx.addAcknowledgement(messageReference);
- tx.commit(true, persistenceManager);
- }
-
public synchronized void addConsumer(final Consumer consumer)
{
consumers.add(consumer);
@@ -294,37 +282,46 @@
}
}
- public synchronized void removeAllReferences()
+ public synchronized boolean removeReferenceWithID(final long id)
{
- messageReferences.clear();
-
- if (!scheduledRunnables.isEmpty())
- {
- Set<ScheduledDeliveryRunnable> clone = new HashSet<ScheduledDeliveryRunnable>(scheduledRunnables);
-
- for (ScheduledDeliveryRunnable runnable: clone)
- {
- runnable.cancel();
- }
-
- scheduledRunnables.clear();
- }
+ ListIterator<MessageReference> iterator = messageReferences.iterator();
+
+ boolean removed = false;
+
+ while (iterator.hasNext())
+ {
+ MessageReference ref = iterator.next();
+
+ if (ref.getMessage().getMessageID() == id)
+ {
+ iterator.remove();
+
+ removed = true;
+
+ break;
+ }
+ }
+
+ return removed;
}
-
- public synchronized void removeReference(final MessageReference messageReference)
+
+ public synchronized MessageReference getReference(final long id)
{
- messageReferences.remove(messageReference , messageReference.getMessage().getPriority());
-
- //FIXME - what about scheduled??
+ ListIterator<MessageReference> iterator = messageReferences.iterator();
+
+ while (iterator.hasNext())
+ {
+ MessageReference ref = iterator.next();
+
+ if (ref.getMessage().getMessageID() == id)
+ {
+ return ref;
+ }
+ }
+
+ return null;
}
- public synchronized void changePriority(final MessageReference messageReference, int priority)
- {
- messageReferences.remove(messageReference , messageReference.getMessage().getPriority());
- messageReferences.addLast(messageReference, priority);
- //FIXME - what about scheduled??
- }
-
public long getPersistenceID()
{
return persistenceID;
@@ -417,6 +414,40 @@
return flowController;
}
+ public synchronized void deleteAllReferences(final StorageManager storageManager) throws Exception
+ {
+ Transaction tx = new TransactionImpl(storageManager, null);
+
+ ListIterator<MessageReference> iter = messageReferences.iterator();
+
+ while (iter.hasNext())
+ {
+ MessageReference ref = iter.next();
+
+ deliveringCount.incrementAndGet();
+
+ tx.addAcknowledgement(ref);
+
+ iter.remove();
+ }
+
+ synchronized (scheduledRunnables)
+ {
+ for (ScheduledDeliveryRunnable runnable: scheduledRunnables)
+ {
+ runnable.cancel();
+
+ deliveringCount.incrementAndGet();
+
+ tx.addAcknowledgement(runnable.getReference());
+ }
+
+ scheduledRunnables.clear();
+ }
+
+ tx.commit();
+ }
+
// Public -----------------------------------------------------------------------------
public boolean equals(Object other)
@@ -648,6 +679,11 @@
cancelled = true;
}
+
+ public MessageReference getReference()
+ {
+ return ref;
+ }
public void run()
{
@@ -660,6 +696,8 @@
if (!removed)
{
log.warn("Failed to remove timeout " + this);
+
+ return;
}
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -26,7 +26,7 @@
import java.util.concurrent.ConcurrentMap;
import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.remoting.PacketDispatcher;
@@ -80,7 +80,7 @@
private final ResourceManager resourceManager;
- private final PersistenceManager persistenceManager;
+ private final StorageManager persistenceManager;
private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
@@ -95,6 +95,8 @@
private final ConcurrentMap<String, ServerSession> sessions = new ConcurrentHashMap<String, ServerSession>();
private final Set<Queue> temporaryQueues = new ConcurrentHashSet<Queue>();
+
+ private final Set<String> temporaryDestinations = new ConcurrentHashSet<String>();
private volatile boolean started;
@@ -106,7 +108,7 @@
final String clientAddress,
final PacketDispatcher dispatcher,
final ResourceManager resourceManager,
- final PersistenceManager persistenceManager,
+ final StorageManager persistenceManager,
final HierarchicalRepository<QueueSettings> queueSettingsRepository,
final PostOffice postOffice, final SecurityStore securityStore,
final ConnectionManager connectionManager)
@@ -201,10 +203,17 @@
for (String address: addresses)
{
- postOffice.removeAllowableAddress(address);
+ postOffice.removeDestination(address, true);
}
+
+ for (String address: temporaryDestinations)
+ {
+ postOffice.removeDestination(address, true);
+ }
temporaryQueues.clear();
+
+ temporaryDestinations.clear();
connectionManager.unregisterConnection(remotingClientSessionID, this);
@@ -246,6 +255,16 @@
temporaryQueues.remove(queue);
}
+ public void addTemporaryDestination(final String address)
+ {
+ temporaryDestinations.add(address);
+ }
+
+ public void removeTemporaryDestination(final String address)
+ {
+ temporaryDestinations.remove(address);
+ }
+
public boolean isStarted()
{
return started;
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -28,7 +28,7 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.HandleStatus;
import org.jboss.messaging.core.server.Queue;
@@ -36,6 +36,8 @@
import org.jboss.messaging.core.server.ServerSession;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.core.transaction.Transaction;
+import org.jboss.messaging.core.transaction.impl.TransactionImpl;
import org.jboss.messaging.util.TokenBucketLimiter;
/**
@@ -79,7 +81,7 @@
private final ServerSession sessionEndpoint;
- private final PersistenceManager persistenceManager;
+ private final StorageManager persistenceManager;
private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
@@ -96,7 +98,7 @@
ServerConsumerImpl(final Queue messageQueue, final boolean noLocal, final Filter filter,
final boolean autoDeleteQueue, final boolean enableFlowControl, final int maxRate,
final String connectionID, final ServerSession sessionEndpoint,
- final PersistenceManager persistenceManager,
+ final StorageManager persistenceManager,
final HierarchicalRepository<QueueSettings> queueSettingsRepository,
final PostOffice postOffice,
final boolean started)
@@ -160,7 +162,7 @@
if (ref.getMessage().isExpired())
{
- ref.expire(persistenceManager, queueSettingsRepository);
+ ref.expire(persistenceManager, postOffice, queueSettingsRepository);
return HandleStatus.HANDLED;
}
@@ -187,8 +189,12 @@
if (connectionID.equals(conId))
{
- ref.acknowledge(persistenceManager);
+ Transaction tx = new TransactionImpl(persistenceManager, postOffice);
+ tx.addAcknowledgement(ref);
+
+ tx.commit();
+
return HandleStatus.HANDLED;
}
}
@@ -232,7 +238,7 @@
if (messageQueue.isDurable())
{
- persistenceManager.deleteAllReferences(messageQueue);
+ messageQueue.deleteAllReferences(persistenceManager);
}
}
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -42,7 +42,7 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.FlowController;
import org.jboss.messaging.core.postoffice.PostOffice;
@@ -113,7 +113,7 @@
private final PacketDispatcher dispatcher;
- private final PersistenceManager persistenceManager;
+ private final StorageManager persistenceManager;
private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
@@ -142,7 +142,7 @@
final boolean autoCommitAcks,
final boolean xa, final ServerConnection connection,
final ResourceManager resourceManager, final PacketSender sender,
- final PacketDispatcher dispatcher, final PersistenceManager persistenceManager,
+ final PacketDispatcher dispatcher, final StorageManager persistenceManager,
final HierarchicalRepository<QueueSettings> queueSettingsRepository,
final PostOffice postOffice, final SecurityStore securityStore) throws Exception
{
@@ -154,7 +154,7 @@
if (!xa)
{
- tx = new TransactionImpl();
+ tx = new TransactionImpl(persistenceManager, postOffice);
}
this.connection = connection;
@@ -292,60 +292,46 @@
}
public void send(final String address, final Message msg) throws Exception
- {
- //check the address exists, if it doesnt add if the user has the correct privileges
- if (!postOffice.containsAllowableAddress(address))
- {
- try
- {
- securityStore.check(address, CheckType.CREATE, connection);
-
- postOffice.addAllowableAddress(address);
- }
- catch (MessagingException e)
- {
- throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
- }
- }
+ {
//check the user has write access to this address
securityStore.check(address, CheckType.WRITE, connection);
- // Assign the message an internal id - this is used to key it in the store
+
msg.setMessageID(persistenceManager.generateMessageID());
// This allows the no-local consumers to filter out the messages that come
- // from the same
- // connection.
+ // from the same connection.
msg.setConnectionID(connection.getID());
-
- postOffice.route(address, msg);
- if (!msg.getReferences().isEmpty())
+ if (autoCommitSends)
{
- if (autoCommitSends)
- {
- if (msg.getNumDurableReferences() != 0)
- {
- persistenceManager.addMessage(msg);
- }
+ List<MessageReference> refs = postOffice.route(address, msg);
- msg.send();
- }
- else
- {
- tx.addMessage(msg);
- }
+ if (msg.getDurableRefCount() != 0)
+ {
+ persistenceManager.storeMessage(address, msg);
+ }
+
+ for (MessageReference ref: refs)
+ {
+ ref.getQueue().addLast(ref);
+ }
}
+ else
+ {
+ tx.addMessage(address, msg);
+ }
}
public synchronized void acknowledge(final long deliveryID, final boolean allUpTo) throws Exception
{
- //log.info("acknowledge called " + deliveryID + " all " + allUpTo);
- // Note that we do not consider it an error if the deliveries cannot be found to be acked.
- // This can legitimately occur if a connection/session/consumer is closed
- // from inside a MessageHandlers onMessage method. In this situation the close will cancel any unacked
- // deliveries, but the subsequent call to delivered() will try and ack again and not find the last
- // delivery on the server.
+ /*
+ Note that we do not consider it an error if the deliveries cannot be found to be acked.
+ This can legitimately occur if a connection/session/consumer is closed
+ from inside a MessageHandlers onMessage method. In this situation the close will cancel any unacked
+ deliveries, but the subsequent call to delivered() will try and ack again and not find the last
+ delivery on the server.
+ */
if (allUpTo)
{
// Ack all deliveries up to and including the specified id
@@ -370,12 +356,12 @@
if (autoCommitAcks)
{
- ref.acknowledge(persistenceManager);
+ doAck(ref);
}
else
{
- tx.addAcknowledgement(ref);
-
+ tx.addAcknowledgement(ref);
+
//Del count is not actually updated in storage unless it's cancelled
ref.incrementDeliveryCount();
}
@@ -408,12 +394,12 @@
if (autoCommitAcks)
{
- ref.acknowledge(persistenceManager);
+ doAck(ref);
}
else
{
tx.addAcknowledgement(ref);
-
+
//Del count is not actually updated in storage unless it's cancelled
ref.incrementDeliveryCount();
}
@@ -426,14 +412,13 @@
public void rollback() throws Exception
{
- //log.info("Roll back called");
if (tx == null)
{
// Might be null if XA
- tx = new TransactionImpl();
+ tx = new TransactionImpl(persistenceManager, postOffice);
}
-
+
// Synchronize to prevent any new deliveries arriving during this recovery
synchronized (this)
{
@@ -441,7 +426,7 @@
// order in a single contiguous block
for (Delivery del : deliveries)
- {
+ {
tx.addAcknowledgement(del.getReference());
}
@@ -450,7 +435,9 @@
deliveryIDSequence -= tx.getAcknowledgementsCount();
}
- tx.rollback(persistenceManager, queueSettingsRepository);
+ tx.rollback(queueSettingsRepository);
+
+ tx = new TransactionImpl(persistenceManager, postOffice);
}
public void cancel(final long deliveryID, final boolean expired) throws Exception
@@ -463,7 +450,7 @@
synchronized (this)
{
- cancelTx = new TransactionImpl();
+ cancelTx = new TransactionImpl(persistenceManager, postOffice);
for (Delivery del : deliveries)
{
@@ -473,7 +460,7 @@
deliveries.clear();
}
- cancelTx.rollback(persistenceManager, queueSettingsRepository);
+ cancelTx.rollback(queueSettingsRepository);
}
else if (expired)
{
@@ -490,7 +477,7 @@
if (delivery.getDeliveryID() == deliveryID)
{
- delivery.getReference().expire(persistenceManager, queueSettingsRepository);
+ delivery.getReference().expire(persistenceManager, postOffice, queueSettingsRepository);
iter.remove();
@@ -506,7 +493,9 @@
public void commit() throws Exception
{
- tx.commit(true, persistenceManager);
+ tx.commit();
+
+ tx = new TransactionImpl(persistenceManager, postOffice);
}
public SessionXAResponseMessage XACommit(final boolean onePhase, final Xid xid) throws Exception
@@ -528,11 +517,11 @@
return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
}
- if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+ if (theTx.getState() == Transaction.State.SUSPENDED) { return new SessionXAResponseMessage(true,
XAException.XAER_PROTO,
"Cannot commit transaction, it is suspended " + xid); }
- theTx.commit(onePhase, persistenceManager);
+ theTx.commit();
boolean removed = resourceManager.removeTransaction(xid);
@@ -550,7 +539,7 @@
{
if (tx != null && tx.getXid().equals(xid))
{
- if (tx.isSuspended())
+ if (tx.getState() == Transaction.State.SUSPENDED)
{
final String msg = "Cannot end, transaction is suspended";
@@ -575,7 +564,7 @@
return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
}
- if (!theTx.isSuspended())
+ if (theTx.getState() != Transaction.State.SUSPENDED)
{
final String msg = "Transaction is not suspended " + xid;
@@ -607,7 +596,7 @@
return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
}
- if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+ if (theTx.getState() == Transaction.State.SUSPENDED) { return new SessionXAResponseMessage(true,
XAException.XAER_PROTO, "Cannot join tx, it is suspended " + xid); }
tx = theTx;
@@ -634,7 +623,7 @@
return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
}
- if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+ if (theTx.getState() == Transaction.State.SUSPENDED) { return new SessionXAResponseMessage(true,
XAException.XAER_PROTO,
"Cannot prepare transaction, it is suspended " + xid); }
@@ -655,7 +644,7 @@
}
else
{
- theTx.prepare(persistenceManager);
+ theTx.prepare();
return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
}
@@ -680,7 +669,7 @@
return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
}
- if (!theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+ if (theTx.getState() != Transaction.State.SUSPENDED) { return new SessionXAResponseMessage(true,
XAException.XAER_PROTO,
"Cannot resume transaction, it is not suspended " + xid); }
@@ -710,11 +699,11 @@
return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
}
- if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+ if (theTx.getState() == Transaction.State.SUSPENDED) { return new SessionXAResponseMessage(true,
XAException.XAER_PROTO,
"Cannot rollback transaction, it is suspended " + xid); }
- theTx.rollback(persistenceManager, queueSettingsRepository);
+ theTx.rollback(queueSettingsRepository);
boolean removed = resourceManager.removeTransaction(xid);
@@ -738,7 +727,7 @@
return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
}
- tx = new TransactionImpl(xid);
+ tx = new TransactionImpl(xid, persistenceManager, postOffice);
boolean added = resourceManager.putTransaction(xid, tx);
@@ -763,7 +752,7 @@
return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
}
- if (tx.isSuspended())
+ if (tx.getState() == Transaction.State.SUSPENDED)
{
final String msg = "Cannot suspend, transaction is already suspended "
+ tx.getXid();
@@ -793,37 +782,49 @@
return resourceManager.setTimeoutSeconds(timeoutSeconds);
}
- public void addAddress(final String address) throws Exception
+ public void addDestination(final String address, final boolean temporary) throws Exception
{
- if (postOffice.containsAllowableAddress(address))
+ securityStore.check(address, CheckType.CREATE, connection);
+
+ if (!postOffice.addDestination(address, temporary))
{
- throw new MessagingException(MessagingException.ADDRESS_EXISTS, "Address already exists: " + address);
+ throw new MessagingException(MessagingException.ADDRESS_EXISTS, "Address already exists: " + address);
}
-
- securityStore.check(address, CheckType.CREATE, connection);
-
- postOffice.addAllowableAddress(address);
+ else
+ {
+ if (temporary)
+ {
+ connection.addTemporaryDestination(address);
+ }
+ }
}
- public void removeAddress(final String address) throws Exception
+ public void removeDestination(final String address, final boolean temporary) throws Exception
{
- if (!postOffice.removeAllowableAddress(address))
+ securityStore.check(address, CheckType.CREATE, connection);
+
+ if (!postOffice.removeDestination(address, temporary))
{
throw new MessagingException(MessagingException.ADDRESS_DOES_NOT_EXIST, "Address does not exist: " + address);
}
+ else
+ {
+ if (temporary)
+ {
+ connection.removeTemporaryDestination(address);
+ }
+ }
}
public void createQueue(final String address, final String queueName,
final String filterString, boolean durable, final boolean temporary) throws Exception
{
//make sure the user has privileges to create this address
- if (!postOffice.containsAllowableAddress(address))
+ if (!postOffice.containsDestination(address))
{
try
{
securityStore.check(address, CheckType.CREATE, connection);
-
- postOffice.addAllowableAddress(address);
}
catch (MessagingException e)
{
@@ -870,10 +871,15 @@
}
Queue queue = binding.getQueue();
+
+ if (queue.getConsumerCount() != 0)
+ {
+ throw new MessagingException(MessagingException.ILLEGAL_STATE, "Cannot delete queue - it has consumers");
+ }
if (queue.isDurable())
{
- persistenceManager.deleteAllReferences(binding.getQueue());
+ binding.getQueue().deleteAllReferences(persistenceManager);
}
if (queue.isTemporary())
@@ -964,7 +970,7 @@
throw new IllegalArgumentException("Address is null");
}
- boolean exists = postOffice.containsAllowableAddress(request.getAddress());
+ boolean exists = postOffice.containsDestination(request.getAddress());
List<String> queueNames = new ArrayList<String>();
@@ -983,21 +989,7 @@
public SessionCreateBrowserResponseMessage createBrowser(final String queueName, final String selector)
throws Exception
- {
- if (!postOffice.containsAllowableAddress(queueName))
- {
- try
- {
- securityStore.check(queueName, CheckType.CREATE, connection);
-
- postOffice.addAllowableAddress(queueName);
- }
- catch (MessagingException e)
- {
- throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
- }
- }
-
+ {
Binding binding = postOffice.getBinding(queueName);
if (binding == null)
@@ -1054,4 +1046,34 @@
{
return "SessionEndpoint[" + id + "]";
}
+
+ // Private --------------------------------------------------------------------------------------------
+
+ private void doAck(final MessageReference ref) throws Exception
+ {
+ Message message = ref.getMessage();
+
+ Queue queue = ref.getQueue();
+
+ if (message.isDurable() && queue.isDurable())
+ {
+ synchronized (message)
+ {
+ message.decrementDurableRefCount();
+
+ if (message.getDurableRefCount() == 0)
+ {
+ persistenceManager.storeDelete(message.getMessageID());
+ }
+ else
+ {
+ persistenceManager.storeAcknowledge(queue.getPersistenceID(), message.getMessageID());
+ }
+ }
+ }
+
+ queue.referenceAcknowledged();
+ }
+
+
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -26,12 +26,13 @@
import javax.transaction.xa.Xid;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.PacketSender;
import org.jboss.messaging.core.remoting.impl.wireformat.NullPacket;
import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddAddressMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCancelMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateBrowserMessage;
@@ -40,7 +41,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveAddressMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAForgetMessage;
@@ -65,6 +66,8 @@
*/
public class ServerSessionPacketHandler extends ServerPacketHandlerSupport
{
+ private static final Logger log = Logger.getLogger(ServerSessionPacketHandler.class);
+
private final ServerSession session;
public ServerSessionPacketHandler(final ServerSession session)
@@ -82,6 +85,7 @@
Packet response = null;
PacketType type = packet.getType();
+
switch (type)
{
case SESS_CREATECONSUMER:
@@ -218,16 +222,16 @@
.getTimeoutSeconds()));
break;
}
- case SESS_ADD_ADDRESS:
+ case SESS_ADD_DESTINATION:
{
- SessionAddAddressMessage message = (SessionAddAddressMessage) packet;
- session.addAddress(message.getAddress());
+ SessionAddDestinationMessage message = (SessionAddDestinationMessage) packet;
+ session.addDestination(message.getAddress(), message.isTemporary());
break;
}
- case SESS_REMOVE_ADDRESS:
+ case SESS_REMOVE_DESTINATION:
{
- SessionRemoveAddressMessage message = (SessionRemoveAddressMessage) packet;
- session.removeAddress(message.getAddress());
+ SessionRemoveDestinationMessage message = (SessionRemoveDestinationMessage) packet;
+ session.removeDestination(message.getAddress(), message.isTemporary());
break;
}
default:
Modified: trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -25,7 +25,6 @@
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
@@ -38,21 +37,20 @@
*/
public interface Transaction
{
- void addSynchronization(TransactionSynchronization sync);
+ void prepare() throws Exception;
+
+ void commit() throws Exception;
- void prepare(PersistenceManager persistenceManager) throws Exception;
+ void rollback(HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
- void commit(boolean onePhase, PersistenceManager persistenceManager) throws Exception;
+ void addMessage(String address, Message message) throws Exception;
- void rollback(PersistenceManager persistenceManager,
- final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
+ void addAcknowledgement(MessageReference acknowledgement) throws Exception;
- void addMessage(Message message);
+ int getAcknowledgementsCount();
- void addAcknowledgement(MessageReference acknowledgement);
+ long getID();
- int getAcknowledgementsCount();
-
Xid getXid();
boolean isEmpty();
@@ -60,6 +58,13 @@
void suspend();
void resume();
+
+ State getState();
- boolean isSuspended();
+ boolean isContainsPersistent();
+
+ static enum State
+ {
+ ACTIVE, PREPARED, COMMITTED, ROLLEDBACK, SUSPENDED;
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -23,6 +23,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
import javax.transaction.xa.Xid;
@@ -40,7 +41,7 @@
*/
public class ResourceManagerImpl implements ResourceManager
{
- private ConcurrentMap<Xid, Transaction> transactions = new ConcurrentHashMap<Xid, Transaction>();
+ private final ConcurrentMap<Xid, Transaction> transactions = new ConcurrentHashMap<Xid, Transaction>();
private final int defaultTimeoutSeconds;
Modified: trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -32,252 +32,318 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.Transaction;
-import org.jboss.messaging.core.transaction.TransactionSynchronization;
/**
*
* A TransactionImpl
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
+ *
*/
public class TransactionImpl implements Transaction
{
- private static final Logger log = Logger.getLogger(TransactionImpl.class);
-
- private final List<Message> messagesToAdd = new ArrayList<Message>();
-
- private final List<MessageReference> acknowledgements = new ArrayList<MessageReference>();
-
- private final List<TransactionSynchronization> synchronizations = new ArrayList<TransactionSynchronization>();
-
- private final Xid xid;
-
- private volatile boolean containsPersistent;
-
- private volatile boolean prepared;
-
- private volatile boolean suspended;
-
- public TransactionImpl()
- {
- this.xid = null;
- }
-
- public TransactionImpl(final Xid xid)
- {
- this.xid = xid;
- }
-
- // Transaction implementation -----------------------------------------------------------
-
- public void addMessage(final Message message)
- {
- messagesToAdd.add(message);
-
- if (message.getNumDurableReferences() != 0)
- {
- containsPersistent = true;
- }
- }
-
- public void addAcknowledgement(final MessageReference acknowledgement)
- {
- acknowledgements.add(acknowledgement);
-
- if (acknowledgement.getMessage().isDurable() && acknowledgement.getQueue().isDurable())
- {
- containsPersistent = true;
- }
- }
-
- public void addSynchronization(final TransactionSynchronization sync)
- {
- synchronizations.add(sync);
- }
-
- public void prepare(final PersistenceManager persistenceManager) throws Exception
- {
- if (xid == null)
- {
- throw new IllegalStateException("Cannot call prepare() on a non XA transaction");
- }
- else if (containsPersistent)
- {
- persistenceManager.prepareTransaction(xid, messagesToAdd, acknowledgements);
- }
-
- prepared = true;
- }
-
- public void commit(final boolean onePhase, final PersistenceManager persistenceManager) throws Exception
- {
- callSynchronizations(SyncType.BEFORE_COMMIT);
-
- if (containsPersistent)
- {
- if (xid == null || onePhase)
- {
- //1PC commit
-
- persistenceManager.commitTransaction(messagesToAdd, acknowledgements);
- }
- else
- {
- //2PC commit
-
- if (!prepared)
- {
- throw new IllegalStateException("Transaction is not prepared");
- }
-
- persistenceManager.commitPreparedTransaction(xid);
- }
- }
-
- for (Message msg: messagesToAdd)
- {
- msg.send();
- }
-
- for (MessageReference reference: acknowledgements)
- {
- reference.getQueue().referenceAcknowledged();
- }
-
- callSynchronizations(SyncType.AFTER_COMMIT);
-
- clear();
- }
-
- public void rollback(final PersistenceManager persistenceManager,
- final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
- {
- callSynchronizations(SyncType.BEFORE_ROLLBACK);
-
- if (prepared)
- {
- persistenceManager.unprepareTransaction(xid, messagesToAdd, acknowledgements);
- }
-
- cancelDeliveries(persistenceManager, queueSettingsRepository);
-
- callSynchronizations(SyncType.AFTER_ROLLBACK);
-
- clear();
- }
-
- public int getAcknowledgementsCount()
- {
- return acknowledgements.size();
- }
-
- public void suspend()
- {
- suspended = true;
- }
-
- public void resume()
- {
- suspended = false;
- }
-
- public boolean isSuspended()
- {
- return suspended;
- }
-
- public Xid getXid()
- {
- return xid;
- }
-
- public boolean isEmpty()
- {
- return messagesToAdd.isEmpty() && acknowledgements.isEmpty();
- }
-
- // Private -------------------------------------------------------------------
-
- private void callSynchronizations(final SyncType type) throws Exception
- {
- for (TransactionSynchronization sync: synchronizations)
- {
- if (type == SyncType.BEFORE_COMMIT)
- {
- sync.beforeCommit();
- }
- else if (type == SyncType.AFTER_COMMIT)
- {
- sync.afterCommit();
- }
- else if (type == SyncType.BEFORE_ROLLBACK)
- {
- sync.beforeRollback();
- }
- else if (type == SyncType.AFTER_ROLLBACK)
- {
- sync.afterRollback();
- }
- }
- }
+ private static final Logger log = Logger.getLogger(TransactionImpl.class);
- private void clear()
- {
- messagesToAdd.clear();
-
- acknowledgements.clear();
-
- synchronizations.clear();
-
- containsPersistent = false;
- }
-
- private void cancelDeliveries(final PersistenceManager persistenceManager,
- final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
- {
- Map<Queue, LinkedList<MessageReference>> queueMap = new HashMap<Queue, LinkedList<MessageReference>>();
-
- //Need to sort into lists - one for each queue involved.
- //Then cancelling back atomicly for each queue adding list on front to guarantee ordering is preserved
-
- for (MessageReference ref: acknowledgements)
- {
- Queue queue = ref.getQueue();
-
- LinkedList<MessageReference> list = queueMap.get(queue);
-
- if (list == null)
- {
- list = new LinkedList<MessageReference>();
-
- queueMap.put(queue, list);
- }
-
- if (ref.cancel(persistenceManager, queueSettingsRepository))
- {
- list.add(ref);
- }
- }
-
- for (Map.Entry<Queue, LinkedList<MessageReference>> entry: queueMap.entrySet())
- {
- LinkedList<MessageReference> refs = entry.getValue();
-
- entry.getKey().addListFirst(refs);
- }
- }
-
- // Inner Enums -------------------------------------------------------------------------------
-
- private enum SyncType
- {
- BEFORE_COMMIT, AFTER_COMMIT, BEFORE_ROLLBACK, AFTER_ROLLBACK;
- }
-
+ private final StorageManager storageManager;
+
+ private final PostOffice postOffice;
+
+ private final List<MessageReference> refsToAdd = new ArrayList<MessageReference>();
+
+ private final List<MessageReference> acknowledgements = new ArrayList<MessageReference>();
+
+ private final Xid xid;
+
+ private final long id;
+
+ private volatile State state = State.ACTIVE;
+
+ private volatile boolean containsPersistent;
+
+ public TransactionImpl(final StorageManager storageManager,
+ final PostOffice postOffice)
+ {
+ this.storageManager = storageManager;
+
+ this.postOffice = postOffice;
+
+ this.xid = null;
+
+ this.id = storageManager.generateTransactionID();
+ }
+
+ public TransactionImpl(final Xid xid, final StorageManager storageManager,
+ final PostOffice postOffice)
+ {
+ this.storageManager = storageManager;
+
+ this.postOffice = postOffice;
+
+ this.xid = xid;
+
+ this.id = storageManager.generateTransactionID();
+ }
+
+ // Transaction implementation
+ // -----------------------------------------------------------
+
+ public long getID()
+ {
+ return id;
+ }
+
+ public void addMessage(final String address, final Message message)
+ throws Exception
+ {
+ if (state != State.ACTIVE)
+ {
+ throw new IllegalStateException("Transaction is in invalid state " + state);
+ }
+
+ List<MessageReference> refs = postOffice.route(address, message);
+
+ refsToAdd.addAll(refs);
+
+ if (message.getDurableRefCount() != 0)
+ {
+ storageManager.storeMessageTransactional(id, address, message);
+
+ containsPersistent = true;
+ }
+ }
+
+ public void addAcknowledgement(final MessageReference acknowledgement)
+ throws Exception
+ {
+ if (state != State.ACTIVE)
+ {
+ throw new IllegalStateException("Transaction is in invalid state " + state);
+ }
+ acknowledgements.add(acknowledgement);
+
+ Message message = acknowledgement.getMessage();
+
+ if (message.isDurable())
+ {
+ Queue queue = acknowledgement.getQueue();
+
+ if (queue.isDurable())
+ {
+ // Need to lock on the message to prevent a race where the ack and
+ // delete
+ // records get recorded in the log in the wrong order
+
+ // TODO For now - we just use synchronized - can probably do better
+ // locking
+
+ synchronized (message)
+ {
+ message.decrementDurableRefCount();
+
+ if (message.getDurableRefCount() == 0)
+ {
+ storageManager.storeDeleteTransactional(id, message
+ .getMessageID());
+ }
+ else
+ {
+ storageManager.storeAcknowledgeTransactional(id, queue
+ .getPersistenceID(), message.getMessageID());
+ }
+
+ containsPersistent = true;
+ }
+ }
+ }
+
+ }
+
+ public void prepare() throws Exception
+ {
+ if (state != State.ACTIVE)
+ {
+ throw new IllegalStateException("Transaction is in invalid state " + state);
+ }
+
+ if (xid == null)
+ {
+ throw new IllegalStateException("Cannot prepare non XA transaction");
+ }
+
+ if (containsPersistent)
+ {
+ storageManager.prepare(id);
+ }
+
+ state = State.PREPARED;
+ }
+
+ public void commit() throws Exception
+ {
+ if (xid != null)
+ {
+ if (state != State.PREPARED)
+ {
+ throw new IllegalStateException("Transaction is in invalid state " + state);
+ }
+ }
+ else
+ {
+ if (state != State.ACTIVE)
+ {
+ throw new IllegalStateException("Transaction is in invalid state " + state);
+ }
+ }
+
+ if (containsPersistent)
+ {
+ storageManager.commit(id);
+ }
+
+ for (MessageReference ref : refsToAdd)
+ {
+ ref.getQueue().addLast(ref);
+ }
+
+ for (MessageReference reference : acknowledgements)
+ {
+ reference.getQueue().referenceAcknowledged();
+ }
+
+ clear();
+
+ state = State.COMMITTED;
+ }
+
+ public void rollback(final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
+ {
+ if (xid != null)
+ {
+ if (state != State.PREPARED && state != State.ACTIVE)
+ {
+ throw new IllegalStateException("Transaction is in invalid state " + state);
+ }
+ }
+ else
+ {
+ if (state != State.ACTIVE)
+ {
+ throw new IllegalStateException("Transaction is in invalid state " + state);
+ }
+ }
+
+ if (containsPersistent)
+ {
+ storageManager.rollback(id);
+ }
+
+ Map<Queue, LinkedList<MessageReference>> queueMap = new HashMap<Queue, LinkedList<MessageReference>>();
+
+ // We sort into lists - one for each queue involved.
+ // Then we cancel back atomicly for each queue adding list on front to
+ // guarantee ordering is preserved
+
+ for (MessageReference ref : acknowledgements)
+ {
+ Queue queue = ref.getQueue();
+
+ Message message = ref.getMessage();
+
+ if (message.isDurable() && queue.isDurable())
+ {
+ // Reverse the decrements we did in the tx
+ message.incrementDurableRefCount();
+ }
+
+ LinkedList<MessageReference> list = queueMap.get(queue);
+
+ if (list == null)
+ {
+ list = new LinkedList<MessageReference>();
+
+ queueMap.put(queue, list);
+ }
+
+ if (ref.cancel(storageManager, postOffice, queueSettingsRepository))
+ {
+ list.add(ref);
+ }
+ }
+
+ for (Map.Entry<Queue, LinkedList<MessageReference>> entry : queueMap
+ .entrySet())
+ {
+ LinkedList<MessageReference> refs = entry.getValue();
+
+ entry.getKey().addListFirst(refs);
+ }
+
+ clear();
+
+ state = State.ROLLEDBACK;
+ }
+
+ public int getAcknowledgementsCount()
+ {
+ return acknowledgements.size();
+ }
+
+ public void suspend()
+ {
+ if (state != State.ACTIVE)
+ {
+ throw new IllegalStateException("Can only suspend active transaction");
+ }
+ state = State.SUSPENDED;
+ }
+
+ public void resume()
+ {
+ if (state != State.SUSPENDED)
+ {
+ throw new IllegalStateException("Can only resume a suspended transaction");
+ }
+ state = State.ACTIVE;
+ }
+
+ public Transaction.State getState()
+ {
+ return state;
+ }
+
+ public Xid getXid()
+ {
+ return xid;
+ }
+
+ public boolean isEmpty()
+ {
+ return refsToAdd.isEmpty() && acknowledgements.isEmpty();
+ }
+
+ public boolean isContainsPersistent()
+ {
+ return containsPersistent;
+ }
+
+ public void setContainsPersistent(final boolean containsPersistent)
+ {
+ this.containsPersistent = containsPersistent;
+ }
+
+ // Private
+ // -------------------------------------------------------------------
+
+ private void clear()
+ {
+ refsToAdd.clear();
+
+ acknowledgements.clear();
+ }
}
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -667,7 +667,7 @@
session.createQueue(queue.getAddress(), queue.getAddress(), null, false, true);
- //session.addAddress(queue.getAddress());
+ session.addDestination(queue.getAddress(), true);
return queue;
}
@@ -691,7 +691,7 @@
{
JBossTemporaryTopic topic = new JBossTemporaryTopic(this, topicName);
- session.addAddress(topic.getAddress());
+ session.addDestination(topic.getAddress(), true);
return topic;
}
@@ -858,7 +858,7 @@
destination.getName() + " since it has subscribers");
}
}
- session.removeAddress(destination.getAddress());
+ session.removeDestination(destination.getAddress(), true);
}
catch (MessagingException e)
{
Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -170,7 +170,7 @@
* @param messageId the id of the message to remove
* @throws Exception if a problem occurred
*/
- void removeMessageFromQueue(String queue, String messageId) throws Exception;
+ // void removeMessageFromQueue(String queue, String messageId) throws Exception;
/**
* removes a particular message from a topic
@@ -178,7 +178,7 @@
* @param messageId the id of the message
* @throws Exception if a problem occurred
*/
- void removeMessageFromTopic(String topic, String messageId) throws Exception;
+ // void removeMessageFromTopic(String topic, String messageId) throws Exception;
/**
* removes all messages from a particular queue
@@ -201,7 +201,7 @@
* @param messageID the id of the message
* @throws Exception if a problem occurred
*/
- void moveMessage(String fromQueue, String toQueue, String messageID) throws Exception;
+ //void moveMessage(String fromQueue, String toQueue, String messageID) throws Exception;
/**
* expires a message
@@ -218,7 +218,7 @@
* @param priority the priority to change the message to
* @throws Exception if a problem occurred
*/
- void changeMessagePriority(String queue, String messageId, int priority) throws Exception;
+ // void changeMessagePriority(String queue, String messageId, int priority) throws Exception;
/**
* returns how many messages a queue is currently holding
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -145,6 +145,7 @@
public boolean createQueue(String queueName, String jndiBinding) throws Exception
{
JBossQueue jBossQueue = new JBossQueue(queueName);
+ messagingServerManagement.addDestination(jBossQueue.getAddress());
messagingServerManagement.createQueue(jBossQueue.getAddress(), jBossQueue.getAddress());
boolean added = bindToJndi(jndiBinding, jBossQueue);
if (added)
@@ -157,7 +158,7 @@
public boolean createTopic(String topicName, String jndiBinding) throws Exception
{
JBossTopic jBossTopic = new JBossTopic(topicName);
- messagingServerManagement.addAddress(jBossTopic.getAddress());
+ messagingServerManagement.addDestination(jBossTopic.getAddress());
boolean added = bindToJndi(jndiBinding, jBossTopic);
if (added)
{
@@ -168,7 +169,9 @@
public boolean destroyQueue(String name) throws Exception
{
+ JBossQueue jBossQueue = new JBossQueue(name);
messagingServerManagement.destroyQueue(name);
+ messagingServerManagement.removeDestination(jBossQueue.getAddress());
List<String> jndiBindings = destinations.get(name);
if (jndiBindings == null || jndiBindings.size() == 0)
{
@@ -185,7 +188,7 @@
public boolean destroyTopic(String name) throws Exception
{
JBossTopic jBossTopic = new JBossTopic(name);
- messagingServerManagement.removeAddress(jBossTopic.getAddress());
+ messagingServerManagement.removeDestination(jBossTopic.getAddress());
List<String> jndiBindings = destinations.get(name);
if (jndiBindings == null || jndiBindings.size() == 0)
{
@@ -330,16 +333,16 @@
return listMessages(subscription, listType);
}
- public void removeMessageFromQueue(String queueName, String messageId) throws Exception
- {
- messagingServerManagement.removeMessageForBinding(new JBossQueue(queueName).getAddress(), new FilterImpl("JMSMessageID='" + messageId + "'"));
- }
+// public void removeMessageFromQueue(String queueName, String messageId) throws Exception
+// {
+// messagingServerManagement.removeMessageForBinding(new JBossQueue(queueName).getAddress(), new FilterImpl("JMSMessageID='" + messageId + "'"));
+// }
+//
+// public void removeMessageFromTopic(String topicName, String messageId) throws Exception
+// {
+// messagingServerManagement.removeMessageForAddress(new JBossTopic(topicName).getAddress(), new FilterImpl("JMSMessageID='" + messageId + "'"));
+// }
- public void removeMessageFromTopic(String topicName, String messageId) throws Exception
- {
- messagingServerManagement.removeMessageForAddress(new JBossTopic(topicName).getAddress(), new FilterImpl("JMSMessageID='" + messageId + "'"));
- }
-
public void removeAllMessagesForQueue(String queueName) throws Exception
{
JBossQueue jBossQueue = new JBossQueue(queueName);
@@ -352,11 +355,11 @@
removeAllMessages(jBossTopic);
}
- public void moveMessage(String fromQueue, String toQueue, String messageId) throws Exception
- {
- messagingServerManagement.moveMessages(new JBossQueue(fromQueue).getAddress(), new JBossQueue(toQueue).getAddress(),
- "JMSMessageID='" + messageId + "'");
- }
+// public void moveMessage(String fromQueue, String toQueue, String messageId) throws Exception
+// {
+// messagingServerManagement.moveMessages(new JBossQueue(fromQueue).getAddress(), new JBossQueue(toQueue).getAddress(),
+// "JMSMessageID='" + messageId + "'");
+// }
public void expireMessage(String queue, String messageId) throws Exception
{
@@ -364,11 +367,11 @@
"JMSMessageID='" + messageId + "'");
}
- public void changeMessagePriority(String queue, String messageId, int priority) throws Exception
- {
- messagingServerManagement.changeMessagePriority(new JBossQueue(queue).getAddress(),
- "JMSMessageID='" + messageId + "'", priority);
- }
+// public void changeMessagePriority(String queue, String messageId, int priority) throws Exception
+// {
+// messagingServerManagement.changeMessagePriority(new JBossQueue(queue).getAddress(),
+// "JMSMessageID='" + messageId + "'", priority);
+// }
public int getMessageCountForQueue(String queue) throws Exception
{
Modified: trunk/src/main/org/jboss/messaging/util/ConcurrentHashSet.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/ConcurrentHashSet.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/src/main/org/jboss/messaging/util/ConcurrentHashSet.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -23,9 +23,9 @@
import java.util.AbstractSet;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
/**
*
@@ -38,9 +38,9 @@
*
* $Id: ConcurrentReaderHashSet.java 1935 2007-01-09 23:29:20Z clebert.suconic at jboss.com $
*/
-public class ConcurrentHashSet<E> extends AbstractSet<E>
+public class ConcurrentHashSet<E> extends AbstractSet<E> implements ConcurrentSet<E>
{
- private Map<E, Object> theMap;
+ private ConcurrentMap<E, Object> theMap;
private static Object dummy = new Object();
@@ -95,5 +95,12 @@
{
return theMap.remove(o) == dummy;
}
+
+ public boolean addIfAbsent(E o)
+ {
+ Object obj = theMap.putIfAbsent(o, dummy);
+
+ return obj == null;
+ }
}
Modified: trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestBase.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/JournalImplTestBase.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -21,6 +21,7 @@
*/
package org.jboss.messaging.core.journal.impl.test.unit;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -70,6 +71,16 @@
private String fileExtension = "jbm";
private SequentialFileFactory fileFactory;
+
+ private void logThem()
+ {
+ log.info("**** loggingg attributes***");
+ log.info("recordlength:" + recordLength);
+ log.info("minfiles:" + minFiles);
+ log.info("minavailableFiles:" + minAvailableFiles);
+ log.info("filesize:" + fileSize);
+ log.info("sync:" + sync);
+ }
protected void setUp() throws Exception
{
@@ -78,6 +89,10 @@
prepareDirectory();
fileFactory = getFileFactory();
+
+ transactions.clear();
+
+ records.clear();
}
protected void tearDown() throws Exception
@@ -94,6 +109,10 @@
{
}
}
+
+ fileFactory = null;
+
+ journal = null;;
}
protected abstract void prepareDirectory() throws Exception;
@@ -567,6 +586,107 @@
}
+ public void testAddUpdateDeleteRestartAndContinue() throws Exception
+ {
+ setup(10, 10, 10 * 1024, true);
+ createJournal();
+ startJournal();
+ load();
+ add(1, 2, 3);
+ update(1, 2);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ add(4, 5, 6);
+ update(5);
+ delete(3);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ add(7, 8);
+ delete(1, 2);
+ delete(4, 5, 6);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ }
+
+ public void testAddUpdateDeleteTransactionalRestartAndContinue() throws Exception
+ {
+ setup(10, 10, 10 * 1024, true);
+ createJournal();
+ startJournal();
+ load();
+ add(1, 1, 2, 3);
+ updateTx(1, 1, 2);
+ commit(1);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ addTx(2, 4, 5, 6);
+ update(2, 5);
+ delete(2, 3);
+ commit(2);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ addTx(3, 7, 8);
+ deleteTx(3, 1, 2);
+ deleteTx(3, 4, 5, 6);
+ commit(3);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ }
+
+ public void testFillFileExactly() throws Exception
+ {
+ this.recordLength = 500;
+
+ int numRecords = 2;
+
+ //The real appended record size in the journal file = SIZE_BYTE + SIZE_LONG + SIZE_INT + recordLength + SIZE_BYTE
+
+ int realLength = 1 + 8 + 4 + this.recordLength + 1;
+
+ int fileSize = numRecords * realLength + 8; //8 for timestamp
+
+ setup(10, 10, fileSize, true);
+
+ logThem();
+
+ createJournal();
+ startJournal();
+ load();
+
+ add(1, 2);
+
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+
+ add(3, 4);
+
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+
+ add(4, 5, 6, 7, 8, 9, 10);
+
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ }
+
// Transactional tests
// ===================
@@ -576,9 +696,10 @@
createJournal();
startJournal();
load();
- addTx(1, false, 1);
- updateTx(1, false, 1);
- deleteTx(1, true, 1);
+ addTx(1, 1);
+ updateTx(1, 1);
+ deleteTx(1, 1);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -591,9 +712,10 @@
createJournal();
startJournal();
load();
- addTx(1, false, 1, 2, 3);
- updateTx(1, false, 1, 2);
- deleteTx(1, true, 1);
+ addTx(1, 1, 2, 3);
+ updateTx(1, 1, 2);
+ deleteTx(1, 1);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -606,9 +728,10 @@
createJournal();
startJournal();
load();
- addTx(1, false, 1, 2, 3);
- updateTx(1, false, 1, 2);
- deleteTx(1, true, 1, 2, 3);
+ addTx(1, 1, 2, 3);
+ updateTx(1, 1, 2);
+ deleteTx(1, 1, 2, 3);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -622,8 +745,9 @@
startJournal();
load();
add(1, 2, 3);
- addTx(1, false, 4, 5, 6);
- updateTx(1, true, 1, 5);
+ addTx(1, 4, 5, 6);
+ updateTx(1, 1, 5);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -637,8 +761,9 @@
startJournal();
load();
add(1, 2, 3);
- addTx(1, false, 4, 5, 6);
- deleteTx(1, true, 1, 2, 3, 4, 5, 6);
+ addTx(1, 4, 5, 6);
+ deleteTx(1, 1, 2, 3, 4, 5, 6);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -652,9 +777,9 @@
startJournal();
load();
add(1, 2, 3);
- addTx(1, false, 4, 5, 6);
- updateTx(1, false, 1, 2, 4, 5);
- deleteTx(1, false, 1, 2, 3, 4, 5, 6);
+ addTx(1, 4, 5, 6);
+ updateTx(1, 1, 2, 4, 5);
+ deleteTx(1, 1, 2, 3, 4, 5, 6);
stopJournal();
createJournal();
startJournal();
@@ -668,17 +793,20 @@
startJournal();
load();
- addTx(1, false, 1, 2, 3, 4, 5, 6);
- updateTx(1, false, 1, 3, 5);
- deleteTx(1, false, 1, 2, 3, 4, 5, 6);
+ addTx(1, 1, 2, 3, 4, 5, 6);
+ updateTx(1, 1, 3, 5);
+ deleteTx(1, 1, 2, 3, 4, 5, 6);
+ commit(1);
- addTx(2, false, 11, 12, 13, 14, 15, 16);
- updateTx(2, false, 11, 13, 15);
- deleteTx(2, false, 11, 12, 13, 14, 15, 16);
+ addTx(2, 11, 12, 13, 14, 15, 16);
+ updateTx(2, 11, 13, 15);
+ deleteTx(2, 11, 12, 13, 14, 15, 16);
+ commit(2);
- addTx(3, false, 21, 22, 23, 24, 25, 26);
- updateTx(3, false, 21, 23, 25);
- deleteTx(3, false, 21, 22, 23, 24, 25, 26);
+ addTx(3, 21, 22, 23, 24, 25, 26);
+ updateTx(3, 21, 23, 25);
+ deleteTx(3, 21, 22, 23, 24, 25, 26);
+ commit(3);
stopJournal();
createJournal();
@@ -693,24 +821,20 @@
startJournal();
load();
- addTx(1, false, 1, 2, 3, 4, 5, 6);
+ addTx(1, 1, 2, 3, 4, 5, 6);
+ addTx(3, 21, 22, 23, 24, 25, 26);
+ updateTx(1, 1, 3, 5);
+ addTx(2, 11, 12, 13, 14, 15, 16);
+ deleteTx(1, 1, 2, 3, 4, 5, 6);
+ updateTx(2, 11, 13, 15);
+ updateTx(3, 21, 23, 25);
+ deleteTx(2, 11, 12, 13, 14, 15, 16);
+ deleteTx(3, 21, 22, 23, 24, 25, 26);
- addTx(3, false, 21, 22, 23, 24, 25, 26);
-
- updateTx(1, false, 1, 3, 5);
+ commit(1);
+ commit(2);
+ commit(3);
- addTx(2, false, 11, 12, 13, 14, 15, 16);
-
- deleteTx(1, false, 1, 2, 3, 4, 5, 6);
-
- updateTx(2, false, 11, 13, 15);
-
- updateTx(3, false, 21, 23, 25);
-
- deleteTx(2, false, 11, 12, 13, 14, 15, 16);
-
- deleteTx(3, false, 21, 22, 23, 24, 25, 26);
-
stopJournal();
createJournal();
startJournal();
@@ -724,24 +848,19 @@
startJournal();
load();
- add(1, 2, 3, 4, 5, 6, 7, 8);
+ add(1, 2, 3, 4, 5, 6, 7, 8);
+ addTx(1, 9, 10, 11, 12);
+ addTx(2, 13, 14, 15, 16, 17);
+ addTx(3, 18, 19, 20, 21, 22);
+ updateTx(1, 1, 2, 3);
+ updateTx(2, 4, 5, 6);
+ commit(2);
+ updateTx(3, 7, 8);
+ deleteTx(1, 1, 2);
+ commit(1);
+ deleteTx(3, 7, 8);
+ commit(3);
- addTx(1, false, 9, 10, 11, 12);
-
- addTx(2, false, 13, 14, 15, 16, 17);
-
- addTx(3, false, 18, 19, 20, 21, 22);
-
- updateTx(1, false, 1, 2, 3);
-
- updateTx(2, true, 4, 5, 6);
-
- updateTx(3, false, 7, 8);
-
- deleteTx(1, true, 1, 2);
-
- deleteTx(3, true, 7, 8);
-
stopJournal();
createJournal();
startJournal();
@@ -755,11 +874,12 @@
startJournal();
load();
add(1,3,5,7,10,13,56,100,102,200,201,202,203);
- addTx(1, false, 675, 676, 677, 700, 703);
+ addTx(1, 675, 676, 677, 700, 703);
update(1,3,5,7,10,13,56,100,102,200,201,202,203);
- updateTx(1, false, 677, 700);
+ updateTx(1, 677, 700);
delete(1,3,5,7,10,13,56,100,102,200,201,202,203);
- deleteTx(1, true, 703, 675, 1,3,5,7,10);
+ deleteTx(1, 703, 675, 1,3,5,7,10);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -772,15 +892,77 @@
createJournal();
startJournal();
load();
- addTx(1, false, 1, 2, 3, 4, 5, 6, 7, 8, 9);
- deleteTx(1, true, 9, 8, 5, 3, 7, 6, 2, 1, 4);
+ addTx(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ deleteTx(1, 9, 8, 5, 3, 7, 6, 2, 1, 4);
+ commit(1);
stopJournal();
createJournal();
startJournal();
loadAndCheck();
}
+ public void testAddOutsideTXThenUpdateInsideTX() throws Exception
+ {
+ setup(10, 10, 10 * 1024, true);
+ createJournal();
+ startJournal();
+ load();
+ add(1, 2, 3);
+ updateTx(1, 1, 2, 3);
+ commit(1);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ }
+ public void testAddOutsideTXThenDeleteInsideTX() throws Exception
+ {
+ setup(10, 10, 10 * 1024, true);
+ createJournal();
+ startJournal();
+ load();
+ add(1, 2, 3);
+ deleteTx(1, 1, 2, 3);
+ commit(1);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ }
+
+ public void testRollback() throws Exception
+ {
+ setup(10, 10, 10 * 1024, true);
+ createJournal();
+ startJournal();
+ load();
+ add(1, 2, 3);
+ deleteTx(1, 1, 2, 3);
+ rollback(1);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ }
+
+ public void testRollbackMultiple() throws Exception
+ {
+ setup(10, 10, 10 * 1024, true);
+ createJournal();
+ startJournal();
+ load();
+ add(1, 2, 3);
+ deleteTx(1, 1, 2, 3);
+ addTx(2, 4, 5, 6);
+ rollback(1);
+ rollback(2);
+ stopJournal();
+ createJournal();
+ startJournal();
+ loadAndCheck();
+ }
+
// XA tests
// ========
@@ -790,9 +972,9 @@
createJournal();
startJournal();
load();
- this.addPrepare(1, false, 1, 2, 3, 4, 5, 6, 7, 8, 9);
- this.updatePrepare(1, false, 1, 2, 3, 4, 7, 8);
- this.deletePrepare(1, false, 1, 2, 3, 4, 5);
+ addTx(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ updateTx(1, 1, 2, 3, 4, 7, 8);
+ deleteTx(1, 1, 2, 3, 4, 5);
stopJournal();
createJournal();
startJournal();
@@ -805,9 +987,10 @@
createJournal();
startJournal();
load();
- this.addPrepare(1, false, 1, 2, 3, 4, 5, 6, 7, 8, 9);
- this.updatePrepare(1, false, 1, 2, 3, 4, 7, 8);
- this.deletePrepare(1, true, 1, 2, 3, 4, 5);
+ addTx(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ updateTx(1, 1, 2, 3, 4, 7, 8);
+ deleteTx(1, 1, 2, 3, 4, 5);
+ prepare(1);
stopJournal();
createJournal();
startJournal();
@@ -820,10 +1003,11 @@
createJournal();
startJournal();
load();
- this.addPrepare(1, false, 1, 2, 3, 4, 5, 6, 7, 8, 9);
- this.updatePrepare(1, false, 1, 2,3, 4, 7, 8);
- this.deletePrepare(1, true, 1, 2, 3, 4, 5);
- this.xaCommit(1);
+ addTx(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ updateTx(1, 1, 2,3, 4, 7, 8);
+ deleteTx(1, 1, 2, 3, 4, 5);
+ prepare(1);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -836,10 +1020,11 @@
createJournal();
startJournal();
load();
- this.addPrepare(1, false, 1, 2, 3, 4, 5, 6, 7, 8, 9);
- this.updatePrepare(1, false, 1, 2,3, 4, 7, 8);
- this.deletePrepare(1, true, 1, 2, 3, 4, 5);
- this.xaRollback(1);
+ addTx(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ updateTx(1, 1, 2,3, 4, 7, 8);
+ deleteTx(1, 1, 2, 3, 4, 5);
+ prepare(1);
+ rollback(1);
stopJournal();
createJournal();
startJournal();
@@ -852,10 +1037,10 @@
createJournal();
startJournal();
load();
- this.add(1, 2, 3, 4, 5, 6);
- this.addPrepare(1, false, 7, 8, 9, 10);
- this.updatePrepare(1, false, 1, 2, 3, 7, 8, 9);
- this.deletePrepare(1, false, 1, 2, 3, 4, 5);
+ add(1, 2, 3, 4, 5, 6);
+ addTx(1, 7, 8, 9, 10);
+ updateTx(1, 1, 2, 3, 7, 8, 9);
+ deleteTx(1, 1, 2, 3, 4, 5);
stopJournal();
createJournal();
startJournal();
@@ -868,10 +1053,11 @@
createJournal();
startJournal();
load();
- this.add(1, 2, 3, 4, 5, 6);
- this.addPrepare(1, false, 7, 8, 9, 10);
- this.updatePrepare(1, false, 1, 2, 3, 7, 8, 9);
- this.deletePrepare(1, true, 1, 2, 3, 4, 5);
+ add(1, 2, 3, 4, 5, 6);
+ addTx(1, 7, 8, 9, 10);
+ updateTx(1, 1, 2, 3, 7, 8, 9);
+ deleteTx(1, 1, 2, 3, 4, 5);
+ prepare(1);
stopJournal();
createJournal();
startJournal();
@@ -884,11 +1070,12 @@
createJournal();
startJournal();
load();
- this.add(1, 2, 3, 4, 5, 6);
- this.addPrepare(1, false, 7, 8, 9, 10);
- this.updatePrepare(1, false, 1, 2, 3, 7, 8, 9);
- this.deletePrepare(1, true, 1, 2, 3, 4, 5);
- this.xaRollback(1);
+ add(1, 2, 3, 4, 5, 6);
+ addTx(1, 7, 8, 9, 10);
+ updateTx(1, 1, 2, 3, 7, 8, 9);
+ deleteTx(1, 1, 2, 3, 4, 5);
+ prepare(1);
+ rollback(1);
stopJournal();
createJournal();
startJournal();
@@ -901,11 +1088,12 @@
createJournal();
startJournal();
load();
- this.add(1, 2, 3, 4, 5, 6);
- this.addPrepare(1, false, 7, 8, 9, 10);
- this.updatePrepare(1, false, 1, 2, 3, 7, 8, 9);
- this.deletePrepare(1, true, 1, 2, 3, 4, 5);
- this.xaCommit(1);
+ add(1, 2, 3, 4, 5, 6);
+ addTx(1, 7, 8, 9, 10);
+ updateTx(1, 1, 2, 3, 7, 8, 9);
+ deleteTx(1, 1, 2, 3, 4, 5);
+ prepare(1);
+ commit(1);
stopJournal();
createJournal();
startJournal();
@@ -918,19 +1106,22 @@
createJournal();
startJournal();
load();
- this.add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
- this.addPrepare(1, false, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
- this.addPrepare(2, false, 21, 22, 23, 24, 25, 26, 27);
- this.updatePrepare(1, false, 1, 3, 6, 11, 14, 17);
- this.addPrepare(3, false, 28, 29, 30, 31, 32, 33, 34, 35);
- this.updatePrepare(3, false, 7, 8, 9, 10);
- this.deletePrepare(2, true, 4, 5, 6, 23, 25, 27);
- this.deletePrepare(1, true, 1, 2, 11, 14, 15);
- this.deletePrepare(3, true, 28, 31, 32, 9);
+ add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ addTx(1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
+ addTx(2, 21, 22, 23, 24, 25, 26, 27);
+ updateTx(1, 1, 3, 6, 11, 14, 17);
+ addTx(3, 28, 29, 30, 31, 32, 33, 34, 35);
+ updateTx(3, 7, 8, 9, 10);
+ deleteTx(2, 4, 5, 6, 23, 25, 27);
+ prepare(2);
+ deleteTx(1, 1, 2, 11, 14, 15);
+ prepare(1);
+ deleteTx(3, 28, 31, 32, 9);
+ prepare(3);
- this.xaCommit(1);
- this.xaRollback(2);
- this.xaCommit(3);
+ commit(1);
+ rollback(2);
+ commit(3);
}
// Private ---------------------------------------------------------------------------------
@@ -988,10 +1179,8 @@
}
checkTransactionsEquivalent(prepared, preparedTransactions);
- }
+ }
-
-
private void load() throws Exception
{
journal.load(null, null);
@@ -1031,146 +1220,49 @@
}
}
- private void addTx(long txID, boolean done, long... arguments) throws Exception
+ private void addTx(long txID, long... arguments) throws Exception
{
- TransactionHolder tx = transactions.get(txID);
+ TransactionHolder tx = getTransaction(txID);
- if (tx == null)
- {
- tx = new TransactionHolder();
-
- transactions.put(txID, tx);
- }
-
for (int i = 0; i < arguments.length; i++)
{
byte[] record = generateRecord(recordLength);
- boolean useDone = done ? i == arguments.length - 1 : false;
+ journal.appendAddRecordTransactional(txID, arguments[i], record);
- journal.appendAddRecordTransactional(txID, arguments[i], record, useDone);
-
tx.records.add(new RecordInfo(arguments[i], record, false));
- }
-
- if (done)
- {
- commitTx(txID);
- }
- }
-
- private void addPrepare(long txID, boolean done, long... arguments) throws Exception
- {
- TransactionHolder tx = transactions.get(txID);
-
- if (tx == null)
- {
- tx = new TransactionHolder();
-
- transactions.put(txID, tx);
- }
-
- for (int i = 0; i < arguments.length; i++)
- {
- byte[] record = generateRecord(recordLength);
-
- boolean useDone = done ? i == arguments.length - 1 : false;
-
- journal.appendAddRecordPrepare(txID, arguments[i], record, useDone);
-
- tx.records.add(new RecordInfo(arguments[i], record, false));
-
- }
-
- if (done)
- {
- tx.prepared = true;
- }
- }
-
- private void updateTx(long txID, boolean done, long... arguments) throws Exception
- {
- TransactionHolder tx = transactions.get(txID);
-
- if (tx == null)
- {
- throw new IllegalStateException("Cannot find tx " + txID);
- }
-
- for (int i = 0; i < arguments.length; i++)
- {
- byte[] updateRecord = generateRecord(recordLength);
-
- boolean useDone = done ? i == arguments.length - 1 : false;
-
- journal.appendUpdateRecordTransactional(txID, arguments[i], updateRecord, useDone);
-
- tx.records.add(new RecordInfo(arguments[i], updateRecord, true));
}
-
- if (done)
- {
- commitTx(txID);
- }
}
- private void updatePrepare(long txID, boolean done, long... arguments) throws Exception
+ private void updateTx(long txID, long... arguments) throws Exception
{
- TransactionHolder tx = transactions.get(txID);
+ TransactionHolder tx = getTransaction(txID);
- if (tx == null)
- {
- throw new IllegalStateException("Cannot find tx " + txID);
- }
-
- if (tx.prepared)
- {
- throw new IllegalStateException("Transaction is already prepared");
- }
-
for (int i = 0; i < arguments.length; i++)
{
byte[] updateRecord = generateRecord(recordLength);
+
+ journal.appendUpdateRecordTransactional(txID, arguments[i], updateRecord);
- boolean useDone = done ? i == arguments.length - 1 : false;
-
- journal.appendUpdateRecordPrepare(txID, arguments[i], updateRecord, useDone);
-
tx.records.add(new RecordInfo(arguments[i], updateRecord, true));
}
-
- if (done)
- {
- tx.prepared = true;
- }
}
-
- private void deleteTx(long txID, boolean done, long... arguments) throws Exception
+
+ private void deleteTx(long txID, long... arguments) throws Exception
{
- TransactionHolder tx = transactions.get(txID);
+ TransactionHolder tx = getTransaction(txID);
- if (tx == null)
- {
- throw new IllegalStateException("Cannot find tx " + txID);
- }
-
for (int i = 0; i < arguments.length; i++)
- {
- boolean useDone = done ? i == arguments.length - 1 : false;
-
- journal.appendDeleteRecordTransactional(txID, arguments[i], useDone);
+ {
+ journal.appendDeleteRecordTransactional(txID, arguments[i]);
tx.deletes.add(arguments[i]);
}
- if (done)
- {
- commitTx(txID);
- }
}
- private void deletePrepare(long txID, boolean done, long... arguments) throws Exception
+ private void prepare(long txID) throws Exception
{
TransactionHolder tx = transactions.get(txID);
@@ -1184,22 +1276,12 @@
throw new IllegalStateException("Transaction is already prepared");
}
- for (int i = 0; i < arguments.length; i++)
- {
- boolean useDone = done ? i == arguments.length - 1 : false;
-
- journal.appendDeleteRecordPrepare(txID, arguments[i], useDone);
-
- tx.deletes.add(arguments[i]);
- }
-
- if (done)
- {
- tx.prepared = true;
- }
+ journal.appendPrepareRecord(txID);
+
+ tx.prepared = true;
}
- private void xaCommit(long txID) throws Exception
+ private void commit(long txID) throws Exception
{
TransactionHolder tx = transactions.get(txID);
@@ -1208,17 +1290,12 @@
throw new IllegalStateException("Cannot find tx " + txID);
}
- if (!tx.prepared)
- {
- throw new IllegalStateException("Transaction is not prepared");
- }
+ journal.appendCommitRecord(txID);
- journal.appendXACommitRecord(txID);
-
this.commitTx(txID);
}
- private void xaRollback(long txID) throws Exception
+ private void rollback(long txID) throws Exception
{
TransactionHolder tx = transactions.remove(txID);
@@ -1227,12 +1304,7 @@
throw new IllegalStateException("Cannot find tx " + txID);
}
- if (!tx.prepared)
- {
- throw new IllegalStateException("Transaction is not prepared");
- }
-
- journal.appendXARollbackRecord(txID);
+ journal.appendRollbackRecord(txID);
}
private void commitTx(long txID)
@@ -1265,7 +1337,20 @@
}
}
-
+ private TransactionHolder getTransaction(long txID)
+ {
+ TransactionHolder tx = transactions.get(txID);
+
+ if (tx == null)
+ {
+ tx = new TransactionHolder();
+
+ transactions.put(txID, tx);
+ }
+
+ return tx;
+ }
+
private void checkTransactionsEquivalent(List<PreparedTransactionInfo> expected, List<PreparedTransactionInfo> actual)
{
assertEquals("Lists not same length", expected.size(), actual.size());
Modified: trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/fakes/FakeSequentialFileFactory.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/fakes/FakeSequentialFileFactory.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/journal/impl/test/unit/fakes/FakeSequentialFileFactory.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -97,7 +97,7 @@
private final boolean sync;
- private ByteBuffer data;
+ private volatile ByteBuffer data;
public ByteBuffer getData()
{
@@ -151,16 +151,9 @@
}
return fileName;
}
-
+
public void open() throws Exception
{
- //log.info("open called");
-
- if (open)
- {
- throw new IllegalStateException("Is already open");
- }
-
open = true;
}
Modified: trunk/tests/src/org/jboss/messaging/core/message/impl/test/unit/MessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/message/impl/test/unit/MessageTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/message/impl/test/unit/MessageTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -287,24 +287,14 @@
{
Message message = new MessageImpl();
- assertTrue(message.getReferences().isEmpty());
-
Queue queue1 = queueFactory.createQueue(1, "queue1", null, false, true);
Queue queue2 = queueFactory.createQueue(2, "queue2", null, false, true);
-
- List<MessageReference> refs = new ArrayList<MessageReference>();
-
+
MessageReference ref1 = message.createReference(queue1);
- refs.add(ref1);
MessageReference ref2 = message.createReference(queue2);
- refs.add(ref2);
MessageReference ref3 = message.createReference(queue1);
- refs.add(ref3);
MessageReference ref4 = message.createReference(queue2);
- refs.add(ref4);
- assertRefListsIdenticalRefs(refs, message.getReferences());
-
assertEquals(queue1, ref1.getQueue());
assertEquals(queue2, ref2.getQueue());
assertEquals(queue1, ref3.getQueue());
@@ -341,66 +331,44 @@
//Non durable queue
Queue queue2 = queueFactory.createQueue(2, "queue2", null, false, false);
- assertEquals(0, messageDurable.getNumDurableReferences());
+ assertEquals(0, messageDurable.getDurableRefCount());
MessageReference ref1 = messageDurable.createReference(queue1);
- assertEquals(1, messageDurable.getNumDurableReferences());
+ assertEquals(1, messageDurable.getDurableRefCount());
MessageReference ref2 = messageDurable.createReference(queue2);
- assertEquals(1, messageDurable.getNumDurableReferences());
+ assertEquals(1, messageDurable.getDurableRefCount());
- assertEquals(0, messageNonDurable.getNumDurableReferences());
+ assertEquals(0, messageNonDurable.getDurableRefCount());
MessageReference ref3 = messageNonDurable.createReference(queue1);
- assertEquals(0, messageNonDurable.getNumDurableReferences());
+ assertEquals(0, messageNonDurable.getDurableRefCount());
MessageReference ref4 = messageNonDurable.createReference(queue2);
- assertEquals(0, messageNonDurable.getNumDurableReferences());
-
- }
-
- public void testDurableReferencePos()
- {
- Message messageDurable = new MessageImpl();
- messageDurable.setDurable(true);
-
- //Durable queue
- Queue queue1 = queueFactory.createQueue(1, "queue1", null, true, false);
-
- //Non durable queue
- Queue queue2 = queueFactory.createQueue(2, "queue2", null, false, false);
-
-
- MessageReference ref1 = messageDurable.createReference(queue1);
-
- MessageReference ref2 = messageDurable.createReference(queue2);
-
- MessageReference ref3 = messageDurable.createReference(queue2);
-
- MessageReference ref4 = messageDurable.createReference(queue1);
-
+ assertEquals(0, messageNonDurable.getDurableRefCount());
+
MessageReference ref5 = messageDurable.createReference(queue1);
- MessageReference ref6 = messageDurable.createReference(queue2);
+ assertEquals(2, messageDurable.getDurableRefCount());
- MessageReference ref7 = messageDurable.createReference(queue1);
+ messageDurable.decrementDurableRefCount();
- MessageReference ref8 = messageDurable.createReference(queue2);
+ assertEquals(1, messageDurable.getDurableRefCount());
- assertEquals(0, messageDurable.getDurableReferencePos(ref1));
+ messageDurable.decrementDurableRefCount();
- assertEquals(1, messageDurable.getDurableReferencePos(ref4));
+ assertEquals(0, messageDurable.getDurableRefCount());
- assertEquals(2, messageDurable.getDurableReferencePos(ref5));
+ messageDurable.incrementDurableRefCount();
- assertEquals(3, messageDurable.getDurableReferencePos(ref7));
-
+ assertEquals(1, messageDurable.getDurableRefCount());
}
+
public void testMarshalling() throws Exception
{
Message msg = new MessageImpl(randomLong(), randomInt(), true, randomLong(), randomLong(), randomByte(),null, null);
Modified: trunk/tests/src/org/jboss/messaging/core/postoffice/impl/test/unit/PostOfficeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/postoffice/impl/test/unit/PostOfficeTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/postoffice/impl/test/unit/PostOfficeTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -27,7 +27,7 @@
import org.easymock.EasyMock;
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.message.Message;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.postoffice.impl.BindingImpl;
@@ -50,7 +50,7 @@
public void testAddQueue() throws Exception
{
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
@@ -101,8 +101,8 @@
public void testRemoveQueue() throws Exception
{
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
-
+ StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
+
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
final int nodeID = 21;
@@ -164,8 +164,8 @@
public void testAddRemoveMultipleWithDifferentConditions() throws Exception
{
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
-
+ StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
+
QueueFactory qf = new FakeQueueFactory();
final int nodeID = 21;
Modified: trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -32,7 +32,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.PONG;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.PROD_SEND;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ACKNOWLEDGE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_ADDRESS;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_DESTINATION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_BINDINGQUERY;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_BINDINGQUERY_RESP;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE;
@@ -55,7 +55,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_QUEUEQUERY;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_QUEUEQUERY_RESP;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_RECOVER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_ADDRESS;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_DESTINATION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ROLLBACK;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_COMMIT;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_END;
@@ -106,7 +106,7 @@
import org.jboss.messaging.core.remoting.impl.codec.ProducerSendMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.RemotingBuffer;
import org.jboss.messaging.core.remoting.impl.codec.SessionAcknowledgeMessageCodec;
-import org.jboss.messaging.core.remoting.impl.codec.SessionAddAddressMessageCodec;
+import org.jboss.messaging.core.remoting.impl.codec.SessionAddDestinationMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionBindingQueryMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionBindingQueryResponseMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionBrowserHasNextMessageResponseMessageCodec;
@@ -124,7 +124,7 @@
import org.jboss.messaging.core.remoting.impl.codec.SessionDeleteQueueMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionQueueQueryMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionQueueQueryResponseMessageCodec;
-import org.jboss.messaging.core.remoting.impl.codec.SessionRemoveAddressMessageCodec;
+import org.jboss.messaging.core.remoting.impl.codec.SessionRemoveDestinationMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionXACommitMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionXAEndMessageCodec;
import org.jboss.messaging.core.remoting.impl.codec.SessionXAForgetMessageCodec;
@@ -160,7 +160,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.ProducerReceiveTokensMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.ProducerSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddAddressMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBrowserHasNextMessageMessage;
@@ -183,7 +183,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRecoverMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveAddressMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRollbackMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
@@ -1369,9 +1369,9 @@
public void testSessionRemoveAddressMessage() throws Exception
{
- SessionRemoveAddressMessage message = new SessionRemoveAddressMessage(randomString());
+ SessionRemoveDestinationMessage message = new SessionRemoveDestinationMessage(randomString(), true);
- AbstractPacketCodec codec = new SessionRemoveAddressMessageCodec();
+ AbstractPacketCodec codec = new SessionRemoveDestinationMessageCodec();
SimpleRemotingBuffer buffer = encode(message, codec);
checkHeader(buffer, message);
@@ -1379,11 +1379,12 @@
Packet decodedPacket = codec.decode(buffer);
- assertTrue(decodedPacket instanceof SessionRemoveAddressMessage);
- SessionRemoveAddressMessage decodedMessage = (SessionRemoveAddressMessage)decodedPacket;
- assertEquals(SESS_REMOVE_ADDRESS, decodedMessage.getType());
+ assertTrue(decodedPacket instanceof SessionRemoveDestinationMessage);
+ SessionRemoveDestinationMessage decodedMessage = (SessionRemoveDestinationMessage)decodedPacket;
+ assertEquals(SESS_REMOVE_DESTINATION, decodedMessage.getType());
assertEquals(message.getAddress(), decodedMessage.getAddress());
+ assertEquals(message.isTemporary(), decodedMessage.isTemporary());
}
@@ -1458,9 +1459,9 @@
public void testSessionAddAddressMessage() throws Exception
{
- SessionAddAddressMessage message = new SessionAddAddressMessage(randomString());
+ SessionAddDestinationMessage message = new SessionAddDestinationMessage(randomString(), true);
- AbstractPacketCodec<SessionAddAddressMessage> codec = new SessionAddAddressMessageCodec();
+ AbstractPacketCodec<SessionAddDestinationMessage> codec = new SessionAddDestinationMessageCodec();
SimpleRemotingBuffer buffer = encode(message, codec);
checkHeader(buffer, message);
@@ -1468,11 +1469,12 @@
Packet decodedPacket = codec.decode(buffer);
- assertTrue(decodedPacket instanceof SessionAddAddressMessage);
- SessionAddAddressMessage decodedMessage = (SessionAddAddressMessage)decodedPacket;
- assertEquals(SESS_ADD_ADDRESS, decodedMessage.getType());
+ assertTrue(decodedPacket instanceof SessionAddDestinationMessage);
+ SessionAddDestinationMessage decodedMessage = (SessionAddDestinationMessage)decodedPacket;
+ assertEquals(SESS_ADD_DESTINATION, decodedMessage.getType());
- assertEquals(message.getAddress(), decodedMessage.getAddress());
+ assertEquals(message.getAddress(), decodedMessage.getAddress());
+ assertEquals(message.isTemporary(), decodedMessage.isTemporary());
}
public void testSessionBindingQueryMessage() throws Exception
Modified: trunk/tests/src/org/jboss/messaging/core/server/impl/test/timing/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/server/impl/test/timing/QueueTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/server/impl/test/timing/QueueTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -26,8 +26,11 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
+import org.easymock.EasyMock;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.MessageReference;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.impl.BindingImpl;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.impl.QueueImpl;
import org.jboss.messaging.core.server.impl.test.unit.fakes.FakeConsumer;
@@ -239,6 +242,96 @@
assertTrue(consumer.getReferences().isEmpty());
}
+ public void testDeleteAllReferences() throws Exception
+ {
+ Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+
+ StorageManager storageManager = EasyMock.createStrictMock(StorageManager.class);
+
+ final int numMessages = 10;
+
+ List<MessageReference> refs = new ArrayList<MessageReference>();
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ MessageReference ref = generateReference(queue, i);
+
+ ref.getMessage().setDurable(i % 2 == 0);
+
+ refs.add(ref);
+
+ queue.addLast(ref);
+ }
+
+ //Add some scheduled too
+
+ final long waitTime = 2000;
+
+ final int numScheduled = 10;
+
+ for (int i = numMessages; i < numMessages + numScheduled; i++)
+ {
+ MessageReference ref = generateReference(queue, i);
+
+ ref.setScheduledDeliveryTime(System.currentTimeMillis() + waitTime);
+
+ ref.getMessage().setDurable(i % 2 == 0);
+
+ refs.add(ref);
+
+ queue.addLast(ref);
+ }
+
+
+ assertEquals(numMessages + numScheduled, queue.getMessageCount());
+ assertEquals(numScheduled, queue.getScheduledCount());
+ assertEquals(0, queue.getDeliveringCount());
+
+ //What I expect to get
+
+ EasyMock.expect(storageManager.generateTransactionID()).andReturn(1L);
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ if (i % 2 == 0)
+ {
+ storageManager.storeDeleteTransactional(1, i);
+ }
+ }
+
+ for (int i = numMessages; i < numMessages + numScheduled; i++)
+ {
+ if (i % 2 == 0)
+ {
+ storageManager.storeDeleteTransactional(1, i);
+ }
+ }
+
+ storageManager.commit(1);
+
+ EasyMock.replay(storageManager);
+
+ queue.deleteAllReferences(storageManager);
+
+ EasyMock.verify(storageManager);
+
+ assertEquals(0, queue.getMessageCount());
+ assertEquals(0, queue.getScheduledCount());
+ assertEquals(0, queue.getDeliveringCount());
+
+ Thread.sleep(waitTime + 500);
+
+ //Make sure scheduled don't arrive
+
+ FakeConsumer consumer = new FakeConsumer();
+
+ queue.addConsumer(consumer);
+
+ queue.deliver();
+
+ assertTrue(consumer.getReferences().isEmpty());
+ }
+
// Inner classes ---------------------------------------------------------------
}
Modified: trunk/tests/src/org/jboss/messaging/core/server/impl/test/unit/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/server/impl/test/unit/QueueTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/server/impl/test/unit/QueueTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -27,8 +27,10 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
+import org.easymock.EasyMock;
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.message.MessageReference;
+import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.server.Consumer;
import org.jboss.messaging.core.server.DistributionPolicy;
import org.jboss.messaging.core.server.HandleStatus;
@@ -37,9 +39,6 @@
import org.jboss.messaging.core.server.impl.RoundRobinDistributionPolicy;
import org.jboss.messaging.core.server.impl.test.unit.fakes.FakeConsumer;
import org.jboss.messaging.core.server.impl.test.unit.fakes.FakeFilter;
-import org.jboss.messaging.core.settings.HierarchicalRepository;
-import org.jboss.messaging.core.settings.impl.HierarchicalObjectRepository;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.test.unit.UnitTestCase;
/**
@@ -735,10 +734,12 @@
}
}
- public void testRemoveAllReferences()
+ public void testDeleteAllReferences() throws Exception
{
Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ StorageManager storageManager = EasyMock.createStrictMock(StorageManager.class);
+
final int numMessages = 10;
List<MessageReference> refs = new ArrayList<MessageReference>();
@@ -747,17 +748,63 @@
{
MessageReference ref = generateReference(queue, i);
+ ref.getMessage().setDurable(i % 2 == 0);
+
refs.add(ref);
queue.addLast(ref);
}
- assertEquals(numMessages, queue.getMessageCount());
- assertEquals(0, queue.getScheduledCount());
+ //Add some scheduled too
+
+ final int numScheduled = 10;
+
+ for (int i = numMessages; i < numMessages + numScheduled; i++)
+ {
+ MessageReference ref = generateReference(queue, i);
+
+ ref.setScheduledDeliveryTime(System.currentTimeMillis() + 1000000000);
+
+ ref.getMessage().setDurable(i % 2 == 0);
+
+ refs.add(ref);
+
+ queue.addLast(ref);
+ }
+
+
+ assertEquals(numMessages + numScheduled, queue.getMessageCount());
+ assertEquals(numScheduled, queue.getScheduledCount());
assertEquals(0, queue.getDeliveringCount());
- queue.removeAllReferences();
+ //What I expect to get
+ EasyMock.expect(storageManager.generateTransactionID()).andReturn(1L);
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ if (i % 2 == 0)
+ {
+ storageManager.storeDeleteTransactional(1, i);
+ }
+ }
+
+ for (int i = numMessages; i < numMessages + numScheduled; i++)
+ {
+ if (i % 2 == 0)
+ {
+ storageManager.storeDeleteTransactional(1, i);
+ }
+ }
+
+ storageManager.commit(1);
+
+ EasyMock.replay(storageManager);
+
+ queue.deleteAllReferences(storageManager);
+
+ EasyMock.verify(storageManager);
+
assertEquals(0, queue.getMessageCount());
assertEquals(0, queue.getScheduledCount());
assertEquals(0, queue.getDeliveringCount());
Modified: trunk/tests/src/org/jboss/messaging/core/transaction/impl/test/unit/TransactionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/transaction/impl/test/unit/TransactionTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/core/transaction/impl/test/unit/TransactionTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -10,14 +10,14 @@
import org.easymock.EasyMock;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.persistence.PersistenceManager;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.impl.QueueImpl;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.HierarchicalObjectRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.Transaction;
-import org.jboss.messaging.core.transaction.TransactionSynchronization;
import org.jboss.messaging.core.transaction.impl.TransactionImpl;
import org.jboss.messaging.test.unit.UnitTestCase;
@@ -44,328 +44,599 @@
queueSettings.setDefault(new QueueSettings());
}
- public void test1PCCommit() throws Exception
+ public void testNonXAConstructor() throws Exception
{
- List<Message> msgsToAdd = new ArrayList<Message>();
+ StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ PostOffice po = EasyMock.createStrictMock(PostOffice.class);
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ final long txID = 123L;
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ EasyMock.expect(sm.generateTransactionID()).andReturn(txID);
+
+ EasyMock.replay(sm);
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
-
- Transaction tx = new TransactionImpl();
+ Transaction tx = new TransactionImpl(sm, po);
+
+ EasyMock.verify(sm);
+
+ assertEquals(txID, tx.getID());
+
+ assertNull(tx.getXid());
+
+ assertEquals(0, tx.getAcknowledgementsCount());
+
+ assertTrue(tx.isEmpty());
+ }
+
+ public void testXAConstructor() throws Exception
+ {
+ StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ PostOffice po = EasyMock.createStrictMock(PostOffice.class);
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ final long txID = 123L;
- pm.commitTransaction(msgsToAdd, refsToRemove);
+ EasyMock.expect(sm.generateTransactionID()).andReturn(txID);
+
+ EasyMock.replay(sm);
- EasyMock.replay(pm);
+ Xid xid = generateXid();
- tx.commit(true, pm);
-
- EasyMock.verify(pm);
-
- assertEquals(ref1, queue.list(null).get(0));
+ Transaction tx = new TransactionImpl(xid, sm, po);
+
+ EasyMock.verify(sm);
+
+ assertEquals(txID, tx.getID());
+
+ assertEquals(xid, tx.getXid());
+
+ assertEquals(0, tx.getAcknowledgementsCount());
+
+ assertTrue(tx.isEmpty());
}
- public void test1PCRollback() throws Exception
+ public void testState() throws Exception
{
- List<Message> msgsToAdd = new ArrayList<Message>();
+ Transaction tx = createTransaction();
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ assertEquals(Transaction.State.ACTIVE, tx.getState());
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ tx.suspend();
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ assertEquals(Transaction.State.SUSPENDED, tx.getState());
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
-
- Transaction tx = new TransactionImpl();
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ tx.resume();
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ assertEquals(Transaction.State.ACTIVE, tx.getState());
- pm.updateDeliveryCount(queue, ref2);
+ tx.commit();
- EasyMock.replay(pm);
+ assertEquals(Transaction.State.COMMITTED, tx.getState());
- tx.rollback(pm, queueSettings);
+ HierarchicalRepository<QueueSettings> repos = EasyMock.createStrictMock(HierarchicalRepository.class);
- EasyMock.verify(pm);
-
- assertEquals(ref2, queue.list(null).get(0));
- }
-
- public void test1PCPrepare() throws Exception
- {
- List<Message> msgsToAdd = new ArrayList<Message>();
+ try
+ {
+ tx.rollback(repos);
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ try
+ {
+ tx.commit();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ try
+ {
+ tx.prepare();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ try
+ {
+ tx.suspend();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
-
- Transaction tx = new TransactionImpl();
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ try
+ {
+ tx.resume();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ tx = createTransaction();
+ assertEquals(Transaction.State.ACTIVE, tx.getState());
+
+ tx.rollback(repos);
+
try
{
- tx.prepare(pm);
- fail("Should throw exception");
+ tx.rollback(repos);
+
+ fail("Should throw exception");
}
catch (IllegalStateException e)
{
- //OK
- }
+ //OK
+ }
- assertTrue(queue.list(null).isEmpty());
- }
-
- public void test2PCPrepareCommit() throws Exception
- {
- List<Message> msgsToAdd = new ArrayList<Message>();
+ try
+ {
+ tx.commit();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ try
+ {
+ tx.prepare();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ try
+ {
+ tx.suspend();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ try
+ {
+ tx.resume();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
+ tx = createTransaction();
- Xid xid = generateXid();
-
- Transaction tx = new TransactionImpl(xid);
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ assertEquals(Transaction.State.ACTIVE, tx.getState());
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ try
+ {
+ tx.prepare();
+
+ fail("Should throw exception");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
- pm.prepareTransaction(xid, msgsToAdd, refsToRemove);
- EasyMock.replay(pm);
+ tx = createTransactionXA();
- tx.prepare(pm);
+ assertEquals(Transaction.State.ACTIVE, tx.getState());
- EasyMock.verify(pm);
+ tx.prepare();
- EasyMock.reset(pm);
+ tx.commit();
- pm.commitPreparedTransaction(xid);
+ try
+ {
+ tx.rollback(repos);
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- EasyMock.replay(pm);
+ try
+ {
+ tx.commit();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- tx.commit(false, pm);
+ try
+ {
+ tx.prepare();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- EasyMock.verify(pm);
- }
-
- public void test2PCCommitBeforePrepare() throws Exception
- {
- List<Message> msgsToAdd = new ArrayList<Message>();
+ try
+ {
+ tx.suspend();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ try
+ {
+ tx.resume();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ tx = createTransactionXA();
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ assertEquals(Transaction.State.ACTIVE, tx.getState());
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
-
- Xid xid = generateXid();
+ tx.prepare();
- Transaction tx = new TransactionImpl(xid);
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ tx.rollback(repos);
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ try
+ {
+ tx.rollback(repos);
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
try
- {
- tx.commit(false, pm);
-
- fail ("Should throw exception");
+ {
+ tx.commit();
+
+ fail("Should throw exception");
}
catch (IllegalStateException e)
{
- //Ok
- }
+ //OK
+ }
+
+ try
+ {
+ tx.prepare();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
+
+ try
+ {
+ tx.suspend();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
+
+ try
+ {
+ tx.resume();
+
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ //OK
+ }
}
- public void test2PCPrepareRollback() throws Exception
+ public void testSendCommit() throws Exception
{
- List<Message> msgsToAdd = new ArrayList<Message>();
+ //Durable queue
+ Queue queue1 = new QueueImpl(12, "queue1", null, false, true, false, -1, scheduledExecutor);
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ //Durable queue
+ Queue queue2 = new QueueImpl(34, "queue2", null, false, true, false, -1, scheduledExecutor);
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ //Non durable queue
+ Queue queue3 = new QueueImpl(65, "queue3", null, false, false, false, -1, scheduledExecutor);
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ //Durable message to send
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
+ Message message1 = this.generateMessage(1);
- Xid xid = generateXid();
-
- Transaction tx = new TransactionImpl(xid);
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ // Non durable message to send
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ Message message2 = this.generateMessage(2);
- pm.prepareTransaction(xid, msgsToAdd, refsToRemove);
+ message2.setDurable(false);
- EasyMock.replay(pm);
- tx.prepare(pm);
+ StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
- EasyMock.verify(pm);
+ PostOffice po= EasyMock.createStrictMock(PostOffice.class);
- EasyMock.reset(pm);
+ final long txID = 123;
- pm.unprepareTransaction(xid, msgsToAdd, refsToRemove);
+ EasyMock.expect(sm.generateTransactionID()).andReturn(txID);
- pm.updateDeliveryCount(queue, ref2);
+ EasyMock.replay(sm);
+
+ Transaction tx = new TransactionImpl(sm, po);
- EasyMock.replay(pm);
+ assertTrue(tx.isEmpty());
+ assertFalse(tx.isContainsPersistent());
+
+ EasyMock.verify(sm);
- tx.rollback(pm, queueSettings);
+ EasyMock.reset(sm);
- EasyMock.verify(pm);
- }
-
- public void testSynchronizations() throws Exception
- {
- List<Message> msgsToAdd = new ArrayList<Message>();
+ final String address1 = "topic1";
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ //Expect:
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ MessageReference ref5 = message1.createReference(queue1);
+ MessageReference ref6 = message1.createReference(queue2);
+ List<MessageReference> message1Refs = new ArrayList<MessageReference>();
+ message1Refs.add(ref5);
+ message1Refs.add(ref6);
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ EasyMock.expect(po.route(address1, message1)).andReturn(message1Refs);
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
-
- Transaction tx = new TransactionImpl();
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ sm.storeMessageTransactional(txID, address1, message1);
- TransactionSynchronization sync = EasyMock.createStrictMock(TransactionSynchronization.class);
+ EasyMock.replay(po);
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ EasyMock.replay(sm);
- tx.addSynchronization(sync);
+ tx.addMessage(address1, message1);
- sync.beforeCommit();
- sync.afterCommit();
+ assertFalse(tx.isEmpty());
+ assertTrue(tx.isContainsPersistent());
- EasyMock.replay(sync);
+
+ EasyMock.verify(po);
- tx.commit(true, pm);
+ EasyMock.verify(sm);
- EasyMock.verify(sync);
+ EasyMock.reset(po);
- EasyMock.reset(sync);
+ EasyMock.reset(sm);
- tx = new TransactionImpl();
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+
+ //Expect:
- tx.addSynchronization(sync);
+ final String address2 = "queue3";
- sync.beforeRollback();
- sync.afterRollback();
+ MessageReference ref7 = message2.createReference(queue3);
+ List<MessageReference> message2Refs = new ArrayList<MessageReference>();
+ message2Refs.add(ref7);
+
+ EasyMock.expect(po.route(address2, message2)).andReturn(message1Refs);
- EasyMock.replay(sync);
+ EasyMock.replay(po);
- tx.rollback(pm, queueSettings);
+ EasyMock.replay(sm);
- EasyMock.verify(sync);
+ tx.addMessage(address2, message2);
+
+ EasyMock.verify(po);
+
+ EasyMock.verify(sm);
+
+ EasyMock.reset(po);
+
+ EasyMock.reset(sm);
+
+ //Expect :
+
+ sm.commit(txID);
+
+ EasyMock.replay(sm);
+
+ tx.commit();
+
+ EasyMock.verify(sm);
+
+ //TODO test messages are routed and refs count reduced
}
- public void testSynchronizations2PC() throws Exception
+
+
+ public void testAckCommit() throws Exception
{
- List<Message> msgsToAdd = new ArrayList<Message>();
+ //Durable queue
+ Queue queue1 = new QueueImpl(12, "queue1", null, false, true, false, -1, scheduledExecutor);
- List<MessageReference> refsToRemove = new ArrayList<MessageReference>();
+ //Durable queue
+ Queue queue2 = new QueueImpl(34, "queue2", null, false, true, false, -1, scheduledExecutor);
- Queue queue = new QueueImpl(1, "queue1", null, false, true, false, -1, scheduledExecutor);
+ //Non durable queue
+ Queue queue3 = new QueueImpl(65, "queue3", null, false, false, false, -1, scheduledExecutor);
- MessageReference ref1 = this.generateReference(queue, 1);
- msgsToAdd.add(ref1.getMessage());
+ //Some refs to ack
- MessageReference ref2 = this.generateReference(queue, 2);
- refsToRemove.add(ref2);
+ Message message1 = this.generateMessage(12);
- Xid xid = generateXid();
-
- Transaction tx = new TransactionImpl(xid);
- tx.addMessage(ref1.getMessage());
- tx.addAcknowledgement(ref2);
+ MessageReference ref1 = message1.createReference(queue1);
- TransactionSynchronization sync = EasyMock.createStrictMock(TransactionSynchronization.class);
+ MessageReference ref2 = message1.createReference(queue2);
- PersistenceManager pm = EasyMock.createStrictMock(PersistenceManager.class);
+ MessageReference ref3 = message1.createReference(queue3);
- tx.addSynchronization(sync);
- sync.beforeCommit();
- sync.afterCommit();
+ //Non durable message to ack
+ Message message2 = this.generateMessage(23);
- EasyMock.replay(sync);
+ message2.setDurable(false);
+
+ MessageReference ref4 = message2.createReference(queue1);
- tx.prepare(pm);
- tx.commit(false, pm);
+
+ StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
- EasyMock.verify(sync);
+ PostOffice po= EasyMock.createStrictMock(PostOffice.class);
- EasyMock.reset(sync);
+ final long txID = 123;
- xid = generateXid();
+ EasyMock.expect(sm.generateTransactionID()).andReturn(txID);
- tx = new TransactionImpl(xid);
- tx.addMessage(ref1.getMessage());
+ EasyMock.replay(sm);
+
+ Transaction tx = new TransactionImpl(sm, po);
+
+ assertTrue(tx.isEmpty());
+
+ assertFalse(tx.isContainsPersistent());
+
+ EasyMock.verify(sm);
+
+ EasyMock.reset(sm);
+
+ //Expect:
+
+ sm.storeAcknowledgeTransactional(txID, queue1.getPersistenceID(), message1.getMessageID());
+ sm.storeDeleteTransactional(txID, message1.getMessageID());
+
+ EasyMock.replay(sm);
+
+ tx.addAcknowledgement(ref3);
+
+ assertFalse(tx.isEmpty());
+ assertFalse(tx.isContainsPersistent());
+
+ tx.addAcknowledgement(ref1);
+
+ assertTrue(tx.isContainsPersistent());
+
tx.addAcknowledgement(ref2);
- tx.addSynchronization(sync);
+ assertTrue(tx.isContainsPersistent());
- sync.beforeRollback();
- sync.afterRollback();
- EasyMock.replay(sync);
+ assertEquals(3, tx.getAcknowledgementsCount());
- tx.prepare(pm);
- tx.rollback(pm, queueSettings);
+ EasyMock.verify(sm);
- EasyMock.verify(sync);
+ EasyMock.reset(sm);
+
+ //Expect:
+
+ //Nothing
+
+ EasyMock.replay(sm);
+
+ tx.addAcknowledgement(ref4);
+
+ assertEquals(4, tx.getAcknowledgementsCount());
+
+ EasyMock.verify(sm);
+
+ EasyMock.reset(sm);
+
+ //Expect:
+
+ sm.commit(txID);
+
+ EasyMock.replay(sm);
+
+ tx.commit();
+
+ EasyMock.verify(sm);
+
+ EasyMock.reset(sm);
+
+ //TODO test messages are routed and refs count reduced
}
+ // Private -------------------------------------------------------------------------
+
+ private Transaction createTransaction()
+ {
+ StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
+
+ PostOffice po = EasyMock.createStrictMock(PostOffice.class);
+
+ final long txID = 123L;
+
+ EasyMock.expect(sm.generateTransactionID()).andReturn(txID);
+
+ EasyMock.replay(sm);
+
+ Transaction tx = new TransactionImpl(sm, po);
+
+ EasyMock.verify(sm);
+
+ return tx;
+ }
+
+ private Transaction createTransactionXA()
+ {
+ StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
+
+ PostOffice po = EasyMock.createStrictMock(PostOffice.class);
+
+ final long txID = 123L;
+
+ EasyMock.expect(sm.generateTransactionID()).andReturn(txID);
+
+ EasyMock.replay(sm);
+
+ Xid xid = this.generateXid();
+
+ Transaction tx = new TransactionImpl(xid, sm, po);
+
+ EasyMock.verify(sm);
+
+ return tx;
+ }
+
+
// Inner classes -----------------------------------------------------------------------
-
+
}
Modified: trunk/tests/src/org/jboss/messaging/test/unit/UnitTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/test/unit/UnitTestCase.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/messaging/test/unit/UnitTestCase.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -252,28 +252,7 @@
assertMapsEquivalent(msg1.getHeaders(), msg2.getHeaders());
- assertEquals(msg1.getReferences().size(), msg2.getReferences().size());
-
- for (int i = 0; i < msg1.getReferences().size(); i++)
- {
- MessageReference ref1 = msg1.getReferences().get(i);
-
- MessageReference ref2 = msg2.getReferences().get(i);
-
- assertEquals(ref1.getScheduledDeliveryTime(), ref2.getScheduledDeliveryTime());
-
- assertEquals(ref1.getDeliveryCount(), ref2.getDeliveryCount());
-
- if (exactQueue)
- {
- assertTrue(ref1.getQueue() == ref2.getQueue());
- }
- else
- {
- assertEquals(ref1.getQueue().getPersistenceID(), ref2.getQueue().getPersistenceID());
- assertEquals(ref1.getQueue().getName(), ref2.getQueue().getName());
- }
- }
+ assertEquals(msg1.getDurableRefCount(), msg2.getDurableRefCount());
}
protected void assertMapsEquivalent(Map<String, Object> headers1, Map<String, Object> headers2)
Modified: trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -598,7 +598,7 @@
}
-// public PersistenceManager getPersistenceManager()
+// public StorageManager getPersistenceManager()
// {
// try
// {
Modified: trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -30,17 +30,11 @@
protected void setUp() throws Exception
{
super.setUp();
-
- String[] args = new String[]{"invm-beans.xml", "jbm-beans.xml"};
+
ic = getInitialContext();
cf = getConnectionFactory();
}
- protected void tearDown() throws Exception
- {
- super.tearDown();
- //ServerManagement.stopServerPeer();
- }
public JMSTestCase(String name)
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -171,6 +171,8 @@
stop();
+ log.info("************ RESTARTING");
+
startNoDelete();
// Messaging server restart implies new ConnectionFactory lookup
@@ -475,6 +477,7 @@
ds.close();
+ log.info("************* UNSUBSCRIBE CALLED");
s.unsubscribe("sub");
}
finally
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -110,7 +110,82 @@
}
}
}
+
+ public void testJMSXDeliveryCountNotDeliveredMessagesNotUpdated() throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = getConnectionFactory().createConnection();
+
+ Session s = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+
+ MessageProducer p = s.createProducer(queue1);
+ p.send(s.createTextMessage("message1"));
+ p.send(s.createTextMessage("message2"));
+ p.send(s.createTextMessage("message3"));
+ p.send(s.createTextMessage("message4"));
+ p.send(s.createTextMessage("message5"));
+
+ MessageConsumer c = s.createConsumer(queue1);
+
+ conn.start();
+
+ TextMessage tm = (TextMessage)c.receive(1000);
+
+ assertEquals("message1", tm.getText());
+ assertFalse(tm.getJMSRedelivered());
+ assertEquals(1, tm.getIntProperty("JMSXDeliveryCount"));
+
+ s.close();
+
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ c = s.createConsumer(queue1);
+
+ tm = (TextMessage)c.receive(1000);
+
+ assertEquals("message1", tm.getText());
+ assertTrue(tm.getJMSRedelivered());
+ assertEquals(2, tm.getIntProperty("JMSXDeliveryCount"));
+
+ tm = (TextMessage)c.receive(1000);
+
+ assertEquals("message2", tm.getText());
+ assertFalse(tm.getJMSRedelivered());
+ assertEquals(1, tm.getIntProperty("JMSXDeliveryCount"));
+
+ tm = (TextMessage)c.receive(1000);
+
+ assertEquals("message3", tm.getText());
+ assertFalse(tm.getJMSRedelivered());
+ assertEquals(1, tm.getIntProperty("JMSXDeliveryCount"));
+
+ tm = (TextMessage)c.receive(1000);
+
+ assertEquals("message4", tm.getText());
+ assertFalse(tm.getJMSRedelivered());
+ assertEquals(1, tm.getIntProperty("JMSXDeliveryCount"));
+
+ tm = (TextMessage)c.receive(1000);
+
+ assertEquals("message5", tm.getText());
+ assertFalse(tm.getJMSRedelivered());
+ assertEquals(1, tm.getIntProperty("JMSXDeliveryCount"));
+
+ tm.acknowledge();
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
public void testRedeliveryOnQueue() throws Exception
{
Connection conn = null;
@@ -297,8 +372,6 @@
//Now close the session without committing
- log.info("Closing session");
-
consumerSess.close();
consumerSess = conn.createSession(true, Session.SESSION_TRANSACTED);
@@ -522,10 +595,8 @@
tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);
- log.info("Rolling back");
mgr.rollback();
- log.info("Rolled back");
-
+
//Must close consumer first
consumer.close();
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -21,19 +21,31 @@
*/
package org.jboss.test.messaging.jms.server;
-import org.jboss.test.messaging.JBMServerTestCase;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
+import javax.naming.NameNotFoundException;
+
import org.jboss.messaging.jms.client.JBossConnectionFactory;
import org.jboss.messaging.jms.server.ConnectionInfo;
import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.MessageStatistics;
import org.jboss.messaging.jms.server.SubscriptionInfo;
-import org.jboss.messaging.jms.server.MessageStatistics;
+import org.jboss.test.messaging.JBMServerTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
-import javax.jms.*;
-import javax.naming.NameNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
/**
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
*/
@@ -546,113 +558,126 @@
}
}
- public void testRemoveMessageFromQueue() throws Exception
- {
- Connection conn = getConnectionFactory().createConnection("guest", "guest");
- try
- {
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = sess.createProducer(queue1);
- Message messageToDelete = null;
- for (int i = 0; i < 10; i++)
- {
- TextMessage message = sess.createTextMessage();
- message.setIntProperty("pos", i);
- producer.send(message);
- if (i == 5)
- {
- messageToDelete = message;
- }
- }
- jmsServerManager.removeMessageFromQueue("Queue1", messageToDelete.getJMSMessageID());
- sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer consumer = sess.createConsumer(queue1);
- conn.start();
- int lastPos = -1;
- for (int i = 0; i < 9; i++)
- {
- Message message = consumer.receive();
- assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
- int pos = message.getIntProperty("pos");
- assertTrue("returned in wrong order", pos > lastPos);
- lastPos = pos;
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
+// public void testRemoveMessageFromQueue() throws Exception
+// {
+// Connection conn = getConnectionFactory().createConnection("guest", "guest");
+// try
+// {
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+// MessageProducer producer = sess.createProducer(queue1);
+// Message messageToDelete = null;
+// for (int i = 0; i < 10; i++)
+// {
+// TextMessage message = sess.createTextMessage();
+// message.setIntProperty("pos", i);
+// producer.send(message);
+// if (i == 5)
+// {
+// messageToDelete = message;
+// }
+// }
+// jmsServerManager.removeMessageFromQueue("Queue1", messageToDelete.getJMSMessageID());
+// sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
+// MessageConsumer consumer = sess.createConsumer(queue1);
+// conn.start();
+// int lastPos = -1;
+// for (int i = 0; i < 9; i++)
+// {
+// Message message = consumer.receive();
+// assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
+// int pos = message.getIntProperty("pos");
+// assertTrue("returned in wrong order", pos > lastPos);
+// lastPos = pos;
+// }
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+// }
- public void testRemoveMessageFromTopic() throws Exception
- {
- Connection conn = getConnectionFactory().createConnection("guest", "guest");
- try
- {
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = sess.createProducer(topic1);
- MessageConsumer consumer = sess.createConsumer(topic1);
- MessageConsumer consumer2 = sess.createConsumer(topic1);
- Message messageToDelete = null;
- for (int i = 0; i < 10; i++)
- {
- TextMessage message = sess.createTextMessage();
- producer.send(message);
- if (i == 5)
- {
- messageToDelete = message;
- }
- }
- jmsServerManager.removeMessageFromTopic("Topic1", messageToDelete.getJMSMessageID());
- conn.start();
- for (int i = 0; i < 9; i++)
- {
- Message message = consumer.receive();
- assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
- message = consumer2.receive();
- assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
+// public void testRemoveMessageFromTopic() throws Exception
+// {
+// Connection conn = getConnectionFactory().createConnection("guest", "guest");
+// try
+// {
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+// MessageProducer producer = sess.createProducer(topic1);
+// MessageConsumer consumer = sess.createConsumer(topic1);
+// MessageConsumer consumer2 = sess.createConsumer(topic1);
+// Message messageToDelete = null;
+// for (int i = 0; i < 10; i++)
+// {
+// TextMessage message = sess.createTextMessage();
+// producer.send(message);
+// if (i == 5)
+// {
+// messageToDelete = message;
+// }
+// }
+// jmsServerManager.removeMessageFromTopic("Topic1", messageToDelete.getJMSMessageID());
+// conn.start();
+// for (int i = 0; i < 9; i++)
+// {
+// Message message = consumer.receive();
+// assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
+// message = consumer2.receive();
+// assertNotSame(messageToDelete.getJMSMessageID(), message.getJMSMessageID());
+// }
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+//
+// }
- }
+// public void testRemoveAllMessagesFromQueue() throws Exception
+// {
+// Connection conn = getConnectionFactory().createConnection("guest", "guest");
+//
+// ServerManagement.getServer(0).createQueue("myQueue", null);
+//
+// Queue queue = (Queue)this.getInitialContext().lookup("/queue/myQueue");
+//
+// try
+// {
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+// MessageProducer producer = sess.createProducer(queue);
+// for (int i = 0; i < 10; i++)
+// {
+// TextMessage message = sess.createTextMessage();
+// producer.send(message);
+// }
+// jmsServerManager.removeAllMessagesForQueue("myQueue");
+// sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
+// MessageConsumer consumer = sess.createConsumer(queue);
+// assertEquals("messages still exist", 0, jmsServerManager.getMessageCountForQueue("myQueue"));
+//
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+//
+// try
+// {
+// ServerManagement.getServer(0).destroyQueue("myQueue", null);
+// }
+// catch (Exception ignore)
+// {
+// }
+// }
+// }
- public void testRemoveAllMessagesFromQueue() throws Exception
- {
- Connection conn = getConnectionFactory().createConnection("guest", "guest");
- try
- {
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = sess.createProducer(queue1);
- for (int i = 0; i < 10; i++)
- {
- TextMessage message = sess.createTextMessage();
- producer.send(message);
- }
- jmsServerManager.removeAllMessagesForQueue("Queue1");
- sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer consumer = sess.createConsumer(queue1);
- assertEquals("messages still exist", 0, jmsServerManager.getMessageCountForQueue("Queue1"));
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
public void testRemoveAllMessagesFromTopic() throws Exception
{
Connection conn = getConnectionFactory().createConnection("guest", "guest");
@@ -689,46 +714,46 @@
}
- public void testMoveMessage() throws Exception
- {
- Connection conn = getConnectionFactory().createConnection("guest", "guest");
- try
- {
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = sess.createProducer(queue1);
- Message messageToMove = null;
- for (int i = 0; i < 10; i++)
- {
- TextMessage message = sess.createTextMessage();
- producer.send(message);
- if (i == 5)
- {
- messageToMove = message;
- }
- }
- jmsServerManager.moveMessage("Queue1", "Queue2", messageToMove.getJMSMessageID());
- MessageConsumer consumer = sess.createConsumer(queue1);
- conn.start();
- for (int i = 0; i < 9; i++)
- {
- Message message = consumer.receive();
- assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
- }
- consumer.close();
- consumer = sess.createConsumer(queue2);
- Message message = consumer.receive();
- assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
+// public void testMoveMessage() throws Exception
+// {
+// Connection conn = getConnectionFactory().createConnection("guest", "guest");
+// try
+// {
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+// MessageProducer producer = sess.createProducer(queue1);
+// Message messageToMove = null;
+// for (int i = 0; i < 10; i++)
+// {
+// TextMessage message = sess.createTextMessage();
+// producer.send(message);
+// if (i == 5)
+// {
+// messageToMove = message;
+// }
+// }
+// jmsServerManager.moveMessage("Queue1", "Queue2", messageToMove.getJMSMessageID());
+// MessageConsumer consumer = sess.createConsumer(queue1);
+// conn.start();
+// for (int i = 0; i < 9; i++)
+// {
+// Message message = consumer.receive();
+// assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+// }
+// consumer.close();
+// consumer = sess.createConsumer(queue2);
+// Message message = consumer.receive();
+// assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+//
+// }
- }
-
public void testExpireMessage() throws Exception
{
Connection conn = getConnectionFactory().createConnection("guest", "guest");
@@ -771,52 +796,52 @@
}
- public void testChangeMessagePriority() throws Exception
- {
- Connection conn = getConnectionFactory().createConnection("guest", "guest");
- try
- {
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = sess.createProducer(queue1);
- producer.setPriority(9);
- Message messageToMove = null;
- for (int i = 0; i < 10; i++)
- {
- TextMessage message = sess.createTextMessage();
+// public void testChangeMessagePriority() throws Exception
+// {
+// Connection conn = getConnectionFactory().createConnection("guest", "guest");
+// try
+// {
+// Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+// MessageProducer producer = sess.createProducer(queue1);
+// producer.setPriority(9);
+// Message messageToMove = null;
+// for (int i = 0; i < 10; i++)
+// {
+// TextMessage message = sess.createTextMessage();
+//
+// producer.send(message);
+// if (i == 5)
+// {
+// messageToMove = message;
+// }
+// }
+// jmsServerManager.changeMessagePriority("Queue1", messageToMove.getJMSMessageID(), 8);
+// MessageConsumer consumer = sess.createConsumer(queue1);
+// conn.start();
+// for (int i = 0; i < 9; i++)
+// {
+// Message message = consumer.receive();
+// assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+// System.out.println("message.getJMSPriority() = " + message.getJMSPriority());
+// assertEquals(9, message.getJMSPriority());
+// }
+// Message message = consumer.receive();
+// assertEquals(8, message.getJMSPriority());
+// assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
+//
+// consumer.close();
+//
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+//
+// }
- producer.send(message);
- if (i == 5)
- {
- messageToMove = message;
- }
- }
- jmsServerManager.changeMessagePriority("Queue1", messageToMove.getJMSMessageID(), 8);
- MessageConsumer consumer = sess.createConsumer(queue1);
- conn.start();
- for (int i = 0; i < 9; i++)
- {
- Message message = consumer.receive();
- assertNotSame(messageToMove.getJMSMessageID(), message.getJMSMessageID());
- System.out.println("message.getJMSPriority() = " + message.getJMSPriority());
- assertEquals(9, message.getJMSPriority());
- }
- Message message = consumer.receive();
- assertEquals(8, message.getJMSPriority());
- assertEquals(messageToMove.getJMSMessageID(), message.getJMSMessageID());
-
- consumer.close();
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
- }
-
public void testMessageStatistics() throws Exception
{
Connection conn = getConnectionFactory().createConnection("guest", "guest");
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -712,7 +712,7 @@
// return servers.get(0).getDestinationManager();
// }
//
-// public static PersistenceManager getPersistenceManager()
+// public static StorageManager getPersistenceManager()
// throws Exception
// {
//
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -133,11 +133,11 @@
{
//Delete the BDB environment
- File dir = new File(System.getProperty("user.home") + "/bdbje/env");
+ File dir = new File("/tmp/jbm-test");
boolean deleted = deleteDirectory(dir);
- log.info("Deleted dir: " +dir.getAbsolutePath() + " deleted: " + deleted);
+ log.info("Deleted dir: " + dir.getAbsolutePath() + " deleted: " + deleted);
}
ConfigurationHelper.addServerConfig(getServerID(), configuration);
@@ -459,7 +459,7 @@
// return getServerPeer().getDestinationManager();
// }
//
-// public PersistenceManager getPersistenceManager()
+// public StorageManager getPersistenceManager()
// {
// return getServerPeer().getPersistenceManagerInstance();
// }
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -322,7 +322,7 @@
// return server.getDestinationManager();
// }
//
-// public PersistenceManager getPersistenceManager()
+// public StorageManager getPersistenceManager()
// {
// return server.getPersistenceManager();
// }
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -65,7 +65,7 @@
// /**
// * Only for in-VM use!
// */
-// public PersistenceManager getPersistenceManager()
+// public StorageManager getPersistenceManager()
// {
// throw new UnsupportedOperationException("This method shouldn't be invoked on a remote server");
// }
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-03-20 14:03:51 UTC (rev 3896)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-03-20 16:43:19 UTC (rev 3897)
@@ -128,7 +128,7 @@
*/
// DestinationManager getDestinationManager() throws Exception;
-// PersistenceManager getPersistenceManager() throws Exception;
+// StorageManager getPersistenceManager() throws Exception;
//
// /**
// * Only for in-VM use
More information about the jboss-cvs-commits
mailing list