Author: clebert.suconic(a)jboss.com
Date: 2012-01-05 09:00:21 -0500 (Thu, 05 Jan 2012)
New Revision: 11973
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
JBPAPP-7205 - Changes on Stopping RemotingService in case of a critical error
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java 2012-01-05
13:57:59 UTC (rev 11972)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/RemotingService.java 2012-01-05
14:00:21 UTC (rev 11973)
@@ -16,7 +16,6 @@
import java.util.Set;
import org.hornetq.api.core.Interceptor;
-import org.hornetq.core.server.HornetQComponent;
import org.hornetq.spi.core.protocol.RemotingConnection;
/**
@@ -25,7 +24,7 @@
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @version <tt>$Revision$</tt>
*/
-public interface RemotingService extends HornetQComponent
+public interface RemotingService
{
/**
* Remove a connection from the connections held by the remoting service.
@@ -41,7 +40,13 @@
void addInterceptor(Interceptor interceptor);
boolean removeInterceptor(Interceptor interceptor);
+
+ void stop(boolean criticalError) throws Exception;
+
+ void start() throws Exception;
+ boolean isStarted();
+
void freeze();
RemotingConnection getServerSideReplicatingConnection();
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2012-01-05
13:57:59 UTC (rev 11972)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2012-01-05
14:00:21 UTC (rev 11973)
@@ -262,7 +262,7 @@
}
}
- public void stop() throws Exception
+ public void stop(final boolean criticalError) throws Exception
{
if (!started)
{
@@ -274,7 +274,7 @@
return;
}
- failureCheckAndFlushThread.close();
+ failureCheckAndFlushThread.close(criticalError);
// We need to stop them accepting first so no new connections are accepted after we
send the disconnect message
for (Acceptor acceptor : acceptors)
@@ -291,9 +291,13 @@
log.debug("Sending disconnect on live connections");
}
+ HashSet<ConnectionEntry> connectionEntries = new
HashSet<ConnectionEntry>();
+
+ connectionEntries.addAll(connections.values());
+
// Now we ensure that no connections will process any more packets after this
method is complete
// then send a disconnect packet
- for (ConnectionEntry entry : connections.values())
+ for (ConnectionEntry entry : connectionEntries)
{
RemotingConnection conn = entry.connection;
@@ -320,12 +324,15 @@
}
threadPool.shutdown();
-
- boolean ok = threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS);
-
- if (!ok)
+
+ if (!criticalError)
{
- log.warn("Timed out waiting for remoting thread pool to terminate");
+ boolean ok = threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS);
+
+ if (!ok)
+ {
+ log.warn("Timed out waiting for remoting thread pool to
terminate");
+ }
}
started = false;
@@ -534,7 +541,7 @@
this.pauseInterval = pauseInterval;
}
- public void close()
+ public void close(final boolean criticalError)
{
closed = true;
@@ -543,13 +550,16 @@
notify();
}
- try
+ if (!criticalError)
{
- join();
+ try
+ {
+ join();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
}
- catch (InterruptedException ignore)
- {
- }
}
@Override
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2012-01-05
13:57:59 UTC (rev 11972)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2012-01-05
14:00:21 UTC (rev 11973)
@@ -492,7 +492,7 @@
}
- remotingService.stop();
+ remotingService.stop(criticalIOError);
// We close all the exception in an attempt to let any pending IO to finish
// to avoid scenarios where the send or ACK got to disk but the response didn't
get to the client
Show replies by date