cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r963934 - in /cassandra/branches/cassandra-0.6: src/java/org/apache/cassandra/config/DatabaseDescriptor.java test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Date Wed, 14 Jul 2010 03:39:32 GMT
Author: jbellis
Date: Wed Jul 14 03:39:32 2010
New Revision: 963934

URL: http://svn.apache.org/viewvc?rev=963934&view=rev
Log:
log diskaccessmode even when it is explicitly set.  patch by Rob Coli; reviewed by jbellis
for CASSANDRA-1277

Modified:
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=963934&r1=963933&r2=963934&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Wed Jul 14 03:39:32 2010
@@ -225,20 +225,24 @@ public class DatabaseDescriptor
             {
                 throw new ConfigurationException("DiskAccessMode must be either 'auto', 'mmap',
'mmap_index_only', or 'standard'");
             }
+
+            /* evaluate the DiskAccessMode conf directive, which also affects indexAccessMode
selection */
             if (diskAccessMode == DiskAccessMode.auto)
             {
                 diskAccessMode = System.getProperty("os.arch").contains("64") ? DiskAccessMode.mmap
: DiskAccessMode.standard;
                 indexAccessMode = diskAccessMode;
-                logger.info("Auto DiskAccessMode determined to be " + diskAccessMode);
+                logger.info("DiskAccessMode 'auto' determined to be " + diskAccessMode +
", indexAccessMode is " + indexAccessMode );
             }
             else if (diskAccessMode == DiskAccessMode.mmap_index_only)
             {
                 diskAccessMode = DiskAccessMode.standard;
                 indexAccessMode = DiskAccessMode.mmap;
+                logger.info("DiskAccessMode is" + diskAccessMode + ", indexAccessMode is
" + indexAccessMode );
             }
             else
             {
                 indexAccessMode = diskAccessMode;
+                logger.info("DiskAccessMode is" + diskAccessMode + ", indexAccessMode is
" + indexAccessMode );
             }
 
             /* Authentication and authorization backend, implementing IAuthenticator */

Modified: cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=963934&r1=963933&r2=963934&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
(original)
+++ cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Wed Jul 14 03:39:32 2010
@@ -19,6 +19,7 @@
 package org.apache.cassandra.db;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.*;
 import java.util.concurrent.ExecutionException;
 
@@ -29,6 +30,7 @@ import org.junit.Test;
 import static junit.framework.Assert.assertEquals;
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.Util;
+import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.WrappedRunnable;
 
@@ -138,44 +140,60 @@ public class ColumnFamilyStoreTest exten
     @Test
     public void testWrappedRangeQuery() throws IOException, ExecutionException, InterruptedException
     {
-        ColumnFamilyStore cfs = insertKey1Key2();
-
+        ColumnFamilyStore cfs = insert("key1", "key2", "key3", "key4", "key5");
         IPartitioner p = StorageService.getPartitioner();
-        RangeSliceReply result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
-                                                   new Range(p.getToken("key15"), p.getToken("key1")),
-                                                   10,
-                                                   null,
-                                                   Arrays.asList("asdf".getBytes()));
-        assertEquals(2, result.rows.size());
+        RangeSliceReply result;
+
+        result = getRangeSlice(cfs, p.getToken("key15"), p.getToken("key1"));
+        assertKeys(result.rows, Arrays.asList("key2", "key3", "key4", "key5", "key1"));
+
+        result = getRangeSlice(cfs, p.getToken("key3"), p.getToken("key3"));
+        assertKeys(result.rows, Arrays.asList("key4", "key5", "key1", "key2", "key3"));
+
+        result = getRangeSlice(cfs, p.getToken("key25"), p.getToken("key25"));
+        assertKeys(result.rows, Arrays.asList("key3", "key4", "key5", "key1", "key2"));
+    }
+
+    private RangeSliceReply getRangeSlice(ColumnFamilyStore cfs, Token start, Token end)
throws IOException, ExecutionException, InterruptedException
+    {
+        return cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
+                                 new Range(start, end),
+                                 10,
+                                 null,
+                                 Arrays.asList("asdf".getBytes()));
+    }
+
+    private void assertKeys(List<Row> rows, List<String> keys) throws UnsupportedEncodingException
+    {
+        assertEquals(keys.size(), rows.size());
+        for (int i = 0; i < keys.size(); i++)
+        {
+            assertEquals(keys.get(i), rows.get(i).key);
+        }
     }
 
     @Test
     public void testSkipStartKey() throws IOException, ExecutionException, InterruptedException
     {
-        ColumnFamilyStore cfs = insertKey1Key2();
-
+        ColumnFamilyStore cfs = insert("key1", "key2");
         IPartitioner p = StorageService.getPartitioner();
-        RangeSliceReply result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
-                                                   new Range(p.getToken("key1"), p.getToken("key2")),
-                                                   10,
-                                                   null,
-                                                   Arrays.asList("asdf".getBytes()));
-        assertEquals(1, result.rows.size());
-        assert result.rows.get(0).key.equals("key2");
+
+        RangeSliceReply result = getRangeSlice(cfs, p.getToken("key1"), p.getToken("key2"));
+        assertKeys(result.rows, Arrays.asList("key2"));
     }
 
-    private ColumnFamilyStore insertKey1Key2() throws IOException, ExecutionException, InterruptedException
+    private ColumnFamilyStore insert(String... keys) throws IOException, ExecutionException,
InterruptedException
     {
         List<RowMutation> rms = new LinkedList<RowMutation>();
         RowMutation rm;
-        rm = new RowMutation("Keyspace2", "key1");
-        rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(),
0);
-        rms.add(rm);
-        Util.writeColumnFamily(rms);
+        for (String key : keys)
+        {
+            rm = new RowMutation("Keyspace2", key);
+            rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(),
0);
+            rms.add(rm);
+        }
 
-        rm = new RowMutation("Keyspace2", "key2");
-        rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(),
0);
-        rms.add(rm);
         return Util.writeColumnFamily(rms);
     }
+
 }



Mime
View raw message