You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2009/06/23 19:47:46 UTC
svn commit: r787758 - in /incubator/cassandra/trunk: conf/
src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/db/
src/java/org/apache/cassandra/io/
Author: jbellis
Date: Tue Jun 23 17:47:45 2009
New Revision: 787758
URL: http://svn.apache.org/viewvc?rev=787758&view=rev
Log:
r/m unused code dealing with sstables, and ConcurrentWriter / FastConcurrentWriter. mmap is not faster than write() for sequential I/O, which is what the vast majority of our writes are. mmap _does_ have an advantage when we seek back to the start of a commitlog segment to update the headers after memtable flush, but we do that infrequently enough that it's not worth the disadvantages (primarily, blowing up if we exceed the 4MB size).
patch by jbellis; reviewed by Eric Evans for CASSANDRA-224
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/db/ColumnFamilyStore.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java
Modified: incubator/cassandra/trunk/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/conf/storage-conf.xml?rev=787758&r1=787757&r2=787758&view=diff
==============================================================================
--- incubator/cassandra/trunk/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/conf/storage-conf.xml Tue Jun 23 17:47:45 2009
@@ -16,7 +16,7 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-<Storage>
+<Storage>
<!--======================================================================-->
<!-- Basic Configuration -->
<!--======================================================================-->
@@ -94,7 +94,6 @@
<!-- Miscellaneous -->
<RpcTimeoutInMillis>5000</RpcTimeoutInMillis>
<CommitLogRotationThresholdInMB>128</CommitLogRotationThresholdInMB>
- <CommitLogFastSync>false</CommitLogFastSync>
<!-- Hosts and Ports -->
<ListenAddress>localhost</ListenAddress>
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=787758&r1=787757&r2=787758&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 Tue Jun 23 17:47:45 2009
@@ -60,7 +60,6 @@
private static int currentIndex_ = 0;
private static String logFileDirectory_;
private static String bootstrapFileDirectory_;
- private static boolean fastSync_ = false;
private static boolean rackAware_ = false;
private static int threadsPerPool_ = 4;
private static List<String> tables_ = new ArrayList<String>();
@@ -291,11 +290,6 @@
if ( value != null)
CommitLog.setSegmentSize(Integer.parseInt(value) * 1024 * 1024);
- /* fast sync option */
- value = xmlUtils.getNodeValue("/Storage/CommitLogFastSync");
- if ( value != null )
- fastSync_ = Boolean.parseBoolean(value);
-
tableToCFMetaDataMap_ = new HashMap<String, Map<String, CFMetaData>>();
/* Rack Aware option */
@@ -749,11 +743,6 @@
logFileDirectory_ = logLocation;
}
- public static boolean isFastSync()
- {
- return fastSync_;
- }
-
public static boolean isRackAware()
{
return rackAware_;
Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=787758&r1=787757&r2=787758&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Tue Jun 23 17:47:45 2009
@@ -1540,10 +1540,6 @@
{
return readStats_.mean();
}
- public String getTableName()
- {
- return table_;
- }
/**
* get a list of columns starting from a given column, in a specified order
Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java?rev=787758&r1=787757&r2=787758&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java Tue Jun 23 17:47:45 2009
@@ -137,12 +137,7 @@
private static IFileWriter createWriter(String file) throws IOException
{
- if ( DatabaseDescriptor.isFastSync() )
- {
- return SequenceFile.fastWriter(file, 4*1024*1024);
- }
- else
- return SequenceFile.writer(file);
+ return SequenceFile.writer(file);
}
static CommitLog open() throws IOException
@@ -406,11 +401,8 @@
discard(cLogCtx, id);
}
-
/*
- * Check if old commit logs can be deleted. However we cannot
- * do this anymore in the Fast Sync mode and hence I think we
- * should get rid of Fast Sync mode altogether.
+ * Check if old commit logs can be deleted.
*
* param @ cLogCtx The commitLog context .
* param @ id id of the columnFamily being flushed to disk.
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=787758&r1=787757&r2=787758&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 Tue Jun 23 17:47:45 2009
@@ -346,14 +346,6 @@
{
return columnFamilyStores_.get(cfName);
}
-
- String getColumnFamilyType(String cfName)
- {
- String cfType = null;
- if ( tableMetadata_ != null )
- cfType = tableMetadata_.getColumnFamilyType(cfName);
- return cfType;
- }
/*
* This method is called to obtain statistics about
@@ -485,31 +477,16 @@
}
}
- String getTableName()
- {
- return table_;
- }
-
boolean isApplicationColumnFamily(String columnFamily)
{
return DatabaseDescriptor.isApplicationColumnFamily(columnFamily);
}
- int getNumberOfColumnFamilies()
- {
- return tableMetadata_.size();
- }
-
int getColumnFamilyId(String columnFamily)
{
return tableMetadata_.getColumnFamilyId(columnFamily);
}
- String getColumnFamilyName(int id)
- {
- return tableMetadata_.getColumnFamilyName(id);
- }
-
boolean isValidColumnFamily(String columnFamily)
{
return tableMetadata_.isValidColumnFamily(columnFamily);
Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java?rev=787758&r1=787757&r2=787758&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java Tue Jun 23 17:47:45 2009
@@ -584,29 +584,6 @@
}
}
-
-/*
- * This abstraction provides LRU symantics for the keys that are
- * "touched". Currently it holds the offset of the key in a data
- * file. May change to hold a reference to a IFileReader which
- * memory maps the key and its associated data on a touch.
-*/
-class TouchedKeyCache extends LinkedHashMap<String, Long>
-{
- private final int capacity_;
-
- TouchedKeyCache(int capacity)
- {
- super(capacity + 1, 1.1f, true);
- capacity_ = capacity;
- }
-
- protected boolean removeEldestEntry(Map.Entry<String, Long> entry)
- {
- return (size() > capacity_);
- }
-}
-
/**
* This is a simple container for the index Key and its corresponding position
* in the data file. Binary search is performed on a list of these objects
Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java?rev=787758&r1=787757&r2=787758&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java Tue Jun 23 17:47:45 2009
@@ -229,284 +229,6 @@
}
- public static class ConcurrentWriter extends AbstractWriter
- {
- private FileChannel fc_;
-
- public ConcurrentWriter(String filename) throws IOException
- {
- super(filename);
- RandomAccessFile raf = new RandomAccessFile(filename, "rw");
- fc_ = raf.getChannel();
- }
-
- public long getCurrentPosition() throws IOException
- {
- return fc_.position();
- }
-
- public void seek(long position) throws IOException
- {
- fc_.position(position);
- }
-
- public void append(DataOutputBuffer buffer) throws IOException
- {
- int length = buffer.getLength();
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(length);
- byteBuffer.put(buffer.getData(), 0, length);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- }
-
- public void append(DataOutputBuffer keyBuffer, DataOutputBuffer buffer) throws IOException
- {
- int keyBufLength = keyBuffer.getLength();
- if (keyBuffer == null || keyBufLength == 0)
- throw new IllegalArgumentException("Key cannot be NULL or of zero length.");
-
- /* Size allocated "int" for key length + key + "int" for data length + data */
- int length = buffer.getLength();
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 + keyBufLength + 4 + length);
- byteBuffer.putInt(keyBufLength);
- byteBuffer.put(keyBuffer.getData(), 0, keyBufLength);
- byteBuffer.putInt(length);
- byteBuffer.put(buffer.getData(), 0, length);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- }
-
- public void append(String key, DataOutputBuffer buffer) throws IOException
- {
- if (key == null)
- throw new IllegalArgumentException("Key cannot be NULL.");
-
- int length = buffer.getLength();
- /* Size allocated : utfPrefix_ + key length + "int" for data size + data */
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(SequenceFile.utfPrefix_ + key.length() + 4 + length);
- SequenceFile.writeUTF(byteBuffer, key);
- byteBuffer.putInt(length);
- byteBuffer.put(buffer.getData(), 0, length);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- }
-
- public void append(String key, byte[] value) throws IOException
- {
- if (key == null)
- throw new IllegalArgumentException("Key cannot be NULL.");
-
- /* Size allocated key length + "int" for data size + data */
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(utfPrefix_ + key.length() + 4 + value.length);
- SequenceFile.writeUTF(byteBuffer, key);
- byteBuffer.putInt(value.length);
- byteBuffer.put(value);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- }
-
- public void append(String key, long value) throws IOException
- {
- if (key == null)
- throw new IllegalArgumentException("Key cannot be NULL.");
-
- /* Size allocated key length + a long */
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(SequenceFile.utfPrefix_ + key.length() + 8);
- SequenceFile.writeUTF(byteBuffer, key);
- byteBuffer.putLong(value);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- }
-
- /*
- * Be extremely careful while using this API. This currently
- * used to write the commit log header in the commit logs.
- * If not used carefully it could completely screw up reads
- * of other key/value pairs that are written.
- */
- public long writeDirect(byte[] bytes) throws IOException
- {
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(bytes.length);
- byteBuffer.put(bytes);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- return fc_.position();
- }
-
- public void writeLong(long value) throws IOException
- {
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(8);
- byteBuffer.putLong(value);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- }
-
- public void close() throws IOException
- {
- fc_.close();
- }
-
- public void close(byte[] footer, int size) throws IOException
- {
- /* Size is marker length + "int" for size + footer data */
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(utfPrefix_ + SequenceFile.marker_.length() + 4 + footer.length);
- SequenceFile.writeUTF(byteBuffer, SequenceFile.marker_);
- byteBuffer.putInt(size);
- byteBuffer.put(footer);
- byteBuffer.flip();
- fc_.write(byteBuffer);
- }
-
- public String getFileName()
- {
- return filename_;
- }
-
- public long getFileSize() throws IOException
- {
- return fc_.size();
- }
- }
-
- public static class FastConcurrentWriter extends AbstractWriter
- {
- private FileChannel fc_;
- private MappedByteBuffer buffer_;
-
- public FastConcurrentWriter(String filename, int size) throws IOException
- {
- super(filename);
- fc_ = new RandomAccessFile(filename, "rw").getChannel();
- buffer_ = fc_.map(FileChannel.MapMode.READ_WRITE, 0, size);
- buffer_.load();
- }
-
- void unmap(final Object buffer)
- {
- AccessController.doPrivileged(new PrivilegedAction<MappedByteBuffer>()
- {
- public MappedByteBuffer run()
- {
- try
- {
- Method getCleanerMethod = buffer.getClass().getMethod("cleaner", new Class[0]);
- getCleanerMethod.setAccessible(true);
- sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer);
- cleaner.clean();
- }
- catch (Throwable e)
- {
- logger_.warn(LogUtil.throwableToString(e));
- }
- return null;
- }
- });
- }
-
-
- public long getCurrentPosition() throws IOException
- {
- return buffer_.position();
- }
-
- public void seek(long position) throws IOException
- {
- buffer_.position((int) position);
- }
-
- public void append(DataOutputBuffer buffer) throws IOException
- {
- buffer_.put(buffer.getData(), 0, buffer.getLength());
- }
-
- public void append(DataOutputBuffer keyBuffer, DataOutputBuffer buffer) throws IOException
- {
- int keyBufLength = keyBuffer.getLength();
- if (keyBuffer == null || keyBufLength == 0)
- throw new IllegalArgumentException("Key cannot be NULL or of zero length.");
-
- int length = buffer.getLength();
- buffer_.putInt(keyBufLength);
- buffer_.put(keyBuffer.getData(), 0, keyBufLength);
- buffer_.putInt(length);
- buffer_.put(buffer.getData(), 0, length);
- }
-
- public void append(String key, DataOutputBuffer buffer) throws IOException
- {
- if (key == null)
- throw new IllegalArgumentException("Key cannot be NULL.");
-
- int length = buffer.getLength();
- SequenceFile.writeUTF(buffer_, key);
- buffer_.putInt(length);
- buffer_.put(buffer.getData(), 0, length);
- }
-
- public void append(String key, byte[] value) throws IOException
- {
- if (key == null)
- throw new IllegalArgumentException("Key cannot be NULL.");
-
- SequenceFile.writeUTF(buffer_, key);
- buffer_.putInt(value.length);
- buffer_.put(value);
- }
-
- public void append(String key, long value) throws IOException
- {
- if (key == null)
- throw new IllegalArgumentException("Key cannot be NULL.");
-
- SequenceFile.writeUTF(buffer_, key);
- buffer_.putLong(value);
- }
-
- /*
- * Be extremely careful while using this API. This currently
- * used to write the commit log header in the commit logs.
- * If not used carefully it could completely screw up reads
- * of other key/value pairs that are written.
- */
- public long writeDirect(byte[] bytes) throws IOException
- {
- buffer_.put(bytes);
- return buffer_.position();
- }
-
- public void writeLong(long value) throws IOException
- {
- buffer_.putLong(value);
- }
-
- public void close() throws IOException
- {
- buffer_.flip();
- buffer_.force();
- unmap(buffer_);
- fc_.truncate(buffer_.limit());
- }
-
- public void close(byte[] footer, int size) throws IOException
- {
- SequenceFile.writeUTF(buffer_, SequenceFile.marker_);
- buffer_.putInt(size);
- buffer_.put(footer);
- close();
- }
-
- public String getFileName()
- {
- return filename_;
- }
-
- public long getFileSize() throws IOException
- {
- return buffer_.position();
- }
- }
-
-
/**
* This is a reader that finds the block for a starting column and returns
* blocks before/after it for each next call. This function assumes that
@@ -1111,11 +833,6 @@
return new BufferWriter(filename, size);
}
- public static IFileWriter fastWriter(String filename, int size) throws IOException
- {
- return new FastConcurrentWriter(filename, size);
- }
-
public static IFileReader reader(String filename) throws IOException
{
return new Reader(filename);