Merge branch 'cassandra-1.1' into trunk

This commit is contained in:
Vijay Parthasarathy 2012-05-21 13:57:21 -07:00
commit ac362dadd3
23 changed files with 110 additions and 66 deletions

View File

@ -64,6 +64,7 @@
* fix missing arrayOffset in FBUtilities.hash (CASSANDRA-4250)
* (cql3) Add name of parameters in CqlResultSet (CASSANDRA-4242)
* (cql3) Correctly validat order by queries (CASSANDRA-4246)
* rename stress to cassandra-stress for saner packaging (CASSANDRA-4256)
Merged from 1.0:
* Fix super columns bug where cache is not updated (CASSANDRA-4190)
* fix maxTimestamp to include row tombstones (CASSANDRA-4116)

View File

@ -12,6 +12,7 @@ bin/sstable2json usr/bin
bin/sstablekeys usr/bin
bin/sstableloader usr/bin
bin/cqlsh usr/bin
tools/bin/cassandra-stress usr/bin
lib/*.jar usr/share/cassandra/lib
lib/*.zip usr/share/cassandra/lib
lib/licenses usr/share/doc/cassandra

4
debian/rules vendored
View File

@ -45,6 +45,10 @@ install: build
dh_install build/apache-cassandra-thrift-$(VERSION).jar \
usr/share/cassandra
# Copy stress jar
dh_install build/tools/lib/stress.jar \
usr/share/cassandra
dh_link usr/share/cassandra/apache-cassandra-$(VERSION).jar \
usr/share/cassandra/apache-cassandra.jar

Binary file not shown.

View File

@ -46,7 +46,7 @@ public class ConcurrentLinkedHashCache<K, V> implements ICache<K, V>
*
* @return initialized cache
*/
public static <K, V> ConcurrentLinkedHashCache<K, V> create(int capacity)
public static <K, V> ConcurrentLinkedHashCache<K, V> create(long capacity)
{
return create(capacity, Weighers.<V>singleton());
}
@ -62,7 +62,7 @@ public class ConcurrentLinkedHashCache<K, V> implements ICache<K, V>
*
* @return initialized cache
*/
public static <K, V> ConcurrentLinkedHashCache<K, V> create(int weightedCapacity, Weigher<V> weigher)
public static <K, V> ConcurrentLinkedHashCache<K, V> create(long weightedCapacity, Weigher<V> weigher)
{
ConcurrentLinkedHashMap<K, V> map = new ConcurrentLinkedHashMap.Builder<K, V>()
.weigher(weigher)
@ -73,12 +73,12 @@ public class ConcurrentLinkedHashCache<K, V> implements ICache<K, V>
return new ConcurrentLinkedHashCache<K, V>(map);
}
public int capacity()
public long capacity()
{
return map.capacity();
}
public void setCapacity(int capacity)
public void setCapacity(long capacity)
{
map.setCapacity(capacity);
}
@ -93,7 +93,7 @@ public class ConcurrentLinkedHashCache<K, V> implements ICache<K, V>
return map.size();
}
public int weightedSize()
public long weightedSize()
{
return map.weightedSize();
}

View File

@ -24,7 +24,7 @@ import org.github.jamm.MemoryMeter;
public class ConcurrentLinkedHashCacheProvider implements IRowCacheProvider
{
public ICache<RowCacheKey, IRowCacheEntry> create(int capacity, boolean useMemoryWeigher)
public ICache<RowCacheKey, IRowCacheEntry> create(long capacity, boolean useMemoryWeigher)
{
return ConcurrentLinkedHashCache.create(capacity, useMemoryWeigher
? createMemoryWeigher()

View File

@ -26,9 +26,9 @@ import java.util.Set;
*/
public interface ICache<K, V>
{
public int capacity();
public long capacity();
public void setCapacity(int capacity);
public void setCapacity(long capacity);
public void put(K key, V value);
@ -42,7 +42,7 @@ public interface ICache<K, V>
public int size();
public int weightedSize();
public long weightedSize();
public void clear();

View File

@ -24,5 +24,5 @@ import org.apache.cassandra.db.ColumnFamily;
*/
public interface IRowCacheProvider
{
public ICache<RowCacheKey, IRowCacheEntry> create(int capacity, boolean useMemoryWeigher);
public ICache<RowCacheKey, IRowCacheEntry> create(long capacity, boolean useMemoryWeigher);
}

View File

@ -71,7 +71,7 @@ public class InstrumentingCache<K, V>
map.remove(key);
}
public int getCapacity()
public long getCapacity()
{
return map.capacity();
}
@ -81,12 +81,12 @@ public class InstrumentingCache<K, V>
return capacitySetManually;
}
public void updateCapacity(int capacity)
public void updateCapacity(long capacity)
{
map.setCapacity(capacity);
}
public void setCapacity(int capacity)
public void setCapacity(long capacity)
{
updateCapacity(capacity);
capacitySetManually = true;
@ -97,7 +97,7 @@ public class InstrumentingCache<K, V>
return map.size();
}
public int weightedSize()
public long weightedSize()
{
return map.weightedSize();
}

View File

@ -49,7 +49,7 @@ public class SerializingCache<K, V> implements ICache<K, V>
private final ConcurrentLinkedHashMap<K, FreeableMemory> map;
private final ISerializer<V> serializer;
public SerializingCache(int capacity, boolean useMemoryWeigher, ISerializer<V> serializer)
public SerializingCache(long capacity, boolean useMemoryWeigher, ISerializer<V> serializer)
{
this.serializer = serializer;
@ -122,12 +122,12 @@ public class SerializingCache<K, V> implements ICache<K, V>
return freeableMemory;
}
public int capacity()
public long capacity()
{
return map.capacity();
}
public void setCapacity(int capacity)
public void setCapacity(long capacity)
{
map.setCapacity(capacity);
}
@ -142,7 +142,7 @@ public class SerializingCache<K, V> implements ICache<K, V>
return map.size();
}
public int weightedSize()
public long weightedSize()
{
return map.weightedSize();
}

View File

@ -29,7 +29,7 @@ import org.apache.cassandra.net.MessagingService;
public class SerializingCacheProvider implements IRowCacheProvider
{
public ICache<RowCacheKey, IRowCacheEntry> create(int capacity, boolean useMemoryWeigher)
public ICache<RowCacheKey, IRowCacheEntry> create(long capacity, boolean useMemoryWeigher)
{
return new SerializingCache<RowCacheKey, IRowCacheEntry>(capacity, useMemoryWeigher, new RowCacheSerializer());
}

View File

@ -125,11 +125,11 @@ public class Config
public boolean trickle_fsync = false;
public int trickle_fsync_interval_in_kb = 10240;
public Integer key_cache_size_in_mb = null;
public Long key_cache_size_in_mb = null;
public int key_cache_save_period = 14400;
public int key_cache_keys_to_save = Integer.MAX_VALUE;
public int row_cache_size_in_mb = 0;
public long row_cache_size_in_mb = 0;
public int row_cache_save_period = 0;
public int row_cache_keys_to_save = Integer.MAX_VALUE;
public String row_cache_provider = ConcurrentLinkedHashCacheProvider.class.getSimpleName();

View File

@ -82,7 +82,7 @@ public class DatabaseDescriptor
private static RequestSchedulerId requestSchedulerId;
private static RequestSchedulerOptions requestSchedulerOptions;
private static int keyCacheSizeInMB;
private static long keyCacheSizeInMB;
private static IRowCacheProvider rowCacheProvider;
/**
@ -1019,7 +1019,7 @@ public class DatabaseDescriptor
return conf.trickle_fsync_interval_in_kb;
}
public static int getKeyCacheSizeInMB()
public static long getKeyCacheSizeInMB()
{
return keyCacheSizeInMB;
}
@ -1034,7 +1034,7 @@ public class DatabaseDescriptor
return conf.key_cache_keys_to_save;
}
public static int getRowCacheSizeInMB()
public static long getRowCacheSizeInMB()
{
return conf.row_cache_size_in_mb;
}

View File

@ -96,7 +96,7 @@ public class CacheService implements CacheServiceMBean
{
logger.info("Initializing key cache with capacity of {} MBs.", DatabaseDescriptor.getKeyCacheSizeInMB());
int keyCacheInMemoryCapacity = DatabaseDescriptor.getKeyCacheSizeInMB() * 1024 * 1024;
long keyCacheInMemoryCapacity = DatabaseDescriptor.getKeyCacheSizeInMB() * 1024 * 1024;
// as values are constant size we can use singleton weigher
// where 48 = 40 bytes (average size of the key) + 8 bytes (size of value)
@ -123,7 +123,7 @@ public class CacheService implements CacheServiceMBean
DatabaseDescriptor.getRowCacheSizeInMB(),
DatabaseDescriptor.getRowCacheProvider().getClass().getName());
int rowCacheInMemoryCapacity = DatabaseDescriptor.getRowCacheSizeInMB() * 1024 * 1024;
long rowCacheInMemoryCapacity = DatabaseDescriptor.getRowCacheSizeInMB() * 1024 * 1024;
// cache object
ICache<RowCacheKey, IRowCacheEntry> rc = DatabaseDescriptor.getRowCacheProvider().create(rowCacheInMemoryCapacity, true);
@ -208,17 +208,17 @@ public class CacheService implements CacheServiceMBean
rowCache.clear();
}
public int getRowCacheCapacityInBytes()
public long getRowCacheCapacityInBytes()
{
return rowCache.getCapacity();
}
public int getRowCacheCapacityInMB()
public long getRowCacheCapacityInMB()
{
return getRowCacheCapacityInBytes() / 1024 / 1024;
}
public void setRowCacheCapacityInMB(int capacity)
public void setRowCacheCapacityInMB(long capacity)
{
if (capacity < 0)
throw new RuntimeException("capacity should not be negative.");
@ -226,17 +226,17 @@ public class CacheService implements CacheServiceMBean
rowCache.setCapacity(capacity * 1024 * 1024);
}
public int getKeyCacheCapacityInBytes()
public long getKeyCacheCapacityInBytes()
{
return keyCache.getCapacity() * AVERAGE_KEY_CACHE_ROW_SIZE;
}
public int getKeyCacheCapacityInMB()
public long getKeyCacheCapacityInMB()
{
return getKeyCacheCapacityInBytes() / 1024 / 1024;
}
public void setKeyCacheCapacityInMB(int capacity)
public void setKeyCacheCapacityInMB(long capacity)
{
if (capacity < 0)
throw new RuntimeException("capacity should not be negative.");
@ -244,12 +244,12 @@ public class CacheService implements CacheServiceMBean
keyCache.setCapacity(capacity * 1024 * 1024 / 48);
}
public int getRowCacheSize()
public long getRowCacheSize()
{
return rowCache.weightedSize();
}
public int getKeyCacheSize()
public long getKeyCacheSize()
{
return keyCache.weightedSize() * AVERAGE_KEY_CACHE_ROW_SIZE;
}

View File

@ -46,17 +46,17 @@ public interface CacheServiceMBean
*/
public void invalidateRowCache();
public int getRowCacheCapacityInMB();
public int getRowCacheCapacityInBytes();
public void setRowCacheCapacityInMB(int capacity);
public long getRowCacheCapacityInMB();
public long getRowCacheCapacityInBytes();
public void setRowCacheCapacityInMB(long capacity);
public int getKeyCacheCapacityInMB();
public int getKeyCacheCapacityInBytes();
public void setKeyCacheCapacityInMB(int capacity);
public long getKeyCacheCapacityInMB();
public long getKeyCacheCapacityInBytes();
public void setKeyCacheCapacityInMB(long capacity);
public int getRowCacheSize();
public long getRowCacheSize();
public int getKeyCacheSize();
public long getKeyCacheSize();
/**
* sets each cache's maximum capacity to "reduce_cache_capacity_to" of its current size

View File

@ -38,7 +38,7 @@ public class CacheProviderTest extends SchemaLoader
String key3 = "key3";
String key4 = "key4";
String key5 = "key5";
private static final int CAPACITY = 4;
private static final long CAPACITY = 4;
private String tableName = "Keyspace1";
private String cfName = "Standard1";

24
tools/bin/stress → tools/bin/cassandra-stress Executable file → Normal file
View File

@ -16,22 +16,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if [ "x$CLASSPATH" = "x" ]; then
# execute from the build dir.
if [ -d `dirname $0`/../../build/classes ]; then
for directory in `dirname $0`/../../build/classes/*; do
CLASSPATH=$CLASSPATH:$directory
done
else
if [ -f `dirname $0`/../lib/stress.jar ]; then
CLASSPATH=`dirname $0`/../lib/stress.jar
if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
for include in /usr/share/cassandra/cassandra.in.sh \
/usr/local/share/cassandra/cassandra.in.sh \
/opt/cassandra/cassandra.in.sh \
`dirname $0`/cassandra.in.sh; do
if [ -r $include ]; then
. $include
break
fi
fi
for jar in `dirname $0`/../../lib/*.jar; do
CLASSPATH=$CLASSPATH:$jar
done
elif [ -r $CASSANDRA_INCLUDE ]; then
. $CASSANDRA_INCLUDE
fi
if [ -x $JAVA_HOME/bin/java ]; then

View File

2
tools/bin/stressd → tools/bin/cassandra-stressd Executable file → Normal file
View File

@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
DESC="Stress Test Daemon"
DESC="Cassandra Stress Test Daemon"
if [ "x$CLASSPATH" = "x" ]; then

42
tools/bin/cassandra.in.sh Normal file
View File

@ -0,0 +1,42 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if [ "x$CASSANDRA_HOME" = "x" ]; then
CASSANDRA_HOME=`dirname $0`/../../
fi
# The directory where Cassandra's configs live (required)
if [ "x$CASSANDRA_CONF" = "x" ]; then
CASSANDRA_CONF=$CASSANDRA_HOME/conf
fi
# This can be the path to a jar file, or a directory containing the
# compiled classes. NOTE: This isn't needed by the startup script,
# it's just used here in constructing the classpath.
cassandra_bin=$CASSANDRA_HOME/build/classes/main
cassandra_bin=$cassandra_bin:$CASSANDRA_HOME/build/classes/stress
cassandra_bin=$cassandra_bin:$CASSANDRA_HOME/build/classes/thrift
#cassandra_bin=$cassandra_home/build/cassandra.jar
# JAVA_HOME can optionally be set here
#JAVA_HOME=/usr/local/jdk6
# The java classpath (required)
CLASSPATH=$CASSANDRA_CONF:$cassandra_bin
for jar in $CASSANDRA_HOME/lib/*.jar; do
CLASSPATH=$CLASSPATH:$jar
done

View File

@ -1,14 +1,14 @@
stress
cassandra-stress
======
Description
-----------
stress is a tool for benchmarking and load testing a Cassandra
cassandra-stress is a tool for benchmarking and load testing a Cassandra
cluster. It is significantly faster than the older py_stress tool.
Setup
-----
Run `ant` from the Cassandra source directory, then stress can be invoke from tools/bin/stress
Run `ant` from the Cassandra source directory, then cassandra-stress can be invoke from tools/bin/cassandra-stress
Usage
-----
@ -42,7 +42,7 @@ Important options:
when switching partioners.) This option sets the number of rows to
slice at a time and defaults to 1000.
-r or --random:
Only used for reads. By default, stress.py will perform reads on rows
Only used for reads. By default, cassandra-stress will perform reads on rows
with a guassian distribution, which will cause some repeats. Setting
this option makes the reads completely random instead.
-i or --progress-interval:
@ -53,6 +53,6 @@ Remember that you must perform inserts before performing reads or range slices.
Examples
--------
* contrib/stress/bin/stress -d 192.168.1.101 # 1M inserts to given host
* contrib/stress/bin/stress -d 192.168.1.101 -o read # 1M reads
* contrib/stress/bin/stress -d 192.168.1.101,192.168.1.102 -n 10000000 # 10M inserts spread across two nodes
* tools/bin/cassandra-stress -d 192.168.1.101 # 1M inserts to given host
* tools/bin/cassandra-stress -d 192.168.1.101 -o read # 1M reads
* tools/bin/cassandra-stress -d 192.168.1.101,192.168.1.102 -n 10000000 # 10M inserts spread across two nodes

View File

@ -100,7 +100,7 @@ public final class Stress
*/
public static void printHelpMessage()
{
System.out.println("Usage: ./bin/stress [options]\n\nOptions:");
System.out.println("Usage: ./bin/cassandra-stress [options]\n\nOptions:");
for(Object o : Session.availableOptions.getOptions())
{