Author: jbellis
Date: Fri Oct 2 18:40:15 2009
New Revision: 821126
URL: http://svn.apache.org/viewvc?rev=821126&view=rev
Log:
change instance variables to final where appropriate
patch by jbellis; reviewed by junrao for CASSANDRA-463
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java?rev=821126&r1=821125&r2=821126&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
Fri Oct 2 18:40:15 2009
@@ -39,23 +39,24 @@
public class Memtable implements Comparable<Memtable>, IFlushable<String>
{
- private static Logger logger_ = Logger.getLogger( Memtable.class );
+ private static final Logger logger_ = Logger.getLogger( Memtable.class
);
private boolean isFrozen_;
private volatile boolean isDirty_;
private volatile boolean isFlushed_; // for tests, in particular
forceBlockingFlush asserts this
- private int threshold_ = DatabaseDescriptor.getMemtableSize()*1024*1024;
- private int thresholdCount_ =
(int)(DatabaseDescriptor.getMemtableObjectCount()*1024*1024);
- private AtomicInteger currentSize_ = new AtomicInteger(0);
- private AtomicInteger currentObjectCount_ = new AtomicInteger(0);
-
- private String table_;
- private String cfName_;
- private long creationTime_;
+ private final int threshold_ =
DatabaseDescriptor.getMemtableSize()*1024*1024; // not static since we might
want to change at runtime
+ private final int thresholdCount_ =
(int)(DatabaseDescriptor.getMemtableObjectCount()*1024*1024);
+
+ private final AtomicInteger currentSize_ = new AtomicInteger(0);
+ private final AtomicInteger currentObjectCount_ = new AtomicInteger(0);
+
+ private final String table_;
+ private final String cfName_;
+ private final long creationTime_;
// we use NBHM with manual locking, so reads are automatically threadsafe
but write merging is serialized per key
- private NonBlockingHashMap<String, ColumnFamily> columnFamilies_ = new
NonBlockingHashMap<String, ColumnFamily>();
- private Object[] keyLocks;
+ private final NonBlockingHashMap<String, ColumnFamily> columnFamilies_ =
new NonBlockingHashMap<String, ColumnFamily>();
+ private final Object[] keyLocks;
Memtable(String table, String cfName)
{
@@ -113,7 +114,7 @@
boolean isThresholdViolated()
{
- return currentSize_.get() >= threshold_ || currentObjectCount_.get()
>= thresholdCount_;
+ return currentSize_.get() >= threshold_ || currentObjectCount_.get()
>= thresholdCount_;
}
String getColumnFamily()
Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=821126&r1=821125&r2=821126&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Fri
Oct 2 18:40:15 2009
@@ -48,7 +48,7 @@
{
public static final String SYSTEM_TABLE = "system";
- private static Logger logger_ = Logger.getLogger(Table.class);
+ private static final Logger logger_ = Logger.getLogger(Table.class);
private static final String SNAPSHOT_SUBDIR_NAME = "snapshots";
/* we use this lock to drain updaters before calling a flush. */
static final ReentrantReadWriteLock flusherLock_ = new
ReentrantReadWriteLock(true);
@@ -312,14 +312,14 @@
}
/* Used to lock the factory for creation of Table instance */
- private static Lock createLock_ = new ReentrantLock();
- private static Map<String, Table> instances_ = new HashMap<String,
Table>();
+ private static final Lock createLock_ = new ReentrantLock();
+ private static final Map<String, Table> instances_ = new HashMap<String,
Table>();
/* Table name. */
- private String table_;
+ private final String table_;
/* Handle to the Table Metadata */
- private Table.TableMetadata tableMetadata_;
+ private final Table.TableMetadata tableMetadata_;
/* ColumnFamilyStore per column family */
- private Map<String, ColumnFamilyStore> columnFamilyStores_ = new
HashMap<String, ColumnFamilyStore>();
+ private final Map<String, ColumnFamilyStore> columnFamilyStores_ = new
HashMap<String, ColumnFamilyStore>();
// cache application CFs since Range queries ask for them a _lot_
private SortedSet<String> applicationColumnFamilies_;
@@ -331,12 +331,12 @@
* Set the isConfigured flag so that we do not read config all the
* time.
*/
- if ( tableInstance == null )
+ if (tableInstance == null)
{
Table.createLock_.lock();
try
{
- if ( tableInstance == null )
+ if (tableInstance == null)
{
tableInstance = new Table(table);
instances_.put(table, tableInstance);