Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 64bit ids #7

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
b06012d
updates sbt-assembly to a version that does exist
christianparpart Jun 4, 2014
f58fccc
Merge remote-tracking branch 'dawanda/master'
christianparpart Sep 3, 2014
e0fa875
.gitignore
christianparpart Sep 16, 2014
ee482f0
Merge branch 'master' of github.com:trapni/sqltap
christianparpart Sep 16, 2014
6d2b92c
porting sqltap to Scala 2.10
christianparpart Sep 16, 2014
b161260
mysql: adds TIMESTAMP2 table column type to TableMapBinlogEvent
christianparpart Aug 27, 2015
9328b3f
porting sqltap to Scala 2.10
christianparpart Sep 16, 2014
3b9b93b
some patches
christianparpart Oct 28, 2014
4f292d7
Update to Scala 2.11.4
Nov 21, 2014
b134c96
Parametrize memcache connection setting
Nov 21, 2014
9f9fa5c
Add TTL support per ctree
Feb 2, 2015
bf870f5
Escape backslashes when writing json
tadassce May 4, 2015
2ff2a4c
.gitignore
christianparpart Sep 16, 2014
890163e
updates sbt-assembly to a version that does exist
christianparpart Jun 4, 2014
a00e4a6
fixes memcache_connections_open / sql_connections_open statistics bug
christianparpart Oct 1, 2015
7a00108
symbolize literals to make the source code a little more readable
christianparpart Oct 1, 2015
36dc9c3
helps 48.toByte to be more readable, it's a '0' literal ;-)
christianparpart Oct 1, 2015
610f3a1
Fixes bug with too large memcached responses and its follow-up resour…
christianparpart Oct 2, 2015
b5ba51f
some personally helpful documentation
christianparpart Oct 2, 2015
60c309d
documentation updates, def rearrangements, and minor code cleanups
christianparpart Oct 4, 2015
e2e323b
code readability improvements
christianparpart Oct 4, 2015
ce21b89
documentation
christianparpart Oct 4, 2015
6f765c8
code cleanup: keep single-statement for-loops more consistent with wh…
christianparpart Oct 4, 2015
fad16b6
more documentationary
christianparpart Oct 4, 2015
c4a5c83
minor code-refactor
christianparpart Oct 4, 2015
793037f
cleanup: remove unnecessary SelectionKey passing, as it is always the…
christianparpart Oct 4, 2015
cbec21b
bugfix for the infamous Memcached protocol error
christianparpart Oct 4, 2015
e77af94
mute record-not-found log messages
christianparpart Oct 4, 2015
a45101a
version bump 0.8.0
christianparpart Oct 4, 2015
ce03a93
Merge remote-tracking branch 'paul/master'
christianparpart Oct 4, 2015
b866a99
Merge remote-tracking branch 'christianparpart/master'
christianparpart Oct 4, 2015
80d6887
dead code cleanup
christianparpart Oct 5, 2015
504f1ae
Improve logger api
christianparpart Oct 5, 2015
f049da7
fixes compiler warning
christianparpart Oct 5, 2015
d234cfc
code cleanup
christianparpart Oct 5, 2015
22869f1
generalize sending simple text HTTP responses
christianparpart Oct 5, 2015
57dedd0
add the ability to optionally log Sqltap queries. CLI- and runtime c…
christianparpart Oct 5, 2015
12d6f47
bump scala version to 2.11.7
christianparpart Oct 5, 2015
bc7a0e4
adds SQL slow query statistics
christianparpart Oct 8, 2015
adc1fbb
DeltaStatistic: code readability improvements
christianparpart Oct 23, 2015
d66b3a2
move src/* to convention src/main/scala/*
itszootime Oct 23, 2015
657cd15
add scalatest as test dependency
itszootime Oct 23, 2015
860f2d6
add specs for existing JSONWriter behaviour
itszootime Oct 23, 2015
841b352
add json string escaping for bytes < 0x20
itszootime Oct 23, 2015
f8da114
Merge pull request #3 from dawanda/escape_utf8_control_chars
christianparpart Nov 2, 2015
e0a3bd8
Merge remote-tracking branch 'dawanda/master'
christianparpart Nov 2, 2015
3522f1f
add escaping for default_order field
itszootime Nov 2, 2015
e4bc8b3
Merge pull request #4 from dawanda/add_default_order_escaping
christianparpart Nov 3, 2015
3136df8
Merge remote-tracking branch 'dawanda/master'
christianparpart Nov 3, 2015
cebe5cd
build.sbt: compile fix
christianparpart Nov 3, 2015
8cd2bdd
version bump to 0.8.1
christianparpart Nov 3, 2015
5cac6f5
Dockerize
Jan 22, 2016
39a5b75
Merge pull request #6 from dawanda/dockerize
christianparpart Jan 22, 2016
22c6318
Dockerfile: adds missing ENV
christianparpart Jan 22, 2016
cf76c52
Dockerfile refactoring, killing unnecessary statements and do some cl…
christianparpart Jan 23, 2016
f35d059
docker: improved bootup script to be a little more user-friendly
christianparpart Jan 23, 2016
c55d041
.dockerignore update
christianparpart Jan 23, 2016
24bcb8f
Dockerfile: drop unnecessary HOSTNAME env var
christianparpart Jan 23, 2016
7d833de
Dockerfile: remove default arg for MEMCACHE_HOST as it must be set ex…
christianparpart Jan 23, 2016
14d6523
Dockerfile: use new startup location
christianparpart Jan 23, 2016
3d3787d
Dockerfile: improved build process
christianparpart Jan 23, 2016
eda87f9
adds Makefile for convinience
christianparpart Jan 23, 2016
8089a8a
bootup.sh: drop requirement of SQLTAP_OPTS env var
christianparpart Jan 23, 2016
ddbf119
docker fixes
christianparpart Jan 23, 2016
ba78cc0
docker: fixing SQLTAP_JARFILE
christianparpart Jan 23, 2016
040c0b8
docker: move ADD bootup.sh at the most bottom place as possible
christianparpart Jan 23, 2016
344415b
Makefile: adds a p[h]ony
christianparpart Jan 25, 2016
393243b
bootup.sh: env var cleanup
christianparpart Jan 25, 2016
1975517
handle >31bit integer field ids
asmuth Mar 2, 2016
7f0d655
also support 64bit integers in RowsBinlogEvent
asmuth Mar 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.gitignore
.DS_Store
/target
/bin
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
.DS_Store
/bin
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM java:8
MAINTAINER DaWanda <[email protected]>

ARG SBT_VERSION="0.13.8"

ENV SQLTAP_HTTP_PORT="3000" \
SQLTAP_THREADS="16" \
SQLTAP_SCHEMA="/etc/sqltap-schema.xml" \
SCHEMA_URL="" \
SQLTAP_OPTS="" \
MYSQL_HOST="127.0.0.1" \
MYSQL_PORT="3306" \
MYSQL_USER="fetch" \
MYSQL_DATABASE="test" \
MYSQL_NUMCONNS="6" \
MYSQL_QUEUELEN="2500" \
JMX_PORT="9191" \
RMI_BIND="127.0.0.1" \
JAVA_XMX="16384M" \
CACHE_BACKEND="memcache" \
MEMCACHE_HOST="" \
MEMCACHE_PORT="11211" \
MEMCACHE_QUEUELEN="8192" \
MEMCACHE_NUMCONNS="20"

ADD https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb /tmp/sbt.deb
RUN dpkg -i /tmp/sbt.deb && rm -f /tmp/sbt.deb
RUN apt-get update && apt-get install sbt

ADD project /usr/src/project/
ADD src /usr/src/src/
ADD build.sbt /usr/src/

RUN cd /usr/src && \
sbt assembly && \
cp -vpi /usr/src/target/scala-*/sqltap.jar /usr/lib/sqltap.jar && \
rm -rf /usr/src/*

EXPOSE $SQLTAP_HTTP_PORT

ADD bootup.sh /bootup.sh
CMD ["/bootup.sh"]
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is part of the "sqltap" project, http://github.com/dawanda/sqltap>
# (c) 2016 Christian Parpart <[email protected]>
#
# Licensed under the MIT License (the "License"); you may not use this
# file except in compliance with the License. You may obtain a copy of
# the License at: http://opensource.org/licenses/MIT

IMAGE = sqltap
VERSION = $(shell grep ^version build.sbt | cut -d\" -f2)

image:
docker build -t ${IMAGE}:${VERSION} .

push: image
docker push ${IMAGE}:${VERSION}

clean:
rm -rf target

.PHONY: image clean push

# vim:ts=8:noet
80 changes: 80 additions & 0 deletions bootup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash
set -ex

SQLTAP_JARFILE="/usr/lib/sqltap.jar"

if [[ "$SCHEMA_URL" != "" ]]; then
curl -sL "$SCHEMA_URL" -o "${SQLTAP_SCHEMA}"
fi

require_arg() {
local name="$1"
local val="${!name}"

echo "${name}: ${val}"

if [[ "${val}" == "" ]]; then
echo "Error. Required argument ${name} missing." 1>&2
exit 1
fi
}

require_args() {
while [[ $# -ne 0 ]]; do
require_arg $1
shift
done
}

require_args SQLTAP_SCHEMA \
MYSQL_PORT \
SQLTAP_HTTP_PORT \
SQLTAP_THREADS \
SCHEMA_URL \
MYSQL_HOST \
MYSQL_PORT \
MYSQL_USER \
MYSQL_DATABASE \
MYSQL_NUMCONNS \
MYSQL_QUEUELEN \
JMX_PORT \
RMI_BIND \
JAVA_XMX \
CACHE_BACKEND

opts=""
opts="$opts --config ${SQLTAP_SCHEMA}"
opts="$opts --http ${SQLTAP_HTTP_PORT}"
opts="$opts --disable-keepalive"
opts="$opts -t ${SQLTAP_THREADS}"
opts="$opts --mysql-host ${MYSQL_HOST}"
opts="$opts --mysql-port ${MYSQL_PORT}"
opts="$opts --mysql-user ${MYSQL_USER}"
opts="$opts --mysql-database ${MYSQL_DATABASE}"
opts="$opts --mysql-numconns ${MYSQL_NUMCONNS}"
opts="$opts --mysql-queuelen ${MYSQL_QUEUELEN}"
opts="$opts --cache-backend ${CACHE_BACKEND}"

if [[ "${CACHE_BACKEND}" == "memcache" ]]; then
require_args MEMCACHE_HOST \
MEMCACHE_PORT \
MEMCACHE_QUEUELEN \
MEMCACHE_NUMCONNS

opts="$opts --memcache-host ${MEMCACHE_HOST}"
opts="$opts --memcache-port ${MEMCACHE_PORT}"
opts="$opts --memcache-queuelen ${MEMCACHE_QUEUELEN}"
opts="$opts --memcache-numconns ${MEMCACHE_NUMCONNS}"
fi

opts="$opts ${SQLTAP_OPTS}"

exec java \
-Djava.rmi.server.hostname="${RMI_BIND}" \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port="${JMX_PORT}" \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Xmx"${JAVA_XMX}" -XX:GCTimeRatio=99 -XX:+UseConcMarkSweepGC \
-jar "${SQLTAP_JARFILE}" \
$opts
12 changes: 7 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ name := "SQLTap"

organization := "com.paulasmuth"

version := "0.7.21"
version := "0.8.1"

mainClass in (Compile, run) := Some("com.paulasmuth.sqltap.SQLTap")

scalaSource in Compile <<= baseDirectory(_ / "src")

scalaVersion := "2.9.1"
scalaVersion := "2.11.7"

assemblySettings

jarName in assembly := "sqltap_0.7.21.jar"
jarName in assembly := { s"${name.value.toLowerCase}.jar" }

fork in run := true

libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.0.2"

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
62 changes: 62 additions & 0 deletions patches/sqltap-encoding-fix.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
diff --git a/src/com/paulasmuth/sqltap/ExpirationHandlerFactory.scala b/src/com/paulasmuth/sqltap/ExpirationHandlerFactory.scala
index 2145f56..cf17011 100644
--- a/src/com/paulasmuth/sqltap/ExpirationHandlerFactory.scala
+++ b/src/com/paulasmuth/sqltap/ExpirationHandlerFactory.scala
@@ -1,5 +1,5 @@
// This file is part of the "SQLTap" project
-// (c) 2011-2013 Paul Asmuth <[email protected]>
+// (c) 2014 Paul Asmuth, Google Inc. <[email protected]>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
@@ -30,8 +30,10 @@ object ExpirationHandlerFactory {
case "noop" =>
handler = new NoopExpirationHandler()

- case "purge" =>
+ case "purge" => {
handler = new PurgeExpirationHandler()
+ ReplicationFeed.start()
+ }

case _ =>
throw new ParseException("unknown expiration handler: " + name)
diff --git a/src/com/paulasmuth/sqltap/HTTPParser.scala b/src/com/paulasmuth/sqltap/HTTPParser.scala
index 22b27be..33cd26d 100644
--- a/src/com/paulasmuth/sqltap/HTTPParser.scala
+++ b/src/com/paulasmuth/sqltap/HTTPParser.scala
@@ -1,5 +1,5 @@
// This file is part of the "SQLTap" project
-// (c) 2011-2013 Paul Asmuth <[email protected]>
+// (c) 2014 Paul Asmuth, Google Inc. <[email protected]>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
@@ -130,7 +130,7 @@ class HTTPParser {
}

def uri_parts() : List[String] = {
- val uri = URLDecoder.decode(http_uri, "UTF-8")
+ val uri = URLDecoder.decode(http_uri)
var pos = uri.length
var cur = pos - 1
var ret = new ListBuffer[String]()
diff --git a/src/com/paulasmuth/sqltap/SQLTap.scala b/src/com/paulasmuth/sqltap/SQLTap.scala
index 357fc20..05c8921 100644
--- a/src/com/paulasmuth/sqltap/SQLTap.scala
+++ b/src/com/paulasmuth/sqltap/SQLTap.scala
@@ -1,5 +1,5 @@
// This file is part of the "SQLTap" project
-// (c) 2011-2013 Paul Asmuth <[email protected]>
+// (c) 2014 Paul Asmuth, Google Inc. <[email protected]>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
@@ -108,7 +108,6 @@ object SQLTap{
Manifest.load(new File(Config.get('config_base)))
RelationTrace.load(Manifest.resources)
ExpirationHandlerFactory.configure(Config.get('expiration_handler))
- ReplicationFeed.start()

val server = new Server(Config.get('threads).toInt)
server.run(Config.get('http_port).toInt)
100 changes: 100 additions & 0 deletions patches/sqltap-log-slow-queries.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
diff -r -u sqltap/src/com/paulasmuth/sqltap/HTTPConnection.scala sqltap-0.7.21/src/com/paulasmuth/sqltap/HTTPConnection.scala
--- sqltap/src/com/paulasmuth/sqltap/HTTPConnection.scala 2014-02-12 16:13:05.009387526 +0100
+++ sqltap-0.7.21/src/com/paulasmuth/sqltap/HTTPConnection.scala 2014-09-04 14:31:28.000000000 +0200
@@ -1,10 +1,9 @@
// This file is part of the "SQLTap" project
-// (c) 2011-2013 Paul Asmuth <[email protected]>
+// (c) 2014 Paul Asmuth, Google Inc. <[email protected]>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT
-
package com.paulasmuth.sqltap

import java.nio.channels.{SocketChannel,SelectionKey}
@@ -23,6 +22,7 @@
private val parser = new HTTPParser()
private var state = HTTP_STATE_INIT
private var last_event : SelectionKey = null
+ private var last_uri : String = "<unknown>" // for debugging only
private var keepalive : Boolean = false
private var resp_buf : ByteBuffer = null

@@ -190,6 +190,7 @@

idle_timer.cancel()
stime = System.nanoTime
+ last_uri = parser.http_uri
seq += 1

if (parser.http_version == "1.1")
@@ -302,8 +303,13 @@
}

def finish() : Unit = {
- Statistics.incr('http_request_time_mean,
- (System.nanoTime - stime) / 1000000.0)
+ val runtime_millis = (System.nanoTime - stime) / 1000000.0
+ Statistics.incr('http_request_time_mean, runtime_millis)
+
+ if (Config.has_key('log_slow_queries) &&
+ runtime_millis >= Config.get('log_slow_queries).toInt) {
+ Logger.log("[HTTP] [Slow Query] (" + runtime_millis + "ms): " + last_uri)
+ }

if (!keepalive)
return close()
diff -r -u sqltap/src/com/paulasmuth/sqltap/mysql/SQLQuery.scala sqltap-0.7.21/src/com/paulasmuth/sqltap/mysql/SQLQuery.scala
--- sqltap/src/com/paulasmuth/sqltap/mysql/SQLQuery.scala 2014-02-12 16:13:05.013389526 +0100
+++ sqltap-0.7.21/src/com/paulasmuth/sqltap/mysql/SQLQuery.scala 2014-09-04 14:31:38.000000000 +0200
@@ -1,10 +1,9 @@
// This file is part of the "SQLTap" project
-// (c) 2011-2013 Paul Asmuth <[email protected]>
+// (c) 2014 Paul Asmuth, Google Inc. <[email protected]>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT
-
package com.paulasmuth.sqltap.mysql

import com.paulasmuth.sqltap._
@@ -44,8 +43,14 @@
tok = System.nanoTime
qtime = tok - tik

- Statistics.incr('sql_request_time_mean, qtime / 1000000.0)
- Logger.debug("Finished (" + (qtime / 1000000.0) + "ms): " + query)
+ val runtime_millis = qtime / 1000000.0
+ Statistics.incr('sql_request_time_mean, runtime_millis)
+ Logger.debug("Finished (" + runtime_millis + "ms): " + query)
+
+ if (Config.has_key('log_slow_queries) &&
+ runtime_millis >= Config.get('log_slow_queries).toInt) {
+ Logger.log("[SQL] [Slow Query] (" + runtime_millis + "ms): " + query)
+ }
}

def error(err: Throwable) : Unit = {
diff -r -u sqltap/src/com/paulasmuth/sqltap/SQLTap.scala sqltap-0.7.21/src/com/paulasmuth/sqltap/SQLTap.scala
--- sqltap/src/com/paulasmuth/sqltap/SQLTap.scala 2014-02-25 17:15:47.049982142 +0100
+++ sqltap-0.7.21/src/com/paulasmuth/sqltap/SQLTap.scala 2014-09-04 14:35:51.000000000 +0200
@@ -72,6 +71,9 @@
else if (args(n) == "--disable-keepalive")
{ Config.set('http_keepalive, "false"); n += 1 }

+ else if (args(n) == "--log-slow-queries")
+ { Config.set('log_slow_queries, args(n+1)); n += 2 }
+
else if ((args(n) == "-t") || (args(n) == "--threads"))
{ Config.set('threads, args(n+1)); n += 2 }

@@ -138,6 +139,7 @@
println(" --memcache-queuelen <num> max mysql queue size per worker ")
println(" --memcache-numconns <num> max number of mysql connections per worker ")
println(" --memcache-mode <name> replication mode (copy, shard) ")
+ println(" --log-slow-queries <millis> log all queries with a runtime > val in ms ")
println(" -h, --help you're reading it... ")
println(" -d, --debug debug mode ")
}
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
Loading