Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C937F200D61 for ; Tue, 5 Dec 2017 00:11:57 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C7B0A160BF9; Mon, 4 Dec 2017 23:11:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 48184160C05 for ; Tue, 5 Dec 2017 00:11:55 +0100 (CET) Received: (qmail 80027 invoked by uid 500); 4 Dec 2017 23:11:54 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 79995 invoked by uid 99); 4 Dec 2017 23:11:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Dec 2017 23:11:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1BE4EF6104; Mon, 4 Dec 2017 23:11:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aweisberg@apache.org To: commits@cassandra.apache.org Date: Mon, 04 Dec 2017 23:11:55 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] cassandra git commit: Support a means of logging all queries as they were invoked. archived-at: Mon, 04 Dec 2017 23:11:58 -0000 Support a means of logging all queries as they were invoked. Patch by Ariel Weisberg; Reviewed by Blake Eggleston Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ae837806 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ae837806 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ae837806 Branch: refs/heads/trunk Commit: ae837806bd07dbb8b881960feeeeb90c1a665d93 Parents: db81f6b Author: Ariel Weisberg Authored: Fri Oct 27 17:16:45 2017 -0400 Committer: Ariel Weisberg Committed: Mon Dec 4 18:06:30 2017 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + NEWS.txt | 8 + bin/fqltool | 88 +++ bin/fqltool.bat | 36 + build.xml | 17 + conf/cassandra.yaml | 9 +- conf/jvm.options | 4 + lib/chronicle-bytes-1.10.1.jar | Bin 0 -> 273664 bytes lib/chronicle-core-1.9.21.jar | Bin 0 -> 199833 bytes lib/chronicle-queue-4.6.55.jar | Bin 0 -> 215247 bytes lib/chronicle-threads-1.9.1.jar | Bin 0 -> 40530 bytes lib/chronicle-wire-1.10.1.jar | Bin 0 -> 419054 bytes lib/licenses/chronicle-bytes-1.10.1.txt | 14 + lib/licenses/chronicle-core-1.9.21.txt | 14 + lib/licenses/chronicle-queue-4.6.55.txt | 14 + lib/licenses/chronicle-threads-1.9.1.txt | 14 + lib/licenses/chronicle-wire-1.10.1.txt | 14 + .../org/apache/cassandra/config/Config.java | 2 + .../cassandra/config/DatabaseDescriptor.java | 5 + .../db/fullquerylog/FullQueryLogger.java | 530 +++++++++++++++ .../apache/cassandra/service/StorageProxy.java | 23 + .../cassandra/service/StorageProxyMBean.java | 21 + .../cassandra/tools/FullQueryLogTool.java | 93 +++ .../org/apache/cassandra/tools/NodeTool.java | 3 + .../apache/cassandra/tools/fqltool/Dump.java | 265 ++++++++ .../tools/nodetool/DisableFullQueryLog.java | 33 + .../tools/nodetool/EnableFullQueryLog.java | 49 ++ .../tools/nodetool/ResetFullQueryLog.java | 33 + .../transport/messages/BatchMessage.java | 21 + .../transport/messages/ExecuteMessage.java | 11 + .../transport/messages/QueryMessage.java | 11 + .../org/apache/cassandra/utils/ObjectSizes.java | 1 + .../apache/cassandra/utils/binlog/BinLog.java | 277 ++++++++ .../utils/concurrent/WeightedQueue.java | 333 ++++++++++ test/unit/org/apache/cassandra/Util.java | 6 +- .../db/fullquerylog/FullQueryLoggerTest.java | 601 +++++++++++++++++ .../cassandra/utils/binlog/BinLogTest.java | 449 +++++++++++++ .../utils/concurrent/WeightedQueueTest.java | 656 +++++++++++++++++++ 38 files changed, 3652 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ae837806/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 8350848..81da11d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0 + * Support a means of logging all queries as they were invoked (CASSANDRA-13983) * Presize collections (CASSANDRA-13760) * Add GroupCommitLogService (CASSANDRA-13530) * Parallelize initial materialized view build (CASSANDRA-12245) http://git-wip-us.apache.org/repos/asf/cassandra/blob/ae837806/NEWS.txt ---------------------------------------------------------------------- diff --git a/NEWS.txt b/NEWS.txt index 622cc54..a14f7ba 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -34,6 +34,14 @@ New features threads is specified by the property `cassandra.yaml:concurrent_materialized_view_builders`. This property can be modified at runtime through both JMX and the new `setconcurrentviewbuilders` and `getconcurrentviewbuilders` nodetool commands. See CASSANDRA-12245 for more details. + - There is now a binary full query log based on Chronicle Queue that can be controlled using + nodetool enablefullquerylog, disablefullquerylog, and resetfullquerylog. The log + contains all queries invoked, approximate time they were invoked, any parameters necessary + to bind wildcard values, and all query options. A human readable version of the log can be + dumped or tailed using the new bin/fqltool utility. The full query log is designed to be safe + to use in production and limits utilization of heap memory and disk space with limits + you can specify when enabling the log. + See nodetool and fqltool help text for more information. Upgrading --------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ae837806/bin/fqltool ---------------------------------------------------------------------- diff --git a/bin/fqltool b/bin/fqltool new file mode 100755 index 0000000..8a05af1 --- /dev/null +++ b/bin/fqltool @@ -0,0 +1,88 @@ +#!/bin/sh + +# 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_INCLUDE" = "x" ]; then + # Locations (in order) to use when searching for an include file. + for include in "`dirname "$0"`/cassandra.in.sh" \ + "$HOME/.cassandra.in.sh" \ + /usr/share/cassandra/cassandra.in.sh \ + /usr/local/share/cassandra/cassandra.in.sh \ + /opt/cassandra/cassandra.in.sh; do + if [ -r "$include" ]; then + . "$include" + break + fi + done +elif [ -r "$CASSANDRA_INCLUDE" ]; then + . "$CASSANDRA_INCLUDE" +fi + +# Use JAVA_HOME if set, otherwise look for java in PATH +if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" +else + JAVA="`which java`" +fi + +if [ "x$JAVA" = "x" ]; then + echo "Java executable not found (hint: set JAVA_HOME)" >&2 + exit 1 +fi + +if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then + echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2 + exit 1 +fi + +# Run cassandra-env.sh to pick up JMX_PORT +if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then + JVM_OPTS_SAVE=$JVM_OPTS + MAX_HEAP_SIZE_SAVE=$MAX_HEAP_SIZE + . "$CASSANDRA_CONF/cassandra-env.sh" + MAX_HEAP_SIZE=$MAX_HEAP_SIZE_SAVE + JVM_OPTS=$JVM_OPTS_SAVE +fi + +# JMX Port passed via cmd line args (-p 9999 / --port 9999 / --port=9999) +# should override the value from cassandra-env.sh +ARGS="" +JVM_ARGS="" +while true +do + if [ ! $1 ]; then break; fi + case $1 in + -D*) + JVM_ARGS="$JVM_ARGS $1" + ;; + *) + ARGS="$ARGS $1" + ;; + esac + shift +done + +if [ "x$MAX_HEAP_SIZE" = "x" ]; then + MAX_HEAP_SIZE="512m" +fi + +"$JAVA" $JAVA_AGENT -ea -da:net.openhft... -cp "$CLASSPATH" $JVM_OPTS -Xmx$MAX_HEAP_SIZE \ + -Dlog4j.configurationFile=log4j2-tools.xml \ + $JVM_ARGS \ + org.apache.cassandra.tools.FullQueryLogTool $ARGS + +# vi:ai sw=4 ts=4 tw=0 et http://git-wip-us.apache.org/repos/asf/cassandra/blob/ae837806/bin/fqltool.bat ---------------------------------------------------------------------- diff --git a/bin/fqltool.bat b/bin/fqltool.bat new file mode 100644 index 0000000..f3103d8 --- /dev/null +++ b/bin/fqltool.bat @@ -0,0 +1,36 @@ +@REM +@REM Licensed to the Apache Software Foundation (ASF) under one or more +@REM contributor license agreements. See the NOTICE file distributed with +@REM this work for additional information regarding copyright ownership. +@REM The ASF licenses this file to You under the Apache License, Version 2.0 +@REM (the "License"); you may not use this file except in compliance with +@REM the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. + +@echo off +if "%OS%" == "Windows_NT" setlocal + +pushd "%~dp0" +call cassandra.in.bat + +if NOT DEFINED JAVA_HOME goto :err + +set CASSANDRA_PARAMS=%CASSANDRA_PARAMS% -Dcassandra.logdir="%CASSANDRA_HOME%\logs" + +"%JAVA_HOME%\bin\java" -cp %CASSANDRA_CLASSPATH% %CASSANDRA_PARAMS% -Dlog4j.configurationFile=log4j2-tools.xml org.apache.cassandra.tools.FullQueryLogTool %* +goto finally + +:err +echo The JAVA_HOME environment variable must be set to run this program! +pause + +:finally +ENDLOCAL & set RC=%ERRORLEVEL% +exit /B %RC% http://git-wip-us.apache.org/repos/asf/cassandra/blob/ae837806/build.xml ---------------------------------------------------------------------- diff --git a/build.xml b/build.xml index 7c63c82..5dee75d 100644 --- a/build.xml +++ b/build.xml @@ -114,6 +114,13 @@ + + + + + + + @@ -422,6 +429,11 @@ + + + + +