[jboss-cvs] JBoss Messaging SVN: r1702 - in branches/Branch_Client_Failover_Experiment/src/main/org/jboss: jms/client/delegate messaging/core/plugin/contract messaging/core/plugin/postoffice messaging/core/plugin/postoffice/cluster
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 4 05:37:03 EST 2006
Author: ovidiu.feodorov at jboss.com
Date: 2006-12-04 05:36:59 -0500 (Mon, 04 Dec 2006)
New Revision: 1702
Modified:
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/PostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeAddressInfo.java
branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PutReplicantRequest.java
Log:
refactoring, logging improvments
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2006-12-04 10:35:01 UTC (rev 1701)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2006-12-04 10:36:59 UTC (rev 1702)
@@ -275,7 +275,7 @@
public String toString()
{
- return "ClientConnectionFactoryDelegate[objectId=" + id + "]";
+ return "ClientConnectionFactoryDelegate[" + id + "]";
}
//This MUST ONLY be used in testing
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/PostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/PostOffice.java 2006-12-04 10:35:01 UTC (rev 1701)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/contract/PostOffice.java 2006-12-04 10:36:59 UTC (rev 1702)
@@ -42,13 +42,16 @@
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision: 1.1 $</tt>
*
* $Id$
*
*/
public interface PostOffice extends MessagingComponent
-{
+{
+ String getOfficeName();
+
Binding bindQueue(String condition, Queue queue) throws Exception;
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java 2006-12-04 10:35:01 UTC (rev 1701)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java 2006-12-04 10:36:59 UTC (rev 1702)
@@ -51,6 +51,7 @@
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision: 1.1 $</tt>
*
* $Id$
@@ -122,7 +123,7 @@
public void start() throws Exception
{
- log.debug(this + " starting");
+ if (trace) { log.trace(this + " starting"); }
super.start();
@@ -142,10 +143,15 @@
super.stop();
- if (trace) { log.trace(this + " stopped"); }
+ log.debug(this + " stopped");
}
- // PostOffice implementation ---------------------------------------
+ // PostOffice implementation ---------------------------------------
+
+ public String getOfficeName()
+ {
+ return officeName;
+ }
public Binding bindQueue(String condition, Queue queue) throws Exception
{
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-12-04 10:35:01 UTC (rev 1701)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-12-04 10:36:59 UTC (rev 1702)
@@ -82,6 +82,7 @@
* A DefaultClusteredPostOffice
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision: 1.1 $</tt>
*
* $Id$
@@ -112,14 +113,6 @@
private MessageDispatcher controlMessageDispatcher;
- private MessageListener controlMessageListener;
-
- private Receiver dataReceiver;
-
- private MembershipListener controlMembershipListener;
-
- private RequestHandler requestHandler;
-
private Object setStateLock = new Object();
private boolean stateSet;
@@ -297,6 +290,8 @@
{
log.warn("Attempt to start() but " + this + " is already started");
}
+
+ if (trace) { log.trace(this + " starting"); }
if (syncChannelConfigElement != null)
{
@@ -314,19 +309,14 @@
asyncChannel.setOpt(Channel.LOCAL, Boolean.FALSE);
- controlMessageListener = new ControlMessageListener();
+ MessageListener cml = new ControlMessageListener();
+ MembershipListener ml = new ControlMembershipListener();
+ RequestHandler rh = new PostOfficeRequestHandler();
- requestHandler = new PostOfficeRequestHandler();
-
- controlMembershipListener = new ControlMembershipListener();
-
- this.controlMessageDispatcher =
- new MessageDispatcher(syncChannel, controlMessageListener,
- controlMembershipListener, requestHandler, true);
+ this.controlMessageDispatcher = new MessageDispatcher(syncChannel, cml, ml, rh, true);
- this.dataReceiver = new DataReceiver();
-
- asyncChannel.setReceiver(dataReceiver);
+ Receiver r = new DataReceiver();
+ asyncChannel.setReceiver(r);
syncChannel.connect(groupName);
@@ -344,10 +334,9 @@
statsSender.start();
- started = true;
-
- if (trace) { log.trace("Started " + this + " with sync address " + syncAddress +
- " async address " + asyncAddress); }
+ started = true;
+
+ log.debug(this + " started");
}
public synchronized void stop(boolean sendNotification) throws Exception
@@ -1265,13 +1254,36 @@
}
}
-
-
-
public int getNodeId()
{
return nodeId;
}
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("ClusteredPostOffice[");
+ sb.append(nodeId).append(":").append(getOfficeName()).append(":");
+
+ if (syncChannel == null)
+ {
+ sb.append("UNINITIALIZED");
+ }
+ else
+ {
+ Address addr = syncChannel.getLocalAddress();
+ if (addr == null)
+ {
+ sb.append("UNCONNECTED");
+ }
+ else
+ {
+ sb.append(addr);
+ }
+ }
+
+ sb.append("]");
+ return sb.toString();
+ }
// Public ------------------------------------------------------------------------------------------
@@ -1678,7 +1690,7 @@
protected void loadBindings() throws Exception
{
- log.debug(this.nodeId + " loading bindings");
+ if (trace) { log.trace(this + " loading bindings"); }
boolean isState = syncChannel.getState(null, stateTimeout);
@@ -1686,7 +1698,7 @@
{
//Must be first member in group or non clustered- we load the state ourself from the database
- if (trace) { log.trace(this.nodeId + " First member of group- so loading bindings from db"); }
+ if (trace) { log.trace(this + " is the first member of group, so will load bindings from database"); }
super.loadBindings();
}
@@ -1724,9 +1736,7 @@
queue = new RemoteQueueStub(nodeId, queueName, channelId, durable, pm, filter);
}
- Binding binding = new DefaultBinding(nodeId, condition, queue, failed);
-
- return binding;
+ return new DefaultBinding(nodeId, condition, queue, failed);
}
// Private ------------------------------------------------------------------------------------------
@@ -1737,9 +1747,7 @@
try
{
- boolean removed = leftSet.remove(nodeId);
-
- return removed;
+ return leftSet.remove(nodeId);
}
finally
{
@@ -1831,7 +1839,7 @@
*/
private void syncSendRequest(ClusterRequest request) throws Exception
{
- if (trace) { log.trace(this.nodeId + " sending synch request to group, request: " + request); }
+ if (trace) { log.trace(this + " sending synch request " + request); }
byte[] bytes = writeRequest(request);
@@ -1839,7 +1847,7 @@
controlMessageDispatcher.castMessage(null, message, GroupRequest.GET_ALL, castTimeout);
- if (trace) { log.trace(this.nodeId + " sent and executed ok"); }
+ if (trace) { log.trace(this + " request sent OK"); }
}
@@ -1935,20 +1943,18 @@
SharedState state = new SharedState(bindings, replicatedData);
- byte[] bytes = StreamUtils.toBytes(state);
-
- return bytes;
+ return StreamUtils.toBytes(state);
}
private void processStateBytes(byte[] bytes) throws Exception
{
- if (trace) { log.trace(this.nodeId + " received state from group"); }
+ if (trace) { log.trace(this + " received state from group"); }
SharedState state = new SharedState();
StreamUtils.fromBytes(state, bytes);
- if (trace) { log.trace(this.nodeId + " received " + state.getBindings().size() + " bindings and map " + state.getReplicatedData()); }
+ if (trace) { log.trace(this + " received " + state.getBindings().size() + " bindings and map " + state.getReplicatedData()); }
nameMaps.clear();
@@ -2118,8 +2124,9 @@
*/
private void nodeJoined(Address address) throws Exception
{
+ if (trace) { log.trace(this + ": " + address + " joined"); }
+
// We need to regenerate the failover map
-
generateFailoverMap(currentView);
}
@@ -2128,6 +2135,8 @@
*/
private void nodeLeft(Address address) throws Throwable
{
+ if (trace) { log.trace(this + ": " + address + " left"); }
+
Integer nodeId = getNodeIdForSyncAddress(address);
if (nodeId != null)
@@ -2255,39 +2264,32 @@
//NOOP
}
- public void viewAccepted(View view)
+ public void viewAccepted(View newView)
{
- if (trace) { log.trace(nodeId + " Got new view, size=" + view.size()); }
+ if (trace) { log.trace(DefaultClusteredPostOffice.this + " got new view: " + newView); }
// JGroups will make sure this method is never called by more than one thread concurrently
View oldView = currentView;
+ currentView = newView;
- currentView = view;
-
try
{
if (oldView != null)
{
- Iterator iter = oldView.getMembers().iterator();
-
- while (iter.hasNext())
+ for(Iterator i = oldView.getMembers().iterator(); i.hasNext(); )
{
- Address address = (Address)iter.next();
-
- if (!view.containsMember(address))
+ Address address = (Address)i.next();
+ if (!newView.containsMember(address))
{
nodeLeft(address);
}
}
}
- Iterator iter = view.getMembers().iterator();
-
- while (iter.hasNext())
+ for(Iterator i = newView.getMembers().iterator(); i.hasNext(); )
{
- Address address = (Address)iter.next();
-
+ Address address = (Address)i.next();
if (oldView == null || !oldView.containsMember(address))
{
nodeJoined(address);
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeAddressInfo.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeAddressInfo.java 2006-12-04 10:35:01 UTC (rev 1701)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PostOfficeAddressInfo.java 2006-12-04 10:36:59 UTC (rev 1702)
@@ -43,42 +43,39 @@
*/
class PostOfficeAddressInfo implements Streamable, Serializable
{
+ // Constants -----------------------------------------------------
+
private static final long serialVersionUID = 8462102430717730566L;
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
private Address syncChannelAddress;
-
private Address asyncChannelAddress;
+ // Constructors --------------------------------------------------
+
public PostOfficeAddressInfo()
- {
+ {
}
-
+
PostOfficeAddressInfo(Address syncChannelAddress, Address asyncChannelAddress)
{
this.syncChannelAddress = syncChannelAddress;
-
this.asyncChannelAddress = asyncChannelAddress;
}
- Address getSyncChannelAddress()
- {
- return syncChannelAddress;
- }
-
- Address getAsyncChannelAddress()
- {
- return asyncChannelAddress;
- }
+ // Streamable implementation -------------------------------------
-
public void read(DataInputStream in) throws Exception
{
syncChannelAddress = new IpAddress();
-
+
syncChannelAddress.readFrom(in);
-
+
asyncChannelAddress = new IpAddress();
-
+
asyncChannelAddress.readFrom(in);
byte[] byteInput = new byte[in.readInt()];
@@ -92,23 +89,46 @@
{
throw new IllegalStateException("Address must be IpAddress");
}
-
+
if (!(asyncChannelAddress instanceof IpAddress))
{
throw new IllegalStateException("Address must be IpAddress");
}
-
+
syncChannelAddress.writeTo(out);
-
+
asyncChannelAddress.writeTo(out);
}
+ // Public --------------------------------------------------------
+
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("syncChannelAddress=" + syncChannelAddress +
- ", asyncChannelAddress=" + asyncChannelAddress +", ");
+ StringBuffer sb = new StringBuffer("[");
+ sb.append("synch addr ").append(syncChannelAddress);
+ sb.append(", asynch addr ").append(asyncChannelAddress);
+ sb.append("]");
- return buffer.toString();
+ return sb.toString();
}
+
+
+ // Package protected ---------------------------------------------
+
+ Address getSyncChannelAddress()
+ {
+ return syncChannelAddress;
+ }
+
+ Address getAsyncChannelAddress()
+ {
+ return asyncChannelAddress;
+ }
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
}
Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PutReplicantRequest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PutReplicantRequest.java 2006-12-04 10:35:01 UTC (rev 1701)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/PutReplicantRequest.java 2006-12-04 10:36:59 UTC (rev 1702)
@@ -102,6 +102,11 @@
// Public --------------------------------------------------------
+ public String toString()
+ {
+ return "PutRequest[" + key + "][" + replicant + "]";
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list