cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1041025 - in /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra: cli/CliClient.java cli/CliOptions.java db/Memtable.java io/sstable/SSTableScanner.java locator/DynamicEndpointSnitch.java tools/ClusterCmd.java tools/NodeProbe.java
Date Wed, 01 Dec 2010 14:43:24 GMT
Author: jbellis
Date: Wed Dec  1 14:43:24 2010
New Revision: 1041025

URL: http://svn.apache.org/viewvc?rev=1041025&view=rev
Log:
move fields to locals or static fields where possible
patch by Dave Brosius; reviewed by jbellis for CASSANDRA-1793

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliOptions.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/ClusterCmd.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeProbe.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java?rev=1041025&r1=1041024&r2=1041025&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java Wed
Dec  1 14:43:24 2010
@@ -89,6 +89,7 @@ public class CliClient extends CliUserHe
         PLACEMENT_STRATEGY,
         STRATEGY_OPTIONS
     }
+    private static final String DEFAULT_PLACEMENT_STRATEGY = "org.apache.cassandra.locator.SimpleStrategy";
 
     private Cassandra.Client thriftClient = null;
     private CliSessionState sessionState  = null;
@@ -97,7 +98,6 @@ public class CliClient extends CliUserHe
     private Map<String, KsDef> keyspacesMap = new HashMap<String, KsDef>();
     private Map<String, AbstractType> cfKeysComparators;
     
-    private final String DEFAULT_PLACEMENT_STRATEGY = "org.apache.cassandra.locator.SimpleStrategy";
     
     public CliClient(CliSessionState cliSessionState, Cassandra.Client thriftClient)
     {

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliOptions.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliOptions.java?rev=1041025&r1=1041024&r2=1041025&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliOptions.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliOptions.java Wed
Dec  1 14:43:24 2010
@@ -27,7 +27,6 @@ import org.apache.commons.cli.*;
 public class CliOptions {
 
     private static Options options = null; // Info about command line options
-    private CommandLine cmd = null;        // Command Line arguments
 
     // Command line options
     private static final String HOST_OPTION = "host";
@@ -72,7 +71,78 @@ public class CliOptions {
         CommandLineParser parser = new PosixParser();
         try
         {
-            cmd = parser.parse(options, args);
+            CommandLine cmd = parser.parse(options, args);
+            
+            if (!cmd.hasOption(HOST_OPTION))
+            {
+                // host name not specified in command line.
+                // In this case, we don't implicitly connect at CLI startup. In this case,
+                // the user must use the "connect" CLI statement to connect.
+                //
+                css.hostName = null;
+                
+                // HelpFormatter formatter = new HelpFormatter();
+                // formatter.printHelp("java com.facebook.infrastructure.cli.CliMain ", options);
+                // System.exit(1);
+            }
+            else 
+            {
+                css.hostName = cmd.getOptionValue(HOST_OPTION);
+            }
+
+            // Look to see if frame has been specified
+            if (cmd.hasOption(UNFRAME_OPTION))
+            {
+                css.framed = false;
+            }
+
+            // Look to see if frame has been specified
+            if (cmd.hasOption(DEBUG_OPTION))
+            {
+                css.debug = true;
+            }
+
+            // Look for optional args.
+            if (cmd.hasOption(PORT_OPTION))
+            {
+                css.thriftPort = Integer.parseInt(cmd.getOptionValue(PORT_OPTION));
+            }
+            else
+            {
+                css.thriftPort = DEFAULT_THRIFT_PORT;
+            }
+         
+            // Look for authentication credentials (username and password)
+            if (cmd.hasOption(USERNAME_OPTION)) 
+            {
+            	css.username = cmd.getOptionValue(USERNAME_OPTION);
+            }
+            if (cmd.hasOption(PASSWORD_OPTION))
+            {
+            	css.password = cmd.getOptionValue(PASSWORD_OPTION);
+            }
+            
+            // Look for keyspace
+            if (cmd.hasOption(KEYSPACE_OPTION)) 
+            {
+            	css.keyspace = cmd.getOptionValue(KEYSPACE_OPTION);
+            }
+            
+            if (cmd.hasOption(BATCH_OPTION))
+            {
+                css.batch = true;
+            }
+
+            if (cmd.hasOption(FILE_OPTION))
+            {
+                css.filename = cmd.getOptionValue(FILE_OPTION);
+            }
+
+            if (cmd.hasOption(HELP_OPTION))
+            {
+                printUsage();
+                System.exit(1);
+            }
         }
         catch (ParseException e)
         {
@@ -80,77 +150,5 @@ public class CliOptions {
             System.err.println("\n" + e.getMessage());
             System.exit(1);
         }
-
-        if (!cmd.hasOption(HOST_OPTION))
-        {
-            // host name not specified in command line.
-            // In this case, we don't implicitly connect at CLI startup. In this case,
-            // the user must use the "connect" CLI statement to connect.
-            //
-            css.hostName = null;
-            
-            // HelpFormatter formatter = new HelpFormatter();
-            // formatter.printHelp("java com.facebook.infrastructure.cli.CliMain ", options);
-            // System.exit(1);
-        }
-        else 
-        {
-            css.hostName = cmd.getOptionValue(HOST_OPTION);
-        }
-
-        // Look to see if frame has been specified
-        if (cmd.hasOption(UNFRAME_OPTION))
-        {
-            css.framed = false;
-        }
-
-        // Look to see if frame has been specified
-        if (cmd.hasOption(DEBUG_OPTION))
-        {
-            css.debug = true;
-        }
-
-        // Look for optional args.
-        if (cmd.hasOption(PORT_OPTION))
-        {
-            css.thriftPort = Integer.parseInt(cmd.getOptionValue(PORT_OPTION));
-        }
-        else
-        {
-            css.thriftPort = DEFAULT_THRIFT_PORT;
-        }
-     
-        // Look for authentication credentials (username and password)
-        if (cmd.hasOption(USERNAME_OPTION)) 
-        {
-        	css.username = cmd.getOptionValue(USERNAME_OPTION);
-        }
-        if (cmd.hasOption(PASSWORD_OPTION))
-        {
-        	css.password = cmd.getOptionValue(PASSWORD_OPTION);
-        }
-        
-        // Look for keyspace
-        if (cmd.hasOption(KEYSPACE_OPTION)) 
-        {
-        	css.keyspace = cmd.getOptionValue(KEYSPACE_OPTION);
-        }
-        
-        if (cmd.hasOption(BATCH_OPTION))
-        {
-            css.batch = true;
-        }
-
-        if (cmd.hasOption(FILE_OPTION))
-        {
-            css.filename = cmd.getOptionValue(FILE_OPTION);
-        }
-
-        if (cmd.hasOption(HELP_OPTION))
-        {
-            printUsage();
-            System.exit(1);
-        }
-
     }
 }

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java?rev=1041025&r1=1041024&r2=1041025&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java Wed Dec
 1 14:43:24 2010
@@ -257,7 +257,6 @@ public class Memtable implements Compara
         return new SimpleAbstractColumnIterator()
         {
             private Iterator<ByteBuffer> iter = filter.columns.iterator();
-            private ByteBuffer current;
 
             public ColumnFamily getColumnFamily()
             {
@@ -273,7 +272,7 @@ public class Memtable implements Compara
             {
                 while (iter.hasNext())
                 {
-                    current = iter.next();
+                    ByteBuffer current = iter.next();
                     IColumn column = cf.getColumn(current);
                     if (column != null)
                         // clone supercolumns so caller can freely removeDeleted or otherwise
mutate it

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java?rev=1041025&r1=1041024&r2=1041025&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
Wed Dec  1 14:43:24 2010
@@ -142,7 +142,6 @@ public class SSTableScanner implements I
 
     private class KeyScanningIterator implements Iterator<IColumnIterator>
     {
-        private long dataStart;
         private long finishedAt;
 
         public boolean hasNext()
@@ -171,7 +170,7 @@ public class SSTableScanner implements I
                                                            sstable.descriptor,
                                                            FBUtilities.readShortByteArray(file));
                 long dataSize = SSTableReader.readRowSize(file, sstable.descriptor);
-                dataStart = file.getFilePointer();
+                long dataStart = file.getFilePointer();
                 finishedAt = dataStart + dataSize;
 
                 if (filter == null)

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java?rev=1041025&r1=1041024&r2=1041025&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
Wed Dec  1 14:43:24 2010
@@ -214,14 +214,12 @@ public class DynamicEndpointSnitch exten
 /** a threadsafe version of BoundedStatsDeque+ArrivalWindow with modification for arbitrary
times **/
 class AdaptiveLatencyTracker extends AbstractStatsDeque
 {
-    private LinkedBlockingDeque latencies;
-    private final int size;                                   
+    private LinkedBlockingDeque<Double> latencies;                                
 
     private static double SENTINEL_COMPARE = 0.0001; // arbitrary; as long as it is the same
across hosts it doesn't matter
 
     AdaptiveLatencyTracker(int size)
     {
-        this.size = size;
-        latencies = new LinkedBlockingDeque(size);
+        latencies = new LinkedBlockingDeque<Double>(size);
     }
 
     public void add(double i)

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/ClusterCmd.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/ClusterCmd.java?rev=1041025&r1=1041024&r2=1041025&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/ClusterCmd.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/ClusterCmd.java Wed
Dec  1 14:43:24 2010
@@ -42,8 +42,6 @@ public class ClusterCmd {
     private static Options options = null;
     private CommandLine cmd = null;
     private NodeProbe probe;
-    private String host;
-    private int port;
 
     static
     {
@@ -64,14 +62,15 @@ public class ClusterCmd {
     private ClusterCmd(String[] cmdArgs) throws ParseException, IOException, InterruptedException
     {
         parseArgs(cmdArgs);
-        this.host = cmd.getOptionValue(HOST_OPT_SHORT);
+        String host = cmd.getOptionValue(HOST_OPT_SHORT);
 
         String portNum = cmd.getOptionValue(PORT_OPT_SHORT);
+        int port;
         if (portNum != null)
         {
             try
             {
-                this.port = Integer.parseInt(portNum);
+                port = Integer.parseInt(portNum);
             }
             catch (NumberFormatException e)
             {
@@ -80,7 +79,7 @@ public class ClusterCmd {
         }
         else
         {
-            this.port = defaultPort;
+            port = defaultPort;
         }
 
         probe = new NodeProbe(host, port);
@@ -95,8 +94,6 @@ public class ClusterCmd {
      */
     public ClusterCmd(String host, int port) throws IOException, InterruptedException
     {
-        this.host = host;
-        this.port = port;
         probe = new NodeProbe(host, port);
     }
 
@@ -170,7 +167,7 @@ public class ClusterCmd {
         {
             try
             {
-                NodeProbe hostProbe = new NodeProbe(liveNode, port);
+                NodeProbe hostProbe = new NodeProbe(liveNode, probe.port);
                 hostProbe.takeSnapshot(snapshotName);
                 System.out.println(liveNode + " snapshot taken");
             }
@@ -190,7 +187,7 @@ public class ClusterCmd {
         {
             try
             {
-                NodeProbe hostProbe = new NodeProbe(liveNode, port);
+                NodeProbe hostProbe = new NodeProbe(liveNode, probe.port);
                 hostProbe.clearSnapshot();
                 System.out.println(liveNode + " snapshot cleared");
             }

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeProbe.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeProbe.java?rev=1041025&r1=1041024&r2=1041025&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeProbe.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/tools/NodeProbe.java Wed
Dec  1 14:43:24 2010
@@ -67,8 +67,8 @@ public class NodeProbe
     private static final String fmtUrl = "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi";
     private static final String ssObjName = "org.apache.cassandra.db:type=StorageService";
     private static final int defaultPort = 8080;
-    private String host;
-    private int port;
+    final String host;
+    final int port;
 
     private JMXConnector jmxc;
     private MBeanServerConnection mbeanServerConn;



Mime
View raw message