cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r828084 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra/net: TcpConnection.java TcpConnectionManager.java
Date Wed, 21 Oct 2009 16:24:15 GMT
Author: jbellis
Date: Wed Oct 21 16:24:14 2009
New Revision: 828084

URL: http://svn.apache.org/viewvc?rev=828084&view=rev
Log:
clean up unused code; add comments.  patch by jbellis for CASSANDRA-488

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnection.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnectionManager.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnection.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnection.java?rev=828084&r1=828083&r2=828084&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnection.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnection.java Wed Oct
21 16:24:14 2009
@@ -288,10 +288,7 @@
             return false;
         
         TcpConnection rhs = (TcpConnection)o;        
-        if ( localEp_.equals(rhs.localEp_) && remoteEp_.equals(rhs.remoteEp_) )
-            return true;
-        else
-            return false;
+        return localEp_.equals(rhs.localEp_) && remoteEp_.equals(rhs.remoteEp_);
     }
     
     public int hashCode()

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnectionManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnectionManager.java?rev=828084&r1=828083&r2=828084&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnectionManager.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/net/TcpConnectionManager.java
Wed Oct 21 16:24:14 2009
@@ -30,26 +30,23 @@
     private List<TcpConnection> allConnections_;
     private EndPoint localEp_;
     private EndPoint remoteEp_;
-    private int initialSize_;
-    private int growthFactor_;
     private int maxSize_;
-    private long lastTimeUsed_;
-    private boolean isShut_;
 
     private int inUse_;
 
+    // TODO! this whole thing is a giant no-op, since "contains" only relies on TcpConnection.equals,
which
+    // is true for any (local, remote) pairs.  So there is only ever at most one TcpConnection
per Manager!
     TcpConnectionManager(int initialSize, int growthFactor, int maxSize, EndPoint localEp,
EndPoint remoteEp)
     {
-        initialSize_ = initialSize;
-        growthFactor_ = growthFactor;
         maxSize_ = maxSize;
         localEp_ = localEp;
         remoteEp_ = remoteEp;
-        isShut_ = false;
-        lastTimeUsed_ = System.currentTimeMillis();
         allConnections_ = new ArrayList<TcpConnection>();
     }
 
+    /**
+     * returns the least loaded connection to remoteEp, creating a new connection if necessary
+     */
     TcpConnection getConnection() throws IOException
     {
         lock_.lock();
@@ -74,7 +71,7 @@
             }
 
             TcpConnection connection = new TcpConnection(this, localEp_, remoteEp_);
-            if (connection != null && !contains(connection))
+            if (!contains(connection))
             {
                 addToPool(connection);
                 connection.inUse_ = true;
@@ -83,10 +80,7 @@
             }
             else
             {
-                if (connection != null)
-                {
-                    connection.closeSocket();
-                }
+                connection.closeSocket();
                 return getLeastLoaded();
             }
         }
@@ -178,7 +172,6 @@
         {
             lock_.unlock();
         }
-        isShut_ = true;
     }
 
     int getPoolSize()



Mime
View raw message