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 2013/11/04 16:49:18 UTC
[1/6] git commit: add non-jamm path for cached statements patch by
Michael Stepura; reviewed by jbellis for CASSANDRA-6293
Updated Branches:
refs/heads/cassandra-1.2 b461c3bfa -> e76819135
refs/heads/cassandra-2.0 4a439d22c -> 424fb4812
refs/heads/trunk 2bbabe154 -> d86b7e3ff
add non-jamm path for cached statements
patch by Michael Stepura; reviewed by jbellis for CASSANDRA-6293
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e7681913
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e7681913
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e7681913
Branch: refs/heads/cassandra-1.2
Commit: e76819135163836ce687cc26d4a085d73e6fbfd0
Parents: b461c3b
Author: Jonathan Ellis <jb...@apache.org>
Authored: Mon Nov 4 09:47:59 2013 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Mon Nov 4 09:47:59 2013 -0600
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/cql3/QueryProcessor.java | 49 +++++++++++++++-----
src/java/org/apache/cassandra/db/Memtable.java | 6 +--
3 files changed, 41 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e2fcbb8..fd93a5f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
1.2.12
+ * add non-jamm path for cached statements (CASSANDRA-6293)
* (Hadoop) Require CFRR batchSize to be at least 2 (CASSANDRA-6114)
* Fix altering column types (CASSANDRA-6185)
* cqlsh: fix CREATE/ALTER WITH completion (CASSANDRA-6196)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index 71a57f4..2d43bdc 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -47,34 +47,54 @@ public class QueryProcessor
private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class);
private static final MemoryMeter meter = new MemoryMeter();
private static final long MAX_CACHE_PREPARED_MEMORY = Runtime.getRuntime().maxMemory() / 256;
+ private static final int MAX_CACHE_PREPARED_COUNT = 10000;
private static EntryWeigher<MD5Digest, CQLStatement> cqlMemoryUsageWeigher = new EntryWeigher<MD5Digest, CQLStatement>()
{
@Override
public int weightOf(MD5Digest key, CQLStatement value)
{
- return Ints.checkedCast(meter.measureDeep(key) + meter.measureDeep(value));
+ return Ints.checkedCast(measure(key) + measure(value));
}
};
- private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(cqlMemoryUsageWeigher)
- .build();
-
private static EntryWeigher<Integer, CQLStatement> thriftMemoryUsageWeigher = new EntryWeigher<Integer, CQLStatement>()
{
@Override
public int weightOf(Integer key, CQLStatement value)
{
- return Ints.checkedCast(meter.measureDeep(key) + meter.measureDeep(value));
+ return Ints.checkedCast(measure(key) + measure(value));
}
};
- private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(thriftMemoryUsageWeigher)
- .build();
+ private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements;
+ private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements;
+
+ static
+ {
+ if (MemoryMeter.isInitialized())
+ {
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(cqlMemoryUsageWeigher)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(thriftMemoryUsageWeigher)
+ .build();
+ }
+ else
+ {
+ logger.error("Unable to initialize MemoryMeter (jamm not specified as javaagent). This means "
+ + "Cassandra will be unable to measure object sizes accurately and may consequently OOM.");
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ }
+ }
public static CQLStatement getPrepared(MD5Digest id)
@@ -211,7 +231,7 @@ public class QueryProcessor
// Concatenate the current keyspace so we don't mix prepared statements between keyspace (#5352).
// (if the keyspace is null, queryString has to have a fully-qualified keyspace so it's fine.
String toHash = keyspace == null ? queryString : keyspace + queryString;
- long statementSize = meter.measureDeep(prepared.statement);
+ long statementSize = measure(prepared.statement);
// don't execute the statement if it's bigger than the allowed threshold
if (statementSize > MAX_CACHE_PREPARED_MEMORY)
throw new InvalidRequestException(String.format("Prepared statement of size %d bytes is larger than allowed maximum of %d bytes.",
@@ -305,4 +325,9 @@ public class QueryProcessor
throw new SyntaxException("Invalid or malformed CQL query string: " + e.getMessage());
}
}
+
+ private static long measure(Object key)
+ {
+ return MemoryMeter.isInitialized() ? meter.measureDeep(key) : 1;
+ }
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 1364030..11a49ed 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -173,9 +173,9 @@ public class Memtable
if (!MemoryMeter.isInitialized())
{
// hack for openjdk. we log a warning about this in the startup script too.
- logger.warn("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
- + " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
- + " upgrade to the Sun JRE instead", cfs.liveRatio);
+ logger.error("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
+ + " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
+ + " upgrade to the Sun JRE instead", cfs.liveRatio);
return;
}
[5/6] git commit: merge from 1.2
Posted by jb...@apache.org.
merge from 1.2
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/424fb481
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/424fb481
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/424fb481
Branch: refs/heads/cassandra-2.0
Commit: 424fb4812e5b3b4882201e44d3576571e51b5fa7
Parents: 4a439d2 e768191
Author: Jonathan Ellis <jb...@apache.org>
Authored: Mon Nov 4 09:49:01 2013 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Mon Nov 4 09:49:01 2013 -0600
----------------------------------------------------------------------
CHANGES.txt | 7 +++
.../apache/cassandra/cql3/QueryProcessor.java | 49 +++++++++++++++-----
src/java/org/apache/cassandra/db/Memtable.java | 6 +--
3 files changed, 47 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/424fb481/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index a6636a5,fd93a5f..38fd876
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,20 -1,11 +1,27 @@@
-1.2.12
+2.0.3
+ * Avoid flushing compaction_history after each operation (CASSANDRA-6287)
+ * Fix repair assertion error when tombstones expire (CASSANDRA-6277)
+ * Skip loading corrupt key cache (CASSANDRA-6260)
+ * Fixes for compacting larger-than-memory rows (CASSANDRA-6274)
+ * Compact hottest sstables first and optionally omit coldest from
+ compaction entirely (CASSANDRA-6109)
+ * Fix modifying column_metadata from thrift (CASSANDRA-6182)
+ * cqlsh: fix LIST USERS output (CASSANDRA-6242)
+ * Add IRequestSink interface (CASSANDRA-6248)
+ * Update memtable size while flushing (CASSANDRA-6249)
+ * Provide hooks around CQL2/CQL3 statement execution (CASSANDRA-6252)
+ * Require Permission.SELECT for CAS updates (CASSANDRA-6247)
+ * New CQL-aware SSTableWriter (CASSANDRA-5894)
+ * Reject CAS operation when the protocol v1 is used (CASSANDRA-6270)
+ * Correctly throw error when frame too large (CASSANDRA-5981)
+Merged from 1.2:
+ * add non-jamm path for cached statements (CASSANDRA-6293)
+ * (Hadoop) Require CFRR batchSize to be at least 2 (CASSANDRA-6114)
+ * Fix altering column types (CASSANDRA-6185)
+ * cqlsh: fix CREATE/ALTER WITH completion (CASSANDRA-6196)
+ * add windows bat files for shell commands (CASSANDRA-6145)
+ * Fix potential stack overflow during range tombstones insertion (CASSANDRA-6181)
+ * (Hadoop) Make LOCAL_ONE the default consistency level (CASSANDRA-6214)
* Require logging in for Thrift CQL2/3 statement preparation (CASSANDRA-6254)
* restrict max_num_tokens to 1536 (CASSANDRA-6267)
* Nodetool gets default JMX port from cassandra-env.sh (CASSANDRA-6273)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/424fb481/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/QueryProcessor.java
index dc2649c,2d43bdc..71bf1b0
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@@ -73,44 -67,35 +69,68 @@@ public class QueryProcesso
}
};
- private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(thriftMemoryUsageWeigher)
- .build();
+ private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements;
+ private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements;
+
+ static
+ {
+ if (MemoryMeter.isInitialized())
+ {
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(cqlMemoryUsageWeigher)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(thriftMemoryUsageWeigher)
+ .build();
+ }
+ else
+ {
+ logger.error("Unable to initialize MemoryMeter (jamm not specified as javaagent). This means "
+ + "Cassandra will be unable to measure object sizes accurately and may consequently OOM.");
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ }
+ }
+ private static final List<PreExecutionHook> preExecutionHooks = new CopyOnWriteArrayList<>();
+ private static final List<PostExecutionHook> postExecutionHooks = new CopyOnWriteArrayList<>();
+ private static final List<PostPreparationHook> postPreparationHooks = new CopyOnWriteArrayList<>();
+
+ public static void addPreExecutionHook(PreExecutionHook hook)
+ {
+ preExecutionHooks.add(hook);
+ }
+
+ public static void removePreExecutionHook(PreExecutionHook hook)
+ {
+ preExecutionHooks.remove(hook);
+ }
+
+ public static void addPostExecutionHook(PostExecutionHook hook)
+ {
+ postExecutionHooks.add(hook);
+ }
+
+ public static void removePostExecutionHook(PostExecutionHook hook)
+ {
+ postExecutionHooks.remove(hook);
+ }
+
+ public static void addPostPreparationHook(PostPreparationHook hook)
+ {
+ postPreparationHooks.add(hook);
+ }
+
+ public static void removePostPreparationHook(PostPreparationHook hook)
+ {
+ postPreparationHooks.remove(hook);
+ }
public static CQLStatement getPrepared(MD5Digest id)
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/424fb481/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
[2/6] git commit: add non-jamm path for cached statements patch by
Michael Stepura; reviewed by jbellis for CASSANDRA-6293
Posted by jb...@apache.org.
add non-jamm path for cached statements
patch by Michael Stepura; reviewed by jbellis for CASSANDRA-6293
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e7681913
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e7681913
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e7681913
Branch: refs/heads/cassandra-2.0
Commit: e76819135163836ce687cc26d4a085d73e6fbfd0
Parents: b461c3b
Author: Jonathan Ellis <jb...@apache.org>
Authored: Mon Nov 4 09:47:59 2013 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Mon Nov 4 09:47:59 2013 -0600
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/cql3/QueryProcessor.java | 49 +++++++++++++++-----
src/java/org/apache/cassandra/db/Memtable.java | 6 +--
3 files changed, 41 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e2fcbb8..fd93a5f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
1.2.12
+ * add non-jamm path for cached statements (CASSANDRA-6293)
* (Hadoop) Require CFRR batchSize to be at least 2 (CASSANDRA-6114)
* Fix altering column types (CASSANDRA-6185)
* cqlsh: fix CREATE/ALTER WITH completion (CASSANDRA-6196)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index 71a57f4..2d43bdc 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -47,34 +47,54 @@ public class QueryProcessor
private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class);
private static final MemoryMeter meter = new MemoryMeter();
private static final long MAX_CACHE_PREPARED_MEMORY = Runtime.getRuntime().maxMemory() / 256;
+ private static final int MAX_CACHE_PREPARED_COUNT = 10000;
private static EntryWeigher<MD5Digest, CQLStatement> cqlMemoryUsageWeigher = new EntryWeigher<MD5Digest, CQLStatement>()
{
@Override
public int weightOf(MD5Digest key, CQLStatement value)
{
- return Ints.checkedCast(meter.measureDeep(key) + meter.measureDeep(value));
+ return Ints.checkedCast(measure(key) + measure(value));
}
};
- private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(cqlMemoryUsageWeigher)
- .build();
-
private static EntryWeigher<Integer, CQLStatement> thriftMemoryUsageWeigher = new EntryWeigher<Integer, CQLStatement>()
{
@Override
public int weightOf(Integer key, CQLStatement value)
{
- return Ints.checkedCast(meter.measureDeep(key) + meter.measureDeep(value));
+ return Ints.checkedCast(measure(key) + measure(value));
}
};
- private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(thriftMemoryUsageWeigher)
- .build();
+ private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements;
+ private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements;
+
+ static
+ {
+ if (MemoryMeter.isInitialized())
+ {
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(cqlMemoryUsageWeigher)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(thriftMemoryUsageWeigher)
+ .build();
+ }
+ else
+ {
+ logger.error("Unable to initialize MemoryMeter (jamm not specified as javaagent). This means "
+ + "Cassandra will be unable to measure object sizes accurately and may consequently OOM.");
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ }
+ }
public static CQLStatement getPrepared(MD5Digest id)
@@ -211,7 +231,7 @@ public class QueryProcessor
// Concatenate the current keyspace so we don't mix prepared statements between keyspace (#5352).
// (if the keyspace is null, queryString has to have a fully-qualified keyspace so it's fine.
String toHash = keyspace == null ? queryString : keyspace + queryString;
- long statementSize = meter.measureDeep(prepared.statement);
+ long statementSize = measure(prepared.statement);
// don't execute the statement if it's bigger than the allowed threshold
if (statementSize > MAX_CACHE_PREPARED_MEMORY)
throw new InvalidRequestException(String.format("Prepared statement of size %d bytes is larger than allowed maximum of %d bytes.",
@@ -305,4 +325,9 @@ public class QueryProcessor
throw new SyntaxException("Invalid or malformed CQL query string: " + e.getMessage());
}
}
+
+ private static long measure(Object key)
+ {
+ return MemoryMeter.isInitialized() ? meter.measureDeep(key) : 1;
+ }
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 1364030..11a49ed 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -173,9 +173,9 @@ public class Memtable
if (!MemoryMeter.isInitialized())
{
// hack for openjdk. we log a warning about this in the startup script too.
- logger.warn("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
- + " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
- + " upgrade to the Sun JRE instead", cfs.liveRatio);
+ logger.error("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
+ + " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
+ + " upgrade to the Sun JRE instead", cfs.liveRatio);
return;
}
[3/6] git commit: add non-jamm path for cached statements patch by
Michael Stepura; reviewed by jbellis for CASSANDRA-6293
Posted by jb...@apache.org.
add non-jamm path for cached statements
patch by Michael Stepura; reviewed by jbellis for CASSANDRA-6293
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e7681913
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e7681913
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e7681913
Branch: refs/heads/trunk
Commit: e76819135163836ce687cc26d4a085d73e6fbfd0
Parents: b461c3b
Author: Jonathan Ellis <jb...@apache.org>
Authored: Mon Nov 4 09:47:59 2013 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Mon Nov 4 09:47:59 2013 -0600
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/cql3/QueryProcessor.java | 49 +++++++++++++++-----
src/java/org/apache/cassandra/db/Memtable.java | 6 +--
3 files changed, 41 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e2fcbb8..fd93a5f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
1.2.12
+ * add non-jamm path for cached statements (CASSANDRA-6293)
* (Hadoop) Require CFRR batchSize to be at least 2 (CASSANDRA-6114)
* Fix altering column types (CASSANDRA-6185)
* cqlsh: fix CREATE/ALTER WITH completion (CASSANDRA-6196)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index 71a57f4..2d43bdc 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -47,34 +47,54 @@ public class QueryProcessor
private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class);
private static final MemoryMeter meter = new MemoryMeter();
private static final long MAX_CACHE_PREPARED_MEMORY = Runtime.getRuntime().maxMemory() / 256;
+ private static final int MAX_CACHE_PREPARED_COUNT = 10000;
private static EntryWeigher<MD5Digest, CQLStatement> cqlMemoryUsageWeigher = new EntryWeigher<MD5Digest, CQLStatement>()
{
@Override
public int weightOf(MD5Digest key, CQLStatement value)
{
- return Ints.checkedCast(meter.measureDeep(key) + meter.measureDeep(value));
+ return Ints.checkedCast(measure(key) + measure(value));
}
};
- private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(cqlMemoryUsageWeigher)
- .build();
-
private static EntryWeigher<Integer, CQLStatement> thriftMemoryUsageWeigher = new EntryWeigher<Integer, CQLStatement>()
{
@Override
public int weightOf(Integer key, CQLStatement value)
{
- return Ints.checkedCast(meter.measureDeep(key) + meter.measureDeep(value));
+ return Ints.checkedCast(measure(key) + measure(value));
}
};
- private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(thriftMemoryUsageWeigher)
- .build();
+ private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements;
+ private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements;
+
+ static
+ {
+ if (MemoryMeter.isInitialized())
+ {
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(cqlMemoryUsageWeigher)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(thriftMemoryUsageWeigher)
+ .build();
+ }
+ else
+ {
+ logger.error("Unable to initialize MemoryMeter (jamm not specified as javaagent). This means "
+ + "Cassandra will be unable to measure object sizes accurately and may consequently OOM.");
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ }
+ }
public static CQLStatement getPrepared(MD5Digest id)
@@ -211,7 +231,7 @@ public class QueryProcessor
// Concatenate the current keyspace so we don't mix prepared statements between keyspace (#5352).
// (if the keyspace is null, queryString has to have a fully-qualified keyspace so it's fine.
String toHash = keyspace == null ? queryString : keyspace + queryString;
- long statementSize = meter.measureDeep(prepared.statement);
+ long statementSize = measure(prepared.statement);
// don't execute the statement if it's bigger than the allowed threshold
if (statementSize > MAX_CACHE_PREPARED_MEMORY)
throw new InvalidRequestException(String.format("Prepared statement of size %d bytes is larger than allowed maximum of %d bytes.",
@@ -305,4 +325,9 @@ public class QueryProcessor
throw new SyntaxException("Invalid or malformed CQL query string: " + e.getMessage());
}
}
+
+ private static long measure(Object key)
+ {
+ return MemoryMeter.isInitialized() ? meter.measureDeep(key) : 1;
+ }
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7681913/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 1364030..11a49ed 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -173,9 +173,9 @@ public class Memtable
if (!MemoryMeter.isInitialized())
{
// hack for openjdk. we log a warning about this in the startup script too.
- logger.warn("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
- + " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
- + " upgrade to the Sun JRE instead", cfs.liveRatio);
+ logger.error("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
+ + " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
+ + " upgrade to the Sun JRE instead", cfs.liveRatio);
return;
}
[4/6] git commit: merge from 1.2
Posted by jb...@apache.org.
merge from 1.2
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/424fb481
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/424fb481
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/424fb481
Branch: refs/heads/trunk
Commit: 424fb4812e5b3b4882201e44d3576571e51b5fa7
Parents: 4a439d2 e768191
Author: Jonathan Ellis <jb...@apache.org>
Authored: Mon Nov 4 09:49:01 2013 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Mon Nov 4 09:49:01 2013 -0600
----------------------------------------------------------------------
CHANGES.txt | 7 +++
.../apache/cassandra/cql3/QueryProcessor.java | 49 +++++++++++++++-----
src/java/org/apache/cassandra/db/Memtable.java | 6 +--
3 files changed, 47 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/424fb481/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index a6636a5,fd93a5f..38fd876
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,20 -1,11 +1,27 @@@
-1.2.12
+2.0.3
+ * Avoid flushing compaction_history after each operation (CASSANDRA-6287)
+ * Fix repair assertion error when tombstones expire (CASSANDRA-6277)
+ * Skip loading corrupt key cache (CASSANDRA-6260)
+ * Fixes for compacting larger-than-memory rows (CASSANDRA-6274)
+ * Compact hottest sstables first and optionally omit coldest from
+ compaction entirely (CASSANDRA-6109)
+ * Fix modifying column_metadata from thrift (CASSANDRA-6182)
+ * cqlsh: fix LIST USERS output (CASSANDRA-6242)
+ * Add IRequestSink interface (CASSANDRA-6248)
+ * Update memtable size while flushing (CASSANDRA-6249)
+ * Provide hooks around CQL2/CQL3 statement execution (CASSANDRA-6252)
+ * Require Permission.SELECT for CAS updates (CASSANDRA-6247)
+ * New CQL-aware SSTableWriter (CASSANDRA-5894)
+ * Reject CAS operation when the protocol v1 is used (CASSANDRA-6270)
+ * Correctly throw error when frame too large (CASSANDRA-5981)
+Merged from 1.2:
+ * add non-jamm path for cached statements (CASSANDRA-6293)
+ * (Hadoop) Require CFRR batchSize to be at least 2 (CASSANDRA-6114)
+ * Fix altering column types (CASSANDRA-6185)
+ * cqlsh: fix CREATE/ALTER WITH completion (CASSANDRA-6196)
+ * add windows bat files for shell commands (CASSANDRA-6145)
+ * Fix potential stack overflow during range tombstones insertion (CASSANDRA-6181)
+ * (Hadoop) Make LOCAL_ONE the default consistency level (CASSANDRA-6214)
* Require logging in for Thrift CQL2/3 statement preparation (CASSANDRA-6254)
* restrict max_num_tokens to 1536 (CASSANDRA-6267)
* Nodetool gets default JMX port from cassandra-env.sh (CASSANDRA-6273)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/424fb481/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/QueryProcessor.java
index dc2649c,2d43bdc..71bf1b0
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@@ -73,44 -67,35 +69,68 @@@ public class QueryProcesso
}
};
- private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
- .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
- .weigher(thriftMemoryUsageWeigher)
- .build();
+ private static final ConcurrentLinkedHashMap<MD5Digest, CQLStatement> preparedStatements;
+ private static final ConcurrentLinkedHashMap<Integer, CQLStatement> thriftPreparedStatements;
+
+ static
+ {
+ if (MemoryMeter.isInitialized())
+ {
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(cqlMemoryUsageWeigher)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_MEMORY)
+ .weigher(thriftMemoryUsageWeigher)
+ .build();
+ }
+ else
+ {
+ logger.error("Unable to initialize MemoryMeter (jamm not specified as javaagent). This means "
+ + "Cassandra will be unable to measure object sizes accurately and may consequently OOM.");
+ preparedStatements = new ConcurrentLinkedHashMap.Builder<MD5Digest, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ thriftPreparedStatements = new ConcurrentLinkedHashMap.Builder<Integer, CQLStatement>()
+ .maximumWeightedCapacity(MAX_CACHE_PREPARED_COUNT)
+ .build();
+ }
+ }
+ private static final List<PreExecutionHook> preExecutionHooks = new CopyOnWriteArrayList<>();
+ private static final List<PostExecutionHook> postExecutionHooks = new CopyOnWriteArrayList<>();
+ private static final List<PostPreparationHook> postPreparationHooks = new CopyOnWriteArrayList<>();
+
+ public static void addPreExecutionHook(PreExecutionHook hook)
+ {
+ preExecutionHooks.add(hook);
+ }
+
+ public static void removePreExecutionHook(PreExecutionHook hook)
+ {
+ preExecutionHooks.remove(hook);
+ }
+
+ public static void addPostExecutionHook(PostExecutionHook hook)
+ {
+ postExecutionHooks.add(hook);
+ }
+
+ public static void removePostExecutionHook(PostExecutionHook hook)
+ {
+ postExecutionHooks.remove(hook);
+ }
+
+ public static void addPostPreparationHook(PostPreparationHook hook)
+ {
+ postPreparationHooks.add(hook);
+ }
+
+ public static void removePostPreparationHook(PostPreparationHook hook)
+ {
+ postPreparationHooks.remove(hook);
+ }
public static CQLStatement getPrepared(MD5Digest id)
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/424fb481/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
[6/6] git commit: Merge branch 'cassandra-2.0' into trunk
Posted by jb...@apache.org.
Merge branch 'cassandra-2.0' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d86b7e3f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d86b7e3f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d86b7e3f
Branch: refs/heads/trunk
Commit: d86b7e3ff446eaf1722e1f7f98218c98c6df0b76
Parents: 2bbabe1 424fb48
Author: Jonathan Ellis <jb...@apache.org>
Authored: Mon Nov 4 09:49:08 2013 -0600
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Mon Nov 4 09:49:08 2013 -0600
----------------------------------------------------------------------
CHANGES.txt | 7 +++
.../apache/cassandra/cql3/QueryProcessor.java | 49 +++++++++++++++-----
src/java/org/apache/cassandra/db/Memtable.java | 6 +--
3 files changed, 47 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d86b7e3f/CHANGES.txt
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d86b7e3f/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d86b7e3f/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------