Date: Friday, January 6, 2006 @ 14:38:51
  Author: gilles
    Path: /cvsroot/carob/carob

Modified: include/Connection.hpp (1.43 -> 1.44)
          include/ConnectionParameters.hpp (1.13 -> 1.14)
          src/Connection.cpp (1.50 -> 1.51) src/ConnectionParameters.cpp
          (1.11 -> 1.12)

Updated to protocol version 0.35: added support for persistentConnection option


----------------------------------+
 include/Connection.hpp           |   10 +++++++++-
 include/ConnectionParameters.hpp |   12 ++++++++++--
 src/Connection.cpp               |   25 +++++++++++++++++++++----
 src/ConnectionParameters.cpp     |    6 ++++--
 4 files changed, 44 insertions(+), 9 deletions(-)


Index: carob/include/Connection.hpp
diff -u carob/include/Connection.hpp:1.43 carob/include/Connection.hpp:1.44
--- carob/include/Connection.hpp:1.43   Thu Jan  5 16:17:27 2006
+++ carob/include/Connection.hpp        Fri Jan  6 14:38:51 2006
@@ -33,7 +33,7 @@
 #include "RequestWithResultSetParameters.hpp"
 
 namespace {
-const int32_t ProtocolVersion = ((int32_t) 0/* major */ << 16) + 33/* minor */;
+const int32_t ProtocolVersion = ((int32_t) 0/* major */ << 16) + 35/* minor */;
 }
 
 namespace CarobNS {
@@ -363,6 +363,14 @@
    */
   bool                mustBeginTransaction;
   /**
+   * True if the connection must be persisted on all cluster backends even when
+   * autoCommit=true
+   */
+  bool                persistent_connection;
+
+  /** Persistent connection identifier if persistentConnection is true */
+  int64_t             persistent_connection_id;
+  /**
    * Controller connection policy used for this connection */
   AbstractControllerConnectPolicy* connect_policy_ptr;
   /**
Index: carob/include/ConnectionParameters.hpp
diff -u carob/include/ConnectionParameters.hpp:1.13 
carob/include/ConnectionParameters.hpp:1.14
--- carob/include/ConnectionParameters.hpp:1.13 Thu Jan  5 16:17:27 2006
+++ carob/include/ConnectionParameters.hpp      Fri Jan  6 14:38:51 2006
@@ -76,6 +76,7 @@
 #define DEFAULT_DEBUG_LEVEL DEBUG_LEVEL_OFF
 #define DEFAULT_POLICY      ROUND_ROBIN
 #define DEFAULT_RETRY_INTERVAL 10
+#define DEFAULT_CONNECTION_PERSISTENCY false
 /**
  * This class contains the parameters for a connection to the controller.
  * This connection parameters will be used by the Connection class.
@@ -94,7 +95,8 @@
                        const std::wstring&  upass             = DEFAULT_PASSWD,
                        DebugLevel           dl                = 
DEFAULT_DEBUG_LEVEL,
                        ConnectPolicy        cp                = DEFAULT_POLICY,
-                       int                  retryIntervalInMs = 
DEFAULT_RETRY_INTERVAL)
+                       int                  retryIntervalInMs = 
DEFAULT_RETRY_INTERVAL,
+                       bool                 persistentConnection = 
DEFAULT_CONNECTION_PERSISTENCY)
                    throw (ConnectionException, UnexpectedException);
        virtual ~ConnectionParameters();
   /**
@@ -132,7 +134,8 @@
   ConnectPolicy       getConnectPolicy() const { return connect_policy; }
   /** Gives the retry interval in ms */
   int                 getRetryInterval() const { return retry_interval_in_ms; }
-  
+  /** Tell wheter the connection must remain persistent */
+  bool                getPersistentConnection() const { return 
persistent_connections; }
 private:
   /** List of controllers to connect to */
   std::vector<ControllerInfo> controller_list;
@@ -148,6 +151,11 @@
   ConnectPolicy       connect_policy;
   /** Time in ms between two connection attempts */
   int                 retry_interval_in_ms;
+  /**
+   * whether a connection in autoCommit mode should remain persistent on 
cluster
+   * backends
+   */
+  bool                persistent_connections;
 };
 
 } //namespace CarobNS
Index: carob/src/Connection.cpp
diff -u carob/src/Connection.cpp:1.50 carob/src/Connection.cpp:1.51
--- carob/src/Connection.cpp:1.50       Thu Jan  5 16:17:27 2006
+++ carob/src/Connection.cpp    Fri Jan  6 14:38:51 2006
@@ -35,6 +35,7 @@
   readOnly(false),
   writeExecutedInTransaction(false),
   mustBeginTransaction(false),
+  persistent_connection(false),
   connect_policy_ptr(NULL)
 {
   wstring fctName(L"Connection::Connection");
@@ -47,6 +48,7 @@
     default:
       throw DriverException(L"Unsupported connection policy #" + 
toWString(prms.getConnectPolicy()));
   }
+  persistent_connection = prms.getPersistentConnection();
   try
   {
     //Do the authentication stuff, then receive ack and other params
@@ -199,21 +201,28 @@
     UnexpectedException)
 {
   wstring fctName(L"Connection::finalizeConnect");
-  bool authenticated = false, authenticatedRead = false;
+  bool authenticated = false,
+       authenticatedRead = false,
+       lineSeparatorSent = false,
+       persistentConnectionSent = false;
   try
   {
-    *driverSocketPtr>>authenticated;
+    *driverSocketPtr >> authenticated;
     authenticatedRead = true;
     if (!authenticated)
     {
       wstring reason;
-      *driverSocketPtr>>reason;
+      *driverSocketPtr >> reason;
       throw AuthenticationException(L"Authentication failed: "+reason);
     }
     else
     {
       // So the controller can correctly parse our requests
       *driverSocketPtr << LINE_SEPARATOR;
+      lineSeparatorSent = true;
+      *driverSocketPtr << persistent_connection;
+      if (persistent_connection)
+        *driverSocketPtr >> persistent_connection_id;
     }
   }
   catch (SocketIOException sockIOExcpt)
@@ -221,8 +230,12 @@
     wstring msg(fctName + L" Authentication failed. Error while ");
     if (!authenticatedRead)
       msg += L"reading controller authenticated ack";
-    else
+    else if (!lineSeparatorSent)
       msg += L"sending line separator";
+    else if (!persistentConnectionSent)
+      msg += L"sending whether to use persistent connections";
+    else
+      msg += L"reading persistent connection id";
     throw AuthenticationException(msg
                                   + L"(" + sockIOExcpt.description() + L")");
     return false;
@@ -845,15 +858,19 @@
     {
       resultReceived.isResultSet = true;
       resultReceived.resultSetPtr = receiveResultSet();
+//JavaReflecting FIXME: remove this
       results.push_back(resultReceived);
     }
     else
     {
       resultReceived.isResultSet = false;
       resultReceived.updateCount = receiveIntOrException();
+//JavaReflecting FIXME: remove this
       if (resultReceived.updateCount != -1)
         results.push_back(resultReceived);
     }
+//JavaReflecting FIXME: add this
+//    results.push_back(resultReceived);
     
   }
   while (hasResult || resultReceived.updateCount != -1);
Index: carob/src/ConnectionParameters.cpp
diff -u carob/src/ConnectionParameters.cpp:1.11 
carob/src/ConnectionParameters.cpp:1.12
--- carob/src/ConnectionParameters.cpp:1.11     Thu Jan  5 16:17:27 2006
+++ carob/src/ConnectionParameters.cpp  Fri Jan  6 14:38:51 2006
@@ -53,14 +53,16 @@
     const std::wstring& upass /*= DEFAULT_PASSWD*/,
     DebugLevel dl /*= DEFAULT_DEBUG_LEVEL*/,
     ConnectPolicy cp /*= DEFAULT_POLICY*/,
-    int retryIntervalInMs /*= DEFAULT_RETRY_INTERVAL*/)
+    int retryIntervalInMs /*= DEFAULT_RETRY_INTERVAL*/,
+    bool persistentConnections /*= DEFAULT_CONNECTION_PERSISTENCY */)
         throw (ConnectionException, UnexpectedException) :
             database_name(checkDatabaseName(db)),
             user_name(uname),
             user_pass(upass),
             debug_level(dl),
             connect_policy(cp),
-            retry_interval_in_ms(retryIntervalInMs)
+            retry_interval_in_ms(retryIntervalInMs),
+            persistent_connections(persistentConnections)
 {
   addController(host, port);
 }

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to