JBoss hornetq SVN: r10704 - branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-05-20 01:38:55 -0400 (Fri, 20 May 2011)
New Revision: 10704
Modified:
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
Log:
fixing test
Modified: branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-19 21:44:05 UTC (rev 10703)
+++ branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-20 05:38:55 UTC (rev 10704)
@@ -121,6 +121,8 @@
assertEquals(i, msg.getIntProperty("count").intValue());
}
+ server.stop();
+
}
finally
{
@@ -130,6 +132,4 @@
}
- public void testImport() {
- }
}
14 years, 7 months
JBoss hornetq SVN: r10703 - branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools.
by do-not-reply@jboss.org
Author: jicken
Date: 2011-05-19 17:44:05 -0400 (Thu, 19 May 2011)
New Revision: 10703
Modified:
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
Log:
queue mapping now added in both cases: existing and non-existing queues
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-19 21:27:14 UTC (rev 10702)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-19 21:44:05 UTC (rev 10703)
@@ -514,6 +514,9 @@
if (!queueQuery.isExists()) {
coreSession.createQueue(queue.getAddress(), queue.getName(), queue.getFilterString(), message.isDurable());
queueQuery = coreSession.queueQuery(SimpleString.toSimpleString(queue.getName()));
+ }
+
+ if (!queueMapping.containsKey(queue.getId())) {
queueMapping.put(queue.getId(), queueQuery.getId());
}
}
14 years, 7 months
JBoss hornetq SVN: r10702 - in branches/Branch_2_2_EAP_export_tool: src/main/org/hornetq/api/core/client and 7 other directories.
by do-not-reply@jboss.org
Author: jicken
Date: 2011-05-19 17:27:14 -0400 (Thu, 19 May 2011)
New Revision: 10702
Added:
branches/Branch_2_2_EAP_export_tool/.gitignore
Modified:
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/api/core/client/ClientSession.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/QueueQueryResult.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
Log:
got rid of reading the target journal
queueQuery used to query if the queue exists; if not, then create the queue
the queue query response object now passes the id of the queue as this is needed to map old/new queue ids
Added: branches/Branch_2_2_EAP_export_tool/.gitignore
===================================================================
--- branches/Branch_2_2_EAP_export_tool/.gitignore (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/.gitignore 2011-05-19 21:27:14 UTC (rev 10702)
@@ -0,0 +1,4 @@
+target
+thirdparty
+native
+build
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/api/core/client/ClientSession.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/api/core/client/ClientSession.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/api/core/client/ClientSession.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -57,6 +57,11 @@
public interface QueueQuery
{
/**
+ * @return the ID of the queue.
+ */
+ long getId();
+
+ /**
* Returns <code>true</code> if the queue exists, <code>false</code> else.
*/
boolean isExists();
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -363,7 +363,9 @@
SessionQueueQueryResponseMessage response = (SessionQueueQueryResponseMessage)channel.sendBlocking(request);
- return new QueueQueryImpl(response.isDurable(),
+ return new QueueQueryImpl(response.getId(),
+ response.getName(),
+ response.isDurable(),
response.getConsumerCount(),
response.getMessageCount(),
response.getFilterString(),
@@ -1855,9 +1857,11 @@
private static class QueueQueryImpl implements QueueQuery
{
+ private final long id;
+ private final SimpleString name;
+
private final boolean exists;
-
private final boolean durable;
private final long messageCount;
@@ -1868,14 +1872,17 @@
private final SimpleString address;
- public QueueQueryImpl(final boolean durable,
+ public QueueQueryImpl(final long id,
+ final SimpleString name,
+ final boolean durable,
final int consumerCount,
final long messageCount,
final SimpleString filterString,
final SimpleString address,
final boolean exists)
{
-
+ this.id = id;
+ this.name = name;
this.durable = durable;
this.consumerCount = consumerCount;
this.messageCount = messageCount;
@@ -1884,6 +1891,10 @@
this.exists = exists;
}
+ public long getId() {
+ return id;
+ }
+
public SimpleString getAddress()
{
return address;
@@ -1914,5 +1925,8 @@
return exists;
}
+ public SimpleString getName() {
+ return name;
+ }
}
}
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -105,10 +105,8 @@
* </ul>
* <p/>
*
- * @param exportFile full qualified name of the export file (/path/name.xml)
* @param bindingsDir directory with the bindings journal
* @param messagesDir directory with the messages journal
- * @param backup flag if a backup should be created before modifying the original journal
* @throws Exception if something goes wrong
*/
public static void exportMessages(final String bindingsDir, final String messagesDir, final OutputStream out) throws Exception
@@ -218,24 +216,6 @@
}
- /*
- *
- * private static void addDelRecordsToOriginal(JournalImpl original, Set<Long> recordsToDelete, List<MessageType> messages) throws Exception {
- List<Long> originalDeletes = new ArrayList<Long>(messages.size() / 3);
- for (MessageType message : messages) {
- if (!recordsToDelete.contains(message.getId()) &&
- !originalDeletes.contains(message.getId())) {
- original.appendDeleteRecord(message.getId(), false, DummyOperationContext.getInstance());
- originalDeletes.add(message.getId());
- }
- }
- if (log.isInfoEnabled()) {
- int size = originalDeletes.size();
- log.info("Deleted " + size + " record" + (size > 1 ? "s" : "") + " from original journal!");
- }
- }
- */
-
private static void loadData(Journal original, final List<RecordInfo> records, final Set<Long> recordsToDelete) throws Exception
{
original.start();
@@ -294,7 +274,6 @@
* Method which writes the XML export file to disk.
*
* @param hqJournalExport the root JAXB context
- * @param exportFile the export filename
* @throws java.io.FileNotFoundException if the export file could not be created
* @throws javax.xml.bind.JAXBException if an error occurs during marshalling
*/
@@ -501,18 +480,17 @@
FileInputStream input = new FileInputStream(new File(importFile));
- return importMessages(input, configuration.getBindingsDirectory(), serverLocator);
+ return importMessages(input, serverLocator);
}
public static long importMessages(final InputStream importFile,
- final String bindingsDirectory,
final ServerLocator serverLocator) throws Exception
{
final JAXBContext context = JAXBContext.newInstance(HornetQExport.class);
final Unmarshaller unmarshaller = context.createUnmarshaller();
- final Map<String, Long> queueBindings = loadBindings(bindingsDirectory);
+ final Map<Long, Long> queueMapping = new HashMap<Long, Long>();
ClientSessionFactory sf = null;
@@ -524,9 +502,22 @@
// message notification callback
final MessagesExportType.Listener listener = new MessagesExportType.Listener()
{
- public void handleMessage(MessageType message) throws Exception
- {
+ public void handleMessage(MessageType message) throws Exception {
+ final List<QueueType> originalQueues = message.getAllPreviousBindings().getQueue();
+ final List<QueueRefType> originalBindings = message.getBindings().getQueue();
+ QueueType queue;
+ ClientSession.QueueQuery queueQuery;
+ for (QueueRefType originalBinding : originalBindings) {
+ queue = originalQueues.get(originalQueues.indexOf(new QueueType(originalBinding.getId())));
+ queueQuery = coreSession.queueQuery(SimpleString.toSimpleString(queue.getName()));
+ if (!queueQuery.isExists()) {
+ coreSession.createQueue(queue.getAddress(), queue.getName(), queue.getFilterString(), message.isDurable());
+ queueQuery = coreSession.queueQuery(SimpleString.toSimpleString(queue.getName()));
+ queueMapping.put(queue.getId(), queueQuery.getId());
+ }
+ }
+
ClientProducer producer = coreSession.createProducer(message.getAddress());
ClientMessage clientMessage = generateClientMessage(message);
producer.send(clientMessage);
@@ -553,7 +544,7 @@
{
if (!ackedQueues.contains(new QueueRefType(binding.getId())))
{
- queues.add(queueBindings.get(message.getAddress()));
+ queues.add(queueMapping.get(binding.getId()));
}
}
clientMessage.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, getByteArrayOf(queues));
@@ -615,6 +606,9 @@
if (target instanceof MessagesExportType)
{
((MessagesExportType)target).setMessageListener(listener);
+ if (((MessagesExportType) target).getBindings() == null) {
+ ((MessagesExportType)target).setOriginalBindings(((HornetQExport)parent).getQueues());
+ }
}
}
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -4,6 +4,7 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.hornetq.api.core.SimpleString;
@@ -79,6 +80,9 @@
@XmlAttribute
protected Long id;
+ @XmlTransient
+ private BindingsJournalType allPreviousBindings;
+
public MessageType(ServerMessage msg) {
setId(msg.getMessageID());
@@ -349,4 +353,12 @@
public int hashCode() {
return id.hashCode();
}
+
+ public BindingsJournalType getAllPreviousBindings() {
+ return allPreviousBindings;
+ }
+
+ public void setAllPreviousBindings(BindingsJournalType allPreviousBindings) {
+ this.allPreviousBindings = allPreviousBindings;
+ }
}
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -6,6 +6,7 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
@@ -35,6 +36,9 @@
@XmlElement(namespace = "urn:hornetq")
protected List<MessageType> message;
+ @XmlTransient
+ private BindingsJournalType bindings;
+
/**
* Gets the value of the message property.
* <p/>
@@ -70,6 +74,7 @@
message = (listener == null) ? null : new ArrayList<MessageType>() {
public boolean add(MessageType o) {
try {
+ o.setAllPreviousBindings(getBindings());
listener.handleMessage(o);
} catch (Exception e) {
e.printStackTrace();
@@ -80,6 +85,14 @@
};
}
+ public void setOriginalBindings(final BindingsJournalType bindings) {
+ this.bindings = bindings;
+ }
+
+ public BindingsJournalType getBindings() {
+ return bindings;
+ }
+
/**
* This listener is invoked every time a new message is unmarshalled.
*/
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -46,6 +46,13 @@
@XmlAttribute(required = true)
protected long id;
+ public QueueType() {
+ }
+
+ public QueueType(long id) {
+ this.id = id;
+ }
+
/**
* Gets the value of the name property.
*
@@ -134,4 +141,20 @@
this.id = value;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ QueueType queueType = (QueueType) o;
+
+ if (id != queueType.id) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) (id ^ (id >>> 32));
+ }
}
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -27,6 +27,8 @@
*/
public class SessionQueueQueryResponseMessage extends PacketImpl
{
+ private long id;
+
private SimpleString name;
private boolean exists;
@@ -45,7 +47,7 @@
public SessionQueueQueryResponseMessage(final QueueQueryResult result)
{
- this(result.getName(), result.getAddress(), result.isDurable(), result.isTemporary(),
+ this(result.getId(), result.getName(), result.getAddress(), result.isDurable(), result.isTemporary(),
result.getFilterString(), result.getConsumerCount(), result.getMessageCount(), result.isExists());
}
@@ -54,6 +56,21 @@
this(null, null, false, false, null, 0, 0, false);
}
+ private SessionQueueQueryResponseMessage(final long id,
+ final SimpleString name,
+ final SimpleString address,
+ final boolean durable,
+ final boolean temporary,
+ final SimpleString filterString,
+ final int consumerCount,
+ final long messageCount,
+ final boolean exists)
+ {
+ this(name,address, durable, temporary, filterString, consumerCount, messageCount, exists);
+ this.id = id;
+
+ }
+
private SessionQueueQueryResponseMessage(final SimpleString name,
final SimpleString address,
final boolean durable,
@@ -82,6 +99,10 @@
this.exists = exists;
}
+ public long getId() {
+ return id;
+ }
+
@Override
public boolean isResponse()
{
@@ -139,6 +160,7 @@
buffer.writeNullableSimpleString(filterString);
buffer.writeNullableSimpleString(address);
buffer.writeNullableSimpleString(name);
+ buffer.writeLong(id);
}
@Override
@@ -152,6 +174,7 @@
filterString = buffer.readNullableSimpleString();
address = buffer.readNullableSimpleString();
name = buffer.readNullableSimpleString();
+ id = buffer.readLong();
}
@Override
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/QueueQueryResult.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/QueueQueryResult.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/QueueQueryResult.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -24,6 +24,8 @@
*/
public class QueueQueryResult
{
+ private long id;
+
private SimpleString name;
private boolean exists;
@@ -50,12 +52,37 @@
{
this(name, address, durable, temporary, filterString, consumerCount, messageCount, true);
}
+ public QueueQueryResult(final long id,
+ final SimpleString name,
+ final SimpleString address,
+ final boolean durable,
+ final boolean temporary,
+ final SimpleString filterString,
+ final int consumerCount,
+ final long messageCount)
+ {
+ this(id, name, address, durable, temporary, filterString, consumerCount, messageCount, true);
+ }
public QueueQueryResult()
{
this(null, null, false, false, null, 0, 0, false);
}
+ private QueueQueryResult(final long id,
+ final SimpleString name,
+ final SimpleString address,
+ final boolean durable,
+ final boolean temporary,
+ final SimpleString filterString,
+ final int consumerCount,
+ final long messageCount,
+ final boolean exists)
+ {
+ this(name, address, durable, temporary, filterString, consumerCount, messageCount, exists);
+ this.id = id;
+ }
+
private QueueQueryResult(final SimpleString name,
final SimpleString address,
final boolean durable,
@@ -82,6 +109,10 @@
this.exists = exists;
}
+ public long getId() {
+ return id;
+ }
+
public boolean isExists()
{
return exists;
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -13,8 +13,6 @@
package org.hornetq.core.server.impl;
-import static org.hornetq.api.core.management.NotificationType.CONSUMER_CREATED;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -74,6 +72,7 @@
import org.hornetq.utils.UUID;
import org.hornetq.utils.json.JSONArray;
import org.hornetq.utils.json.JSONObject;
+import static org.hornetq.api.core.management.NotificationType.CONSUMER_CREATED;
/*
* Session implementation
@@ -495,7 +494,8 @@
SimpleString filterString = filter == null ? null : filter.getFilterString();
- response = new QueueQueryResult(name,
+ response = new QueueQueryResult(queue.getID(),
+ name,
binding.getAddress(),
queue.isDurable(),
queue.isTemporary(),
Modified: branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-19 15:00:06 UTC (rev 10701)
+++ branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-19 21:27:14 UTC (rev 10702)
@@ -105,7 +105,7 @@
locator = createInVMNonHALocator();
- ManageDataTool.importMessages(is, getBindingsDir(), locator);
+ ManageDataTool.importMessages(is, locator);
ClientSessionFactory csf = locator.createSessionFactory();
@@ -121,8 +121,6 @@
assertEquals(i, msg.getIntProperty("count").intValue());
}
-
-
}
finally
{
14 years, 7 months
JBoss hornetq SVN: r10700 - branches.
by do-not-reply@jboss.org
Author: borges
Date: 2011-05-19 09:26:07 -0400 (Thu, 19 May 2011)
New Revision: 10700
Added:
branches/HORNETQ-698_SplitJournal/
Log:
Create branch for case HORNETQ-698.
14 years, 7 months
JBoss hornetq SVN: r10699 - in branches/Branch_2_2_EAP_export_tool: src/config/common/schema and 5 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-05-18 22:21:45 -0400 (Wed, 18 May 2011)
New Revision: 10699
Added:
branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
Modified:
branches/Branch_2_2_EAP_export_tool/pom.xml
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
Log:
Branch for import/export tool
Modified: branches/Branch_2_2_EAP_export_tool/pom.xml
===================================================================
--- branches/Branch_2_2_EAP_export_tool/pom.xml 2011-05-19 02:18:50 UTC (rev 10698)
+++ branches/Branch_2_2_EAP_export_tool/pom.xml 2011-05-19 02:21:45 UTC (rev 10699)
@@ -319,6 +319,11 @@
<artifactId>spring-jms</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
</dependencies>
Added: branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/config/common/schema/hornetq-export.xsd 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:hornetq"
+ xmlns="urn:hornetq"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:element name="hq-journal-export">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element type="bindings-journalType" name="queues" maxOccurs="1"/>
+ <xsd:element type="messages-journalType" name="messages" maxOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="bindings-journalType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="messages-journalType">
+ <xsd:sequence>
+ <xsd:element type="messageType" name="message" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- bindings -->
+
+ <xsd:complexType name="bindingsType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueType">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="address" type="xsd:string"/>
+ <xsd:element name="filterString" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id" use="required"/>
+ </xsd:complexType>
+
+ <!-- journal -->
+
+ <xsd:complexType name="messageType">
+ <xsd:sequence>
+ <xsd:element type="xsd:string" name="address"/>
+ <xsd:element type="xsd:byte" name="type">
+ <xsd:annotation>
+ <xsd:documentation>see interface Message</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:boolean" name="durable"/>
+ <xsd:element type="xsd:long" name="expiration"/>
+ <xsd:element type="xsd:long" name="timestamp"/>
+ <xsd:element type="propertiesType" name="properties"/>
+ <xsd:element type="xsd:byte" name="priority"/>
+ <xsd:element type="xsd:string" name="payload">
+ <xsd:annotation>
+ <xsd:documentation>ref to byte array in <msgId> directory</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:string" name="userId"/>
+ <xsd:element type="bindType" name="bindings"/>
+ <xsd:element type="ackType" name="acks"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertiesType">
+ <xsd:sequence>
+ <xsd:element type="propertyType" name="property" maxOccurs="unbounded" minOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute type="xsd:string" name="key" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="bindType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="ackType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueRefType">
+ <xsd:attribute name="id" type="xsd:long"/>
+ </xsd:complexType>
+</xsd:schema>
\ No newline at end of file
Modified: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-05-19 02:18:50 UTC (rev 10698)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -53,7 +53,6 @@
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.journal.TransactionFailureCallback;
import org.hornetq.core.journal.impl.AIOSequentialFileFactory;
-import org.hornetq.core.journal.impl.ExportJournal;
import org.hornetq.core.journal.impl.JournalFile;
import org.hornetq.core.journal.impl.JournalImpl;
import org.hornetq.core.journal.impl.JournalReaderCallback;
@@ -108,6 +107,7 @@
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
* @author <a href="jmesnil(a)redhat.com">Jeff Mesnil</a>
+ * @author <a href="torben(a)redhat.com">Torben Jaeger</a>
*
*/
public class JournalStorageManager implements StorageManager
@@ -199,6 +199,7 @@
private final Map<SimpleString, PersistedAddressSetting> mapPersistedAddressSettings = new ConcurrentHashMap<SimpleString, PersistedAddressSetting>();
+
public JournalStorageManager(final Configuration config, final ExecutorFactory executorFactory)
{
this(config, executorFactory, null);
@@ -2169,7 +2170,7 @@
}
}
- private static class PersistentQueueBindingEncoding implements EncodingSupport, QueueBindingInfo
+ protected static class PersistentQueueBindingEncoding implements EncodingSupport, QueueBindingInfo
{
long id;
@@ -2337,7 +2338,7 @@
private static class QueueEncoding implements EncodingSupport
{
- long queueID;
+ public long queueID;
public QueueEncoding(final long queueID)
{
@@ -2389,7 +2390,7 @@
}
}
- private static class RefEncoding extends QueueEncoding
+ protected static class RefEncoding extends QueueEncoding
{
public RefEncoding()
{
@@ -2839,7 +2840,7 @@
// Encoding functions for binding Journal
- private static Object newObjectEncoding(RecordInfo info)
+ protected static Object newObjectEncoding(RecordInfo info)
{
HornetQBuffer buffer = HornetQBuffers.wrappedBuffer(info.data);
long id = info.id;
@@ -2981,9 +2982,9 @@
}
}
- private static class ReferenceDescribe
+ protected static class ReferenceDescribe
{
- RefEncoding refEncoding;
+ public RefEncoding refEncoding;
public ReferenceDescribe(RefEncoding refEncoding)
{
@@ -2997,9 +2998,9 @@
}
- private static class AckDescribe
+ protected static class AckDescribe
{
- RefEncoding refEncoding;
+ public RefEncoding refEncoding;
public AckDescribe(RefEncoding refEncoding)
{
@@ -3013,14 +3014,14 @@
}
- private static class MessageDescribe
+ protected static class MessageDescribe
{
public MessageDescribe(Message msg)
{
this.msg = msg;
}
- Message msg;
+ public Message msg;
public String toString()
{
@@ -3322,5 +3323,4 @@
journal.stop();
}
-
}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ExportData.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.tools;
+
+/**
+ * A ExportData
+ *
+ * @author clebertsuconic
+ *
+ *
+ */
+public class ExportData
+{
+
+ public static void main(String args[])
+ {
+ if (args.length != 4) {
+ System.out.println("Usage Export: java org.hornetq.core.persistence.tools.ExportData <bindings-journal-dir> <messages-journal-dir>");
+ System.exit(-1);
+ }
+ try
+ {
+ ManageDataTool.exportMessages(args[0], args[1], System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ }
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ImportData.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.tools;
+
+/**
+ * A ImportData
+ *
+ * @author clebertsuconic
+ *
+ *
+ */
+public class ImportData
+{
+
+ public static void main(String args[])
+ {
+ if (args.length != 3) {
+ System.out.println("Usage Export: java org.hornetq.core.persistence.tools.ImportData <import-file-name> <hq-config-file> <connector-name>");
+ System.exit(-1);
+ }
+ try
+ {
+ ManageDataTool.importMessages(args[0], args[1], args[2]);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,694 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.tools;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.config.impl.FileConfiguration;
+import org.hornetq.core.journal.Journal;
+import org.hornetq.core.journal.LoaderCallback;
+import org.hornetq.core.journal.PreparedTransactionInfo;
+import org.hornetq.core.journal.RecordInfo;
+import org.hornetq.core.journal.SequentialFileFactory;
+import org.hornetq.core.journal.impl.JournalImpl;
+import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.impl.MessageImpl;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
+import org.hornetq.core.persistence.tools.xmlmodel.BindingsJournalType;
+import org.hornetq.core.persistence.tools.xmlmodel.HornetQExport;
+import org.hornetq.core.persistence.tools.xmlmodel.MessageType;
+import org.hornetq.core.persistence.tools.xmlmodel.MessagesExportType;
+import org.hornetq.core.persistence.tools.xmlmodel.PropertyType;
+import org.hornetq.core.persistence.tools.xmlmodel.QueueRefType;
+import org.hornetq.core.persistence.tools.xmlmodel.QueueType;
+import org.hornetq.core.server.ServerMessage;
+import org.hornetq.utils.Base64;
+import org.hornetq.utils.ExecutorFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * @author <a href="mailto:torben@redhat.com">Torben Jaeger</a>
+ */
+public class ManageDataTool extends JournalStorageManager
+{
+ private static final Logger log = Logger.getLogger(ManageDataTool.class);
+
+ private static long messageCounter = 0;
+
+ private ManageDataTool(final Configuration config, final ExecutorFactory executorFactory)
+ {
+ super(config, executorFactory);
+ }
+
+ /**
+ * Method which will export the binary HQ journal to a XML representation of messages and bindings.
+ * <p/>
+ * Some rules to keep in mind:
+ * <ul>
+ * <li> not all records of the journals are exported (no 1-to-1 copy); see exporting rules below.
+ * <li> the binary journal should not be started/loaded
+ * </ul>
+ * <p/>
+ * Rules for exporting:
+ * <ul>
+ * <li> ADD records are exported
+ * <li> REF records are exported
+ * <li> records with ACKs are <b>not</b> exported coz the messages have already been delivered
+ * <li> records which are part of a prepared TX are <b>not</b> exported due to recovery
+ * <li> records which are part of failed TX are <b>not</b> exported due to recovery
+ * <li> records with a delete request are <b>not</b> exported coz the messages have already been delivered
+ * <li> records with internal message headers (like routing) are <b>not</b> exported
+ * </ul>
+ * <p/>
+ *
+ * @param exportFile full qualified name of the export file (/path/name.xml)
+ * @param bindingsDir directory with the bindings journal
+ * @param messagesDir directory with the messages journal
+ * @param backup flag if a backup should be created before modifying the original journal
+ * @throws Exception if something goes wrong
+ */
+ public static void exportMessages(final String bindingsDir, final String messagesDir, final OutputStream out) throws Exception
+ {
+
+ // Will use only default values. The load function should adapt to anything different
+ ConfigurationImpl defaultValues = new ConfigurationImpl();
+ defaultValues.setJournalDirectory(messagesDir);
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Generating backup of original journal ...");
+ }
+
+ SequentialFileFactory messagesFF = new NIOSequentialFileFactory(messagesDir);
+ JournalImpl messagesJournal = new JournalImpl(defaultValues.getJournalFileSize(),
+ defaultValues.getJournalMinFiles(),
+ 0,
+ 0,
+ messagesFF,
+ "hornetq-data",
+ "hq",
+ 1);
+
+ SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir);
+ JournalImpl bindingsJournal = new JournalImpl(1024 * 1024,
+ 2,
+ -1,
+ 0,
+ bindingsFF,
+ "hornetq-bindings",
+ "bindings",
+ 1);
+
+ HornetQExport hqJournalExport = new HornetQExport();
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Exporting bindings ...");
+ }
+ hqJournalExport.setQueues(exportBindings(bindingsJournal));
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Exporting journal ...");
+ }
+ hqJournalExport.setMessages(exportMessages(messagesJournal));
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Writing export file ...");
+ }
+ writeExportToFile(hqJournalExport, out);
+
+ if (log.isInfoEnabled())
+ {
+ log.info("Export done!");
+ }
+ }
+
+ private static BindingsJournalType exportBindings(JournalImpl original) throws Exception
+ {
+ try
+ {
+ final List<RecordInfo> records = new LinkedList<RecordInfo>();
+ final Set<Long> recordsToDelete = new HashSet<Long>();
+
+ loadData(original, records, recordsToDelete);
+
+ return buildXmlBindings(records);
+
+ }
+ finally
+ {
+ original.stop();
+ }
+ }
+
+ /**
+ * Method to load the journal and prepare the record lists/sets to work on.
+ *
+ * @param original the journal to export
+ * @return an XML representation of the journal
+ * @throws Exception if the journal is corrupt
+ */
+ private static MessagesExportType exportMessages(JournalImpl original) throws Exception
+ {
+
+ try
+ {
+ final List<RecordInfo> records = new LinkedList<RecordInfo>();
+ final Set<Long> recordsToDelete = new HashSet<Long>();
+
+ loadData(original, records, recordsToDelete);
+
+ MessagesExportType journal = buildXmlMessages(records, recordsToDelete);
+
+ // addDelRecordsToOriginal(original, recordsToDelete, journal.getMessage());
+
+ return journal;
+
+ }
+ finally
+ {
+ original.stop();
+ }
+
+ }
+
+ /*
+ *
+ * private static void addDelRecordsToOriginal(JournalImpl original, Set<Long> recordsToDelete, List<MessageType> messages) throws Exception {
+ List<Long> originalDeletes = new ArrayList<Long>(messages.size() / 3);
+ for (MessageType message : messages) {
+ if (!recordsToDelete.contains(message.getId()) &&
+ !originalDeletes.contains(message.getId())) {
+ original.appendDeleteRecord(message.getId(), false, DummyOperationContext.getInstance());
+ originalDeletes.add(message.getId());
+ }
+ }
+ if (log.isInfoEnabled()) {
+ int size = originalDeletes.size();
+ log.info("Deleted " + size + " record" + (size > 1 ? "s" : "") + " from original journal!");
+ }
+ }
+ */
+
+ private static void loadData(Journal original, final List<RecordInfo> records, final Set<Long> recordsToDelete) throws Exception
+ {
+ original.start();
+
+ original.load(new LoaderCallback()
+ {
+ private void logNotExportedRecord(long id, String reason)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Record " + id + " will not be exported due to " + reason + "!");
+ }
+ }
+
+ private void addToNotExportedRecords(List<RecordInfo> list, String reason)
+ {
+ for (RecordInfo record : list)
+ {
+ logNotExportedRecord(record.id, reason);
+ recordsToDelete.add(record.id);
+ }
+ }
+
+ public void addPreparedTransaction(PreparedTransactionInfo preparedTransaction)
+ {
+ addToNotExportedRecords(preparedTransaction.records, "prepared TX");
+ addToNotExportedRecords(preparedTransaction.recordsToDelete, "prepared TX");
+ }
+
+ public void addRecord(RecordInfo info)
+ {
+ records.add(info);
+ }
+
+ public void deleteRecord(long id)
+ {
+ logNotExportedRecord(id, "DEL");
+ recordsToDelete.add(id);
+ }
+
+ public void updateRecord(RecordInfo info)
+ {
+ records.add(info);
+ }
+
+ public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> _recordsToDelete)
+ {
+ addToNotExportedRecords(records, "failed TX");
+ addToNotExportedRecords(_recordsToDelete, "failed TX");
+ }
+
+ });
+ }
+
+ /**
+ * Method which writes the XML export file to disk.
+ *
+ * @param hqJournalExport the root JAXB context
+ * @param exportFile the export filename
+ * @throws java.io.FileNotFoundException if the export file could not be created
+ * @throws javax.xml.bind.JAXBException if an error occurs during marshalling
+ */
+ private static void writeExportToFile(HornetQExport hqJournalExport, OutputStream os) throws JAXBException,
+ FileNotFoundException
+ {
+
+ // todo: http://jaxb.java.net/guide/Different_ways_of_marshalling.html#Marshalling...
+
+ JAXBContext jc = JAXBContext.newInstance(HornetQExport.class);
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ m.marshal(hqJournalExport, os);
+ }
+
+ /**
+ * Method which creates the JAXB representation of the XML export file.
+ *
+ * @param records the records to process
+ * @param recordsToDelete records which are @see DeleteRecord
+ * @return @see BindingsJournalType or @see MessagesJournalType
+ */
+ private static MessagesExportType buildXmlMessages(List<RecordInfo> records, Set<Long> recordsToDelete)
+ {
+
+ MessagesExportType journalType = new MessagesExportType();
+
+ // Export Journal
+ for (RecordInfo info : records)
+ {
+
+ if (recordsToDelete.contains(info.id))
+ {
+ // deleted records are not exported
+ continue;
+ }
+
+ switch (info.getUserRecordType())
+ {
+
+ case JournalStorageManager.ADD_MESSAGE:
+ handleAddMessage(journalType, info);
+ break;
+
+ case JournalStorageManager.ADD_REF:
+ handleAddRef(journalType, info);
+ break;
+
+ case JournalStorageManager.ACKNOWLEDGE_REF:
+ handleAckRef(journalType, info);
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug(new StringBuilder().append("Record ")
+ .append(info.id)
+ .append(" is not exported!")
+ .toString());
+ }
+ break;
+ }
+ }
+
+ return journalType;
+ }
+
+ private static void handleAddMessage(MessagesExportType journalType, RecordInfo info)
+ {
+ JournalStorageManager.MessageDescribe message = (JournalStorageManager.MessageDescribe)JournalStorageManager.newObjectEncoding(info);
+
+ MessageType messageType = new MessageType((ServerMessage)message.msg);
+
+ byte[] data = info.data;
+ messageType.setPayload(Base64.encodeBytes(data, 0, data.length, Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
+
+ journalType.getMessage().add(messageType);
+ }
+
+ private static void handleAddRef(MessagesExportType journalType, RecordInfo info)
+ {
+ JournalStorageManager.ReferenceDescribe ref = (JournalStorageManager.ReferenceDescribe)JournalStorageManager.newObjectEncoding(info);
+
+ MessageType message = getMessage(journalType, info);
+
+ if (message == null)
+ {
+ throw new IllegalStateException("Journal is corrupt: AddRef without Add!");
+ }
+
+ QueueRefType queueRef = new QueueRefType();
+ queueRef.setId(ref.refEncoding.queueID);
+
+ message.getBindings().getQueue().add(queueRef);
+
+ }
+
+ private static MessageType getMessage(MessagesExportType journalType, RecordInfo info)
+ {
+ List<MessageType> messages = journalType.getMessage();
+ return messages.get(messages.indexOf(new MessageType(info.id)));
+ }
+
+ private static void handleAckRef(MessagesExportType journalType, RecordInfo info)
+ {
+ JournalStorageManager.AckDescribe ack = (JournalStorageManager.AckDescribe)JournalStorageManager.newObjectEncoding(info);
+
+ MessageType message = getMessage(journalType, info);
+
+ if (message == null)
+ {
+ throw new IllegalStateException("Journal is corrupt: Ack without Add!");
+ }
+
+ QueueRefType queueRef = new QueueRefType();
+ queueRef.setId(ack.refEncoding.queueID);
+
+ message.getAcks().getQueue().add(queueRef);
+
+ }
+
+ private static BindingsJournalType buildXmlBindings(List<RecordInfo> records)
+ {
+
+ BindingsJournalType journalType = new BindingsJournalType();
+
+ // Export Journal
+ for (RecordInfo info : records)
+ {
+
+ switch (info.getUserRecordType())
+ {
+
+ case JournalStorageManager.QUEUE_BINDING_RECORD:
+ handleQBindingRecord(journalType, info);
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug(new StringBuilder().append("Record ")
+ .append(info.id)
+ .append(" is not exported!")
+ .toString());
+ }
+ break;
+
+ }
+
+ }
+
+ return journalType;
+ }
+
+ private static void handleQBindingRecord(BindingsJournalType journalType, RecordInfo info)
+ {
+ JournalStorageManager.PersistentQueueBindingEncoding persistentQueueBindingEncoding = JournalStorageManager.newBindingEncoding(info.id,
+ HornetQBuffers.wrappedBuffer(info.data));
+
+ QueueType queueType = new QueueType();
+ queueType.setId(persistentQueueBindingEncoding.getId());
+
+ SimpleString queueName = persistentQueueBindingEncoding.getQueueName();
+ queueType.setName(queueName != null ? queueName.toString() : "");
+ SimpleString address = persistentQueueBindingEncoding.getAddress();
+ queueType.setAddress(address != null ? address.toString() : "");
+ SimpleString filterString = persistentQueueBindingEncoding.getFilterString();
+ queueType.setFilterString(filterString != null ? filterString.toString() : "");
+
+ journalType.getQueue().add(queueType);
+ }
+
+ /**
+ * Imports messages which were exported as a XML representation using @see #exportMessages(String,String,String).
+ *
+ * This is done by starting an embedded HQ server which connects the queues transparently.
+ *
+ * @param importFile full qualified name of the import file (/path/file)
+ * @param configurationFile the configuration URL of a running HQ server
+ * @param connectorName the name of the connector used to connect to the HQ server
+ * @return the number of imported records
+ * @throws Exception if an error occurs while importing
+ */
+ public static long importMessages(final String importFile, final String configurationFile, final String connectorName) throws Exception
+ {
+ FileConfiguration configuration = null;
+ try
+ {
+ configuration = new FileConfiguration();
+ configuration.setConfigurationUrl(configurationFile);
+ configuration.start();
+ }
+ finally
+ {
+ if (configuration != null)
+ {
+ configuration.stop();
+ }
+ }
+
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(configuration.getConnectorConfigurations()
+ .get(connectorName));
+
+ FileInputStream input = new FileInputStream(new File(importFile));
+
+ return importMessages(input, configuration.getBindingsDirectory(), serverLocator);
+ }
+
+ public static long importMessages(final InputStream importFile,
+ final String bindingsDirectory,
+ final ServerLocator serverLocator) throws Exception
+ {
+ final JAXBContext context = JAXBContext.newInstance(HornetQExport.class);
+
+ final Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ final Map<String, Long> queueBindings = loadBindings(bindingsDirectory);
+
+ ClientSessionFactory sf = null;
+
+ try
+ {
+ sf = serverLocator.createSessionFactory();
+ final ClientSession coreSession = sf.createSession();
+
+ // message notification callback
+ final MessagesExportType.Listener listener = new MessagesExportType.Listener()
+ {
+ public void handleMessage(MessageType message) throws Exception
+ {
+
+ ClientProducer producer = coreSession.createProducer(message.getAddress());
+ ClientMessage clientMessage = generateClientMessage(message);
+ producer.send(clientMessage);
+ producer.close();
+ }
+
+ private ClientMessage generateClientMessage(MessageType message) throws IOException
+ {
+ ClientMessage clientMessage = coreSession.createMessage(message.getType(),
+ message.isDurable(),
+ message.getExpiration(),
+ message.getTimestamp(),
+ message.getPriority());
+ List<QueueRefType> bindings = message.getBindings().getQueue();
+ List<QueueRefType> ackedQueues = message.getAcks().getQueue();
+ List<Long> queues = new ArrayList<Long>(bindings.size());
+
+ // Adress
+ clientMessage.setAddress(new SimpleString(message.getAddress()));
+
+ // Routing
+ // only map Q if not already ACKed
+ for (QueueRefType binding : bindings)
+ {
+ if (!ackedQueues.contains(new QueueRefType(binding.getId())))
+ {
+ queues.add(queueBindings.get(message.getAddress()));
+ }
+ }
+ clientMessage.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, getByteArrayOf(queues));
+
+ // Properties
+ List<PropertyType> properties = message.getProperties().getProperty();
+ for (PropertyType property : properties)
+ {
+ clientMessage.putStringProperty(property.getKey(), property.getValue());
+ }
+
+ // Payload
+ HornetQBuffer buffer = clientMessage.getBodyBuffer();
+ buffer.writeBytes(Base64.decode(message.getPayload(), Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
+
+ // UserID
+ // todo: need to set?
+
+ return clientMessage;
+ }
+
+ private byte[] getByteArrayOf(List<Long> queues) throws IOException
+ {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(bos);
+ try
+ {
+ for (long id : queues)
+ {
+ dos.writeLong(id);
+ }
+ dos.flush();
+ }
+ finally
+ {
+ try
+ {
+ dos.close();
+ bos.close();
+ }
+ catch (IOException e)
+ {
+ // could not close streams
+ }
+ }
+
+ return bos.toByteArray();
+ }
+
+ };
+
+ messageCounter = 0;
+
+ // install the callback on all message instances
+ unmarshaller.setListener(new Unmarshaller.Listener()
+ {
+ public void beforeUnmarshal(Object target, Object parent)
+ {
+ if (target instanceof MessagesExportType)
+ {
+ ((MessagesExportType)target).setMessageListener(listener);
+ }
+ }
+
+ public void afterUnmarshal(Object target, Object parent)
+ {
+ if (target instanceof MessagesExportType)
+ {
+ ((MessagesExportType)target).setMessageListener(null);
+ messageCounter++;
+ }
+ }
+ });
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ XMLReader reader = factory.newSAXParser().getXMLReader();
+ reader.setContentHandler(unmarshaller.getUnmarshallerHandler());
+
+ reader.parse(new InputSource(importFile));
+ }
+ finally
+ {
+ if (sf != null)
+ {
+ sf.close();
+ }
+ }
+
+ return messageCounter;
+ }
+
+ private static Map<String, Long> loadBindings(final String bindingsDirectry) throws Exception
+ {
+ final Map<String, Long> queueMapping;
+
+ JournalImpl bindingsJournal = null;
+ try
+ {
+
+ SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDirectry);
+ bindingsJournal = new JournalImpl(FileConfiguration.DEFAULT_JOURNAL_FILE_SIZE,
+ FileConfiguration.DEFAULT_JOURNAL_MIN_FILES,
+ 0,
+ 0,
+ bindingsFF,
+ "hornetq-bindings",
+ "bindings",
+ 1);
+
+ bindingsJournal.start();
+ List<RecordInfo> committedRecordsB = new ArrayList<RecordInfo>();
+ List<PreparedTransactionInfo> preparedTxnB = new ArrayList<PreparedTransactionInfo>();
+ bindingsJournal.load(committedRecordsB, preparedTxnB, null, false);
+
+ queueMapping = new HashMap<String, Long>();
+
+ for (RecordInfo bindingRecord : committedRecordsB)
+ {
+ if (bindingRecord.getUserRecordType() == JournalStorageManager.QUEUE_BINDING_RECORD)
+ {
+ // mapping old/new queue binding
+ PersistentQueueBindingEncoding queueBinding = JournalStorageManager.newBindingEncoding(bindingRecord.id,
+ HornetQBuffers.wrappedBuffer(bindingRecord.data));
+ queueMapping.put(queueBinding.getAddress().toString(), queueBinding.getId());
+ }
+ }
+ }
+ finally
+ {
+ if (bindingsJournal != null)
+ {
+ bindingsJournal.stop();
+ }
+ }
+ return queueMapping;
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/hornetq-export.xsd 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:hornetq"
+ xmlns="urn:hornetq"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:element name="hq-journal-export">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element type="bindings-journalType" name="queues" maxOccurs="1"/>
+ <xsd:element type="messages-journalType" name="messages" maxOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="bindings-journalType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="messages-journalType">
+ <xsd:sequence>
+ <xsd:element type="messageType" name="message" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- bindings -->
+
+ <xsd:complexType name="bindingsType">
+ <xsd:sequence>
+ <xsd:element type="queueType" name="queue"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueType">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="address" type="xsd:string"/>
+ <xsd:element name="filterString" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id" use="required"/>
+ </xsd:complexType>
+
+ <!-- journal -->
+
+ <xsd:complexType name="messageType">
+ <xsd:sequence>
+ <xsd:element type="xsd:string" name="address"/>
+ <xsd:element type="xsd:byte" name="type">
+ <xsd:annotation>
+ <xsd:documentation>see interface Message</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:boolean" name="durable"/>
+ <xsd:element type="xsd:long" name="expiration"/>
+ <xsd:element type="xsd:long" name="timestamp"/>
+ <xsd:element type="propertiesType" name="properties"/>
+ <xsd:element type="xsd:byte" name="priority"/>
+ <xsd:element type="xsd:string" name="payload">
+ <xsd:annotation>
+ <xsd:documentation>ref to byte array in <msgId> directory</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element type="xsd:string" name="userId"/>
+ <xsd:element type="bindType" name="bindings"/>
+ <xsd:element type="ackType" name="acks"/>
+ </xsd:sequence>
+ <xsd:attribute type="xsd:long" name="id"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertiesType">
+ <xsd:sequence>
+ <xsd:element type="propertyType" name="property" maxOccurs="unbounded" minOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute type="xsd:string" name="key" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="bindType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="ackType">
+ <xsd:sequence>
+ <xsd:element name="queue" type="queueRefType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="queueRefType">
+ <xsd:attribute name="id" type="xsd:long"/>
+ </xsd:complexType>
+</xsd:schema>
\ No newline at end of file
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/AckType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ackType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ackType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueRefType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ackType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class AckType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<QueueRefType> queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the queue property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getQueue().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link QueueRefType }
+ *
+ *
+ */
+ public List<QueueRefType> getQueue() {
+ if (queue == null) {
+ queue = new ArrayList<QueueRefType>();
+ }
+ return this.queue;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for bindType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="bindType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueRefType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "bindType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class BindType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<QueueRefType> queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the queue property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getQueue().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link QueueRefType }
+ *
+ *
+ */
+ public List<QueueRefType> getQueue() {
+ if (queue == null) {
+ queue = new ArrayList<QueueRefType>();
+ }
+ return this.queue;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsJournalType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for bindings-journalType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="bindings-journalType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "bindings-journalType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class BindingsJournalType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<QueueType> queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the queue property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getQueue().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link QueueType }
+ *
+ *
+ */
+ public List<QueueType> getQueue() {
+ if (queue == null) {
+ queue = new ArrayList<QueueType>();
+ }
+ return this.queue;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/BindingsType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,61 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for bindingsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="bindingsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queue" type="{urn:hornetq}queueType"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "bindingsType", namespace = "urn:hornetq", propOrder = {
+ "queue"
+})
+public class BindingsType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected QueueType queue;
+
+ /**
+ * Gets the value of the queue property.
+ *
+ * @return
+ * possible object is
+ * {@link QueueType }
+ *
+ */
+ public QueueType getQueue() {
+ return queue;
+ }
+
+ /**
+ * Sets the value of the queue property.
+ *
+ * @param value
+ * allowed object is
+ * {@link QueueType }
+ *
+ */
+ public void setQueue(QueueType value) {
+ this.queue = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/HornetQExport.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,91 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="queues" type="{urn:hornetq}bindings-journalType"/>
+ * <element name="messages" type="{urn:hornetq}messages-journalType"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "queues",
+ "messages"
+})
+@XmlRootElement(name = "hq-journal-export", namespace = "urn:hornetq")
+public class HornetQExport {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected BindingsJournalType queues;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected MessagesExportType messages;
+
+ /**
+ * Gets the value of the queues property.
+ *
+ * @return
+ * possible object is
+ * {@link BindingsJournalType }
+ *
+ */
+ public BindingsJournalType getQueues() {
+ return queues;
+ }
+
+ /**
+ * Sets the value of the queues property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BindingsJournalType }
+ *
+ */
+ public void setQueues(BindingsJournalType value) {
+ this.queues = value;
+ }
+
+ /**
+ * Gets the value of the messages property.
+ *
+ * @return
+ * possible object is
+ * {@link MessagesExportType }
+ *
+ */
+ public MessagesExportType getMessages() {
+ return messages;
+ }
+
+ /**
+ * Sets the value of the messages property.
+ *
+ * @param value
+ * allowed object is
+ * {@link MessagesExportType }
+ *
+ */
+ public void setMessages(MessagesExportType value) {
+ this.messages = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessageType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,352 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.server.ServerMessage;
+
+
+/**
+ * <p>Java class for messageType complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType name="messageType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="address" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="type" type="{http://www.w3.org/2001/XMLSchema}byte"/>
+ * <element name="durable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ * <element name="expiration" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ * <element name="timestamp" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ * <element name="properties" type="{urn:hornetq}propertiesType"/>
+ * <element name="priority" type="{http://www.w3.org/2001/XMLSchema}byte"/>
+ * <element name="payload" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="userId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="bindings" type="{urn:hornetq}bindType"/>
+ * <element name="acks" type="{urn:hornetq}ackType"/>
+ * </sequence>
+ * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "messageType", namespace = "urn:hornetq", propOrder = {
+ "address",
+ "type",
+ "durable",
+ "expiration",
+ "timestamp",
+ "properties",
+ "priority",
+ "payload",
+ "userId",
+ "bindings",
+ "acks"
+})
+public class MessageType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String address;
+ @XmlElement(namespace = "urn:hornetq")
+ protected byte type;
+ @XmlElement(namespace = "urn:hornetq")
+ protected boolean durable;
+ @XmlElement(namespace = "urn:hornetq")
+ protected long expiration;
+ @XmlElement(namespace = "urn:hornetq")
+ protected long timestamp;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected PropertiesType properties;
+ @XmlElement(namespace = "urn:hornetq")
+ protected byte priority;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String payload;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String userId;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected BindType bindings = new BindType();
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected AckType acks = new AckType();
+ @XmlAttribute
+ protected Long id;
+
+ public MessageType(ServerMessage msg) {
+ setId(msg.getMessageID());
+
+ setAddress(msg.getAddress() != null ? msg.getAddress().toString() : "");
+
+ setType(msg.getType());
+ setDurable(msg.isDurable());
+ setExpiration(msg.getExpiration());
+ setTimestamp(msg.getTimestamp());
+
+ PropertiesType properties = new PropertiesType();
+ for (SimpleString propName : msg.getPropertyNames()) {
+ PropertyType propertyType = new PropertyType();
+ propertyType.setKey(propName.toString());
+ propertyType.setValue(msg.getSimpleStringProperty(propName).toString());
+ properties.getProperty().add(propertyType);
+ }
+ setProperties(properties);
+ setPriority(msg.getPriority());
+ if (msg.getUserID() != null)
+ {
+ setUserId(msg.getUserID().toString());
+ }
+ else
+ {
+ setUserId("");
+ }
+ }
+
+ /**
+ * Ctor for equals.
+ *
+ * @param id the messageID
+ */
+ public MessageType(long id) {
+ setId(id);
+ }
+
+ /**
+ * Default Ctor.
+ */
+ public MessageType() {
+ }
+
+ /**
+ * Gets the value of the address property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * Sets the value of the address property.
+ *
+ * @param value allowed object is
+ * {@link String }
+ */
+ public void setAddress(String value) {
+ this.address = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ */
+ public byte getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ */
+ public void setType(byte value) {
+ this.type = value;
+ }
+
+ /**
+ * Gets the value of the durable property.
+ */
+ public boolean isDurable() {
+ return durable;
+ }
+
+ /**
+ * Sets the value of the durable property.
+ */
+ public void setDurable(boolean value) {
+ this.durable = value;
+ }
+
+ /**
+ * Gets the value of the expiration property.
+ */
+ public long getExpiration() {
+ return expiration;
+ }
+
+ /**
+ * Sets the value of the expiration property.
+ */
+ public void setExpiration(long value) {
+ this.expiration = value;
+ }
+
+ /**
+ * Gets the value of the timestamp property.
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Sets the value of the timestamp property.
+ */
+ public void setTimestamp(long value) {
+ this.timestamp = value;
+ }
+
+ /**
+ * Gets the value of the properties property.
+ *
+ * @return possible object is
+ * {@link PropertiesType }
+ */
+ public PropertiesType getProperties() {
+ return properties;
+ }
+
+ /**
+ * Sets the value of the properties property.
+ *
+ * @param value allowed object is
+ * {@link PropertiesType }
+ */
+ public void setProperties(PropertiesType value) {
+ this.properties = value;
+ }
+
+ /**
+ * Gets the value of the priority property.
+ */
+ public byte getPriority() {
+ return priority;
+ }
+
+ /**
+ * Sets the value of the priority property.
+ */
+ public void setPriority(byte value) {
+ this.priority = value;
+ }
+
+ /**
+ * Gets the value of the payload property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getPayload() {
+ return payload;
+ }
+
+ /**
+ * Sets the value of the payload property.
+ *
+ * @param value allowed object is
+ * {@link String }
+ */
+ public void setPayload(String value) {
+ this.payload = value;
+ }
+
+ /**
+ * Gets the value of the userId property.
+ *
+ * @return possible object is
+ * {@link String }
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * Sets the value of the userId property.
+ *
+ * @param value allowed object is
+ * {@link String }
+ */
+ public void setUserId(String value) {
+ this.userId = value;
+ }
+
+ /**
+ * Gets the value of the bindings property.
+ *
+ * @return possible object is
+ * {@link BindType }
+ */
+ public BindType getBindings() {
+ return bindings;
+ }
+
+ /**
+ * Sets the value of the bindings property.
+ *
+ * @param value allowed object is
+ * {@link BindType }
+ */
+ public void setBindings(BindType value) {
+ this.bindings = value;
+ }
+
+ /**
+ * Gets the value of the acks property.
+ *
+ * @return possible object is
+ * {@link AckType }
+ */
+ public AckType getAcks() {
+ return acks;
+ }
+
+ /**
+ * Sets the value of the acks property.
+ *
+ * @param value allowed object is
+ * {@link AckType }
+ */
+ public void setAcks(AckType value) {
+ this.acks = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return possible object is
+ * {@link Long }
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value allowed object is
+ * {@link Long }
+ */
+ public void setId(Long value) {
+ this.id = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ MessageType that = (MessageType) o;
+
+ if (!id.equals(that.id)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/MessagesExportType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,89 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for messages-journalType complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType name="messages-journalType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="message" type="{urn:hornetq}messageType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "messages-journalType", namespace = "urn:hornetq", propOrder = {
+ "message"
+})
+public class MessagesExportType {
+
+ @XmlElement(namespace = "urn:hornetq")
+ protected List<MessageType> message;
+
+ /**
+ * Gets the value of the message property.
+ * <p/>
+ * <p/>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the message property.
+ * <p/>
+ * <p/>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getMessage().add(newItem);
+ * </pre>
+ * <p/>
+ * <p/>
+ * <p/>
+ * Objects of the following type(s) are allowed in the list
+ * {@link MessageType }
+ */
+ public List<MessageType> getMessage() {
+ if (message == null) {
+ message = new ArrayList<MessageType>();
+ }
+ return this.message;
+ }
+
+ /**
+ * Install a listener for messages on this object. If listener is null, the listener
+ * is removed again.
+ */
+ public void setMessageListener(final Listener listener) {
+ message = (listener == null) ? null : new ArrayList<MessageType>() {
+ public boolean add(MessageType o) {
+ try {
+ listener.handleMessage(o);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("Could not handle message " + o);
+ }
+ return false;
+ }
+ };
+ }
+
+ /**
+ * This listener is invoked every time a new message is unmarshalled.
+ */
+ public static interface Listener {
+ void handleMessage(MessageType message) throws Exception;
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/ObjectFactory.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,119 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.hornetq.core.journal.export package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.hornetq.core.journal.export
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link BindType }
+ *
+ */
+ public BindType createBindType() {
+ return new BindType();
+ }
+
+ /**
+ * Create an instance of {@link HornetQExport }
+ *
+ */
+ public HornetQExport createHqJournalExport() {
+ return new HornetQExport();
+ }
+
+ /**
+ * Create an instance of {@link AckType }
+ *
+ */
+ public AckType createAckType() {
+ return new AckType();
+ }
+
+ /**
+ * Create an instance of {@link PropertiesType }
+ *
+ */
+ public PropertiesType createPropertiesType() {
+ return new PropertiesType();
+ }
+
+ /**
+ * Create an instance of {@link PropertyType }
+ *
+ */
+ public PropertyType createPropertyType() {
+ return new PropertyType();
+ }
+
+ /**
+ * Create an instance of {@link MessageType }
+ *
+ */
+ public MessageType createMessageType() {
+ return new MessageType();
+ }
+
+ /**
+ * Create an instance of {@link QueueRefType }
+ *
+ */
+ public QueueRefType createQueueRefType() {
+ return new QueueRefType();
+ }
+
+ /**
+ * Create an instance of {@link QueueType }
+ *
+ */
+ public QueueType createQueueType() {
+ return new QueueType();
+ }
+
+ /**
+ * Create an instance of {@link BindingsType }
+ *
+ */
+ public BindingsType createBindingsType() {
+ return new BindingsType();
+ }
+
+ /**
+ * Create an instance of {@link BindingsJournalType }
+ *
+ */
+ public BindingsJournalType createBindingsJournalType() {
+ return new BindingsJournalType();
+ }
+
+ /**
+ * Create an instance of {@link MessagesExportType }
+ *
+ */
+ public MessagesExportType createMessagesJournalType() {
+ return new MessagesExportType();
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertiesType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,68 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for propertiesType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="propertiesType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="property" type="{urn:hornetq}propertyType" maxOccurs="unbounded"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "propertiesType", namespace = "urn:hornetq", propOrder = {
+ "property"
+})
+public class PropertiesType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected List<PropertyType> property;
+
+ /**
+ * Gets the value of the property property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the property property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getProperty().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link PropertyType }
+ *
+ *
+ */
+ public List<PropertyType> getProperty() {
+ if (property == null) {
+ property = new ArrayList<PropertyType>();
+ }
+ return this.property;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/PropertyType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,86 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for propertyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="propertyType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="key" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "propertyType", namespace = "urn:hornetq", propOrder = {
+ "value"
+})
+public class PropertyType {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(required = true)
+ protected String key;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the key property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the value of the key property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setKey(String value) {
+ this.key = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueRefType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,74 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for queueRefType complex type.
+ * <p/>
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p/>
+ * <pre>
+ * <complexType name="queueRefType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "queueRefType", namespace = "urn:hornetq")
+public class QueueRefType {
+
+ @XmlAttribute
+ protected Long id;
+
+ public QueueRefType() {
+ }
+
+ public QueueRefType(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return possible object is
+ * {@link Long }
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value allowed object is
+ * {@link Long }
+ */
+ public void setId(Long value) {
+ this.id = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ QueueRefType that = (QueueRefType) o;
+
+ if (!id.equals(that.id)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
Added: branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/xmlmodel/QueueType.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,137 @@
+package org.hornetq.core.persistence.tools.xmlmodel;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for queueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="queueType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="address" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="filterString" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * </sequence>
+ * <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "queueType", namespace = "urn:hornetq", propOrder = {
+ "name",
+ "address",
+ "filterString"
+})
+public class QueueType {
+
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String name;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String address;
+ @XmlElement(namespace = "urn:hornetq", required = true)
+ protected String filterString;
+ @XmlAttribute(required = true)
+ protected long id;
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the address property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * Sets the value of the address property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAddress(String value) {
+ this.address = value;
+ }
+
+ /**
+ * Gets the value of the filterString property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getFilterString() {
+ return filterString;
+ }
+
+ /**
+ * Sets the value of the filterString property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setFilterString(String value) {
+ this.filterString = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ */
+ public void setId(long value) {
+ this.id = value;
+ }
+
+}
Added: branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
===================================================================
--- branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java (rev 0)
+++ branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-19 02:21:45 UTC (rev 10699)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.persistence;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.core.persistence.tools.ManageDataTool;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.jms.client.HornetQJMSConnectionFactory;
+import org.hornetq.tests.util.ServiceTestBase;
+
+/**
+ * UnitTest for importing/exporting journal messages.
+ * <p/>
+ * Scenario:
+ *
+ * @author Torben Jaeger</a>
+ * @author Clebert Suconic</a>
+ */
+public class ExportDataTest extends ServiceTestBase {
+
+ protected static HornetQJMSConnectionFactory myCf;
+
+ public void testExportImport() throws Exception {
+
+ HornetQServer server = createServer(true);
+
+
+ server.start();
+
+ ServerLocator locator = createNonHALocator(false);
+ ClientSessionFactory sf = locator.createSessionFactory();
+ ClientSession session = null;
+
+ try
+ {
+ session = sf.createSession();
+
+ session.createQueue("ADDRESS", "Q1");
+ session.createQueue("ADDRESS", "Q2");
+
+ ClientProducer prod = session.createProducer("ADDRESS");
+
+ for (int i = 0 ; i < 100; i++)
+ {
+ ClientMessage msg = session.createMessage(true);
+ msg.putStringProperty("prop", "TST1");
+ msg.putIntProperty("count", i);
+ for (int b = 0; b < 1024; b++)
+ {
+ msg.getBodyBuffer().writeByte(getSamplebyte(b));
+ }
+ prod.send(msg);
+ }
+
+ session.start();
+ ClientConsumer cons = session.createConsumer("Q1");
+
+ for (int i = 0; i < 50; i++)
+ {
+ ClientMessage msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+ assertEquals(i, msg.getIntProperty("count").intValue());
+ }
+
+ session.commit();
+
+ session.close();
+ sf.close();
+ locator.close();
+
+ server.stop();
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+
+ ManageDataTool.exportMessages(getBindingsDir(), getJournalDir(), bout);
+
+ InputStream is = new ByteArrayInputStream(bout.toByteArray());
+
+ clearData();
+
+ server = createServer(true);
+
+ server.start();
+
+ locator = createInVMNonHALocator();
+
+ ManageDataTool.importMessages(is, getBindingsDir(), locator);
+
+ ClientSessionFactory csf = locator.createSessionFactory();
+
+ session = csf.createSession();
+ session.start();
+ cons = session.createConsumer("Q1");
+
+ for (int i = 50; i < 100; i++)
+ {
+ ClientMessage msg = cons.receive(1000);
+ assertNotNull(msg);
+ msg.acknowledge();
+ assertEquals(i, msg.getIntProperty("count").intValue());
+ }
+
+
+
+ }
+ finally
+ {
+ sf.close();
+ locator.close();
+ }
+
+ }
+
+ public void testImport() {
+ }
+}
14 years, 7 months
JBoss hornetq SVN: r10698 - branches.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-05-18 22:18:50 -0400 (Wed, 18 May 2011)
New Revision: 10698
Added:
branches/Branch_2_2_EAP_export_tool/
Log:
creating branch
14 years, 7 months
JBoss hornetq SVN: r10697 - trunk/etc.
by do-not-reply@jboss.org
Author: borges
Date: 2011-05-18 11:43:58 -0400 (Wed, 18 May 2011)
New Revision: 10697
Modified:
trunk/etc/checkstyle.xml
Log:
Simplify the checkstyle configuration taken from AS7
Modified: trunk/etc/checkstyle.xml
===================================================================
--- trunk/etc/checkstyle.xml 2011-05-18 10:37:54 UTC (rev 10696)
+++ trunk/etc/checkstyle.xml 2011-05-18 15:43:58 UTC (rev 10697)
@@ -16,25 +16,22 @@
<module name="TreeWalker">
- <property name="cacheFile" value="${checkstyle.cache.file}"/>
-
<!-- Checks for imports -->
<module name="AvoidStarImport"/>
<module name="RedundantImport"/>
- <!-- Disabled until checkstyle can recognize imports which are used only by javadoc -->
- <!--<module name="UnusedImports"/>-->
+ <module name="UnusedImports"/>
<!-- Modifier Checks -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
- <module name="LeftCurly"/>
+ <!-- <module name="LeftCurly"/> -->
<!-- Checks for common coding problems -->
<!-- Disabled until http://sourceforge.net/tracker/?func=detail&aid=2843447&group_id=29721&at... is fixed-->
<!--<module name="DoubleCheckedLocking"/>-->
- <module name="EmptyStatement"/>
+ <!-- <module name="EmptyStatement"/> -->
<module name="EqualsHashCode"/>
<module name="IllegalInstantiation"/>
<module name="RedundantThrows">
14 years, 7 months
JBoss hornetq SVN: r10696 - in trunk: hornetq-jms-client and 1 other directory.
by do-not-reply@jboss.org
Author: borges
Date: 2011-05-18 06:37:54 -0400 (Wed, 18 May 2011)
New Revision: 10696
Modified:
trunk/hornetq-core-client/pom.xml
trunk/hornetq-jms-client/pom.xml
Log:
Reverting the "target=1.5" changes.
I had misunderstood the issue with merging changes with Branch_2_2, which
this does not address.
Modified: trunk/hornetq-core-client/pom.xml
===================================================================
--- trunk/hornetq-core-client/pom.xml 2011-05-18 02:38:49 UTC (rev 10695)
+++ trunk/hornetq-core-client/pom.xml 2011-05-18 10:37:54 UTC (rev 10696)
@@ -25,13 +25,6 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
Modified: trunk/hornetq-jms-client/pom.xml
===================================================================
--- trunk/hornetq-jms-client/pom.xml 2011-05-18 02:38:49 UTC (rev 10695)
+++ trunk/hornetq-jms-client/pom.xml 2011-05-18 10:37:54 UTC (rev 10696)
@@ -24,13 +24,6 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
14 years, 7 months
JBoss hornetq SVN: r10695 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-05-17 22:38:49 -0400 (Tue, 17 May 2011)
New Revision: 10695
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java
Log:
tweaks on test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2011-05-18 02:31:12 UTC (rev 10694)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2011-05-18 02:38:49 UTC (rev 10695)
@@ -3574,7 +3574,7 @@
ClientMessage message = null;
- for (int i = 0; i < 500; i++)
+ for (int i = 0; i < 100; i++)
{
log.info("send message #" + i);
message = session.createMessage(true);
@@ -3588,10 +3588,6 @@
if ((i + 1) % 2 == 0)
{
session.commit();
- if (i < 400)
- {
- pgStoreAddress.forceAnotherPage();
- }
}
}
@@ -3626,7 +3622,7 @@
pgStoreDLA.startPaging();
}
- for (int i = 2; i < 500; i++)
+ for (int i = 2; i < 100; i++)
{
log.info("Received message " + i);
message = cons.receive(5000);
@@ -3666,7 +3662,7 @@
cons = session.createConsumer(ADDRESS);
- for (int i = 2; i < 500; i++)
+ for (int i = 2; i < 100; i++)
{
log.info("Received message " + i);
message = cons.receive(5000);
14 years, 7 months
JBoss hornetq SVN: r10694 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-05-17 22:31:12 -0400 (Tue, 17 May 2011)
New Revision: 10694
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
test fix
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-05-17 22:03:37 UTC (rev 10693)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-05-18 02:31:12 UTC (rev 10694)
@@ -541,8 +541,7 @@
}
catch (Exception e)
{
- System.out.println("port " + port + " is already bound");
- System.exit(0);
+ throw new IllegalStateException("port " + port + " is already bound");
}
finally
{
14 years, 7 months