Author: chirino
Date: Thu Feb 9 08:04:54 2006
New Revision: 376332
URL: http://svn.apache.org/viewcvs?rev=376332&view=rev
Log:
The QueueMasterSlaveTest and TopicMasterSlaveTest were hanging on on teardown
of the test case due us issuing a transport request() that never returned.
Converterted to just issuing a oneway and it seems to have fixed the issue.
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java?rev=376332&r1=376331&r2=376332&view=diff
==============================================================================
---
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
(original)
+++
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
Thu Feb 9 08:04:54 2006
@@ -26,7 +26,6 @@
import org.apache.activemq.command.CommandTypes;
import org.apache.activemq.command.ConnectionId;
import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.ExceptionResponse;
import org.apache.activemq.command.MessageDispatch;
import org.apache.activemq.command.ProducerInfo;
import org.apache.activemq.command.Response;
@@ -59,6 +58,7 @@
private Transport remoteBroker;
private TransportConnector connector;
private AtomicBoolean masterActive=new AtomicBoolean(false);
+ private AtomicBoolean started=new AtomicBoolean(false);
IdGenerator idGenerator=new IdGenerator();
ConnectionInfo connectionInfo;
@@ -75,7 +75,10 @@
}
public void start() throws Exception{
-
+ if( !started.compareAndSet(false, true) ) {
+ return;
+ }
+
localBroker=TransportFactory.connect(localURI);
remoteBroker=TransportFactory.connect(remoteURI);
log.info("Starting a network connection between "+localBroker+" and
"+remoteBroker+" has been established.");
@@ -84,16 +87,22 @@
public void onCommand(Command command){
}
public void onException(IOException error){
- serviceLocalException(error);
+ if( started.get() ) {
+ serviceLocalException(error);
+ }
}
});
remoteBroker.setTransportListener(new TransportListener(){
public void onCommand(Command command){
- serviceRemoteCommand(command);
+ if( started.get() ) {
+ serviceRemoteCommand(command);
+ }
}
public void onException(IOException error){
- serviceRemoteException(error);
+ if( started.get() ) {
+ serviceRemoteException(error);
+ }
}
});
@@ -145,14 +154,18 @@
log.info("Slave connection between "+localBroker+" and
"+remoteBroker+" has been established.");
}
- public void stop() throws Exception{
+ public void stop() throws Exception{
+ if( !started.compareAndSet(true, false) ) {
+ return;
+ }
+
masterActive.set(false);
try{
- if (connectionInfo!=null){
- localBroker.request(connectionInfo.createRemoveCommand());
- }
- localBroker.setTransportListener(null);
- remoteBroker.setTransportListener(null);
+// if (connectionInfo!=null){
+// localBroker.request(connectionInfo.createRemoveCommand());
+// }
+// localBroker.setTransportListener(null);
+// remoteBroker.setTransportListener(null);
remoteBroker.oneway(new ShutdownInfo());
localBroker.oneway(new ShutdownInfo());
}catch(IOException e){
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?rev=376332&r1=376331&r2=376332&view=diff
==============================================================================
---
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
(original)
+++
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Thu Feb 9 08:04:54 2006
@@ -296,7 +296,7 @@
public void send(ConnectionContext context, Message message) throws
Throwable {
message.getMessageId().setBrokerSequenceId(sequenceGenerator.getNextSequenceId());
- if (message.getTimestamp() > 0 && (message.getBrokerPath() == null |
message.getBrokerPath().length == 0)) {
+ if (message.getTimestamp() > 0 && (message.getBrokerPath() == null ||
message.getBrokerPath().length == 0)) {
//timestamp not been disabled and has not passed through a network
message.setTimestamp(System.currentTimeMillis());
}