You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by oy...@apache.org on 2008/02/27 11:10:27 UTC

svn commit: r631534 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication: master/MasterController.java net/ReplicationMessageTransmit.java

Author: oysteing
Date: Wed Feb 27 02:10:21 2008
New Revision: 631534

URL: http://svn.apache.org/viewvc?rev=631534&view=rev
Log:
DERBY-3364: Replication failover implementation must be modified to fail at the master after slave has been stopped
Contributed by V Narayanan
Changes:
M java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java
* Set a timeout on the socket that is translated as a timeout on the
  reads on the I/P streams 
M java/engine/org/apache/derby/impl/services/replication/master/MasterController.java
* Stop log shipment and tear down network both with successful and
  non-successful failover.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java?rev=631534&r1=631533&r2=631534&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java Wed Feb 27 02:10:21 2008
@@ -274,9 +274,10 @@
         } else if (ack.getType() == ReplicationMessage.TYPE_ACK) {
             //An exception is thrown to indicate the successful completion 
             //of failover. Also the AsynchronousLogShipper thread is terminated.
+            //The socket connection that is obtained needs to be torn down.
             //The exception thrown is of Database Severity, this shuts
             //down the master database.
-            logShipper.stopLogShipment();
+            teardownNetwork();
             throw StandardException.newException
                     (SQLState.REPLICATION_FAILOVER_SUCCESSFUL, dbname);  
         } else {
@@ -299,6 +300,7 @@
      */
     private void handleFailoverFailure(Throwable t) 
     throws StandardException {
+        teardownNetwork();
         rawStoreFactory.unfreeze();
         if (t != null) {
             throw StandardException.newException

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java?rev=631534&r1=631533&r2=631534&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java Wed Feb 27 02:10:21 2008
@@ -119,6 +119,13 @@
             }
         });
         
+        //The reads on the InputStreams obtained from the socket on the
+        //transmitter should not hang indefinitely. Use the timeout
+        //used for the connection establishment here to ensure that the
+        //reads timeout after the timeout period mentioned for the
+        //connection.
+        s.setSoTimeout(timeout_);
+        
         socketConn = new SocketConnection(s);
         
         //send the initiate message and receive acknowledgment