cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject svn commit: r802898 - in /incubator/cassandra/trunk: conf/storage-conf.xml src/java/org/apache/cassandra/config/DatabaseDescriptor.java src/java/org/apache/cassandra/service/CassandraDaemon.java
Date Mon, 10 Aug 2009 18:57:03 GMT
Author: eevans
Date: Mon Aug 10 18:57:03 2009
New Revision: 802898

URL: http://svn.apache.org/viewvc?rev=802898&view=rev
Log:
CASSANDRA-241 optional support for framed transport

Modified:
    incubator/cassandra/trunk/conf/storage-conf.xml
    incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java

Modified: incubator/cassandra/trunk/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/conf/storage-conf.xml?rev=802898&r1=802897&r2=802898&view=diff
==============================================================================
--- incubator/cassandra/trunk/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/conf/storage-conf.xml Mon Aug 10 18:57:03 2009
@@ -187,6 +187,11 @@
     <ThriftAddress>localhost</ThriftAddress>
     <!-- Thrift RPC port (the port clients connect to). -->
     <ThriftPort>9160</ThriftPort>
+    <!-- Whether or not to use a framed transport for Thrift. If this option
+         is set to true then you must also use a framed transport on the 
+         client-side, (framed and non-framed transports are not compatible).
+    -->
+    <ThriftFramedTransport>false</ThriftFramedTransport>
 
 
     <!--======================================================================-->

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=802898&r1=802897&r2=802898&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Mon Aug 10 18:57:03 2009
@@ -52,6 +52,7 @@
     private static int storagePort_ = 7000;
     private static int controlPort_ = 7001;
     private static int thriftPort_ = 9160;
+    private static boolean thriftFramed_ = false;
     private static String listenAddress_; // leave null so we can fall through to getLocalHost
     private static String thriftAddress_;
     private static String clusterName_ = "Test";
@@ -263,6 +264,23 @@
             if (port != null)
                 thriftPort_ = Integer.parseInt(port);
 
+            /* Framed (Thrift) transport (default to "no") */
+            String framedRaw = xmlUtils.getNodeValue("/Storage/ThriftFramedTransport");
+            if (framedRaw != null)
+            {
+                if (framedRaw.compareToIgnoreCase("true") == 0 || 
+                        framedRaw.compareToIgnoreCase("false") == 0)
+                {
+                    thriftFramed_ = Boolean.valueOf(framedRaw);
+                }
+                else
+                {
+                    throw new ConfigurationException("Unrecognized value " + 
+                            "for ThriftFramedTransport.  Use 'true' or 'false'."); 
+                }
+            }
+            
+
             /* Number of days to keep the memtable around w/o flushing */
             String lifetime = xmlUtils.getNodeValue("/Storage/MemtableLifetimeInDays");
             if ( lifetime != null )
@@ -524,6 +542,11 @@
         }
     }
 
+    public static boolean isThriftFramed()
+    {
+        return thriftFramed_;
+    }
+
     private static AbstractType getComparator(Node columnFamily, String attr)
     throws ConfigurationException, TransformerException, NoSuchMethodException, InvocationTargetException,
IllegalAccessException, InstantiationException
     {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java?rev=802898&r1=802897&r2=802898&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java Mon
Aug 10 18:57:03 2009
@@ -30,6 +30,7 @@
 import org.apache.thrift.transport.TServerSocket;
 import org.apache.thrift.transport.TTransportException;
 import org.apache.thrift.transport.TTransportFactory;
+import org.apache.thrift.transport.TFramedTransport;
 import org.apache.thrift.TProcessorFactory;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.utils.FBUtilities;
@@ -107,14 +108,28 @@
 
         // Protocol factory
         TProtocolFactory tProtocolFactory = new TBinaryProtocol.Factory();
+        
+        // Transport factory
+        TTransportFactory inTransportFactory, outTransportFactory;
+        if (DatabaseDescriptor.isThriftFramed())
+        {
+            inTransportFactory = new TFramedTransport.Factory();
+            outTransportFactory = new TFramedTransport.Factory();
+            
+        }
+        else
+        {
+            inTransportFactory = new TTransportFactory();
+            outTransportFactory = new TTransportFactory();
+        }
 
         // ThreadPool Server
         TThreadPoolServer.Options options = new TThreadPoolServer.Options();
         options.minWorkerThreads = 64;
         serverEngine = new TThreadPoolServer(new TProcessorFactory(processor),
                                              tServerSocket,
-                                             new TTransportFactory(),
-                                             new TTransportFactory(),
+                                             inTransportFactory,
+                                             outTransportFactory,
                                              tProtocolFactory,
                                              tProtocolFactory,
                                              options);



Mime
View raw message