[Jboss-cvs] JBoss Messaging SVN: r1289 - in trunk: src/main/org/jboss/jms/client src/main/org/jboss/jms/client/container src/main/org/jboss/jms/client/delegate src/main/org/jboss/jms/client/remoting src/main/org/jboss/jms/message src/main/org/jboss/jms/server/destination src/main/org/jboss/jms/server/endpoint src/main/org/jboss/jms/server/remoting src/main/org/jboss/jms/tx src/main/org/jboss/messaging/core src/main/org/jboss/messaging/core/message src/main/org/jboss/messaging/core/plugin src/main/org/jboss/messaging/core/plugin/postoffice src/main/org/jboss/messaging/core/plugin/postoffice/cluster src/main/org/jboss/messaging/core/tx src/main/org/jboss/messaging/util tests/src/org/jboss/test/messaging/jms tests/src/org/jboss/test/messaging/tools
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 14 10:00:04 EDT 2006
Author: timfox
Date: 2006-09-14 09:59:28 -0400 (Thu, 14 Sep 2006)
New Revision: 1289
Added:
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBinding.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBindingImpl.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredQueue.java
trunk/src/main/org/jboss/messaging/util/Streamable.java
Removed:
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBinding.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBindingImpl.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckMessage.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MeasuredQueue.java
trunk/tests/src/org/jboss/test/messaging/tools/tx/
Modified:
trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java
trunk/src/main/org/jboss/jms/client/container/ConsumerAspect.java
trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
trunk/src/main/org/jboss/jms/client/remoting/HandleMessageResponse.java
trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java
trunk/src/main/org/jboss/jms/message/JBossMapMessage.java
trunk/src/main/org/jboss/jms/message/JBossMessage.java
trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java
trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java
trunk/src/main/org/jboss/jms/message/JBossTextMessage.java
trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java
trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java
trunk/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java
trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java
trunk/src/main/org/jboss/jms/tx/AckInfo.java
trunk/src/main/org/jboss/jms/tx/TransactionRequest.java
trunk/src/main/org/jboss/jms/tx/TxState.java
trunk/src/main/org/jboss/messaging/core/Message.java
trunk/src/main/org/jboss/messaging/core/Routable.java
trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java
trunk/src/main/org/jboss/messaging/core/message/CoreMessage.java
trunk/src/main/org/jboss/messaging/core/message/MessageSupport.java
trunk/src/main/org/jboss/messaging/core/message/RoutableSupport.java
trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java
trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
trunk/src/main/org/jboss/messaging/core/plugin/SimpleMessageReference.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/BindingImpl.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BasicRedistributionPolicy.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BindRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterTransaction.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredPostOfficeImpl.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageHolder.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessagesRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveMessagesCallback.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveTransactionRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStats.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStatsRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendNodeIdRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendTransactionRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SharedState.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/UnbindRequest.java
trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java
trunk/src/main/org/jboss/messaging/util/NotYetImplementedException.java
trunk/src/main/org/jboss/messaging/util/SafeUTF.java
trunk/src/main/org/jboss/messaging/util/StreamUtils.java
trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java
trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java
trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java
Log:
Yet more clustering work
Modified: trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -34,7 +34,6 @@
import javax.jms.TopicPublisher;
import org.jboss.jms.delegate.ProducerDelegate;
-import org.jboss.jms.delegate.SessionDelegate;
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.util.ThreadContextClassLoaderChanger;
import org.jboss.logging.Logger;
Modified: trunk/src/main/org/jboss/jms/client/container/ConsumerAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ConsumerAspect.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/client/container/ConsumerAspect.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -31,7 +31,6 @@
import org.jboss.jms.client.state.SessionState;
import org.jboss.jms.delegate.ConsumerDelegate;
import org.jboss.jms.delegate.SessionDelegate;
-import org.jboss.logging.Logger;
import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
@@ -51,9 +50,6 @@
{
// Constants -----------------------------------------------------
- private static final Logger log = Logger.getLogger(ConsumerAspect.class);
-
-
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -44,7 +44,6 @@
import org.jboss.jms.message.StreamMessageProxy;
import org.jboss.jms.message.TextMessageProxy;
import org.jboss.jms.tx.AckInfo;
-import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
/**
@@ -61,9 +60,6 @@
{
// Constants -----------------------------------------------------
- private static final Logger log = Logger.getLogger(ClientSessionDelegate.class);
-
-
private static final long serialVersionUID = -8096852898620279131L;
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/client/remoting/HandleMessageResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/HandleMessageResponse.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/client/remoting/HandleMessageResponse.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,11 +21,11 @@
*/
package org.jboss.jms.client.remoting;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import org.jboss.messaging.util.Streamable;
+
/**
* A HandleMessageResponse
*
@@ -37,7 +37,7 @@
* $Id$
*
*/
-public class HandleMessageResponse implements Externalizable
+public class HandleMessageResponse implements Streamable
{
private static final long serialVersionUID = 2500443290413453569L;
@@ -67,17 +67,17 @@
}
- // Externalizable implementation
+ // Streamable implementation
// ---------------------------------------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeBoolean(full);
out.writeInt(messagesAccepted);
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
full = in.readBoolean();
Modified: trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -26,9 +26,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
-import java.io.Externalizable;
import java.io.IOException;
-import java.io.ObjectInput;
import java.util.HashMap;
import java.util.Map;
@@ -53,12 +51,10 @@
*
* $Id$
*/
-public class JBossBytesMessage extends JBossMessage implements BytesMessage, Externalizable
+public class JBossBytesMessage extends JBossMessage implements BytesMessage
{
// Static -------------------------------------------------------
- private static final long serialVersionUID = 4636242783244742795L;
-
private static final Logger log = Logger.getLogger(JBossBytesMessage.class);
public static final byte TYPE = 1;
@@ -150,11 +146,11 @@
}
}
- // Externalizable override ---------------------------------------
+ // Streamable override ---------------------------------------
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
- super.readExternal(in);
+ super.read(in);
// transfer the value read into payloadAsBytes by superclass to payload, since this is how
// BytesMessage instances keep it
@@ -584,11 +580,13 @@
baos = null;
bais = null;
dis = null;
- dos = null;
+ dos = null;
}
- catch (IOException e)
+ catch (Exception e)
{
- throw new MessagingJMSException("IOException", e);
+ JMSException e2 = new JMSException(e.getMessage());
+ e2.setStackTrace(e.getStackTrace());
+ throw e2;
}
}
Modified: trunk/src/main/org/jboss/jms/message/JBossMapMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossMapMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/message/JBossMapMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,8 @@
*/
package org.jboss.jms.message;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.Enumeration;
@@ -54,11 +53,8 @@
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -8018832209056373908L;
-
public static final byte TYPE = 2;
-
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
@@ -503,13 +499,13 @@
// Protected -----------------------------------------------------
- protected void writePayloadExternal(ObjectOutput out, Serializable thePayload) throws IOException
+ protected void writePayload(DataOutputStream out, Serializable thePayload) throws Exception
{
StreamUtils.writeMap(out, ((Map)getPayload()), true);
}
- protected Serializable readPayloadExternal(ObjectInput in, int length)
- throws IOException, ClassNotFoundException
+ protected Serializable readPayload(DataInputStream in, int length)
+ throws Exception
{
HashMap m = StreamUtils.readMap(in, true);
return m;
Modified: trunk/src/main/org/jboss/jms/message/JBossMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/message/JBossMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,9 @@
*/
package org.jboss.jms.message;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -73,9 +73,7 @@
public class JBossMessage extends MessageSupport implements javax.jms.Message
{
// Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 8341387096828690976L;
-
+
public static final byte TYPE = 0;
private static final byte NULL = 0;
@@ -936,11 +934,11 @@
this.messageID = messageID;
}
- // Externalizable implementation ---------------------------------
+ // Streamable implementation ---------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
- super.writeExternal(out);
+ super.write(out);
writeDestination(out, destination);
@@ -980,9 +978,9 @@
}
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
- super.readExternal(in);
+ super.read(in);
destination = readDestination(in);
@@ -1081,7 +1079,7 @@
// Protected -----------------------------------------------------
- protected void writeDestination(ObjectOutput out, Destination dest) throws IOException
+ protected void writeDestination(DataOutputStream out, Destination dest) throws IOException
{
JBossDestination jb = (JBossDestination)dest;
@@ -1117,7 +1115,7 @@
}
}
- protected JBossDestination readDestination(ObjectInput in) throws IOException
+ protected JBossDestination readDestination(DataInputStream in) throws IOException
{
byte b = in.readByte();
Modified: trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/message/JBossObjectMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -44,8 +44,6 @@
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -1626960567569667875L;
-
public static final byte TYPE = 3;
// Attributes ----------------------------------------------------
@@ -134,7 +132,7 @@
public Serializable getObject() throws JMSException
{
- return getPayload();
+ return getPayload();
}
// JBossMessage overrides ----------------------------------------
Modified: trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/message/JBossStreamMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,8 @@
*/
package org.jboss.jms.message;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -55,8 +54,6 @@
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = 5504501713994881078L;
-
public static final byte TYPE = 4;
// Attributes ----------------------------------------------------
@@ -694,13 +691,13 @@
// Protected -----------------------------------------------------
- protected void writePayloadExternal(ObjectOutput out, Serializable thePayload) throws IOException
+ protected void writePayload(DataOutputStream out, Serializable thePayload) throws Exception
{
StreamUtils.writeList(out, (List)thePayload);
}
- protected Serializable readPayloadExternal(ObjectInput in, int length)
- throws IOException, ClassNotFoundException
+ protected Serializable readPayload(DataInputStream in, int length)
+ throws Exception
{
ArrayList l = StreamUtils.readList(in);
return l;
Modified: trunk/src/main/org/jboss/jms/message/JBossTextMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossTextMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/message/JBossTextMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,8 @@
*/
package org.jboss.jms.message;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -51,8 +50,6 @@
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = 7965361851565655163L;
-
public static final byte TYPE = 5;
// Attributes ----------------------------------------------------
@@ -156,13 +153,13 @@
// Protected -----------------------------------------------------
- protected void writePayloadExternal(ObjectOutput out, Serializable thePayload) throws IOException
+ protected void writePayload(DataOutputStream out, Serializable thePayload) throws Exception
{
SafeUTF.instance.safeWriteUTF(out, (String)thePayload);
}
- protected Serializable readPayloadExternal(ObjectInput in, int length)
- throws IOException, ClassNotFoundException
+ protected Serializable readPayload(DataInputStream in, int length)
+ throws Exception
{
return SafeUTF.instance.safeReadUTF(in);
}
Modified: trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/server/destination/ManagedTopic.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -29,7 +29,6 @@
import org.jboss.jms.selector.Selector;
import org.jboss.jms.util.MessageQueueNameHelper;
-import org.jboss.logging.Logger;
import org.jboss.messaging.core.local.Queue;
import org.jboss.messaging.core.plugin.contract.Binding;
@@ -46,9 +45,6 @@
*/
public class ManagedTopic extends ManagedDestination
{
- private static final Logger log = Logger.getLogger(ManagedTopic.class);
-
-
public ManagedTopic()
{
}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,10 +21,8 @@
*/
package org.jboss.jms.server.endpoint;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -32,6 +30,7 @@
import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.message.MessageProxy;
import org.jboss.messaging.core.message.MessageFactory;
+import org.jboss.messaging.util.Streamable;
/**
*
@@ -44,12 +43,10 @@
* $Id$
*
*/
-public class ClientDelivery implements Externalizable
+public class ClientDelivery implements Streamable
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = 8375144805659344430L;
-
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
@@ -71,10 +68,10 @@
this.consumerID = consumerID;
}
- // Externalizable implementation
+ // Streamable implementation
// ---------------------------------------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeInt(consumerID);
@@ -90,11 +87,11 @@
out.writeInt(mp.getDeliveryCount());
- mp.getMessage().writeExternal(out);
+ mp.getMessage().write(out);
}
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
consumerID = in.readInt();
@@ -110,7 +107,7 @@
JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);
- m.readExternal(in);
+ m.read(in);
MessageProxy md = JBossMessage.createThinDelegate(m, deliveryCount);
Modified: trunk/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,8 +21,6 @@
*/
package org.jboss.jms.server.endpoint;
-import java.io.Serializable;
-
import org.jboss.jms.message.MessageProxy;
import org.jboss.jms.server.ConnectionManager;
import org.jboss.jms.server.remoting.MessagingMarshallable;
@@ -38,12 +36,10 @@
*
* $Id$
*/
-public class DeliveryRunnable implements Runnable, Serializable
+public class DeliveryRunnable implements Runnable
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = 8375144805659344430L;
-
private static final Logger log = Logger.getLogger(DeliveryRunnable.class);
// Static --------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -74,8 +74,6 @@
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = 535443606137461274L;
-
private static final Logger log = Logger.getLogger(ServerConsumerEndpoint.class);
// Static --------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,10 +21,10 @@
*/
package org.jboss.jms.server.remoting;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
@@ -80,15 +80,12 @@
// The request codes - start from zero
- protected static final byte SERIALIZED = 0;
-
+ protected static final byte SERIALIZED = 0;
protected static final byte ACKNOWLEDGE = 1;
protected static final byte ACKNOWLEDGE_BATCH = 2;
- protected static final byte SEND = 3;
-
+ protected static final byte SEND = 3;
protected static final byte CANCEL_DELIVERIES = 4;
protected static final byte MORE = 5;
-
protected static final byte SEND_TRANSACTION = 6;
protected static final byte GET_ID_BLOCK = 7;
@@ -123,262 +120,276 @@
// Marshaller implementation -------------------------------------
public void write(Object obj, OutputStream out) throws IOException
- {
- // sanity check
- if (!(out instanceof ObjectOutputStream))
+ {
+ DataOutputStream dos;
+
+ if (out instanceof DataOutputStream)
{
- log.error("out is a " + out.getClass());
- throw new IllegalStateException("OutputStream must be an ObjectOutputStream");
+ dos = (DataOutputStream)out;
}
+ else
+ {
+ //TODO - We should get remoting to pass in a DataOutputStream
+ //So we don't have to wrap it every time
+ dos = new DataOutputStream(out);
+ }
+
+ handleVersion(obj, dos);
- ObjectOutputStream oos = (ObjectOutputStream)out;
-
- handleVersion(obj, oos);
-
- if (obj instanceof InvocationRequest)
+ try
{
- if (trace) { log.trace("writing InvocationRequest"); }
-
- InvocationRequest req = (InvocationRequest)obj;
-
- Object param;
-
- if (req.getParameter() instanceof MessagingMarshallable)
+
+ if (obj instanceof InvocationRequest)
{
- param = ((MessagingMarshallable)req.getParameter()).getLoad();
- }
- else
- {
- param = req.getParameter();
- }
-
- if (trace) { log.trace("param is " + param); }
-
- if (param instanceof MethodInvocation)
- {
- MethodInvocation mi = (MethodInvocation)param;
-
- String methodName = mi.getMethod().getName();
-
- if (trace) { log.trace("methodInvocation (" + methodName + "())"); }
-
- if (methodName.equals("send"))
+ if (trace) { log.trace("writing InvocationRequest"); }
+
+ InvocationRequest req = (InvocationRequest)obj;
+
+ Object param;
+
+ if (req.getParameter() instanceof MessagingMarshallable)
{
- oos.writeByte(SEND);
-
- writeHeader(mi, oos);
-
- JBossMessage m = (JBossMessage)mi.getArguments()[0];
-
- oos.writeByte(m.getType());
-
- m.writeExternal(oos);
-
- oos.flush();
-
- if (trace) { log.trace("wrote send()"); }
+ param = ((MessagingMarshallable)req.getParameter()).getLoad();
}
- else if ("more".equals(methodName))
+ else
{
- oos.writeByte(MORE);
-
- writeHeader(mi, oos);
-
- oos.flush();
-
- if (trace) { log.trace("wrote activate()"); }
- }
- else if ("acknowledge".equals(methodName))
- {
- oos.writeByte(ACKNOWLEDGE);
-
- writeHeader(mi, oos);
-
- AckInfo ack = (AckInfo)mi.getArguments()[0];
-
- ack.writeExternal(oos);
-
- oos.flush();
-
- if (trace) { log.trace("wrote acknowledge()"); }
+ param = req.getParameter();
}
- else if ("acknowledgeBatch".equals(methodName))
+
+ if (trace) { log.trace("param is " + param); }
+
+ if (param instanceof MethodInvocation)
{
- oos.writeByte(ACKNOWLEDGE_BATCH);
-
- writeHeader(mi, oos);
-
- List acks = (List)mi.getArguments()[0];
-
- oos.writeInt(acks.size());
-
- Iterator iter = acks.iterator();
-
- while (iter.hasNext())
+ MethodInvocation mi = (MethodInvocation)param;
+
+ String methodName = mi.getMethod().getName();
+
+ if (trace) { log.trace("methodInvocation (" + methodName + "())"); }
+
+ if (methodName.equals("send"))
{
- AckInfo ack = (AckInfo)iter.next();
- ack.writeExternal(oos);
+ dos.writeByte(SEND);
+
+ writeHeader(mi, dos);
+
+ JBossMessage m = (JBossMessage)mi.getArguments()[0];
+
+ dos.writeByte(m.getType());
+
+ m.write(dos);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote send()"); }
}
-
- oos.flush();
-
- if (trace) { log.trace("wrote acknowledge()"); }
+ else if ("more".equals(methodName))
+ {
+ dos.writeByte(MORE);
+
+ writeHeader(mi, dos);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote activate()"); }
+ }
+ else if ("acknowledge".equals(methodName))
+ {
+ dos.writeByte(ACKNOWLEDGE);
+
+ writeHeader(mi, dos);
+
+ AckInfo ack = (AckInfo)mi.getArguments()[0];
+
+ ack.write(dos);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote acknowledge()"); }
+ }
+ else if ("acknowledgeBatch".equals(methodName))
+ {
+ dos.writeByte(ACKNOWLEDGE_BATCH);
+
+ writeHeader(mi, dos);
+
+ List acks = (List)mi.getArguments()[0];
+
+ dos.writeInt(acks.size());
+
+ Iterator iter = acks.iterator();
+
+ while (iter.hasNext())
+ {
+ AckInfo ack = (AckInfo)iter.next();
+ ack.write(dos);
+ }
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote acknowledge()"); }
+ }
+ else if ("sendTransaction".equals(methodName))
+ {
+ dos.writeByte(SEND_TRANSACTION);
+
+ writeHeader(mi, dos);
+
+ TransactionRequest request = (TransactionRequest)mi.getArguments()[0];
+
+ request.write(dos);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote getMessageNow()"); }
+ }
+ else if ("getIdBlock".equals(methodName))
+ {
+ dos.writeByte(GET_ID_BLOCK);
+
+ writeHeader(mi, dos);
+
+ int size = ((Integer)mi.getArguments()[0]).intValue();
+
+ dos.writeInt(size);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote getIdBlock()"); }
+ }
+ else if ("cancelDeliveries".equals(methodName) && mi.getArguments() != null)
+ {
+ dos.writeByte(CANCEL_DELIVERIES);
+
+ writeHeader(mi, dos);
+
+ List ids = (List)mi.getArguments()[0];
+
+ dos.writeInt(ids.size());
+
+ Iterator iter = ids.iterator();
+
+ while (iter.hasNext())
+ {
+ AckInfo ack = (AckInfo)iter.next();
+ ack.write(dos);
+ }
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote cancelDeliveries()"); }
+ }
+ else
+ {
+ dos.write(SERIALIZED);
+
+ // Delegate to serialization to handle the wire format
+ serializableMarshaller.write(obj, dos);
+
+ if (trace) { log.trace("wrote using standard serialization"); }
+ }
}
- else if ("sendTransaction".equals(methodName))
+ else if (param instanceof ClientDelivery)
{
- oos.writeByte(SEND_TRANSACTION);
-
- writeHeader(mi, oos);
-
- TransactionRequest request = (TransactionRequest)mi.getArguments()[0];
-
- request.writeExternal(oos);
-
- oos.flush();
-
- if (trace) { log.trace("wrote getMessageNow()"); }
+ //Message delivery callback
+
+ if (trace) { log.trace("DeliveryRunnable"); }
+
+ ClientDelivery dr = (ClientDelivery)param;
+
+ dos.writeByte(CALLBACK);
+
+ dr.write(dos);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote DeliveryRunnable"); }
}
- else if ("getIdBlock".equals(methodName))
+ else
{
- oos.writeByte(GET_ID_BLOCK);
-
- writeHeader(mi, oos);
-
- int size = ((Integer)mi.getArguments()[0]).intValue();
-
- oos.writeInt(size);
-
- oos.flush();
-
- if (trace) { log.trace("wrote getIdBlock()"); }
- }
- else if ("cancelDeliveries".equals(methodName) && mi.getArguments() != null)
+ //Internal invocation
+
+ dos.write(SERIALIZED);
+
+ //Delegate to serialization to handle the wire format
+ serializableMarshaller.write(obj, dos);
+
+ if (trace) { log.trace("wrote using standard serialization"); }
+ }
+ }
+ else if (obj instanceof InvocationResponse)
+ {
+ if (trace) { log.trace("writing InvocationResponse"); }
+
+ InvocationResponse resp = (InvocationResponse)obj;
+
+ Object res;
+
+ if (resp.getResult() instanceof MessagingMarshallable)
{
- oos.writeByte(CANCEL_DELIVERIES);
-
- writeHeader(mi, oos);
-
- List ids = (List)mi.getArguments()[0];
-
- oos.writeInt(ids.size());
-
- Iterator iter = ids.iterator();
-
- while (iter.hasNext())
- {
- AckInfo ack = (AckInfo)iter.next();
- ack.writeExternal(oos);
- }
-
- oos.flush();
-
- if (trace) { log.trace("wrote cancelDeliveries()"); }
+ res = ((MessagingMarshallable)resp.getResult()).getLoad();
}
else
{
- oos.write(SERIALIZED);
-
- // Delegate to serialization to handle the wire format
- serializableMarshaller.write(obj, oos);
-
+ res = resp.getResult();
+ }
+
+ if (trace) { log.trace("result is " + res); }
+
+ if (res == null && !resp.isException())
+ {
+ dos.write(NULL_RESPONSE);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote null response"); }
+ }
+ else if (res instanceof IdBlock)
+ {
+ //Return value from getMessageNow
+ dos.write(ID_BLOCK_RESPONSE);
+
+ IdBlock block = (IdBlock)res;
+
+ block.write(dos);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote id block response"); }
+ }
+ else if (res instanceof HandleMessageResponse)
+ {
+ //Return value from delivering messages to client
+ dos.write(HANDLE_MESSAGE_RESPONSE);
+
+ HandleMessageResponse response = (HandleMessageResponse)res;
+
+ response.write(dos);
+
+ dos.flush();
+
+ if (trace) { log.trace("wrote handle message response"); }
+ }
+ else
+ {
+ dos.write(SERIALIZED);
+
+ //Delegate to serialization to handle the wire format
+ serializableMarshaller.write(obj, out);
+
if (trace) { log.trace("wrote using standard serialization"); }
}
}
- else if (param instanceof ClientDelivery)
- {
- //Message delivery callback
-
- if (trace) { log.trace("DeliveryRunnable"); }
-
- ClientDelivery dr = (ClientDelivery)param;
-
- oos.writeByte(CALLBACK);
-
- dr.writeExternal(oos);
-
- oos.flush();
-
- if (trace) { log.trace("wrote DeliveryRunnable"); }
- }
else
{
- //Internal invocation
-
- oos.write(SERIALIZED);
-
- //Delegate to serialization to handle the wire format
- serializableMarshaller.write(obj, oos);
-
- if (trace) { log.trace("wrote using standard serialization"); }
+ throw new IllegalStateException("Invalid object " + obj);
}
}
- else if (obj instanceof InvocationResponse)
+ catch (Exception e)
{
- if (trace) { log.trace("writing InvocationResponse"); }
-
- InvocationResponse resp = (InvocationResponse)obj;
-
- Object res;
-
- if (resp.getResult() instanceof MessagingMarshallable)
- {
- res = ((MessagingMarshallable)resp.getResult()).getLoad();
- }
- else
- {
- res = resp.getResult();
- }
-
- if (trace) { log.trace("result is " + res); }
-
- if (res == null && !resp.isException())
- {
- oos.write(NULL_RESPONSE);
-
- oos.flush();
-
- if (trace) { log.trace("wrote null response"); }
- }
- else if (res instanceof IdBlock)
- {
- //Return value from getMessageNow
- oos.write(ID_BLOCK_RESPONSE);
-
- IdBlock block = (IdBlock)res;
-
- block.writeExternal(oos);
-
- oos.flush();
-
- if (trace) { log.trace("wrote id block response"); }
- }
- else if (res instanceof HandleMessageResponse)
- {
- //Return value from delivering messages to client
- oos.write(HANDLE_MESSAGE_RESPONSE);
-
- HandleMessageResponse response = (HandleMessageResponse)res;
-
- response.writeExternal(oos);
-
- oos.flush();
-
- if (trace) { log.trace("wrote handle message response"); }
- }
- else
- {
- oos.write(SERIALIZED);
-
- //Delegate to serialization to handle the wire format
- serializableMarshaller.write(obj, out);
-
- if (trace) { log.trace("wrote using standard serialization"); }
- }
+ IOException e2 = new IOException(e.getMessage());
+ e2.setStackTrace(e.getStackTrace());
+ throw e2;
}
- else
- {
- throw new IllegalStateException("Invalid object " + obj);
- }
}
public Marshaller cloneMarshaller() throws CloneNotSupportedException
@@ -389,244 +400,258 @@
// UnMarshaller implementation -----------------------------------
public Object read(InputStream in, Map map) throws IOException, ClassNotFoundException
- {
- // Sanity check
- if (!(in instanceof ObjectInputStream))
+ {
+ if (in instanceof JBossObjectInputStream)
{
- log.error("in is a " + in.getClass());
- throw new IllegalStateException("InputStream must be an ObjectInputStream");
- }
-
- ObjectInputStream ois = (ObjectInputStream)in;
-
- if (ois instanceof JBossObjectInputStream)
- {
// Need to explicitly set the classloader
- ((JBossObjectInputStream)ois).
+ ((JBossObjectInputStream)in).
setClassLoader(Thread.currentThread().getContextClassLoader());
}
+
+ DataInputStream dis;
+
+ //TODO We should ensure that remoting always passes in a DataInputStream
+ //This saves us wrapping it each time
+ if (in instanceof DataInputStream)
+ {
+ dis = (DataInputStream)in;
+ }
+ else
+ {
+ dis = new DataInputStream(in);
+ }
// First byte read is always version
- byte version = ois.readByte();
+ byte version = dis.readByte();
- byte formatType = (byte)ois.read();
+ byte formatType = (byte)dis.read();
if (trace) { log.trace("reading, format type is " + formatType); }
-
- switch (formatType)
+
+ try
{
- case SERIALIZED:
+
+ switch (formatType)
{
- // Delegate to serialization
- Object ret = serializableUnMarshaller.read(ois, map);
-
- if (trace) { log.trace("read using standard serialization"); }
-
- return ret;
- }
- case SEND:
- {
- MethodInvocation mi = readHeader(ois);
-
- byte messageType = ois.readByte();
-
- JBossMessage m = (JBossMessage)MessageFactory.createMessage(messageType);
-
- m.readExternal(ois);
-
- Object[] args = new Object[] {m};
-
- mi.setArguments(args);
-
- InvocationRequest request =
- new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
- new MessagingMarshallable(version, mi), null, null, null);
-
- if (trace) { log.trace("read send()"); }
-
- return request;
- }
- case MORE:
- {
- MethodInvocation mi = readHeader(ois);
-
- InvocationRequest request =
- new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
- new MessagingMarshallable(version, mi), null, null, null);
-
- if (trace) { log.trace("read activate()"); }
-
- return request;
- }
- case SEND_TRANSACTION:
- {
- MethodInvocation mi = readHeader(ois);
-
- TransactionRequest tr = new TransactionRequest();
-
- tr.readExternal(ois);
-
- Object[] args = new Object[] {tr};
-
- mi.setArguments(args);
-
- InvocationRequest request =
- new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
- new MessagingMarshallable(version, mi), null, null, null);
-
- if (trace) { log.trace("read sendTransaction()"); }
-
- return request;
- }
- case GET_ID_BLOCK:
- {
- MethodInvocation mi = readHeader(ois);
-
- int size = ois.readInt();
-
- Object[] args = new Object[] {new Integer(size)};
-
- mi.setArguments(args);
-
- InvocationRequest request =
- new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
- new MessagingMarshallable(version, mi), null, null, null);
-
- if (trace) { log.trace("read getIdBlock()"); }
-
- return request;
- }
- case ACKNOWLEDGE:
- {
- MethodInvocation mi = readHeader(ois);
-
- AckInfo info = new AckInfo();
-
- info.readExternal(ois);
-
- Object[] args = new Object[] {info};
-
- mi.setArguments(args);
-
- InvocationRequest request =
- new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
- new MessagingMarshallable(version, mi), null, null, null);
-
- if (trace) { log.trace("read acknowledge()"); }
-
- return request;
- }
- case ACKNOWLEDGE_BATCH:
- {
- MethodInvocation mi = readHeader(ois);
-
- int num = ois.readInt();
-
- List acks = new ArrayList(num);
-
- for (int i = 0; i < num; i++)
+ case SERIALIZED:
{
- AckInfo ack = new AckInfo();
+ // Delegate to serialization
+ Object ret = serializableUnMarshaller.read(dis, map);
+
+ if (trace) { log.trace("read using standard serialization"); }
+
+ return ret;
+ }
+ case SEND:
+ {
+ MethodInvocation mi = readHeader(dis);
+
+ byte messageType = dis.readByte();
+
+ JBossMessage m = (JBossMessage)MessageFactory.createMessage(messageType);
+
+ m.read(dis);
+
+ Object[] args = new Object[] {m};
+
+ mi.setArguments(args);
+
+ InvocationRequest request =
+ new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+ new MessagingMarshallable(version, mi), null, null, null);
+
+ if (trace) { log.trace("read send()"); }
+
+ return request;
+ }
+ case MORE:
+ {
+ MethodInvocation mi = readHeader(dis);
+
+ InvocationRequest request =
+ new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+ new MessagingMarshallable(version, mi), null, null, null);
+
+ if (trace) { log.trace("read activate()"); }
+
+ return request;
+ }
+ case SEND_TRANSACTION:
+ {
+ MethodInvocation mi = readHeader(dis);
+
+ TransactionRequest tr = new TransactionRequest();
+
+ tr.read(dis);
+
+ Object[] args = new Object[] {tr};
+
+ mi.setArguments(args);
+
+ InvocationRequest request =
+ new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+ new MessagingMarshallable(version, mi), null, null, null);
+
+ if (trace) { log.trace("read sendTransaction()"); }
+
+ return request;
+ }
+ case GET_ID_BLOCK:
+ {
+ MethodInvocation mi = readHeader(dis);
+
+ int size = dis.readInt();
+
+ Object[] args = new Object[] {new Integer(size)};
+
+ mi.setArguments(args);
+
+ InvocationRequest request =
+ new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+ new MessagingMarshallable(version, mi), null, null, null);
+
+ if (trace) { log.trace("read getIdBlock()"); }
+
+ return request;
+ }
+ case ACKNOWLEDGE:
+ {
+ MethodInvocation mi = readHeader(dis);
- ack.readExternal(ois);
+ AckInfo info = new AckInfo();
- acks.add(ack);
+ info.read(dis);
+
+ Object[] args = new Object[] {info};
+
+ mi.setArguments(args);
+
+ InvocationRequest request =
+ new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+ new MessagingMarshallable(version, mi), null, null, null);
+
+ if (trace) { log.trace("read acknowledge()"); }
+
+ return request;
}
-
- Object[] args = new Object[] {acks};
-
- mi.setArguments(args);
-
- InvocationRequest request =
- new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
- new MessagingMarshallable(version, mi), null, null, null);
-
- if (trace) { log.trace("read acknowledge()"); }
-
- return request;
- }
- case CANCEL_DELIVERIES:
- {
- MethodInvocation mi = readHeader(ois);
-
- int size = ois.readInt();
-
- List acks = new ArrayList(size);
-
- for (int i = 0; i < size; i++)
+ case ACKNOWLEDGE_BATCH:
{
- AckInfo ack = new AckInfo();
+ MethodInvocation mi = readHeader(dis);
+
+ int num = dis.readInt();
- ack.readExternal(ois);
+ List acks = new ArrayList(num);
- acks.add(ack);
+ for (int i = 0; i < num; i++)
+ {
+ AckInfo ack = new AckInfo();
+
+ ack.read(dis);
+
+ acks.add(ack);
+ }
+
+ Object[] args = new Object[] {acks};
+
+ mi.setArguments(args);
+
+ InvocationRequest request =
+ new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+ new MessagingMarshallable(version, mi), null, null, null);
+
+ if (trace) { log.trace("read acknowledge()"); }
+
+ return request;
}
-
- Object[] args = new Object[] {acks};
-
- mi.setArguments(args);
-
- InvocationRequest request =
- new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
- new MessagingMarshallable(version, mi), null, null, null);
-
- if (trace) { log.trace("read cancelDeliveries()"); }
-
- return request;
+ case CANCEL_DELIVERIES:
+ {
+ MethodInvocation mi = readHeader(dis);
+
+ int size = dis.readInt();
+
+ List acks = new ArrayList(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ AckInfo ack = new AckInfo();
+
+ ack.read(dis);
+
+ acks.add(ack);
+ }
+
+ Object[] args = new Object[] {acks};
+
+ mi.setArguments(args);
+
+ InvocationRequest request =
+ new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+ new MessagingMarshallable(version, mi), null, null, null);
+
+ if (trace) { log.trace("read cancelDeliveries()"); }
+
+ return request;
+ }
+ case ID_BLOCK_RESPONSE:
+ {
+ IdBlock block = new IdBlock();
+
+ block.read(dis);
+
+ InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, block), false, null);
+
+ if (trace) { log.trace("read id block response"); }
+
+ return resp;
+ }
+ case HANDLE_MESSAGE_RESPONSE:
+ {
+ HandleMessageResponse res = new HandleMessageResponse();
+
+ res.read(dis);
+
+ InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, res), false, null);
+
+ if (trace) { log.trace("read handle message response"); }
+
+ return resp;
+ }
+ case NULL_RESPONSE:
+ {
+ InvocationResponse resp =
+ new InvocationResponse(null, new MessagingMarshallable(version, null), false, null);
+
+ if (trace) { log.trace("read null response"); }
+
+ return resp;
+ }
+ case CALLBACK:
+ {
+ ClientDelivery dr = new ClientDelivery();
+
+ dr.read(dis);
+
+ InvocationRequest request =
+ new InvocationRequest(null, CallbackServerFactory.JMS_CALLBACK_SUBSYSTEM,
+ new MessagingMarshallable(version, dr), null, null, null);
+
+ if (trace) { log.trace("read callback()"); }
+
+ return request;
+ }
+ default:
+ {
+ throw new IllegalStateException("Invalid format type " + formatType);
+ }
}
- case ID_BLOCK_RESPONSE:
- {
- IdBlock block = new IdBlock();
-
- block.readExternal(ois);
-
- InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, block), false, null);
-
- if (trace) { log.trace("read id block response"); }
-
- return resp;
- }
- case HANDLE_MESSAGE_RESPONSE:
- {
- HandleMessageResponse res = new HandleMessageResponse();
-
- res.readExternal(ois);
-
- InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, res), false, null);
-
- if (trace) { log.trace("read handle message response"); }
-
- return resp;
- }
- case NULL_RESPONSE:
- {
- InvocationResponse resp =
- new InvocationResponse(null, new MessagingMarshallable(version, null), false, null);
-
- if (trace) { log.trace("read null response"); }
-
- return resp;
- }
- case CALLBACK:
- {
- ClientDelivery dr = new ClientDelivery();
-
- dr.readExternal(ois);
-
- InvocationRequest request =
- new InvocationRequest(null, CallbackServerFactory.JMS_CALLBACK_SUBSYSTEM,
- new MessagingMarshallable(version, dr), null, null, null);
-
- if (trace) { log.trace("read callback()"); }
-
- return request;
- }
- default:
- {
- throw new IllegalStateException("Invalid format type " + formatType);
- }
}
+ catch (Exception e)
+ {
+ IOException e2 = new IOException(e.getMessage());
+ e2.setStackTrace(e.getStackTrace());
+ throw e2;
+ }
}
@@ -637,7 +662,6 @@
public void setClassLoader(ClassLoader classloader)
{
- //log.warn("ignoring setClassLoader(" + classloader + ")");
}
// Public --------------------------------------------------------
@@ -646,7 +670,7 @@
// Protected -----------------------------------------------------
- protected void handleVersion(Object obj, ObjectOutputStream oos) throws IOException
+ protected void handleVersion(Object obj, DataOutputStream oos) throws IOException
{
Object load = null;
@@ -681,7 +705,7 @@
// Private -------------------------------------------------------
- private void writeHeader(MethodInvocation mi, ObjectOutputStream dos) throws IOException
+ private void writeHeader(MethodInvocation mi, DataOutputStream dos) throws IOException
{
int objectId = ((Integer)mi.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue();
@@ -690,7 +714,7 @@
dos.writeLong(mi.getMethodHash());
}
- private MethodInvocation readHeader(ObjectInputStream ois) throws IOException
+ private MethodInvocation readHeader(DataInputStream ois) throws IOException
{
int objectId = ois.readInt();
Modified: trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,7 +21,6 @@
*/
package org.jboss.jms.server.remoting;
-import java.io.Serializable;
/**
*
@@ -32,12 +31,10 @@
*
* $Id$
*/
-public class MessagingMarshallable implements Serializable
+public class MessagingMarshallable
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -575513130283539747L;
-
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/tx/AckInfo.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/AckInfo.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/tx/AckInfo.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,12 +21,11 @@
*/
package org.jboss.jms.tx;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import org.jboss.jms.message.MessageProxy;
+import org.jboss.messaging.util.Streamable;
/**
* Struct like class for holding information regarding an acknowledgement to be passed to the server
@@ -36,12 +35,10 @@
*
* $Id$
*/
-public class AckInfo implements Externalizable
+public class AckInfo implements Streamable
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -5951156790257302184L;
-
// Attributes ----------------------------------------------------
protected long messageID;
@@ -94,15 +91,15 @@
return "AckInfo[" + messageID + ", " + consumerID + "]";
}
- // Externalizable implementation ---------------------------------
+ // Streamable implementation ---------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeLong(messageID);
out.writeInt(consumerID);
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
messageID = in.readLong();
consumerID = in.readInt();
Modified: trunk/src/main/org/jboss/jms/tx/TransactionRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/TransactionRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/tx/TransactionRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,14 +21,13 @@
*/
package org.jboss.jms.tx;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import javax.transaction.xa.Xid;
import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.util.Streamable;
/**
* This class contians all the data needed to perform a JMS transaction.
@@ -47,12 +46,10 @@
*
* $Id$
*/
-public class TransactionRequest implements Externalizable
+public class TransactionRequest implements Streamable
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -5371388526898322431L;
-
public final static byte ONE_PHASE_COMMIT_REQUEST = 0;
public final static byte TWO_PHASE_PREPARE_REQUEST = 2;
public final static byte TWO_PHASE_COMMIT_REQUEST = 3;
@@ -86,9 +83,9 @@
this.state = state;
}
- // Externalizable implementation ---------------------------------
+ // Streamable implementation ---------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeInt(requestType);
@@ -114,7 +111,7 @@
if (state != null)
{
out.write(PRESENT);
- state.writeExternal(out);
+ state.write(out);
}
else
{
@@ -122,7 +119,7 @@
}
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
requestType = in.readInt();
@@ -158,7 +155,7 @@
{
state = new TxState();
- state.readExternal(in);
+ state.read(in);
}
}
Modified: trunk/src/main/org/jboss/jms/tx/TxState.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/TxState.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/jms/tx/TxState.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,16 +21,15 @@
*/
package org.jboss.jms.tx;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jboss.jms.message.JBossMessage;
import org.jboss.messaging.core.message.MessageFactory;
+import org.jboss.messaging.util.Streamable;
/**
* Holds information for a JMS transaction to be sent to the server for
@@ -40,11 +39,10 @@
*
* @author <a href="mailto:tim.fox at jboss.com>Tim Fox </a>
*/
-public class TxState implements Externalizable
+public class TxState implements Streamable
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -7255482761072658186L;
-
+
public final static byte TX_OPEN = 0;
public final static byte TX_ENDED = 1;
@@ -98,9 +96,9 @@
this.state = state;
}
- // Externalizable implementation ---------------------------------
+ // Streamable implementation ---------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeInt(state);
if (messages == null)
@@ -116,7 +114,7 @@
JBossMessage m = (JBossMessage)iter.next();
//We don't use writeObject to avoid serialization overhead
out.writeByte(m.getType());
- m.writeExternal(out);
+ m.write(out);
}
}
if (acks == null)
@@ -131,12 +129,12 @@
{
AckInfo a = (AckInfo)iter.next();
//We don't use writeObject to avoid serialization overhead
- a.writeExternal(out);
+ a.write(out);
}
}
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
state = in.readInt();
int numMessages = in.readInt();
@@ -151,7 +149,7 @@
{
byte type = in.readByte();
JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);
- m.readExternal(in);
+ m.read(in);
messages.add(m);
}
}
@@ -167,7 +165,7 @@
for (int i = 0; i < numAcks; i++)
{
AckInfo info = new AckInfo();
- info.readExternal(in);
+ info.read(in);
acks.add(info);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/Message.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Message.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/Message.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -48,4 +48,6 @@
int getPersistentChannelCount();
+ byte getType();
+
}
Modified: trunk/src/main/org/jboss/messaging/core/Routable.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Routable.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/Routable.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -25,6 +25,8 @@
import java.util.Map;
import java.util.Set;
+import org.jboss.messaging.util.Streamable;
+
/**
* An atomic, self containted unit of data that is being routed by the messaging system.
*
@@ -40,7 +42,7 @@
*
* $Id$
*/
-public interface Routable extends Serializable
+public interface Routable extends Streamable
{
static final String REMOTE_ROUTABLE = "REMOTE_ROUTABLE";
static final String REPLICATOR_ID = "REPLICATOR_ID";
Modified: trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/SimpleDelivery.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,8 +21,6 @@
*/
package org.jboss.messaging.core;
-import java.io.Serializable;
-
import org.jboss.logging.Logger;
import org.jboss.messaging.core.tx.Transaction;
@@ -35,16 +33,13 @@
*
* $Id$
*/
-public class SimpleDelivery implements Delivery, Serializable
+public class SimpleDelivery implements Delivery
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = 4995034535739753957L;
-
// Static --------------------------------------------------------
private static final Logger log = Logger.getLogger(SimpleDelivery.class);
-
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/message/CoreMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/CoreMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/message/CoreMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -34,8 +34,6 @@
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -1926255243537983723L;
-
public static final byte TYPE = 127;
// Attributes ----------------------------------------------------
@@ -67,6 +65,11 @@
{
return "CoreMessage["+messageID+"]";
}
+
+ public byte getType()
+ {
+ return TYPE;
+ }
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/message/MessageSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/MessageSupport.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/message/MessageSupport.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -23,16 +23,13 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.Serializable;
import java.util.Map;
import org.jboss.messaging.core.Message;
import org.jboss.messaging.util.StreamUtils;
-import org.jboss.serial.io.JBossObjectInputStream;
-import org.jboss.serial.io.JBossObjectOutputStream;
/**
@@ -48,8 +45,6 @@
{
// Constants -----------------------------------------------------
- private static final long serialVersionUID = -4474943687659785336L;
-
// Attributes ----------------------------------------------------
// Must be hidden from subclasses
@@ -159,31 +154,34 @@
{
if (payloadAsByteArray == null && payload != null)
{
+ // convert the payload into a byte array and store internally
+
+ //TODO - investigate how changing the buffer size effects
+ //performance
+
+ //Ideally I would like to use the pre-existing DataOutputStream and
+ //not create another one - but would then have to add markers on the stream
+ //to signify the end of the payload
+ //This would have the advantage of us not having to allocate buffers here
+ //We could do this by creating our own FilterOutputStream that makes sure
+ //the end of marker sequence doesn't occur in the payload
+
+ final int BUFFER_SIZE = 2048;
+
try
{
- // convert the payload into a byte array and store internally
- final int BUFFER_SIZE = 4096;
- JBossObjectOutputStream oos = null;
- try
- {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
- oos = new JBossObjectOutputStream(bos);
- writePayloadExternal(oos, payload);
- payloadAsByteArray = bos.toByteArray();
- payload = null;
- }
- finally
- {
- if (oos != null)
- {
- oos.close();
- }
- }
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
+ DataOutputStream daos = new DataOutputStream(bos);
+ writePayload(daos, payload);
+ daos.close();
+ payloadAsByteArray = bos.toByteArray();
+ payload = null;
}
- catch (IOException e)
+ catch (Exception e)
{
- //Should never happen
- throw new RuntimeException("Failed to convert payload to byte[]", e);
+ RuntimeException e2 = new RuntimeException(e.getMessage());
+ e2.setStackTrace(e.getStackTrace());
+ throw e2;
}
}
return payloadAsByteArray;
@@ -202,30 +200,24 @@
else if (payloadAsByteArray != null)
{
// deserialize the payload from byte[]
- JBossObjectInputStream ois = null;
+
+ //TODO use the same DataInputStream as in the read() method and
+ //add markers on the stream to represent end of payload
+ ByteArrayInputStream bis = new ByteArrayInputStream(payloadAsByteArray);
+ DataInputStream dis = new DataInputStream(bis);
try
{
- try
- {
- ByteArrayInputStream bis = new ByteArrayInputStream(payloadAsByteArray);
- ois = new JBossObjectInputStream(bis);
- payload = readPayloadExternal(ois, payloadAsByteArray.length);
- }
- finally
- {
- if (ois != null)
- {
- ois.close();
- }
- }
- payloadAsByteArray = null;
- return payload;
+ payload = readPayload(dis, payloadAsByteArray.length);
}
catch (Exception e)
{
- //This should never really happen in normal use so throw a unchecked exception
- throw new RuntimeException("Failed to read payload", e);
- }
+ RuntimeException e2 = new RuntimeException(e.getMessage());
+ e2.setStackTrace(e.getStackTrace());
+ throw e2;
+ }
+
+ payloadAsByteArray = null;
+ return payload;
}
else
{
@@ -293,11 +285,11 @@
return "M["+messageID+"]";
}
- // Externalizable implementation ---------------------------------
+ // Streamable implementation ---------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
- super.writeExternal(out);
+ super.write(out);
byte[] bytes = getPayloadAsByteArray();
@@ -312,9 +304,9 @@
}
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
- super.readExternal(in);
+ super.read(in);
int length = in.readInt();
@@ -336,17 +328,19 @@
/**
* Override this if you want more sophisticated payload externalization.
+ * @throws Exception TODO
*/
- protected void writePayloadExternal(ObjectOutput out, Serializable thePayload) throws IOException
+ protected void writePayload(DataOutputStream out, Serializable thePayload) throws Exception
{
StreamUtils.writeObject(out, thePayload, true, true);
}
/**
* Override this if you want more sophisticated payload externalization.
+ * @throws Exception TODO
*/
- protected Serializable readPayloadExternal(ObjectInput in, int length)
- throws IOException, ClassNotFoundException
+ protected Serializable readPayload(DataInputStream in, int length)
+ throws Exception
{
return (Serializable)StreamUtils.readObject(in, true);
}
Modified: trunk/src/main/org/jboss/messaging/core/message/RoutableSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/RoutableSupport.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/message/RoutableSupport.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,10 +21,8 @@
*/
package org.jboss.messaging.core.message;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -41,19 +39,14 @@
*
* $Id$
*/
-public abstract class RoutableSupport implements Routable, Externalizable
+public abstract class RoutableSupport implements Routable
{
-
// Constants -----------------------------------------------------
private static final Logger log = Logger.getLogger(RoutableSupport.class);
-
-
// Static --------------------------------------------------------
-
-
-
+
// Attributes ----------------------------------------------------
private boolean trace = log.isTraceEnabled();
@@ -242,9 +235,9 @@
this.priority = priority;
}
- // Externalizable implementation ---------------------------------
+ // Streamable implementation ---------------------------------
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeLong(messageID);
out.writeBoolean(reliable);
@@ -256,7 +249,7 @@
out.writeInt(deliveryCount);
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
messageID = in.readLong();
reliable = in.readBoolean();
Modified: trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,11 +21,11 @@
*/
package org.jboss.messaging.core.plugin;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import org.jboss.messaging.util.Streamable;
+
/**
*
* A IdBlock.
@@ -35,10 +35,8 @@
*
* IdBlock.java,v 1.1 2006/03/07 17:11:15 timfox Exp
*/
-public class IdBlock implements Externalizable
+public class IdBlock implements Streamable
{
- private static final long serialVersionUID = 8923493066889334803L;
-
protected long low;
protected long high;
@@ -64,14 +62,14 @@
return high;
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
low = in.readLong();
high = in.readLong();
}
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeLong(low);
Modified: trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -24,6 +24,8 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -61,8 +63,6 @@
import org.jboss.messaging.util.JDBCUtil;
import org.jboss.messaging.util.StreamUtils;
import org.jboss.messaging.util.Util;
-import org.jboss.serial.io.JBossObjectInputStream;
-import org.jboss.serial.io.JBossObjectOutputStream;
/**
*
@@ -3427,26 +3427,16 @@
}
final int BUFFER_SIZE = 1024;
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
- JBossObjectOutputStream oos = null;
+ DataOutputStream oos = new DataOutputStream(bos);
- try
- {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
-
- oos = new JBossObjectOutputStream(bos);
-
- StreamUtils.writeMap(oos, map, true);
-
- return bos.toByteArray();
- }
- finally
- {
- if (oos != null)
- {
- oos.close();
- }
- }
+ StreamUtils.writeMap(oos, map, true);
+
+ oos.close();
+
+ return bos.toByteArray();
}
protected HashMap bytesToMap(byte[] bytes) throws Exception
@@ -3455,35 +3445,26 @@
{
return new HashMap();
}
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- JBossObjectInputStream ois = null;
+ DataInputStream dais = new DataInputStream(bis);
- try
+ Map m = StreamUtils.readMap(dais, true);
+
+ dais.close();
+
+ HashMap map;
+ if (!(m instanceof HashMap))
{
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-
- ois = new JBossObjectInputStream(bis);
-
- Map m = StreamUtils.readMap(ois, true);
- HashMap map;
- if (!(m instanceof HashMap))
- {
- map = new HashMap(m);
- }
- else
- {
- map = (HashMap) m;
- }
-
- return map;
+ map = new HashMap(m);
}
- finally
+ else
{
- if (ois != null)
- {
- ois.close();
- }
+ map = (HashMap) m;
}
+
+ return map;
}
protected void updateMessageChannelCount(Message m, PreparedStatement ps) throws Exception
@@ -3592,7 +3573,7 @@
}
else
{
- ps.setByte(9, CoreMessage.TYPE);
+ ps.setByte(9, m.getType());
ps.setNull(10, Types.VARCHAR);
ps.setNull(11, Types.VARCHAR);
ps.setNull(12, Types.BINARY);
Modified: trunk/src/main/org/jboss/messaging/core/plugin/SimpleMessageReference.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/SimpleMessageReference.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/SimpleMessageReference.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -43,8 +43,6 @@
*/
public class SimpleMessageReference extends RoutableSupport implements MessageReference
{
- private static final long serialVersionUID = -6794716217132447293L;
-
private static final Logger log = Logger.getLogger(SimpleMessageReference.class);
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/BindingImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/BindingImpl.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/BindingImpl.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,15 +21,12 @@
*/
package org.jboss.messaging.core.plugin.postoffice;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import org.jboss.messaging.core.local.Queue;
import org.jboss.messaging.core.plugin.contract.Binding;
+import org.jboss.messaging.util.StreamUtils;
/**
*
@@ -41,14 +38,8 @@
* $Id$
*
*/
-public class BindingImpl implements Binding, Externalizable
+public class BindingImpl implements Binding
{
- private static final long serialVersionUID = -5518552214992031242L;
-
- private static final byte NULL = 0;
-
- private static final byte NOT_NULL = 1;
-
private String nodeId;
private String queueName;
@@ -64,7 +55,7 @@
private long channelId;
private boolean durable;
-
+
public BindingImpl()
{
}
@@ -148,8 +139,7 @@
}
}
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ public void read(DataInputStream in) throws Exception
{
nodeId = in.readUTF();
@@ -159,14 +149,14 @@
active = in.readBoolean();
- selector = readString(in);
+ selector = (String)StreamUtils.readObject(in, false);
channelId = in.readLong();
durable = in.readBoolean();
}
- public void writeExternal(ObjectOutput out) throws IOException
+ public void write(DataOutputStream out) throws Exception
{
out.writeUTF(nodeId);
@@ -176,38 +166,11 @@
out.writeBoolean(active);
- writeString(selector, out);
+ StreamUtils.writeObject(out, selector, false, false);
out.writeLong(channelId);
out.writeBoolean(durable);
}
-
- private void writeString(String string, DataOutput out) throws IOException
- {
- if (string == null)
- {
- out.writeByte(NULL);
- }
- else
- {
- out.writeByte(NOT_NULL);
- out.writeUTF(string);
- }
- }
-
- private String readString(DataInput in) throws IOException
- {
- byte b = in.readByte();
-
- if (b == NULL)
- {
- return null;
- }
- else
- {
- return in.readUTF();
- }
- }
-
+
}
Deleted: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBinding.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBinding.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBinding.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin.postoffice.cluster;
-
-import org.jboss.messaging.core.plugin.contract.Binding;
-
-/**
- * A BalancedBinding
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public interface BalancedBinding extends Binding
-{
- double getConsumptionRate();
-
- int getMessageCount();
-
- void setConsumptionRate(double rate);
-
- void setMessageCount(int count);
-}
Deleted: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBindingImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBindingImpl.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BalancedBindingImpl.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin.postoffice.cluster;
-
-import org.jboss.messaging.core.plugin.postoffice.BindingImpl;
-
-/**
- * A BalancedBindingImpl
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class BalancedBindingImpl extends BindingImpl implements BalancedBinding
-{
- private double consumptionRate;
-
- private int messageCount;
-
- public BalancedBindingImpl()
- {
- }
-
- public BalancedBindingImpl(String nodeId, String queueName, String condition, String selector, long channelId, boolean durable)
- {
- super(nodeId, queueName, condition, selector, channelId, durable);
- }
-
- public double getConsumptionRate()
- {
- return consumptionRate;
- }
-
- public int getMessageCount()
- {
- return messageCount;
- }
-
- public void setConsumptionRate(double consumptionRate)
- {
- this.consumptionRate = consumptionRate;
- }
-
- public void setMessageCount(int messageCount)
- {
- this.messageCount = messageCount;
- }
-
-
-
-}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BasicRedistributionPolicy.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BasicRedistributionPolicy.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BasicRedistributionPolicy.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -48,11 +48,11 @@
{
Iterator iter = bindings.iterator();
- BalancedBinding localBinding = null;
+ ClusteredBinding localBinding = null;
while (iter.hasNext())
{
- BalancedBinding binding = (BalancedBinding)iter.next();
+ ClusteredBinding binding = (ClusteredBinding)iter.next();
if (binding.getNodeId().equals(localNodeId))
{
@@ -78,11 +78,11 @@
double maxRate = 0;
- BalancedBinding maxRateBinding = null;
+ ClusteredBinding maxRateBinding = null;
while (iter.hasNext())
{
- BalancedBinding binding = (BalancedBinding)iter.next();
+ ClusteredBinding binding = (ClusteredBinding)iter.next();
if (!binding.getNodeId().equals(localNodeId))
{
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BindRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BindRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/BindRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,6 +21,11 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.messaging.util.StreamUtils;
+
/**
* A BindRequest
*
@@ -30,10 +35,8 @@
* $Id$
*
*/
-class BindRequest implements ClusterRequest
+class BindRequest extends ClusterRequest
{
- private static final long serialVersionUID = -2881616453863261327L;
-
private String nodeId;
private String queueName;
@@ -46,6 +49,12 @@
private boolean durable;
+ static final byte TYPE = 1;
+
+ BindRequest()
+ {
+ }
+
BindRequest(String nodeId, String queueName, String condition, String filterString,
long channelId, boolean durable)
{
@@ -68,4 +77,39 @@
filterString, channelId, durable);
}
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ nodeId = in.readUTF();
+
+ queueName = in.readUTF();
+
+ condition = in.readUTF();
+
+ filterString = (String)StreamUtils.readObject(in, false);
+
+ channelId = in.readLong();
+
+ durable = in.readBoolean();
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(nodeId);
+
+ out.writeUTF(queueName);
+
+ out.writeUTF(condition);
+
+ StreamUtils.writeObject(out, filterString, false, false);
+
+ out.writeLong(channelId);
+
+ out.writeBoolean(durable);
+ }
}
Deleted: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckMessage.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckMessage.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin.postoffice.cluster;
-
-/**
- * A CheckMessage
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-class CheckMessage implements ClusterRequest
-{
- private static final long serialVersionUID = 6254127318656179872L;
-
- private String nodeId;
-
- CheckMessage(String nodeId)
- {
- this.nodeId = nodeId;
- }
-
- public void execute(PostOfficeInternal office) throws Exception
- {
- office.check(nodeId);
- }
-}
Added: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/CheckRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.plugin.postoffice.cluster;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+
+/**
+ * A CheckMessage
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+class CheckRequest extends ClusterRequest
+{
+ private String nodeId;
+
+ static final int TYPE = 2;
+
+ CheckRequest()
+ {
+ }
+
+ CheckRequest(String nodeId)
+ {
+ this.nodeId = nodeId;
+ }
+
+ public void execute(PostOfficeInternal office) throws Exception
+ {
+ office.check(nodeId);
+ }
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws IOException
+ {
+ nodeId = in.readUTF();
+ }
+
+ public void write(DataOutputStream out) throws IOException
+ {
+ out.writeUTF(nodeId);
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,8 +21,10 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
-import java.io.Serializable;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import org.jboss.messaging.util.Streamable;
/**
*
@@ -34,7 +36,84 @@
* $Id$
*
*/
-interface ClusterRequest extends Serializable
+abstract class ClusterRequest implements Streamable
{
- void execute(PostOfficeInternal office) throws Exception;
+ /*
+ * Factory method
+ */
+ static ClusterRequest createFromStream(DataInputStream dais) throws Exception
+ {
+ byte type = dais.readByte();
+
+ ClusterRequest request = null;
+
+ switch (type)
+ {
+ case BindRequest.TYPE:
+ {
+ request = new BindRequest();
+ break;
+ }
+ case CheckRequest.TYPE:
+ {
+ request = new CheckRequest();
+ break;
+ }
+ case MessageRequest.TYPE:
+ {
+ request = new MessageRequest();
+ break;
+ }
+ case MessagesRequest.TYPE:
+ {
+ request = new MessagesRequest();
+ break;
+ }
+ case MoveTransactionRequest.TYPE:
+ {
+ request = new MoveTransactionRequest();
+ break;
+ }
+ case QueueStatsRequest.TYPE:
+ {
+ request = new QueueStatsRequest();
+ break;
+ }
+ case SendNodeIdRequest.TYPE:
+ {
+ request = new SendNodeIdRequest();
+ break;
+ }
+ case SendTransactionRequest.TYPE:
+ {
+ request = new SendTransactionRequest();
+ break;
+ }
+ case UnbindRequest.TYPE:
+ {
+ request = new UnbindRequest();
+ break;
+ }
+ default:
+ {
+ throw new IllegalArgumentException("Invalid type: " + type);
+ }
+ }
+
+ request.read(dais);
+
+ return request;
+ }
+
+ public static void writeToStream(DataOutputStream daos, ClusterRequest request) throws Exception
+ {
+ daos.writeByte(request.getType());
+
+ request.write(daos);
+ }
+
+ abstract void execute(PostOfficeInternal office) throws Exception;
+
+ abstract byte getType();
+
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterTransaction.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterTransaction.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusterTransaction.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -30,7 +30,7 @@
* $Id$
*
*/
-public interface ClusterTransaction
+interface ClusterTransaction
{
void commit(PostOfficeInternal office) throws Exception;
}
Added: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBinding.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBinding.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBinding.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.plugin.postoffice.cluster;
+
+import org.jboss.messaging.core.plugin.contract.Binding;
+import org.jboss.messaging.util.Streamable;
+
+/**
+ *
+ * A ClusteredBinding
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public interface ClusteredBinding extends Binding, Streamable
+{
+ double getConsumptionRate();
+
+ int getMessageCount();
+
+ void setConsumptionRate(double rate);
+
+ void setMessageCount(int count);
+}
Added: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBindingImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBindingImpl.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredBindingImpl.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.plugin.postoffice.cluster;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.messaging.core.plugin.postoffice.BindingImpl;
+
+/**
+ *
+ * A ClusteredBindingImpl
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ClusteredBindingImpl extends BindingImpl implements ClusteredBinding
+{
+ private double consumptionRate;
+
+ private int messageCount;
+
+ public ClusteredBindingImpl()
+ {
+ }
+
+ public ClusteredBindingImpl(String nodeId, String queueName, String condition, String selector, long channelId, boolean durable)
+ {
+ super(nodeId, queueName, condition, selector, channelId, durable);
+ }
+
+ public double getConsumptionRate()
+ {
+ return consumptionRate;
+ }
+
+ public int getMessageCount()
+ {
+ return messageCount;
+ }
+
+ public void setConsumptionRate(double consumptionRate)
+ {
+ this.consumptionRate = consumptionRate;
+ }
+
+ public void setMessageCount(int messageCount)
+ {
+ this.messageCount = messageCount;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ super.read(in);
+
+ consumptionRate = in.readDouble();
+
+ messageCount = in.readInt();
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ super.write(out);
+
+ out.writeDouble(consumptionRate);
+
+ out.writeInt(messageCount);
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredPostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredPostOfficeImpl.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredPostOfficeImpl.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,6 +21,10 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -44,6 +48,7 @@
import org.jboss.messaging.core.plugin.postoffice.PostOfficeImpl;
import org.jboss.messaging.core.tx.Transaction;
import org.jboss.messaging.core.tx.TransactionRepository;
+import org.jboss.messaging.util.StreamUtils;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.JChannel;
@@ -55,7 +60,6 @@
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.MessageDispatcher;
import org.jgroups.blocks.RequestHandler;
-import org.jgroups.util.Util;
import org.w3c.dom.Element;
/**
@@ -307,7 +311,7 @@
public void recover() throws Exception
{
//We send a "check" message to all nodes of the cluster
- asyncSendRequest(new CheckMessage(nodeId));
+ asyncSendRequest(new CheckRequest(nodeId));
}
public boolean route(MessageReference ref, String condition, Transaction tx) throws Exception
@@ -515,7 +519,7 @@
throw new IllegalArgumentException(this.nodeId + "Binding already exists for node Id " + nodeId + " queue name " + queueName);
}
- binding = new BalancedBindingImpl(nodeId, queueName, condition, filterString,
+ binding = new ClusteredBindingImpl(nodeId, queueName, condition, filterString,
channelID, durable);
binding.activate();
@@ -682,8 +686,9 @@
*/
public void asyncSendRequest(ClusterRequest request) throws Exception
{
- //TODO - handle serialization more efficiently
- asyncChannel.send(new Message(null, null, request));
+ byte[] bytes = writeRequest(request);
+
+ asyncChannel.send(new Message(null, null, bytes));
}
/*
@@ -693,7 +698,9 @@
{
Address address = (Address)nodeIdAddressMap.get(nodeId);
- Message m = new Message(address, null, request);
+ byte[] bytes = writeRequest(request);
+
+ Message m = new Message(address, null, bytes);
//TODO - handle serialization more efficiently
asyncChannel.send(m);
@@ -835,9 +842,9 @@
while (iter.hasNext())
{
- BalancedBinding bb = (BalancedBinding)iter.next();
+ ClusteredBinding bb = (ClusteredBinding)iter.next();
- MeasuredQueue q = (MeasuredQueue)bb.getQueue();
+ ClusteredQueue q = (ClusteredQueue)bb.getQueue();
//We don't bother sending the stat if there is less than STATS_DIFFERENCE_MARGIN_PERCENT % difference
@@ -924,7 +931,7 @@
{
QueueStats st = (QueueStats)iter.next();
- BalancedBinding bb = (BalancedBinding)nameMap.get(st.getQueueName());
+ ClusteredBinding bb = (ClusteredBinding)nameMap.get(st.getQueueName());
if (bb == null)
{
@@ -951,7 +958,7 @@
protected Binding createBinding(String nodeId, String queueName, String condition, String filter,
long channelId, boolean durable)
{
- return new BalancedBindingImpl(nodeId, queueName, condition, filter,
+ return new ClusteredBindingImpl(nodeId, queueName, condition, filter,
channelId, durable);
}
@@ -986,7 +993,9 @@
{
//TODO - handle serialization more efficiently
- Message message = new Message(null, null, request);
+ byte[] bytes = StreamUtils.toBytes(request);
+
+ Message message = new Message(null, null, bytes);
controlMessageDispatcher.castMessage(null, message, GroupRequest.GET_ALL, castTimeout);
}
@@ -1123,15 +1132,17 @@
SharedState state = new SharedState(bindings, nodeIdAddressMap);
- byte[] bytes = Util.objectToByteBuffer(state);
-
+ byte[] bytes = StreamUtils.toBytes(state);
+
return bytes;
}
private void processStateBytes(byte[] bytes) throws Exception
{
- SharedState state = (SharedState)Util.objectFromByteBuffer(bytes);
+ SharedState state = new SharedState();
+ StreamUtils.fromBytes(state, bytes);
+
nameMaps.clear();
conditionMap.clear();
@@ -1168,7 +1179,7 @@
Transaction tx = tr.createTransaction();
- List dels = ((MeasuredQueue)fromQueue).getDeliveries(num);
+ List dels = ((ClusteredQueue)fromQueue).getDeliveries(num);
Iterator iter = dels.iterator();
@@ -1187,6 +1198,32 @@
}
+ private byte[] writeRequest(ClusterRequest request) throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
+
+ DataOutputStream daos = new DataOutputStream(baos);
+
+ ClusterRequest.writeToStream(daos, request);
+
+ daos.flush();
+
+ return baos.toByteArray();
+ }
+
+ private ClusterRequest readRequest(byte[] bytes) throws Exception
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+
+ DataInputStream dais = new DataInputStream(bais);
+
+ ClusterRequest request = ClusterRequest.createFromStream(dais);
+
+ dais.close();
+
+ return request;
+ }
+
// Inner classes -------------------------------------------------------------------
/*
@@ -1352,9 +1389,10 @@
{
try
{
- //TODO handle deserialization more efficiently
- ClusterRequest request = (ClusterRequest)message.getObject();
+ byte[] bytes = message.getBuffer();
+ ClusterRequest request = readRequest(bytes);
+
request.execute(ClusteredPostOfficeImpl.this);
}
catch (Exception e)
@@ -1377,13 +1415,13 @@
private class PostOfficeRequestHandler implements RequestHandler
{
public Object handle(Message message)
- {
- //TODO handle deserialization more efficiently
-
- ClusterRequest request = (ClusterRequest)message.getObject();
-
+ {
try
- {
+ {
+ byte[] bytes = message.getBuffer();
+
+ ClusterRequest request = readRequest(bytes);
+
request.execute(ClusteredPostOfficeImpl.this);
}
catch (Exception e)
Added: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredQueue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredQueue.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/ClusteredQueue.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.plugin.postoffice.cluster;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.messaging.core.Delivery;
+import org.jboss.messaging.core.Filter;
+import org.jboss.messaging.core.MessageReference;
+import org.jboss.messaging.core.SimpleDelivery;
+import org.jboss.messaging.core.local.Queue;
+import org.jboss.messaging.core.plugin.contract.MessageStore;
+import org.jboss.messaging.core.plugin.contract.PersistenceManager;
+
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+
+/**
+ *
+ * A ClusteredQueue
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ClusteredQueue extends Queue
+{
+ private static final int MIN_PERIOD = 1000;
+
+ private long lastTime;
+
+ private double lastGrowthRate;
+
+ private volatile int numberAdded;
+
+ private volatile int numberConsumed;
+
+ public ClusteredQueue(long id, MessageStore ms, PersistenceManager pm, boolean acceptReliableMessages, boolean recoverable, int fullSize, int pageSize, int downCacheSize, QueuedExecutor executor, Filter filter)
+ {
+ super(id, ms, pm, acceptReliableMessages, recoverable, fullSize, pageSize,
+ downCacheSize, executor, filter);
+
+ lastTime = System.currentTimeMillis();
+
+ numberAdded = numberConsumed = 0;
+ }
+
+ /**
+ *
+ * @return The rate of growth in messages per second of the queue
+ * Rate of growth is defined as follows:
+ * growth = (number of messages added - number of messages consumed) / time
+ */
+ public synchronized double getGrowthRate()
+ {
+ long now = System.currentTimeMillis();
+
+ long period = now - lastTime;
+
+ if (period <= MIN_PERIOD)
+ {
+ //Cache the value to avoid recalculating too often
+ return lastGrowthRate;
+ }
+
+ lastGrowthRate = 1000 * (numberAdded - numberConsumed) / ((double)period);
+
+ lastTime = now;
+
+ numberAdded = numberConsumed = 0;
+
+ return lastGrowthRate;
+ }
+
+ public List getDeliveries(int number) throws Exception
+ {
+ List dels = new ArrayList();
+
+ synchronized (refLock)
+ {
+ synchronized (deliveryLock)
+ {
+ MessageReference ref;
+
+ while ((ref = removeFirstInMemory()) != null)
+ {
+ SimpleDelivery del = new SimpleDelivery(this, ref);
+
+ deliveries.add(del);
+
+ dels.add(del);
+ }
+ return dels;
+ }
+ }
+ }
+
+ protected void addReferenceInMemory(MessageReference ref) throws Exception
+ {
+ super.addReferenceInMemory(ref);
+
+ //This is ok, since the channel ensures only one thread calls this method at once
+ numberAdded++;
+ }
+
+ protected boolean acknowledgeInMemory(Delivery d)
+ {
+ boolean acked = super.acknowledgeInMemory(d);
+
+ // This is ok, since the channel ensures only one thread calls this method at once
+ numberConsumed--;
+
+ return acked;
+ }
+}
Deleted: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MeasuredQueue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MeasuredQueue.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MeasuredQueue.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.plugin.postoffice.cluster;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.messaging.core.Delivery;
-import org.jboss.messaging.core.Filter;
-import org.jboss.messaging.core.MessageReference;
-import org.jboss.messaging.core.SimpleDelivery;
-import org.jboss.messaging.core.local.Queue;
-import org.jboss.messaging.core.plugin.contract.MessageStore;
-import org.jboss.messaging.core.plugin.contract.PersistenceManager;
-
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-
-/**
- *
- * A MeasuredQueue
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class MeasuredQueue extends Queue
-{
- private static final int MIN_PERIOD = 1000;
-
- private long lastTime;
-
- private double lastGrowthRate;
-
- private volatile int numberAdded;
-
- private volatile int numberConsumed;
-
- public MeasuredQueue(long id, MessageStore ms, PersistenceManager pm, boolean acceptReliableMessages, boolean recoverable, int fullSize, int pageSize, int downCacheSize, QueuedExecutor executor, Filter filter)
- {
- super(id, ms, pm, acceptReliableMessages, recoverable, fullSize, pageSize,
- downCacheSize, executor, filter);
-
- lastTime = System.currentTimeMillis();
-
- numberAdded = numberConsumed = 0;
- }
-
- /**
- *
- * @return The rate of growth in messages per second of the queue
- * Rate of growth is defined as follows:
- * growth = (number of messages added - number of messages consumed) / time
- */
- public synchronized double getGrowthRate()
- {
- long now = System.currentTimeMillis();
-
- long period = now - lastTime;
-
- if (period <= MIN_PERIOD)
- {
- //Cache the value to avoid recalculating too often
- return lastGrowthRate;
- }
-
- lastGrowthRate = 1000 * (numberAdded - numberConsumed) / ((double)period);
-
- lastTime = now;
-
- numberAdded = numberConsumed = 0;
-
- return lastGrowthRate;
- }
-
- public List getDeliveries(int number) throws Exception
- {
- List dels = new ArrayList();
-
- synchronized (refLock)
- {
- synchronized (deliveryLock)
- {
- MessageReference ref;
-
- while ((ref = removeFirstInMemory()) != null)
- {
- SimpleDelivery del = new SimpleDelivery(this, ref);
-
- deliveries.add(del);
-
- dels.add(del);
- }
- return dels;
- }
- }
- }
-
- protected void addReferenceInMemory(MessageReference ref) throws Exception
- {
- super.addReferenceInMemory(ref);
-
- //This is ok, since the channel ensures only one thread calls this method at once
- numberAdded++;
- }
-
- protected boolean acknowledgeInMemory(Delivery d)
- {
- boolean acked = super.acknowledgeInMemory(d);
-
- // This is ok, since the channel ensures only one thread calls this method at once
- numberConsumed--;
-
- return acked;
- }
-}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageHolder.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageHolder.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageHolder.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,10 +21,14 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
-import java.io.Serializable;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.util.Map;
import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.message.MessageFactory;
+import org.jboss.messaging.util.StreamUtils;
+import org.jboss.messaging.util.Streamable;
/**
* A MessageHolder
@@ -35,7 +39,7 @@
* $Id$
*
*/
-class MessageHolder implements Serializable
+class MessageHolder implements Streamable
{
private String routingKey;
@@ -43,6 +47,10 @@
private Map queueNameToNodeIdMap;
+ public MessageHolder()
+ {
+ }
+
MessageHolder(String routingKey, Message message, Map queueNameToNodeIdMap)
{
this.routingKey = routingKey;
@@ -66,4 +74,25 @@
{
return queueNameToNodeIdMap;
}
+
+ public void read(DataInputStream in) throws Exception
+ {
+ routingKey = in.readUTF();
+
+ byte type = in.readByte();
+ Message msg = MessageFactory.createMessage(type);
+ msg.read(in);
+
+ queueNameToNodeIdMap = (Map)StreamUtils.readObject(in, false);
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(routingKey);
+
+ out.writeByte(message.getType());
+ message.write(out);
+
+ StreamUtils.writeObject(out, queueNameToNodeIdMap, true, false);
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessageRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,13 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.util.Map;
import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.message.MessageFactory;
+import org.jboss.messaging.util.StreamUtils;
/**
* A MessageRequest
@@ -36,9 +40,9 @@
* $Id$
*
*/
-class MessageRequest implements ClusterRequest
+class MessageRequest extends ClusterRequest
{
- private static final long serialVersionUID = 6681458404259394725L;
+ static final int TYPE = 3;
private String routingKey;
@@ -46,6 +50,10 @@
private Map queueNameNodeIdMap;
+ MessageRequest()
+ {
+ }
+
MessageRequest(String routingKey, Message message, Map queueNameNodeIdMap)
{
this.routingKey = routingKey;
@@ -58,5 +66,31 @@
public void execute(PostOfficeInternal office) throws Exception
{
office.routeFromCluster(message, routingKey, queueNameNodeIdMap);
- }
+ }
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ routingKey = in.readUTF();
+
+ byte type = in.readByte();
+ Message msg = MessageFactory.createMessage(type);
+ msg.read(in);
+
+ queueNameNodeIdMap = (Map)StreamUtils.readObject(in, false);
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(routingKey);
+
+ out.writeByte(message.getType());
+ message.write(out);
+
+ StreamUtils.writeObject(out, queueNameNodeIdMap, true, false);
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessagesRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessagesRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MessagesRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,13 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
/**
* A MessagesRequest
*
@@ -35,12 +39,16 @@
* $Id$
*
*/
-class MessagesRequest implements ClusterRequest
+class MessagesRequest extends ClusterRequest
{
- private static final long serialVersionUID = 3069447863470810127L;
+ static final int TYPE = 4;
private List messageHolders;
+ MessagesRequest()
+ {
+ }
+
MessagesRequest(List messageHolders)
{
this.messageHolders = messageHolders;
@@ -56,6 +64,33 @@
office.routeFromCluster(holder.getMessage(), holder.getRoutingKey(), holder.getQueueNameToNodeIdMap());
}
+ }
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ int size = in.readInt();
+ messageHolders = new ArrayList(size);
+ for (int i = 0; i < size; i++)
+ {
+ MessageHolder holder = new MessageHolder();
+ holder.read(in);
+ }
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeInt(messageHolders.size());
+ Iterator iter = messageHolders.iterator();
+ while (iter.hasNext())
+ {
+ MessageHolder holder = (MessageHolder)iter.next();
+ holder.write(out);
+ }
}
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveMessagesCallback.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveMessagesCallback.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveMessagesCallback.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -36,7 +36,7 @@
* $Id$
*
*/
-public class MoveMessagesCallback implements TxCallback
+class MoveMessagesCallback implements TxCallback
{
private List messages;
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveTransactionRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveTransactionRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/MoveTransactionRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,8 +21,15 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.message.MessageFactory;
+
/**
*
* A MoveTransactionRequest
@@ -35,10 +42,16 @@
*/
class MoveTransactionRequest extends TransactionRequest
{
+ static final int TYPE = 5;
+
+ private String queueName;
+
private List messages;
- private String queueName;
-
+ MoveTransactionRequest()
+ {
+ }
+
MoveTransactionRequest(String nodeId, long txId, List messages, String queueName)
{
super(nodeId, txId, true);
@@ -57,6 +70,47 @@
{
office.addToQueue(queueName, messages);
}
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ super.read(in);
+
+ queueName = in.readUTF();
+
+ int size = in.readInt();
+
+ messages = new ArrayList(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ byte type = in.readByte();
+ Message msg = MessageFactory.createMessage(type);
+ msg.read(in);
+ messages.add(msg);
+ }
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ super.write(out);
+
+ out.writeUTF(queueName);
+
+ out.writeInt(messages.size());
+
+ Iterator iter = messages.iterator();
+ while (iter.hasNext())
+ {
+ Message message = (Message)iter.next();
+ out.writeByte(message.getType());
+ message.write(out);
+ }
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStats.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStats.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStats.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,8 +21,11 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
-import java.io.Serializable;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import org.jboss.messaging.util.Streamable;
+
/**
* A QueueStats
*
@@ -32,7 +35,7 @@
* $Id$
*
*/
-public class QueueStats implements Serializable
+class QueueStats implements Streamable
{
private String queueName;
@@ -40,7 +43,11 @@
private int messageCount;
- public QueueStats(String queueName, double consumptionRate, int messageCount)
+ public QueueStats()
+ {
+ }
+
+ QueueStats(String queueName, double consumptionRate, int messageCount)
{
this.queueName = queueName;
@@ -49,18 +56,36 @@
this.messageCount = messageCount;
}
- public double getConsumptionRate()
+ double getConsumptionRate()
{
return consumptionRate;
}
- public int getMessageCount()
+ int getMessageCount()
{
return messageCount;
}
- public String getQueueName()
+ String getQueueName()
{
return queueName;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ queueName = in.readUTF();
+
+ consumptionRate = in.readDouble();
+
+ messageCount = in.readInt();
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(queueName);
+
+ out.writeDouble(consumptionRate);
+
+ out.writeInt(messageCount);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStatsRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStatsRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/QueueStatsRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,8 +21,13 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+
/**
* A QueueStatsRequest
*
@@ -32,13 +37,19 @@
* $Id$
*
*/
-public class QueueStatsRequest implements ClusterRequest
+class QueueStatsRequest extends ClusterRequest
{
+ static final int TYPE = 6;
+
private String nodeId;
private List queueStats;
- public QueueStatsRequest(String nodeId, List stats)
+ QueueStatsRequest()
+ {
+ }
+
+ QueueStatsRequest(String nodeId, List stats)
{
this.nodeId = nodeId;
@@ -49,4 +60,43 @@
{
office.updateQueueStats(nodeId, queueStats);
}
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+
+ public void read(DataInputStream in) throws Exception
+ {
+ nodeId = in.readUTF();
+
+ int size = in.readInt();
+
+ queueStats = new ArrayList(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ QueueStats stats = new QueueStats();
+
+ stats.read(in);
+
+ queueStats.add(stats);
+ }
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(nodeId);
+
+ out.writeInt(queueStats.size());
+
+ Iterator iter = queueStats.iterator();
+ while (iter.hasNext())
+ {
+ QueueStats stats = (QueueStats)iter.next();
+
+ stats.write(out);
+ }
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendNodeIdRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendNodeIdRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendNodeIdRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,6 +21,9 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
import org.jgroups.Address;
/**
@@ -33,14 +36,18 @@
* $Id$
*
*/
-class SendNodeIdRequest implements ClusterRequest
+class SendNodeIdRequest extends ClusterRequest
{
- private static final long serialVersionUID = -3463428410402454526L;
+ static final int TYPE = 7;
private Address address;
private String nodeId;
+ SendNodeIdRequest()
+ {
+ }
+
SendNodeIdRequest(Address address, String nodeId)
{
this.address = address;
@@ -52,4 +59,21 @@
{
office.handleAddressNodeMapping(address, nodeId);
}
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendTransactionRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendTransactionRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SendTransactionRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,13 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
/**
* A SendTransactionRequest
*
@@ -37,8 +41,14 @@
*/
class SendTransactionRequest extends TransactionRequest
{
+ static final int TYPE = 8;
+
private List messageHolders;
-
+
+ SendTransactionRequest()
+ {
+ }
+
SendTransactionRequest(String nodeId, long txId, List messageHolders)
{
super(nodeId, txId, true);
@@ -62,5 +72,34 @@
office.routeFromCluster(holder.getMessage(), holder.getRoutingKey(), holder.getQueueNameToNodeIdMap());
}
}
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ super.read(in);
+ int size = in.readInt();
+ messageHolders = new ArrayList(size);
+ for (int i = 0; i < size; i++)
+ {
+ MessageHolder holder = new MessageHolder();
+ holder.read(in);
+ }
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ super.write(out);
+ out.writeInt(messageHolders.size());
+ Iterator iter = messageHolders.iterator();
+ while (iter.hasNext())
+ {
+ MessageHolder holder = (MessageHolder)iter.next();
+ holder.write(out);
+ }
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SharedState.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SharedState.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/SharedState.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,10 +21,17 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
-import java.io.Serializable;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.jboss.messaging.core.plugin.contract.Binding;
+import org.jboss.messaging.util.StreamUtils;
+import org.jboss.messaging.util.Streamable;
+
/**
* A SharedState
*
@@ -34,14 +41,16 @@
* $Id$
*
*/
-class SharedState implements Serializable
-{
- private static final long serialVersionUID = 7782131373080845107L;
-
+class SharedState implements Streamable
+{
private List bindings;
private Map nodeIdAddressMap;
+ SharedState()
+ {
+ }
+
SharedState(List bindings, Map nodeIdAddressMap)
{
this.bindings = bindings;
@@ -58,4 +67,39 @@
{
return nodeIdAddressMap;
}
+
+ public void read(DataInputStream in) throws Exception
+ {
+ int size = in.readInt();
+ bindings = new ArrayList(size);
+ for (int i = 0; i < size; i++)
+ {
+ ClusteredBinding bb = new ClusteredBindingImpl();
+ bb.read(in);
+ bindings.add(bb);
+ }
+
+ nodeIdAddressMap = (Map)StreamUtils.readObject(in, false);
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeInt(bindings.size());
+ Iterator iter = bindings.iterator();
+ while (iter.hasNext())
+ {
+ Binding binding = (Binding)iter.next();
+
+ if (!(binding instanceof ClusteredBinding))
+ {
+ throw new IllegalStateException("Can only cluster clustered bindings");
+ }
+
+ ClusteredBinding bb = (ClusteredBinding)binding;
+
+ bb.write(out);
+ }
+
+ StreamUtils.writeObject(out, nodeIdAddressMap, true, false);
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionId.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,6 +21,11 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.messaging.util.Streamable;
+
/**
* A Transactionid
*
@@ -30,7 +35,7 @@
* $Id$
*
*/
-class TransactionId
+class TransactionId implements Streamable
{
private String nodeId;
@@ -38,6 +43,10 @@
private int hash;
+ TransactionId()
+ {
+ }
+
TransactionId(String nodeId, long txId)
{
this.nodeId = nodeId;
@@ -92,4 +101,22 @@
hash = 37 * hash + nodeId.hashCode();
}
+
+ public void read(DataInputStream in) throws Exception
+ {
+ nodeId = in.readUTF();
+
+ txId = in.readLong();
+
+ hash = in.readInt();
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(nodeId);
+
+ out.writeLong(txId);
+
+ out.writeInt(hash);
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/TransactionRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,7 +21,11 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+
/**
* A TransactionRequest
*
@@ -31,13 +35,17 @@
* $Id$
*
*/
-abstract class TransactionRequest implements ClusterRequest, ClusterTransaction
+abstract class TransactionRequest extends ClusterRequest implements ClusterTransaction
{
private String nodeId;
private long txId;
private boolean hold;
+
+ TransactionRequest()
+ {
+ }
TransactionRequest(String nodeId, long txId, boolean hold)
{
@@ -61,6 +69,24 @@
office.commitTransaction(id);
}
}
+
+ public void read(DataInputStream in) throws Exception
+ {
+ nodeId = in.readUTF();
+
+ txId = in.readLong();
+
+ hold = in.readBoolean();
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(nodeId);
+
+ out.writeLong(txId);
+
+ out.writeBoolean(hold);
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/UnbindRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/UnbindRequest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/UnbindRequest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,6 +21,8 @@
*/
package org.jboss.messaging.core.plugin.postoffice.cluster;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
/**
* A UnbindRequest
@@ -31,13 +33,17 @@
* $Id$
*
*/
-class UnbindRequest implements ClusterRequest
+class UnbindRequest extends ClusterRequest
{
- private static final long serialVersionUID = 6597644036507360965L;
+ static final int TYPE = 9;
private String nodeId;
private String queueName;
+
+ UnbindRequest()
+ {
+ }
UnbindRequest(String nodeId, String queueName)
{
@@ -49,5 +55,24 @@
public void execute(PostOfficeInternal office) throws Exception
{
office.removeBindingFromCluster(nodeId, queueName);
+ }
+
+ public byte getType()
+ {
+ return TYPE;
+ }
+
+ public void read(DataInputStream in) throws Exception
+ {
+ nodeId = in.readUTF();
+
+ queueName = in.readUTF();
+ }
+
+ public void write(DataOutputStream out) throws Exception
+ {
+ out.writeUTF(nodeId);
+
+ out.writeUTF(queueName);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,8 +21,6 @@
*/
package org.jboss.messaging.core.tx;
-import java.io.Serializable;
-
import javax.transaction.xa.Xid;
/**
@@ -34,10 +32,8 @@
*
* @version $Revision 1.1 $
*/
-public class XidImpl implements Xid, Serializable
+public class XidImpl implements Xid
{
- private static final long serialVersionUID = -8400538772058491159L;
-
protected byte[] branchQualifier;
protected int formatId;
Modified: trunk/src/main/org/jboss/messaging/util/NotYetImplementedException.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/NotYetImplementedException.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/util/NotYetImplementedException.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -31,6 +31,8 @@
{
// Constants -----------------------------------------------------
+ private static final long serialVersionUID = 3795167990062836913L;
+
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/util/SafeUTF.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/SafeUTF.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/util/SafeUTF.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,9 @@
*/
package org.jboss.messaging.util;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
/**
*
@@ -73,7 +73,7 @@
this.chunkSize = chunkSize;
}
- public void safeWriteUTF(ObjectOutput out, String str) throws IOException
+ public void safeWriteUTF(DataOutputStream out, String str) throws IOException
{
if (str == null)
{
@@ -116,7 +116,7 @@
}
}
- public String safeReadUTF(ObjectInput in) throws IOException
+ public String safeReadUTF(DataInputStream in) throws IOException
{
boolean isNull = in.readByte() == NULL;
Modified: trunk/src/main/org/jboss/messaging/util/StreamUtils.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/StreamUtils.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/util/StreamUtils.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,9 +21,13 @@
*/
package org.jboss.messaging.util;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -32,6 +36,11 @@
import java.util.Map;
import java.util.Set;
+import org.jboss.serial.io.JBossObjectInputStream;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+
+
/**
* A StreamUtils
*
@@ -45,41 +54,71 @@
*/
public class StreamUtils
{
- protected static final byte BYTE = 0;
+ private static final int BUFFER_SIZE = 4096;
+
+ private static final byte NULL = 0;
+
+ private static final byte STRING = 1;
+
+ private static final byte MAP = 2;
+
+ private static final byte BYTE = 3;
- protected static final byte SHORT = 1;
+ private static final byte SHORT = 4;
- protected static final byte INT = 2;
+ private static final byte INT = 5;
- protected static final byte LONG = 3;
+ private static final byte LONG = 6;
- protected static final byte FLOAT = 4;
+ private static final byte FLOAT = 7;
- protected static final byte DOUBLE = 5;
+ private static final byte DOUBLE = 8;
- protected static final byte BOOLEAN = 6;
-
- protected static final byte STRING = 7;
-
- protected static final byte SERIALIZABLE = 8;
-
- protected static final byte NULL = 9;
+ private static final byte BOOLEAN = 9;
- protected static final byte BYTES = 10;
+ private static final byte BYTES = 10;
+
+ private static final byte LIST = 11;
- protected static final byte MAP = 11;
+ private static final byte SERIALIZABLE = 12;
- protected static final byte LIST = 12;
+ private static boolean useJBossSerialization = false;
- protected static final byte NOT_NULL = 13;
+ public static void setUseJBossSerialization(boolean use)
+ {
+ useJBossSerialization = use;
+ }
+
- public static Object readObject(ObjectInput in, boolean longStrings)
+ public static Object readObject(DataInputStream in, boolean longStrings)
throws IOException, ClassNotFoundException
{
byte type = in.readByte();
Object value = null;
switch (type)
{
+ case NULL:
+ {
+ value = null;
+ break;
+ }
+ case STRING :
+ if (longStrings)
+ {
+ //We cope with >= 64K Strings
+ value = SafeUTF.instance.safeReadUTF(in);
+ }
+ else
+ {
+ //Limited to < 64K Strings
+ value = in.readUTF();
+ }
+ break;
+ case MAP:
+ {
+ value = readMap(in, false);
+ break;
+ }
case BYTE :
value = new Byte(in.readByte());
break;
@@ -100,30 +139,13 @@
break;
case BOOLEAN :
value = in.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
- break;
- case STRING :
- if (longStrings)
- {
- //We cope with >= 64K Strings
- value = SafeUTF.instance.safeReadUTF(in);
- }
- else
- {
- //Limited to < 64K Strings
- value = in.readUTF();
- }
- break;
+ break;
case BYTES :
int size = in.readInt();
byte[] bytes = new byte[size];
in.readFully(bytes);
value = bytes;
- break;
- case MAP:
- {
- value = readMap(in, false);
- break;
- }
+ break;
case LIST:
{
value = readList(in);
@@ -131,14 +153,20 @@
}
case SERIALIZABLE:
{
- value = (Serializable)in.readObject();
+ ObjectInputStream ois;
+ if (useJBossSerialization)
+ {
+ ois = new JBossObjectInputStream(in);
+ }
+ else
+ {
+ ois = new ObjectInputStream(in);
+ }
+
+ value = (Serializable)ois.readObject();
+ ois.close();
break;
- }
- case NULL:
- {
- value = null;
- break;
- }
+ }
default :
{
throw new IllegalStateException("Unknown type: " + type);
@@ -147,10 +175,10 @@
return value;
}
- public static void writeObject(ObjectOutput out, Object object,
+ public static void writeObject(DataOutputStream out, Object object,
boolean containerTypes, boolean longStrings) throws IOException
{
- // We cheat with some often used types - more efficient than using object serialization
+ // more efficient than using object serialization for well known types
if (object == null)
{
out.writeByte(NULL);
@@ -169,6 +197,11 @@
out.writeUTF((String)object);
}
}
+ else if (containerTypes && object instanceof Map)
+ {
+ out.write(MAP);
+ writeMap(out, (Map)object, false);
+ }
else if (object instanceof Integer)
{
out.writeByte(INT);
@@ -215,16 +248,23 @@
{
out.write(LIST);
writeList(out, (List)object);
- }
- else if (containerTypes && object instanceof HashMap)
- {
- out.write(MAP);
- writeMap(out, (Map)object, false);
- }
+ }
else if (object instanceof Serializable)
{
out.writeByte(SERIALIZABLE);
- out.writeObject(object);
+ ObjectOutputStream oos;
+
+ if (useJBossSerialization)
+ {
+ oos = new JBossObjectOutputStream(out);
+ }
+ else
+ {
+ oos = new ObjectOutputStream(out);
+ }
+
+ oos.writeObject(object);
+ oos.close();
}
else
{
@@ -232,7 +272,7 @@
}
}
- public static void writeList(ObjectOutput out, List list) throws IOException
+ public static void writeList(DataOutputStream out, List list) throws IOException
{
out.writeInt(list.size());
Iterator iter = list.iterator();
@@ -243,7 +283,7 @@
}
}
- public static ArrayList readList(ObjectInput in) throws ClassNotFoundException, IOException
+ public static ArrayList readList(DataInputStream in) throws ClassNotFoundException, IOException
{
int size = in.readInt();
ArrayList list = new ArrayList(size);
@@ -255,7 +295,7 @@
return list;
}
- public static void writeMap(ObjectOutput out, Map map, boolean stringKeys) throws IOException
+ public static void writeMap(DataOutputStream out, Map map, boolean stringKeys) throws IOException
{
Set entrySet = map.entrySet();
out.writeInt(entrySet.size());
@@ -288,7 +328,7 @@
}
}
- public static HashMap readMap(ObjectInput in, boolean stringKeys) throws IOException, ClassNotFoundException
+ public static HashMap readMap(DataInputStream in, boolean stringKeys) throws IOException, ClassNotFoundException
{
int size = in.readInt();
HashMap m = new HashMap(size);
@@ -310,4 +350,29 @@
}
return m;
}
+
+ public static byte[] toBytes(Streamable streamable) throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(BUFFER_SIZE);
+
+ DataOutputStream daos = new DataOutputStream(baos);
+
+ streamable.write(daos);
+
+ daos.close();
+
+ return baos.toByteArray();
+ }
+
+ public static void fromBytes(Streamable streamable, byte[] bytes) throws Exception
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+
+ DataInputStream dais = new DataInputStream(bais);
+
+ streamable.read(dais);
+
+ dais.close();
+ }
+
}
Added: trunk/src/main/org/jboss/messaging/util/Streamable.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/Streamable.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/src/main/org/jboss/messaging/util/Streamable.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.util;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+/**
+ * A Streamable
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public interface Streamable
+{
+ void write(DataOutputStream out) throws Exception;
+
+ void read(DataInputStream in) throws Exception;
+}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -32,13 +32,13 @@
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Topic;
+import javax.management.ObjectName;
import javax.naming.InitialContext;
-import javax.management.ObjectName;
+import org.jboss.jms.util.XMLUtil;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.jms.util.XMLUtil;
/**
* Test JMS Security.
Modified: trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -23,8 +23,8 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import javax.jms.Connection;
import javax.jms.Destination;
@@ -143,7 +143,7 @@
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream dos = new ObjectOutputStream(bos);
+ DataOutputStream dos = new DataOutputStream(bos);
SafeUTF su = new SafeUTF(chunkSize);
@@ -155,7 +155,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream dis = new ObjectInputStream(bis);
+ DataInputStream dis = new DataInputStream(bis);
String s2 = su.safeReadUTF(dis);
@@ -166,7 +166,7 @@
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream dos = new ObjectOutputStream(bos);
+ DataOutputStream dos = new DataOutputStream(bos);
String s = "abcdefghijklmnopqrstuvwxyz";
@@ -180,7 +180,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream dis = new ObjectInputStream(bis);
+ DataInputStream dis = new DataInputStream(bis);
String s2 = su.safeReadUTF(dis);
Modified: trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -195,6 +195,7 @@
static class Wibble2 implements Serializable
{
+ private static final long serialVersionUID = -5146179676719808756L;
String s;
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -21,19 +21,18 @@
*/
package org.jboss.test.messaging.jms;
-import javax.naming.InitialContext;
-import javax.jms.Destination;
import javax.jms.Connection;
-import javax.jms.Session;
+import javax.jms.Destination;
+import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
-import javax.jms.Message;
+import javax.jms.Session;
import javax.jms.TextMessage;
+import javax.naming.InitialContext;
import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.tx.TransactionManagerImpl;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -88,7 +87,7 @@
{
ServerManagement.undeployQueue("Queue");
ServerManagement.undeployTopic("Topic");
- TransactionManagerImpl.getInstance().setState(TransactionManagerImpl.OPERATIONAL);
+ // TransactionManagerImpl.getInstance().setState(TransactionManagerImpl.OPERATIONAL);
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java 2006-09-13 22:33:43 UTC (rev 1288)
+++ trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java 2006-09-14 13:59:28 UTC (rev 1289)
@@ -23,9 +23,9 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.EOFException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -131,11 +131,9 @@
acknowledgeBatchMethod = sessionDelegate.getMethod("acknowledgeBatch", new Class[] { java.util.List.class });
cancelDeliveriesMethod = sessionDelegate.getMethod("cancelDeliveries", new Class[] { java.util.List.class });
-
-
+
//Consumer
-
-
+
moreMethod = consumerDelegate.getMethod("more", null);
//Connection
@@ -223,10 +221,7 @@
{
wf.testHandleMessageResponse();
}
-
-
-
-
+
// Public --------------------------------------------------------
public static class SerializableObject implements Serializable
@@ -235,8 +230,7 @@
private static final long serialVersionUID = 1L;
public SerializableObject()
- {
-
+ {
}
SerializableObject(String s, long l)
@@ -247,8 +241,7 @@
public String s;
- public long l;
-
+ public long l;
}
/**
@@ -280,7 +273,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -290,7 +283,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
//Check the bytes
@@ -309,7 +302,7 @@
//Next should be the externalized AckInfo
AckInfo ack2 = new AckInfo();
- ack2.readExternal(ois);
+ ack2.read(ois);
assertEquals(ack.getMessageID(), ack2.getMessageID());
assertEquals(ack.getConsumerID(), ack2.getConsumerID());
@@ -327,7 +320,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -377,7 +370,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -387,7 +380,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
//Check the bytes
@@ -409,21 +402,21 @@
//Now the acks
AckInfo ack = new AckInfo();
- ack.readExternal(ois);
+ ack.read(ois);
assertEquals(ackA.getMessageID(), ack.getMessageID());
assertEquals(ackA.getConsumerID(), ack.getConsumerID());
ack = new AckInfo();
- ack.readExternal(ois);
+ ack.read(ois);
assertEquals(ackB.getMessageID(), ack.getMessageID());
assertEquals(ackB.getConsumerID(), ack.getConsumerID());
ack = new AckInfo();
- ack.readExternal(ois);
+ ack.read(ois);
assertEquals(ackC.getMessageID(), ack.getMessageID());
assertEquals(ackC.getConsumerID(), ack.getConsumerID());
@@ -442,7 +435,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -500,7 +493,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -510,7 +503,7 @@
// Check the bytes
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
// First byte should be version
byte version = ois.readByte();
@@ -519,7 +512,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -561,7 +554,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -569,7 +562,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
// First byte should be version
byte version = ois.readByte();
@@ -578,7 +571,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
@@ -605,7 +598,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -613,7 +606,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
// First byte should be version
byte version = ois.readByte();
@@ -622,7 +615,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
@@ -660,7 +653,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -670,7 +663,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
//Check the bytes
@@ -694,7 +687,7 @@
//Next should come the message
JBossMessage m2 = new JBossMessage();
- m2.readExternal(ois);
+ m2.read(ois);
//should be eos
@@ -711,7 +704,7 @@
MessageTest.ensureEquivalent(m, m2);
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -760,7 +753,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -770,7 +763,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
//Check the bytes
@@ -790,7 +783,7 @@
TransactionRequest req = new TransactionRequest();
- req.readExternal(ois);
+ req.read(ois);
//should be eos
@@ -816,7 +809,7 @@
assertEquals(info.getMessageID(), info2.getMessageID());
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -871,7 +864,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -881,7 +874,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
//Check the bytes
@@ -908,9 +901,9 @@
AckInfo rack2 = new AckInfo();
- rack1.readExternal(ois);
+ rack1.read(ois);
- rack2.readExternal(ois);
+ rack2.read(ois);
assertEquals(ack1.getConsumerID(), rack1.getConsumerID());
@@ -934,7 +927,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -970,14 +963,14 @@
InvocationResponse resp = new InvocationResponse(null, mm, false, null);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(resp, oos);
oos.flush();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
// First byte should be version
assertEquals(77, ois.readByte());
@@ -1002,7 +995,7 @@
// END of the invalid section
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
@@ -1032,7 +1025,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -1042,7 +1035,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
//Check the bytes
@@ -1070,7 +1063,7 @@
}
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -1113,7 +1106,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
MessagingMarshallable mm = new MessagingMarshallable((byte)77, dr);
@@ -1125,7 +1118,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
//Check the bytes
@@ -1152,7 +1145,7 @@
//And now the message itself
JBossMessage r1 = new JBossMessage();
- r1.readExternal(ois);
+ r1.read(ois);
//Next byte should be type
@@ -1164,7 +1157,7 @@
//And now the message itself
JBossMessage r2 = new JBossMessage();
- r2.readExternal(ois);
+ r2.read(ois);
//Next byte should be type
@@ -1176,7 +1169,7 @@
//And now the message itself
JBossMessage r3 = new JBossMessage();
- r3.readExternal(ois);
+ r3.read(ois);
MessageTest.ensureEquivalent(m1, r1);
MessageTest.ensureEquivalent(m2, r2);
@@ -1195,7 +1188,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
@@ -1237,7 +1230,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -1245,7 +1238,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
// First byte should be version
assertEquals(77, ois.readByte());
@@ -1256,7 +1249,7 @@
IdBlock block2 = new IdBlock();
- block2.readExternal(ois);
+ block2.read(ois);
assertEquals(block.getLow(), block2.getLow());
assertEquals(block.getHigh(), block2.getHigh());
@@ -1274,7 +1267,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
@@ -1298,7 +1291,7 @@
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ DataOutputStream oos = new DataOutputStream(bos);
wf.write(ir, oos);
@@ -1306,7 +1299,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
+ DataInputStream ois = new DataInputStream(bis);
// First byte should be version
assertEquals(77, ois.readByte());
@@ -1317,7 +1310,7 @@
HandleMessageResponse h2 = new HandleMessageResponse();
- h2.readExternal(ois);
+ h2.read(ois);
assertEquals(h.clientIsFull(), h2.clientIsFull());
assertEquals(h.getNumberAccepted(), h2.getNumberAccepted());
@@ -1335,7 +1328,7 @@
bis.reset();
- ois = new ObjectInputStream(bis);
+ ois = new DataInputStream(bis);
InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
More information about the jboss-cvs-commits
mailing list