merge from 0.8

git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1125113 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2011-05-19 21:19:30 +00:00
commit ae7dbe3d2a
30 changed files with 310 additions and 159 deletions

View File

@ -8,9 +8,22 @@
* add CQL TTL support (CASSANDRA-2476) * add CQL TTL support (CASSANDRA-2476)
* optimize batches containing multiple updates to the same row * optimize batches containing multiple updates to the same row
(CASSANDRA-2583) (CASSANDRA-2583)
* adjust hinted handoff page size to avoid OOM with large columns
(CASSANDRA-2652)
* mark BRAF buffer invalid post-flush so we don't re-flush partial
buffers again, especially on CL writes (CASSANDRA-2660)
* add DROP INDEX support to CLI (CASSANDRA-2616)
* don't perform HH to client-mode [storageproxy] nodes (CASSANDRA-2668)
0.8.0-rc1 0.8.0-final
* fix CQL grammar warning and cqlsh regression from CASSANDRA-2622
* add ant generate-cql-html target (CASSANDRA-2526)
* update CQL consistency levels (CASSANDRA-2566)
* debian packaging fixes (CASSANDRA-2481, 2647)
0.8.0-rc1
* faster flushes and compaction from fixing excessively pessimistic * faster flushes and compaction from fixing excessively pessimistic
rebuffering in BRAF (CASSANDRA-2581) rebuffering in BRAF (CASSANDRA-2581)
* fix returning null column values in the python cql driver (CASSANDRA-2593) * fix returning null column values in the python cql driver (CASSANDRA-2593)
@ -37,8 +50,10 @@
* initialize local ep state prior to gossip startup if needed (CASSANDRA-2638) * initialize local ep state prior to gossip startup if needed (CASSANDRA-2638)
* fix counter increment lost after restart (CASSANDRA-2642) * fix counter increment lost after restart (CASSANDRA-2642)
* add quote-escaping via backslash to CLI (CASSANDRA-2623) * add quote-escaping via backslash to CLI (CASSANDRA-2623)
* fig pig example script (CASSANDRA-2487) * fix pig example script (CASSANDRA-2487)
* fix dynamic snitch race in adding latencies (CASSANDRA-2618) * fix dynamic snitch race in adding latencies (CASSANDRA-2618)
* Start/stop cassandra after more important services such as mdadm in
debian packaging (CASSANDRA-2481)
0.8.0-beta2 0.8.0-beta2

View File

@ -62,6 +62,15 @@ JMX
- By default, JMX now listens on port 7199. - By default, JMX now listens on port 7199.
0.7.6
=====
Upgrading
---------
- Nothing specific to 0.7.6, but see 0.7.3 Upgrading if upgrading
from earlier than 0.7.1.
0.7.5 0.7.5
===== =====

View File

@ -221,6 +221,19 @@
<arg value="${build.src.gen-java}/org/apache/cassandra/cql/" /> <arg value="${build.src.gen-java}/org/apache/cassandra/cql/" />
</java> </java>
</target> </target>
<target name="generate-cql-html" depends="maven-ant-tasks-init" description="Generate HTML from textile source">
<artifact:dependencies pathId="wikitext.classpath">
<dependency groupId="com.datastax.wikitext" artifactId="wikitext-core-ant" version="1.3"/>
<dependency groupId="org.fusesource.wikitext" artifactId="textile-core" version="1.3"/>
</artifact:dependencies>
<taskdef classpathref="wikitext.classpath" resource="wikitexttasks.properties" />
<wikitext-to-html markupLanguage="Textile">
<fileset dir="${basedir}">
<include name="doc/cql/*.textile"/>
</fileset>
</wikitext-to-html>
</target>
<target name="scm-svn-info" description="Determines the current Subversion URL with peg revision" <target name="scm-svn-info" description="Determines the current Subversion URL with peg revision"
if="scm.provider.svn"> if="scm.provider.svn">

View File

@ -102,6 +102,7 @@ seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider - class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters: parameters:
# seeds is actually a comma-delimited list of addresses. # seeds is actually a comma-delimited list of addresses.
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "127.0.0.1" - seeds: "127.0.0.1"
# emergency pressure valve: each time heap usage after a full (CMS) # emergency pressure valve: each time heap usage after a full (CMS)

View File

@ -2,9 +2,15 @@
# The directory where Cassandra's configs live (required) # The directory where Cassandra's configs live (required)
CASSANDRA_CONF=/etc/cassandra CASSANDRA_CONF=/etc/cassandra
CASSANDRA_HOME=/usr/share/cassandra
# The java classpath (required) # The java classpath (required)
CLASSPATH=$CASSANDRA_CONF CLASSPATH=$CASSANDRA_CONF
for jar in /usr/share/cassandra/lib/*.jar; do
CLASSPATH=$CLASSPATH:$jar
done
for jar in /usr/share/cassandra/*.jar; do for jar in /usr/share/cassandra/*.jar; do
CLASSPATH=$CLASSPATH:$jar CLASSPATH=$CLASSPATH:$jar
done done

View File

@ -9,5 +9,5 @@ bin/nodetool usr/bin
bin/json2sstable usr/bin bin/json2sstable usr/bin
bin/sstable2json usr/bin bin/sstable2json usr/bin
bin/sstablekeys usr/bin bin/sstablekeys usr/bin
lib/*.jar usr/share/cassandra lib/*.jar usr/share/cassandra/lib
lib/licenses usr/share/doc/cassandra lib/licenses usr/share/doc/cassandra

2
debian/changelog vendored
View File

@ -2,7 +2,7 @@ cassandra (0.8.0~rc1) unstable; urgency=low
* Release candidate * Release candidate
-- Eric Evans <eevans@apache.org> Tue, 10 May 2011 19:09:27 -0500 -- Eric Evans <eevans@apache.org> Thu, 12 May 2011 18:35:26 -0500
cassandra (0.8.0~beta2) unstable; urgency=low cassandra (0.8.0~beta2) unstable; urgency=low

1
debian/dirs vendored
View File

@ -1,4 +1,5 @@
usr/share/cassandra usr/share/cassandra
usr/share/cassandra/lib
usr/sbin usr/sbin
usr/bin usr/bin
etc/cassandra etc/cassandra

10
debian/init vendored
View File

@ -1,8 +1,10 @@
#! /bin/sh #! /bin/sh
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: cassandra # Provides: cassandra
# Required-Start: $remote_fs # Required-Start: $remote_fs $network $named $time
# Required-Stop: $remote_fs # Required-Stop: $remote_fs $network $named $time
# Should-Start: ntp mdadm
# Should-Stop: ntp mdadm
# Default-Start: 2 3 4 5 # Default-Start: 2 3 4 5
# Default-Stop: 0 1 6 # Default-Stop: 0 1 6
# Short-Description: distributed storage system for structured data # Short-Description: distributed storage system for structured data
@ -19,6 +21,7 @@ SCRIPTNAME=/etc/init.d/$NAME
CONFDIR=/etc/cassandra CONFDIR=/etc/cassandra
JSVC=/usr/bin/jsvc JSVC=/usr/bin/jsvc
WAIT_FOR_START=10 WAIT_FOR_START=10
CASSANDRA_HOME=/usr/share/cassandra
# The first existing directory is used for JAVA_HOME if needed. # The first existing directory is used for JAVA_HOME if needed.
JVM_SEARCH_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun" JVM_SEARCH_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun"
@ -78,6 +81,9 @@ fi
classpath() classpath()
{ {
cp="$EXTRA_CLASSPATH" cp="$EXTRA_CLASSPATH"
for j in /usr/share/$NAME/lib/*.jar; do
[ "x$cp" = "x" ] && cp=$j || cp=$cp:$j
done
for j in /usr/share/$NAME/*.jar; do for j in /usr/share/$NAME/*.jar; do
[ "x$cp" = "x" ] && cp=$j || cp=$cp:$j [ "x$cp" = "x" ] && cp=$j || cp=$cp:$j
done done

2
debian/rules vendored
View File

@ -51,7 +51,7 @@ binary-indep: build install
dh_testdir dh_testdir
dh_testroot dh_testroot
dh_installchangelogs dh_installchangelogs
dh_installinit dh_installinit -u'start 50 2 3 4 5 . stop 50 0 1 6 .'
dh_installdocs README.txt CHANGES.txt NEWS.txt dh_installdocs README.txt CHANGES.txt NEWS.txt
dh_compress dh_compress
dh_fixperms dh_fixperms

View File

@ -1,63 +0,0 @@
<!--
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.
-->
<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body><h1 id="CassandraQueryLanguageCQLv1.0.0">Cassandra Query Language (CQL) v1.0.0</h1><h2 id="TableofContents">Table of Contents</h2><ol style="list-style: none;"><li><a href="#CassandraQueryLanguageCQLv1.0.0">Cassandra Query Language (CQL) v1.0.0</a><ol style="list-style: none;"><li><a href="#TableofContents">Table of Contents</a></li><li><a href="#USE">USE</a></li><li><a href="#SELECT">SELECT</a><ol style="list-style: none;"><li><a href="#SpecifyingColumns">Specifying Columns</a></li><li><a href="#ColumnFamily">Column Family</a></li><li><a href="#ConsistencyLevel">Consistency Level</a></li><li><a href="#Filteringrows">Filtering rows</a></li><li><a href="#Limits">Limits</a></li></ol></li><li><a href="#UPDATE">UPDATE</a><ol style="list-style: none;"><li><a href="#ColumnFamily2">Column Family</a></li><li><a href="#ConsistencyLevel2">Consistency Level</a></li><li><a href="#SpecifyingColumnsandRow">Specifying Columns and Row</a></li></ol></li><li><a href="#DELETE">DELETE</a><ol style="list-style: none;"><li><a href="#SpecifyingColumns2">Specifying Columns</a></li><li><a href="#ColumnFamily3">Column Family</a></li><li><a href="#ConsistencyLevel3">Consistency Level</a></li><li><a href="#deleterows">Specifying Rows</a></li></ol></li><li><a href="#TRUNCATE">TRUNCATE</a></li><li><a href="#CREATEKEYSPACE">CREATE KEYSPACE</a></li><li><a href="#CREATECOLUMNFAMILY">CREATE COLUMNFAMILY</a><ol style="list-style: none;"><li><a href="#keytypes">Specifying Key Type</a></li><li><a href="#columntypes">Specifying Column Type (optional)</a></li><li><a href="#ColumnFamilyOptionsoptional">Column Family Options (optional)</a></li></ol></li><li><a href="#CREATEINDEX">CREATE INDEX</a></li><li><a href="#DROP">DROP</a></li><li><a href="#CommonIdioms">Common Idioms</a><ol style="list-style: none;"><li><a href="#consistency">Specifying Consistency</a></li><li><a href="#terms">Term specification</a></li></ol></li></ol></li><li><a href="#Versioning">Versioning</a></li><li><a href="#Changes">Changes</a></li></ol><h2 id="USE">USE</h2><p><i>Synopsis:</i></p><pre><code>USE &lt;KEYSPACE&gt;;
</code></pre><p>A <code>USE</code> statement consists of the <code>USE</code> keyword, followed by a valid keyspace name. Its purpose is to assign the per-connection, current working keyspace. All subsequent keyspace-specific actions will be performed in the context of the supplied value.</p><h2 id="SELECT">SELECT</h2><p><i>Synopsis:</i></p><pre><code>SELECT [FIRST N] [REVERSED] &lt;SELECT EXPR&gt; FROM &lt;COLUMN FAMILY&gt; [USING &lt;CONSISTENCY&gt;]
[WHERE &lt;CLAUSE&gt;] [LIMIT N];
</code></pre><p>A <code>SELECT</code> is used to read one or more records from a Cassandra column family. It returns a result-set of rows, where each row consists of a key and a collection of columns corresponding to the query.</p><h3 id="SpecifyingColumns">Specifying Columns</h3><pre><code>SELECT [FIRST N] [REVERSED] name1, name2, name3 FROM ...
SELECT [FIRST N] [REVERSED] name1..nameN FROM ...
</code></pre><p>The SELECT expression determines which columns will appear in the results and takes the form of either a comma separated list of names, or a range. The range notation consists of a start and end column name separated by two periods (<code>..</code>). The set of columns returned for a range is start and end inclusive.</p><p>The <code>FIRST</code> option accepts an integer argument and can be used to apply a limit to the number of columns returned per row. When this limit is left unset it defaults to 10,000 columns.</p><p>The <code>REVERSED</code> option causes the sort order of the results to be reversed.</p><p>It is worth noting that unlike the projection in a SQL SELECT, there is no guarantee that the results will contain all of the columns specified. This is because Cassandra is schema-less and there are no guarantees that a given column exists.</p><h3 id="ColumnFamily">Column Family</h3><pre><code>SELECT ... FROM &lt;COLUMN FAMILY&gt; ...
</code></pre><p>The <code>FROM</code> clause is used to specify the Cassandra column family applicable to a <code>SELECT</code> query.</p><h3 id="ConsistencyLevel">Consistency Level</h3><pre><code>SELECT ... [USING &lt;CONSISTENCY&gt;] ...
</code></pre><p>Following the column family clause is an optional <a href="#consistency">consistency level specification</a>.</p><h3 id="Filteringrows">Filtering rows</h3><pre><code>SELECT ... WHERE KEY = keyname AND name1 = value1
SELECT ... WHERE KEY &gt;= startkey and KEY =&lt; endkey AND name1 = value1
</code></pre><p>The WHERE clause provides for filtering the rows that appear in results. The clause can filter on a key name, or range of keys, and in the case of indexed columns, on column values. Key filters are specified using the <code>KEY</code> keyword, a relational operator, (one of <code>=</code>, <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;</code>, and <code>&lt;=</code>), and a term value. When terms appear on both sides of a relational operator it is assumed the filter applies to an indexed column. With column index filters, the term on the left of the operator is the name, the term on the right is the value to filter <i>on</i>.</p><p><i>Note: The greater-than and less-than operators (<code>&gt;</code> and <code>&lt;</code>) result in key ranges that are inclusive of the terms. There is no supported notion of &#8220;strictly&#8221; greater-than or less-than; these operators are merely supported as aliases to <code>&gt;=</code> and <code>&lt;=</code>.</i> </p><h3 id="Limits">Limits</h3><pre><code>SELECT ... WHERE &lt;CLAUSE&gt; [LIMIT N] ...
</code></pre><p>Limiting the number of rows returned can be achieved by adding the <code>LIMIT</code> option to a <code>SELECT</code> expression. <code>LIMIT</code> defaults to 10,000 when left unset.</p><h2 id="UPDATE">UPDATE</h2><p><em>Synopsis:</em></p><pre><code>UPDATE &lt;COLUMN FAMILY&gt; [USING CONSISTENCY &lt;CL&gt;]
SET name1 = value1, name2 = value2 WHERE KEY = keyname;
</code></pre><p>An <code>UPDATE</code> is used to write one or more columns to a record in a Cassandra column family. No results are returned.</p><h3 id="ColumnFamily2">Column Family</h3><pre><code>UPDATE &lt;COLUMN FAMILY&gt; ...
</code></pre><p>Statements begin with the <code>UPDATE</code> keyword followed by a Cassandra column family name.</p><h3 id="ConsistencyLevel2">Consistency Level</h3><pre><code>UPDATE ... [USING &lt;CONSISTENCY&gt;] ...
</code></pre><p>Following the column family identifier is an optional <a href="#consistency">consistency level specification</a>.</p><h3 id="SpecifyingColumnsandRow">Specifying Columns and Row</h3><pre><code>UPDATE ... SET name1 = value1, name2 = value2 WHERE KEY = keyname;
</code></pre><p>Rows are created or updated by supplying column names and values in term assignment format. Multiple columns can be set by separating the name/value pairs using commas. Each update statement requires exactly one key to be specified using a WHERE clause and the <code>KEY</code> keyword.</p><p>Additionally, it is also possible to send multiple UPDATES to a node at once using a batch syntax:</p><pre><code>BEGIN BATCH [USING &lt;CONSISTENCY&gt;]
UPDATE CF1 SET name1 = value1, name2 = value2 WHERE KEY = keyname1;
UPDATE CF1 SET name3 = value3 WHERE KEY = keyname2;
UPDATE CF2 SET name4 = value4, name5 = value5 WHERE KEY = keyname3;
APPLY BATCH
</code></pre><p>When batching UPDATEs, a single consistency level is used for the entire batch, it appears after the <code>BEGIN BATCH</code> statement, and uses the standard <a href="#consistency">consistency level specification</a>. Batch UPDATEs default to <code>CONSISTENCY.ONE</code> when left unspecified.</p><p><em>NOTE: While there are no isolation guarantees, <code>UPDATE</code> queries are atomic within a give record.</em></p><h2 id="DELETE">DELETE</h2><p><em>Synopsis:</em></p><pre><code>DELETE [COLUMNS] FROM &lt;COLUMN FAMILY&gt; [USING &lt;CONSISTENCY&gt;] WHERE KEY = keyname1
DELETE [COLUMNS] FROM &lt;COLUMN FAMILY&gt; [USING &lt;CONSISTENCY&gt;] WHERE KEY IN (keyname1, keyname2);
</code></pre><p>A <code>DELETE</code> is used to perform the removal of one or more columns from one or more rows.</p><h3 id="SpecifyingColumns2">Specifying Columns</h3><pre><code>DELETE [COLUMNS] ...
</code></pre><p>Following the <code>DELETE</code> keyword is an optional comma-delimited list of column name terms. When no column names are specified, the remove applies to the entire row(s) matched by the <a href="#deleterows">WHERE clause</a></p><h3 id="ColumnFamily3">Column Family</h3><pre><code>DELETE ... FROM &lt;COLUMN FAMILY&gt; ...
</code></pre><p>The column family name follows the list of column names.</p><h3 id="ConsistencyLevel3">Consistency Level</h3><pre><code>UPDATE ... [USING &lt;CONSISTENCY&gt;] ...
</code></pre><p>Following the column family identifier is an optional <a href="#consistency">consistency level specification</a>.</p><h3 id="deleterows">Specifying Rows</h3><pre><code>UPDATE ... WHERE KEY = keyname1
UPDATE ... WHERE KEY IN (keyname1, keyname2)
</code></pre><p>The <code>WHERE</code> clause is used to determine which row(s) a <code>DELETE</code> applies to. The first form allows the specification of a single keyname using the <code>KEY</code> keyword and the <code>=</code> operator. The second form allows a list of keyname terms to be specified using the <code>IN</code> notation and a parenthesized list of comma-delimited keyname terms.</p><h2 id="TRUNCATE">TRUNCATE</h2><p><em>Synopsis:</em></p><pre><code>TRUNCATE &lt;COLUMN FAMILY&gt;
</code></pre><p>Accepts a single argument for the column family name, and permanently removes all data from said column family.</p><h2 id="CREATEKEYSPACE">CREATE KEYSPACE</h2><p><em>Synopsis:</em></p><pre><code>CREATE KEYSPACE &lt;NAME&gt; WITH replication_factor = &lt;NUM&gt; AND strategy_class = &lt;STRATEGY&gt;
[AND strategy_options.&lt;OPTION&gt; = &lt;VALUE&gt; [AND strategy_options.&lt;OPTION&gt; = &lt;VALUE&gt;]];
</code></pre><p>The <code>CREATE KEYSPACE</code> statement creates a new top-level namespace (aka &#8220;keyspace&#8221;). Valid names are any string constructed of alphanumeric characters and underscores, but must begin with a letter. Properties such as replication strategy and count are specified during creation using the following accepted keyword arguments:</p><table><tr><th>keyword</th><th>required</th><th>description</th></tr><tr><td>replication_factor</td><td>yes</td><td>Numeric argument that specifies the number of replicas for this keyspace.</td></tr><tr><td>strategy_class</td><td>yes</td><td>Class name to use for managing replica placement. Any of the shipped strategies can be used by specifying the class name relative to org.apache.cassandra.locator, others will need to be fully-qualified and located on the classpath.</td></tr><tr><td>strategy_options</td><td>no</td><td>Some strategies require additional arguments which can be supplied by appending the option name to the <code>strategy_options</code> keyword, separated by a colon (<code>:</code>). For example, a strategy option of &#8220;DC1&#8221; with a value of &#8220;1&#8221; would be specified as <code>strategy_options:DC1 = 1</code>.</td></tr></table><h2 id="CREATECOLUMNFAMILY">CREATE COLUMNFAMILY</h2><p><em>Synopsis:</em></p><pre><code>CREATE COLUMNFAMILY &lt;COLUMN FAMILY&gt; (KEY &lt;type&gt; PRIMARY KEY [, name1 type, name2 type, ...]);
CREATE COLUMNFAMILY &lt;COLUMN FAMILY&gt; (KEY &lt;type&gt; PRIMARY KEY [, name1 type, name2 type, ...])
[WITH keyword1 = arg1 [AND keyword2 = arg2 [AND ...]]];
</code></pre><p><code>CREATE COLUMNFAMILY</code> statements create new column family namespaces under the current keyspace. Valid column family names are strings of alphanumeric characters and underscores, which begin with a letter.</p><h3 id="keytypes">Specifying Key Type</h3><pre><code>CREATE ... (KEY &lt;type&gt; PRIMARY KEY) ...
</code></pre><p>When creating a new column family, you must specify key type. The list of possible key types is identical to column comparators/validators, (see <a href="columntypes">Specifying Column Type</a>). It&#8217;s important to note that the key type must be compatible with the partitioner in use, for example <code>OrderPreservingPartitioner</code> and <code>CollatingOrderPreservingPartitioner</code> both require UTF-8 keys.</p><h3 id="columntypes">Specifying Column Type (optional)</h3><pre><code>CREATE ... (KEY &lt;type&gt; PRIMARY KEY, name1 type, name2 type) ...
</code></pre><p>It is possible to assign columns a type during column family creation. Columns configured with a type are validated accordingly when a write occurs. Column types are specified as a parenthesized, comma-separated list of column term and type pairs. The list of recognized types are:</p><table><tr><th>type</th><th>description</th></tr><tr><td>bytea</td><td>Arbitrary bytes (no validation)</td></tr><tr><td>ascii</td><td>ASCII character string</td></tr><tr><td>text</td><td>UTF8 encoded string</td></tr><tr><td>varchar</td><td>UTF8 encoded string</td></tr><tr><td>uuid</td><td>Type 1, or type 4 UUID</td></tr><tr><td>varint</td><td>4-byte integer</td></tr><tr><td>bigint</td><td>8-byte long</td></tr></table><p><em>Note: In addition to the recognized types listed above, it is also possible to supply a string containing the name of a class (a sub-class of <code>AbstractType</code>), either fully qualified, or relative to the <code>org.apache.cassandra.db.marshal</code> package.</em></p><h3 id="ColumnFamilyOptionsoptional">Column Family Options (optional)</h3><pre><code>CREATE COLUMNFAMILY ... WITH keyword1 = arg1 AND keyword2 = arg2;
</code></pre><p>A number of optional keyword arguments can be supplied to control the configuration of a new column family.</p><table><tr><th>keyword</th><th>default</th><th>description</th></tr><tr><td>comparator</td><td>text</td><td>Determines sorting and validation of column names. Valid values are identical to the types listed in <a href="#columntypes">Specifying Column Type</a> above.</td></tr><tr><td>comment</td><td>none</td><td>A free-form, human-readable comment.</td></tr><tr><td>row_cache_size</td><td>0</td><td>Number of rows whose entire contents to cache in memory.</td></tr><tr><td>key_cache_size</td><td>200000</td><td>Number of keys per SSTable whose locations are kept in memory in &#8220;mostly LRU&#8221; order.</td></tr><tr><td>read_repair_chance</td><td>1.0</td><td>The probability with which read repairs should be invoked on non-quorum reads.</td></tr><tr><td>gc_grace_seconds</td><td>864000</td><td>Time to wait before garbage collecting tombstones (deletion markers).</td></tr><tr><td>default_validation</td><td>text</td><td>Determines validation of column values. Valid values are identical to the types listed in <a href="#columntypes">Specifying Column Type</a> above.</td></tr><tr><td>min_compaction_threshold</td><td>4</td><td>Minimum number of SSTables needed to start a minor compaction.</td></tr><tr><td>max_compaction_threshold</td><td>32</td><td>Maximum number of SSTables allowed before a minor compaction is forced.</td></tr><tr><td>row_cache_save_period_in_seconds</td><td>0</td><td>Number of seconds between saving row caches.</td></tr><tr><td>key_cache_save_period_in_seconds</td><td>14400</td><td>Number of seconds between saving key caches.</td></tr><tr><td>memtable_flush_after_mins</td><td>60</td><td>Maximum time to leave a dirty table unflushed.</td></tr><tr><td>memtable_throughput_in_mb</td><td>dynamic</td><td>Maximum size of the memtable before it is flushed.</td></tr><tr><td>memtable_operations_in_millions</td><td>dynamic</td><td>Number of operations in millions before the memtable is flushed.</td></tr><tr><td>replicate_on_write</td><td>false</td><td></td></tr></table><h2 id="CREATEINDEX">CREATE INDEX</h2><p><em>Synopsis:</em></p><pre><code>CREATE INDEX [index_name] ON &lt;column_family&gt; (column_name);
</code></pre><p>A <code>CREATE INDEX</code> statement is used to create a new, automatic secondary index for the named column.</p><h2 id="DROP">DROP</h2><p><em>Synopsis:</em></p><pre><code>DROP &lt;KEYSPACE|COLUMNFAMILY&gt; namespace;
</code></pre><p><code>DROP</code> statements result in the immediate, irreversible removal of keyspace and column family namespaces.</p><h2 id="CommonIdioms">Common Idioms</h2><h3 id="consistency">Specifying Consistency</h3><pre><code>... USING &lt;CONSISTENCY&gt; ...
</code></pre><p>Consistency level specifications are made up the keyword <code>USING</code>, followed by a consistency level identifier. Valid consistency levels are as follows:</p><ul><li><code>CONSISTENCY ZERO</code></li><li><code>CONSISTENCY ONE</code> (default)</li><li><code>CONSISTENCY QUORUM</code></li><li><code>CONSISTENCY ALL</code></li><li><code>CONSISTENCY DCQUORUM</code></li><li><code>CONSISTENCY DCQUORUMSYNC</code></li></ul><h3 id="terms">Term specification</h3><p>Terms are used in statements to specify things such as keyspaces, column families, indexes, column names and values, and keyword arguments. The rules governing term specification are as follows:</p><ul><li>Any single quoted string literal (example: <code>'apple'</code>).</li><li>Unquoted alpha-numeric strings that begin with a letter (example: <code>carrot</code>).</li><li>Unquoted numeric literals (example: <code>100</code>).</li><li>UUID strings in hyphen-delimited hex notation (example: <code>1438fc5c-4ff6-11e0-b97f-0026c650d722</code>). </li></ul><p>Terms which do not conform to these rules result in an exception.</p><p>How column name/value terms are interpreted is determined by the configured type.</p><table><tr><th>type</th><th>term</th></tr><tr><td>ascii</td><td>Any string which can be decoded using ASCII charset</td></tr><tr><td>text / varchar</td><td>Any string which can be decoded using UTF8 charset</td></tr><tr><td>uuid</td><td>Standard UUID string format (hyphen-delimited hex notation)</td></tr><tr><td>uuid</td><td>Standard UUID string format (hyphen-delimited hex notation)</td></tr><tr><td>uuid</td><td>The string <code>now</code>, to represent a type-1 (time-based) UUID with a date-time component based on the current time</td></tr><tr><td>uuid</td><td>Numeric value representing milliseconds since epoch</td></tr><tr><td>uuid</td><td>An <a href="http://en.wikipedia.org/wiki/8601">iso8601 timestamp</a></td></tr><tr><td>bigint</td><td>Numeric value capable of fitting in 8 bytes</td></tr><tr><td>varint</td><td>Numeric value of arbitrary size</td></tr><tr><td>bytea</td><td>Hex-encoded strings (converted directly to the corresponding bytes)</td></tr></table><h1 id="Versioning">Versioning</h1><p>Versioning of the CQL language adheres to the <a href="http://semver.org">Semantic Versioning</a> guidelines. Versions take the form X.Y.Z where X, Y, and Z are integer values representing major, minor, and patch level respectively. There is no correlation between Cassandra release versions and the CQL language version.</p><table><tr><th>version</th><th>description</th></tr><tr><td>Patch</td><td>The patch version is incremented when bugs are fixed.</td></tr><tr><td>Minor</td><td>Minor version increments occur when new, but backward compatible, functionality is introduced.</td></tr><tr><td>Major</td><td>The major version <em>must</em> be bumped when backward incompatible changes are introduced. This should rarely (if ever) occur.</td></tr></table><h1 id="Changes">Changes</h1><pre>Tue, 22 Mar 2011 18:10:28 -0700 - Eric Evans &lt;eevans@rackspace.com&gt;
* Initial version, 1.0.0
</pre></body></html>

View File

@ -299,12 +299,12 @@ bc.
Consistency level specifications are made up the keyword @USING@, followed by a consistency level identifier. Valid consistency levels are as follows: Consistency level specifications are made up the keyword @USING@, followed by a consistency level identifier. Valid consistency levels are as follows:
* @CONSISTENCY ZERO@ * @CONSISTENCY ANY@
* @CONSISTENCY ONE@ (default) * @CONSISTENCY ONE@ (default)
* @CONSISTENCY QUORUM@ * @CONSISTENCY QUORUM@
* @CONSISTENCY ALL@ * @CONSISTENCY ALL@
* @CONSISTENCY DCQUORUM@ * @CONSISTENCY LOCAL_QUORUM@
* @CONSISTENCY DCQUORUMSYNC@ * @CONSISTENCY EACH_QUORUM@
h3(#terms). Term specification h3(#terms). Term specification

View File

@ -30,7 +30,7 @@ try:
except ImportError: except ImportError:
sys.path.append(os.path.abspath(os.path.dirname(__file__))) sys.path.append(os.path.abspath(os.path.dirname(__file__)))
import cql import cql
from cql.results import ResultSet from cql.cursor import _COUNT_DESCRIPTION
HISTORY = os.path.join(os.path.expanduser('~'), '.cqlsh') HISTORY = os.path.join(os.path.expanduser('~'), '.cqlsh')
CQLTYPES = ("bytes", "ascii", "utf8", "timeuuid", "uuid", "long", "int") CQLTYPES = ("bytes", "ascii", "utf8", "timeuuid", "uuid", "long", "int")
@ -131,7 +131,9 @@ class Shell(cmd.Cmd):
self.cursor.execute(statement) self.cursor.execute(statement)
if isinstance(self.cursor.result, ResultSet): if self.cursor.description is _COUNT_DESCRIPTION:
if self.cursor.result: print self.cursor.result[0]
else:
for x in range(self.cursor.rowcount): for x in range(self.cursor.rowcount):
row = self.cursor.fetchone() row = self.cursor.fetchone()
self.printout(repr(row[0]), BLUE, False) self.printout(repr(row[0]), BLUE, False)
@ -142,8 +144,6 @@ class Shell(cmd.Cmd):
self.printout(",", newline=False) self.printout(",", newline=False)
self.printout(repr(value), YELLOW, False) self.printout(repr(value), YELLOW, False)
self.printout("") self.printout("")
else:
if self.cursor.result: print self.cursor.result[0]
def emptyline(self): def emptyline(self):
pass pass

View File

@ -20,7 +20,7 @@ from os.path import abspath, join, dirname
setup( setup(
name="cql", name="cql",
version="1.0.1", version="1.0.2",
description="Cassandra Query Language driver", description="Cassandra Query Language driver",
long_description=open(abspath(join(dirname(__file__), 'README'))).read(), long_description=open(abspath(join(dirname(__file__), 'README'))).read(),
url="http://cassandra.apache.org", url="http://cassandra.apache.org",

View File

@ -61,6 +61,7 @@ tokens {
NODE_TRUNCATE; NODE_TRUNCATE;
NODE_ASSUME; NODE_ASSUME;
NODE_CONSISTENCY_LEVEL; NODE_CONSISTENCY_LEVEL;
NODE_DROP_INDEX;
// Internal Nodes. // Internal Nodes.
NODE_COLUMN_ACCESS; NODE_COLUMN_ACCESS;
@ -160,6 +161,7 @@ statement
| truncateStatement | truncateStatement
| assumeStatement | assumeStatement
| consistencyLevelStatement | consistencyLevelStatement
| dropIndex
| -> ^(NODE_NO_OP) | -> ^(NODE_NO_OP)
; ;
@ -203,6 +205,8 @@ helpStatement
-> ^(NODE_HELP NODE_DEL_KEYSPACE) -> ^(NODE_HELP NODE_DEL_KEYSPACE)
| HELP DROP COLUMN FAMILY | HELP DROP COLUMN FAMILY
-> ^(NODE_HELP NODE_DEL_COLUMN_FAMILY) -> ^(NODE_HELP NODE_DEL_COLUMN_FAMILY)
| HELP DROP INDEX
-> ^(NODE_HELP NODE_DROP_INDEX)
| HELP GET | HELP GET
-> ^(NODE_HELP NODE_THRIFT_GET) -> ^(NODE_HELP NODE_THRIFT_GET)
| HELP SET | HELP SET
@ -337,6 +341,11 @@ delColumnFamily
-> ^(NODE_DEL_COLUMN_FAMILY columnFamily) -> ^(NODE_DEL_COLUMN_FAMILY columnFamily)
; ;
dropIndex
: DROP INDEX ON columnFamily '.' columnName
-> ^(NODE_DROP_INDEX columnFamily columnName)
;
showVersion showVersion
: SHOW API_VERSION : SHOW API_VERSION
-> ^(NODE_SHOW_VERSION) -> ^(NODE_SHOW_VERSION)
@ -562,6 +571,8 @@ TRUNCATE: 'TRUNCATE';
ASSUME: 'ASSUME'; ASSUME: 'ASSUME';
TTL: 'TTL'; TTL: 'TTL';
CONSISTENCYLEVEL: 'CONSISTENCYLEVEL'; CONSISTENCYLEVEL: 'CONSISTENCYLEVEL';
INDEX: 'INDEX';
ON: 'ON';
IP_ADDRESS IP_ADDRESS
: IntegerPositiveLiteral '.' IntegerPositiveLiteral '.' IntegerPositiveLiteral '.' IntegerPositiveLiteral : IntegerPositiveLiteral '.' IntegerPositiveLiteral '.' IntegerPositiveLiteral '.' IntegerPositiveLiteral
@ -603,10 +614,57 @@ Identifier
// literals // literals
StringLiteral StringLiteral
: : '\'' SingleStringCharacter* '\''
'\'' (~'\'')* '\'' ( '\'' (~'\'')* '\'' )*
; ;
fragment SingleStringCharacter
: ~('\'' | '\\')
| '\\' EscapeSequence
;
fragment EscapeSequence
: CharacterEscapeSequence
| '0'
| HexEscapeSequence
| UnicodeEscapeSequence
;
fragment CharacterEscapeSequence
: SingleEscapeCharacter
| NonEscapeCharacter
;
fragment NonEscapeCharacter
: ~(EscapeCharacter)
;
fragment SingleEscapeCharacter
: '\'' | '"' | '\\' | 'b' | 'f' | 'n' | 'r' | 't' | 'v'
;
fragment EscapeCharacter
: SingleEscapeCharacter
| DecimalDigit
| 'x'
| 'u'
;
fragment HexEscapeSequence
: 'x' HexDigit HexDigit
;
fragment UnicodeEscapeSequence
: 'u' HexDigit HexDigit HexDigit HexDigit
;
fragment HexDigit
: DecimalDigit | ('a'..'f') | ('A'..'F')
;
fragment DecimalDigit
: ('0'..'9')
;
// //
// syntactic elements // syntactic elements
// //

View File

@ -61,13 +61,14 @@ public class CliClient
*/ */
public enum Function public enum Function
{ {
BYTES (BytesType.instance), BYTES (BytesType.instance),
INTEGER (IntegerType.instance), INTEGER (IntegerType.instance),
LONG (LongType.instance), LONG (LongType.instance),
LEXICALUUID (LexicalUUIDType.instance), LEXICALUUID (LexicalUUIDType.instance),
TIMEUUID (TimeUUIDType.instance), TIMEUUID (TimeUUIDType.instance),
UTF8 (UTF8Type.instance), UTF8 (UTF8Type.instance),
ASCII (AsciiType.instance); ASCII (AsciiType.instance),
COUNTERCOLUMN (CounterColumnType.instance);
private AbstractType validator; private AbstractType validator;
@ -268,6 +269,10 @@ public class CliClient
case CliParser.NODE_THRIFT_DECR: case CliParser.NODE_THRIFT_DECR:
executeIncr(tree, -1L); executeIncr(tree, -1L);
break; break;
case CliParser.NODE_DROP_INDEX:
executeDropIndex(tree);
break;
case CliParser.NODE_NO_OP: case CliParser.NODE_NO_OP:
// comment lines come here; they are treated as no ops. // comment lines come here; they are treated as no ops.
break; break;
@ -1321,6 +1326,58 @@ public class CliClient
printSliceList(columnFamilyDef, keySlices); printSliceList(columnFamilyDef, keySlices);
} }
// DROP INDEX ON <CF>.<COLUMN>
private void executeDropIndex(Tree statement)
{
if (!CliMain.isConnected() || !hasKeySpace())
return;
// getColumnFamily will check if CF exists for us
String columnFamily = CliCompiler.getColumnFamily(statement, keyspacesMap.get(keySpace).cf_defs);
String rawColumName = statement.getChild(1).getText();
CfDef cfDef = getCfDef(columnFamily);
ByteBuffer columnName = columnNameAsBytes(rawColumName, cfDef);
boolean foundColumn = false;
for (ColumnDef column : cfDef.getColumn_metadata())
{
if (column.name.equals(columnName))
{
foundColumn = true;
if (column.getIndex_type() == null)
throw new RuntimeException(String.format("Column '%s' does not have an index.", rawColumName));
column.setIndex_name(null);
column.setIndex_type(null);
}
}
if (!foundColumn)
throw new RuntimeException(String.format("Column '%s' definition was not found in ColumnFamily '%s'.",
rawColumName,
columnFamily));
try
{
String mySchemaVersion = thriftClient.system_update_column_family(cfDef);
sessionState.out.println(mySchemaVersion);
validateSchemaIsSettled(mySchemaVersion);
keyspacesMap.put(keySpace, thriftClient.describe_keyspace(keySpace));
}
catch (InvalidRequestException e)
{
System.err.println(e.why);
}
catch (Exception e)
{
throw new RuntimeException(e.getMessage(), e);
}
}
// TRUNCATE <columnFamily> // TRUNCATE <columnFamily>
private void executeTruncate(String columnFamily) private void executeTruncate(String columnFamily)
{ {
@ -1403,6 +1460,9 @@ public class CliClient
return; return;
} }
// making string representation look property e.g. o.a.c.db.marshal.UTF8Type
defaultType = comparator.getClass().getName();
if (assumptionElement.equals("COMPARATOR")) if (assumptionElement.equals("COMPARATOR"))
{ {
columnFamily.setComparator_type(defaultType); columnFamily.setComparator_type(defaultType);

View File

@ -412,7 +412,7 @@ termPair[Map<Term, Term> columns]
// Note: ranges are inclusive so >= and >, and < and <= all have the same semantics. // Note: ranges are inclusive so >= and >, and < and <= all have the same semantics.
relation returns [Relation rel] relation returns [Relation rel]
: { Term entity = new Term("KEY", STRING_LITERAL); } : { Term entity = new Term("KEY", STRING_LITERAL); }
(K_KEY | name=term { entity = $name.item; } ) type=('=' | '<' | '<=' | '>=' | '>') t=term (name=term { entity = $name.item; } ) type=('=' | '<' | '<=' | '>=' | '>') t=term
{ return new Relation(entity, $type.text, $t.item); } { return new Relation(entity, $type.text, $t.item); }
; ;
@ -440,9 +440,10 @@ K_USING: U S I N G;
K_CONSISTENCY: C O N S I S T E N C Y; K_CONSISTENCY: C O N S I S T E N C Y;
K_LEVEL: ( O N E K_LEVEL: ( O N E
| Q U O R U M | Q U O R U M
| A L L | A L L
| D C Q U O R U M | A N Y
| D C Q U O R U M S Y N C | L O C A L '_' Q U O R U M
| E A C H '_' Q U O R U M
) )
; ;
K_USE: U S E; K_USE: U S E;

View File

@ -461,6 +461,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
*/ */
public static void scrubDataDirectories(String table, String columnFamily) public static void scrubDataDirectories(String table, String columnFamily)
{ {
logger.info("Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)");
for (Map.Entry<Descriptor,Set<Component>> sstableFiles : files(table, columnFamily, true).entrySet()) for (Map.Entry<Descriptor,Set<Component>> sstableFiles : files(table, columnFamily, true).entrySet())
{ {
Descriptor desc = sstableFiles.getKey(); Descriptor desc = sstableFiles.getKey();

View File

@ -845,19 +845,19 @@ public class CompactionManager implements CompactionManagerMBean
totalkeysWritten++; totalkeysWritten++;
} }
else else
{ {
cfs.invalidateCachedRow(row.getKey()); cfs.invalidateCachedRow(row.getKey());
if (!indexedColumns.isEmpty() || isCommutative) if (!indexedColumns.isEmpty() || isCommutative)
{ {
while (row.hasNext()) while (row.hasNext())
{ {
IColumn column = row.next(); IColumn column = row.next();
if (column instanceof CounterColumn) if (column instanceof CounterColumn)
renewer.maybeRenew((CounterColumn)column); renewer.maybeRenew((CounterColumn) column);
if (indexedColumns.contains(column.name())) if (indexedColumns.contains(column.name()))
Table.cleanupIndexEntry(cfs, row.getKey().key, column); Table.cleanupIndexEntry(cfs, row.getKey().key, column);
} }
} }
} }
} }
} }
@ -1169,31 +1169,6 @@ public class CompactionManager implements CompactionManagerMBean
} }
} }
public void checkAllColumnFamilies() throws IOException
{
// perform estimates
for (final ColumnFamilyStore cfs : ColumnFamilyStore.all())
{
Runnable runnable = new Runnable()
{
public void run ()
{
logger.debug("Estimating compactions for " + cfs.columnFamily);
final Set<List<SSTableReader>> buckets = getBuckets(convertSSTablesToPairs(cfs.getSSTables()), 50L * 1024L * 1024L);
updateEstimateFor(cfs, buckets);
}
};
executor.submit(runnable);
}
// actually schedule compactions. done in a second pass so all the estimates occur before we
// bog down the executor in actual compactions.
for (ColumnFamilyStore cfs : ColumnFamilyStore.all())
{
submitMinorIfNeeded(cfs);
}
}
public int getActiveCompactions() public int getActiveCompactions()
{ {
return executor.getActiveCount(); return executor.getActiveCount();

View File

@ -115,7 +115,7 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
logger_.debug("Created HHOM instance, registered MBean."); logger_.debug("Created HHOM instance, registered MBean.");
} }
private static boolean sendMessage(InetAddress endpoint, String tableName, String cfName, ByteBuffer key) throws IOException private static boolean sendRow(InetAddress endpoint, String tableName, String cfName, ByteBuffer key) throws IOException
{ {
if (!Gossiper.instance.isKnownEndpoint(endpoint)) if (!Gossiper.instance.isKnownEndpoint(endpoint))
{ {
@ -130,10 +130,21 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
Table table = Table.open(tableName); Table table = Table.open(tableName);
DecoratedKey<?> dkey = StorageService.getPartitioner().decorateKey(key); DecoratedKey<?> dkey = StorageService.getPartitioner().decorateKey(key);
ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName); ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
int pageSize = PAGE_SIZE;
// send less columns per page if they are very large
if (cfs.getMeanColumns() > 0)
{
int averageColumnSize = (int) (cfs.getMeanRowSize() / cfs.getMeanColumns());
pageSize = Math.min(PAGE_SIZE, DatabaseDescriptor.getInMemoryCompactionLimit() / averageColumnSize);
pageSize = Math.max(2, pageSize); // page size of 1 does not allow actual paging b/c of >= behavior on startColumn
logger_.debug("average hinted-row column size is {}; using pageSize of {}", averageColumnSize, pageSize);
}
ByteBuffer startColumn = ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer startColumn = ByteBufferUtil.EMPTY_BYTE_BUFFER;
while (true) while (true)
{ {
QueryFilter filter = QueryFilter.getSliceFilter(dkey, new QueryPath(cfs.getColumnFamilyName()), startColumn, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, PAGE_SIZE); QueryFilter filter = QueryFilter.getSliceFilter(dkey, new QueryPath(cfs.getColumnFamilyName()), startColumn, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, pageSize);
ColumnFamily cf = cfs.getColumnFamily(filter); ColumnFamily cf = cfs.getColumnFamily(filter);
if (pagingFinished(cf, startColumn)) if (pagingFinished(cf, startColumn))
break; break;
@ -326,7 +337,7 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
for (IColumn tableCF : tableCFs) for (IColumn tableCF : tableCFs)
{ {
String[] parts = getTableAndCFNames(tableCF.name()); String[] parts = getTableAndCFNames(tableCF.name());
if (sendMessage(endpoint, parts[0], parts[1], keyColumn.name())) if (sendRow(endpoint, parts[0], parts[1], keyColumn.name()))
{ {
deleteHintKey(endpointAsUTF8, keyColumn.name(), tableCF.name(), tableCF.timestamp()); deleteHintKey(endpointAsUTF8, keyColumn.name(), tableCF.name(), tableCF.timestamp());
rowsReplayed++; rowsReplayed++;

View File

@ -128,7 +128,7 @@ public class EndpointState
hasToken = value; hasToken = value;
} }
public boolean getHasToken() public boolean hasToken()
{ {
return hasToken; return hasToken;
} }

View File

@ -452,7 +452,7 @@ public class Gossiper implements IFailureDetectionEventListener
// check if this is a fat client. fat clients are removed automatically from // check if this is a fat client. fat clients are removed automatically from
// gosip after FatClientTimeout // gosip after FatClientTimeout
if (!epState.getHasToken() && !epState.isAlive() && (duration > FatClientTimeout)) if (!epState.hasToken() && !epState.isAlive() && (duration > FatClientTimeout))
{ {
if (StorageService.instance.getTokenMetadata().isMember(endpoint)) if (StorageService.instance.getTokenMetadata().isMember(endpoint))
epState.setHasToken(true); epState.setHasToken(true);
@ -475,7 +475,7 @@ public class Gossiper implements IFailureDetectionEventListener
if (!justRemovedEndpoints.isEmpty()) if (!justRemovedEndpoints.isEmpty())
{ {
for (Map.Entry<InetAddress, Long> entry : justRemovedEndpoints.entrySet()) for (Entry<InetAddress, Long> entry : justRemovedEndpoints.entrySet())
{ {
if ((now - entry.getValue()) > QUARANTINE_DELAY) if ((now - entry.getValue()) > QUARANTINE_DELAY)
{ {

View File

@ -156,7 +156,7 @@ public abstract class SSTable
{ {
throw new IOError(e); throw new IOError(e);
} }
logger.info("Deleted " + desc); logger.debug("Deleted {}", desc);
return true; return true;
} }

View File

@ -128,6 +128,9 @@ public class BufferedRandomAccessFile extends RandomAccessFile implements FileDa
fd = CLibrary.getfd(this.getFD()); fd = CLibrary.getfd(this.getFD());
} }
/**
* Flush (flush()) whatever writes are pending, and block until the data has been persistently committed (fsync()).
*/
public void sync() throws IOException public void sync() throws IOException
{ {
if (syncNeeded) if (syncNeeded)
@ -150,6 +153,11 @@ public class BufferedRandomAccessFile extends RandomAccessFile implements FileDa
} }
} }
/**
* If we are dirty, flush dirty contents to the operating system. Does not imply fsync().
*
* Currently, for implementation reasons, this also invalidates the buffer.
*/
public void flush() throws IOException public void flush() throws IOException
{ {
if (isDirty) if (isDirty)
@ -181,6 +189,9 @@ public class BufferedRandomAccessFile extends RandomAccessFile implements FileDa
} }
// Remember that we wrote, so we don't write it again on next flush().
resetBuffer();
isDirty = false; isDirty = false;
} }
} }
@ -220,16 +231,18 @@ public class BufferedRandomAccessFile extends RandomAccessFile implements FileDa
reBuffer(); reBuffer();
} }
private void resetBuffer()
{
bufferOffset = current;
validBufferBytes = 0;
}
private void reBuffer() throws IOException private void reBuffer() throws IOException
{ {
flush(); // synchronizing buffer and file on disk flush(); // synchronizing buffer and file on disk
resetBuffer();
bufferOffset = current;
if (bufferOffset >= channel.size()) if (bufferOffset >= channel.size())
{
validBufferBytes = 0;
return; return;
}
if (bufferOffset < minBufferOffset) if (bufferOffset < minBufferOffset)
minBufferOffset = bufferOffset; minBufferOffset = bufferOffset;

View File

@ -28,11 +28,11 @@ public class RackInferringSnitch extends AbstractNetworkTopologySnitch
{ {
public String getRack(InetAddress endpoint) public String getRack(InetAddress endpoint)
{ {
return Byte.toString(endpoint.getAddress()[2]); return Integer.toString(endpoint.getAddress()[2] & 0xFF, 10);
} }
public String getDatacenter(InetAddress endpoint) public String getDatacenter(InetAddress endpoint)
{ {
return Byte.toString(endpoint.getAddress()[1]); return Integer.toString(endpoint.getAddress()[1] & 0xFF, 10);
} }
} }

View File

@ -83,6 +83,7 @@ public final class MessagingService implements MessagingServiceMBean
private final SimpleCondition listenGate; private final SimpleCondition listenGate;
private final Map<StorageService.Verb, AtomicInteger> droppedMessages = new EnumMap<StorageService.Verb, AtomicInteger>(StorageService.Verb.class); private final Map<StorageService.Verb, AtomicInteger> droppedMessages = new EnumMap<StorageService.Verb, AtomicInteger>(StorageService.Verb.class);
private final List<ILatencySubscriber> subscribers = new ArrayList<ILatencySubscriber>(); private final List<ILatencySubscriber> subscribers = new ArrayList<ILatencySubscriber>();
private static final long DEFAULT_CALLBACK_TIMEOUT = (long) (1.1 * DatabaseDescriptor.getRpcTimeout());
{ {
for (StorageService.Verb verb : StorageService.Verb.values()) for (StorageService.Verb verb : StorageService.Verb.values())
@ -121,7 +122,7 @@ public final class MessagingService implements MessagingServiceMBean
return null; return null;
} }
}; };
callbacks = new ExpiringMap<String, Pair<InetAddress, IMessageCallback>>((long) (1.1 * DatabaseDescriptor.getRpcTimeout()), timeoutReporter); callbacks = new ExpiringMap<String, Pair<InetAddress, IMessageCallback>>(DEFAULT_CALLBACK_TIMEOUT, timeoutReporter);
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try try
@ -256,7 +257,12 @@ public final class MessagingService implements MessagingServiceMBean
private void addCallback(IMessageCallback cb, String messageId, InetAddress to) private void addCallback(IMessageCallback cb, String messageId, InetAddress to)
{ {
Pair<InetAddress, IMessageCallback> previous = callbacks.put(messageId, new Pair<InetAddress, IMessageCallback>(to, cb)); addCallback(cb, messageId, to, DEFAULT_CALLBACK_TIMEOUT);
}
private void addCallback(IMessageCallback cb, String messageId, InetAddress to, long timeout)
{
Pair<InetAddress, IMessageCallback> previous = callbacks.put(messageId, new Pair<InetAddress, IMessageCallback>(to, cb), timeout);
assert previous == null; assert previous == null;
} }
@ -267,6 +273,14 @@ public final class MessagingService implements MessagingServiceMBean
return Integer.toString(idGen.incrementAndGet()); return Integer.toString(idGen.incrementAndGet());
} }
/*
* @see #sendRR(Message message, InetAddress to, IMessageCallback cb, long timeout)
*/
public String sendRR(Message message, InetAddress to, IMessageCallback cb)
{
return sendRR(message, to, cb, DEFAULT_CALLBACK_TIMEOUT);
}
/** /**
* Send a message to a given endpoint. This method specifies a callback * Send a message to a given endpoint. This method specifies a callback
* which is invoked with the actual response. * which is invoked with the actual response.
@ -275,12 +289,13 @@ public final class MessagingService implements MessagingServiceMBean
* @param cb callback interface which is used to pass the responses or * @param cb callback interface which is used to pass the responses or
* suggest that a timeout occurred to the invoker of the send(). * suggest that a timeout occurred to the invoker of the send().
* suggest that a timeout occurred to the invoker of the send(). * suggest that a timeout occurred to the invoker of the send().
* @param timeout the timeout used for expiration
* @return an reference to message id used to match with the result * @return an reference to message id used to match with the result
*/ */
public String sendRR(Message message, InetAddress to, IMessageCallback cb) public String sendRR(Message message, InetAddress to, IMessageCallback cb, long timeout)
{ {
String id = nextId(); String id = nextId();
addCallback(cb, id, to); addCallback(cb, id, to, timeout);
sendOneWay(message, id, to); sendOneWay(message, id, to);
return id; return id;
} }
@ -624,4 +639,9 @@ public final class MessagingService implements MessagingServiceMBean
completedTasks.put(entry.getKey().getHostAddress(), entry.getValue().ackCon.getCompletedMesssages()); completedTasks.put(entry.getKey().getHostAddress(), entry.getValue().ackCon.getCompletedMesssages());
return completedTasks; return completedTasks;
} }
public static long getDefaultCallbackTimeout()
{
return DEFAULT_CALLBACK_TIMEOUT;
}
} }

View File

@ -1184,7 +1184,7 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
public void onAlive(InetAddress endpoint, EndpointState state) public void onAlive(InetAddress endpoint, EndpointState state)
{ {
if (!isClientMode) if (!isClientMode && state.hasToken())
deliverHints(endpoint); deliverHints(endpoint);
} }

View File

@ -32,11 +32,13 @@ public class ExpiringMap<K, V>
{ {
private final T value; private final T value;
private final long age; private final long age;
private final long expiration;
CacheableObject(T o) CacheableObject(T o, long e)
{ {
assert o != null; assert o != null;
value = o; value = o;
expiration = e;
age = System.currentTimeMillis(); age = System.currentTimeMillis();
} }
@ -45,26 +47,21 @@ public class ExpiringMap<K, V>
return value; return value;
} }
boolean isReadyToDie(long expiration) boolean isReadyToDie(long start)
{ {
return ((System.currentTimeMillis() - age) > expiration); return ((start - age) > expiration);
} }
} }
private class CacheMonitor extends TimerTask private class CacheMonitor extends TimerTask
{ {
private final long expiration;
CacheMonitor(long expiration)
{
this.expiration = expiration;
}
public void run() public void run()
{ {
long start = System.currentTimeMillis();
for (Map.Entry<K, CacheableObject<V>> entry : cache.entrySet()) for (Map.Entry<K, CacheableObject<V>> entry : cache.entrySet())
{ {
if (entry.getValue().isReadyToDie(expiration)) if (entry.getValue().isReadyToDie(start))
{ {
cache.remove(entry.getKey()); cache.remove(entry.getKey());
if (postExpireHook != null) if (postExpireHook != null)
@ -77,6 +74,7 @@ public class ExpiringMap<K, V>
private final NonBlockingHashMap<K, CacheableObject<V>> cache = new NonBlockingHashMap<K, CacheableObject<V>>(); private final NonBlockingHashMap<K, CacheableObject<V>> cache = new NonBlockingHashMap<K, CacheableObject<V>>();
private final Timer timer; private final Timer timer;
private static int counter = 0; private static int counter = 0;
private final long expiration;
public ExpiringMap(long expiration) public ExpiringMap(long expiration)
{ {
@ -90,13 +88,15 @@ public class ExpiringMap<K, V>
public ExpiringMap(long expiration, Function<Pair<K,V>, ?> postExpireHook) public ExpiringMap(long expiration, Function<Pair<K,V>, ?> postExpireHook)
{ {
this.postExpireHook = postExpireHook; this.postExpireHook = postExpireHook;
this.expiration = expiration;
if (expiration <= 0) if (expiration <= 0)
{ {
throw new IllegalArgumentException("Argument specified must be a positive number"); throw new IllegalArgumentException("Argument specified must be a positive number");
} }
timer = new Timer("EXPIRING-MAP-TIMER-" + (++counter), true); timer = new Timer("EXPIRING-MAP-TIMER-" + (++counter), true);
timer.schedule(new CacheMonitor(expiration), expiration / 2, expiration / 2); timer.schedule(new CacheMonitor(), expiration / 2, expiration / 2);
} }
public void shutdown() public void shutdown()
@ -106,7 +106,12 @@ public class ExpiringMap<K, V>
public V put(K key, V value) public V put(K key, V value)
{ {
CacheableObject<V> previous = cache.put(key, new CacheableObject<V>(value)); return put(key, value, this.expiration);
}
public V put(K key, V value, long timeout)
{
CacheableObject<V> previous = cache.put(key, new CacheableObject<V>(value, timeout));
return (previous == null) ? null : previous.getValue(); return (previous == null) ? null : previous.getValue();
} }

View File

@ -44,6 +44,7 @@ help: |
describe keyspace Describe a keyspace and it's column families. describe keyspace Describe a keyspace and it's column families.
drop column family Remove a column family and it's data. drop column family Remove a column family and it's data.
drop keyspace Remove a keyspace and it's data. drop keyspace Remove a keyspace and it's data.
drop index Remove an existing index from specific column.
get Get rows and columns. get Get rows and columns.
incr Increments a counter column. incr Increments a counter column.
list List rows in a column family. list List rows in a column family.
@ -827,6 +828,18 @@ commands:
Example: Example:
drop column family Standard2; drop column family Standard2;
- name: NODE_DROP_INDEX
help: |
drop index on <cf>.<column>;
Drops index on specified column of the column family.
Required Parameters:
- cf: Name of the column family.
- column: Name of the column to delete index on.
Example:
drop index on Users.name;
- name: NODE_THRIFT_GET - name: NODE_THRIFT_GET
help: | help: |
get <cf>['<key>']; get <cf>['<key>'];
@ -1074,13 +1087,13 @@ commands:
- type: Validator type to use when processing values. - type: Validator type to use when processing values.
Supported values are: Supported values are:
- AsciiType - ascii
- BytesType - bytes
- CounterColumnType (distributed counter column) - counterColumn (distributed counter column)
- IntegerType (a generic variable-length integer type) - integer (a generic variable-length integer type)
- LexicalUUIDType - lexicalUUID
- LongType - long
- UTF8Type - utf8
It is also valid to specify the fully-qualified class name to a class that It is also valid to specify the fully-qualified class name to a class that
extends org.apache.Cassandra.db.marshal.AbstractType. extends org.apache.Cassandra.db.marshal.AbstractType.

View File

@ -40,9 +40,14 @@ public class CliTest extends CleanupHelper
"create column family CF1 with comparator=UTF8Type and column_metadata=[{ column_name:world, validation_class:IntegerType, index_type:0, index_name:IdxName }, { column_name:world2, validation_class:LongType, index_type:KEYS, index_name:LongIdxName}];", "create column family CF1 with comparator=UTF8Type and column_metadata=[{ column_name:world, validation_class:IntegerType, index_type:0, index_name:IdxName }, { column_name:world2, validation_class:LongType, index_type:KEYS, index_name:LongIdxName}];",
"assume CF1 keys as utf8;", "assume CF1 keys as utf8;",
"set CF1[hello][world] = 123848374878933948398384;", "set CF1[hello][world] = 123848374878933948398384;",
"set CF1[hello][test_quote] = 'value\\'';",
"set CF1['k\\'ey'][VALUE] = 'VAL';",
"set CF1['k\\'ey'][VALUE] = 'VAL\\'';",
"set CF1[hello][-31337] = 'some string value';", "set CF1[hello][-31337] = 'some string value';",
"get CF1[hello][-31337];", "get CF1[hello][-31337];",
"get CF1[hello][world];", "get CF1[hello][world];",
"get CF1[hello][test_quote];",
"get CF1['k\\'ey'][VALUE]",
"set CF1[hello][-31337] = -23876;", "set CF1[hello][-31337] = -23876;",
"set CF1[hello][-31337] = long(-23876);", "set CF1[hello][-31337] = long(-23876);",
"set CF1[hello][world2] = 15;", "set CF1[hello][world2] = 15;",
@ -105,6 +110,7 @@ public class CliTest extends CleanupHelper
"get Counter1['hello']['cassandra'];", "get Counter1['hello']['cassandra'];",
"get Counter1['hello'];", "get Counter1['hello'];",
"truncate CF1;", "truncate CF1;",
"drop index on CF1.world2;",
"update keyspace TestKeySpace with placement_strategy='org.apache.cassandra.locator.LocalStrategy';", "update keyspace TestKeySpace with placement_strategy='org.apache.cassandra.locator.LocalStrategy';",
"update keyspace TestKeySpace with strategy_options=[{DC1:3, DC2:4, DC5:1}];", "update keyspace TestKeySpace with strategy_options=[{DC1:3, DC2:4, DC5:1}];",
"assume CF1 comparator as utf8;", "assume CF1 comparator as utf8;",