Permalink
Browse files

Basic implementation with in-memory storage

* Multi-module structure for Java 8 with Maven Wrapper (`./mvnw`)
  * source and javadoc jars are produced
  * javadoc excludes packages marked internal
* CONTRIBUTING.md explains code format and contribution agreement
  * Missing license header will break compilation
* Thrift classes are annotated with swift, and generated by auto-value
  * Note runtime is patched until facebook/swift issue 274 is merged.
* Tests use JUnit and AssertJ

The ZipkinServer works, albeit in-memory:
```bash
$ du -k zipkin-java-server/target/zipkin-server
10056	zipkin-java-server/target/zipkin-server
$ zipkin-java-server/target/zipkin-server
Sep 07, 2015 5:52:56 PM io.airlift.log.Logger info
INFO: started transport thrift:9410 (:9410)
Sep 07, 2015 5:52:56 PM io.airlift.log.Logger info
INFO: started transport thrift:9411 (:9411)
```

Further work is needed to port backends and handle time skew adjustment.
We can do this collaboratively vs a forever-branch.
  • Loading branch information...
1 parent 5f94019 commit db311ab9a60192549f2b9282b5882368504deafb @adriancole adriancole committed Aug 29, 2015
Showing with 2,690 additions and 8 deletions.
  1. +13 −8 .gitignore
  2. +13 −0 .travis.yml
  3. +30 −0 CONTRIBUTING.md
  4. BIN maven/maven-wrapper.jar
  5. +3 −0 maven/maven-wrapper.properties
  6. +234 −0 mvnw
  7. +174 −0 mvnw.bat
  8. +258 −0 pom.xml
  9. +11 −0 src/etc/header.txt
  10. +43 −0 zipkin-java-core/pom.xml
  11. +68 −0 zipkin-java-core/src/main/java/io/zipkin/Annotation.java
  12. +84 −0 zipkin-java-core/src/main/java/io/zipkin/BinaryAnnotation.java
  13. +27 −0 zipkin-java-core/src/main/java/io/zipkin/Constants.java
  14. +57 −0 zipkin-java-core/src/main/java/io/zipkin/Endpoint.java
  15. +116 −0 zipkin-java-core/src/main/java/io/zipkin/Span.java
  16. +41 −0 zipkin-java-core/src/main/java/io/zipkin/Trace.java
  17. +23 −0 zipkin-java-core/src/main/java/io/zipkin/internal/Nullable.java
  18. +38 −0 zipkin-java-core/src/test/java/io/zipkin/SpanTest.java
  19. +39 −0 zipkin-java-dependencies/pom.xml
  20. +60 −0 zipkin-java-dependencies/src/main/java/io/zipkin/dependencies/Dependencies.java
  21. +35 −0 zipkin-java-dependencies/src/main/java/io/zipkin/dependencies/DependenciesException.java
  22. +59 −0 zipkin-java-dependencies/src/main/java/io/zipkin/dependencies/DependencyLink.java
  23. +31 −0 zipkin-java-dependencies/src/main/java/io/zipkin/dependencies/DependencySink.java
  24. +40 −0 zipkin-java-dependencies/src/main/java/io/zipkin/dependencies/DependencySource.java
  25. +77 −0 zipkin-java-dependencies/src/main/java/io/zipkin/dependencies/Moments.java
  26. +43 −0 zipkin-java-query/pom.xml
  27. +137 −0 zipkin-java-query/src/main/java/io/zipkin/query/InMemoryZipkinQuery.java
  28. +34 −0 zipkin-java-query/src/main/java/io/zipkin/query/QueryException.java
  29. +87 −0 zipkin-java-query/src/main/java/io/zipkin/query/QueryRequest.java
  30. +53 −0 zipkin-java-query/src/main/java/io/zipkin/query/ZipkinQuery.java
  31. +29 −0 zipkin-java-query/src/test/java/io/zipkin/query/InMemoryZipkinQueryTest.java
  32. +247 −0 zipkin-java-query/src/test/java/io/zipkin/query/ZipkinQueryTest.java
  33. +56 −0 zipkin-java-scribe/pom.xml
  34. +48 −0 zipkin-java-scribe/src/main/java/io/zipkin/scribe/LogEntry.java
  35. +31 −0 zipkin-java-scribe/src/main/java/io/zipkin/scribe/ResultCode.java
  36. +26 −0 zipkin-java-scribe/src/main/java/io/zipkin/scribe/Scribe.java
  37. +56 −0 zipkin-java-scribe/src/main/java/io/zipkin/scribe/ScribeSpanConsumer.java
  38. +81 −0 zipkin-java-server/dependency-reduced-pom.xml
  39. +99 −0 zipkin-java-server/pom.xml
  40. +89 −0 zipkin-java-server/src/main/java/io/zipkin/ZipkinServer.java
View
@@ -1,8 +1,13 @@
-.gradle
-build/
-
-# Ignore Gradle GUI config
-gradle-app.setting
-
-# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
-!gradle-wrapper.jar
+*~
+#*
+*#
+.#*
+.classpath
+.project
+.settings/
+.springBeans
+target/
+_site/
+.idea
+*.iml
+*.swp
View
@@ -0,0 +1,13 @@
+sudo: false
+
+cache:
+ directories:
+ - $HOME/.m2
+
+language: java
+
+jdk:
+ - oraclejdk8
+
+install:
+- ./mvnw install
View
@@ -0,0 +1,30 @@
+# Contributing to Zipkin
+
+If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request (on a branch other than `master` or `gh-pages`).
+
+When submitting code, please apply [Square Code Style](https://github.com/square/java-code-styles).
+* If the settings import correctly, CodeStyle/Java will be named Square and use 2 space tab and indent, with 4 space continuation indent.
+
+## License
+
+By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/openzipkin/zipkin/blob/master/LICENSE
+
+All files are released with the Apache 2.0 license.
+
+If you are adding a new file it should have a header like below. This can be automatically added by running `./mvnw com.mycila:license-maven-plugin:format`.
+
+```
+/**
+ * Copyright 2015 The OpenZipkin Authors
+ *
+ * Licensed 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.
+ */
+ ```
Binary file not shown.
@@ -0,0 +1,3 @@
+#Maven download properties
+#Tue Sep 01 07:17:40 PDT 2015
+distributionUrl=https\://repository.apache.org/content/repositories/releases/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip
View
234 mvnw
@@ -0,0 +1,234 @@
+#!/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.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ #
+ # Look for the Apple JDKs first to preserve the existing behaviour, and then look
+ # for the new JDKs provided by Oracle.
+ #
+ if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
+ #
+ # Apple JDKs
+ #
+ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
+ fi
+
+ if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
+ #
+ # Apple JDKs
+ #
+ export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
+ fi
+
+ if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
+ #
+ # Oracle JDKs
+ #
+ export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
+ fi
+
+ if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
+ #
+ # Apple JDKs
+ #
+ export JAVA_HOME=`/usr/libexec/java_home`
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Migwn, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+fi
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+ local basedir=$(pwd)
+ local wdir=$(pwd)
+ while [ "$wdir" != '/' ] ; do
+ wdir=$(cd "$wdir/.."; pwd)
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER="org.apache.maven.wrapper.MavenWrapperMain"
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ -classpath \
+"$MAVEN_PROJECTBASEDIR/maven/maven-wrapper.jar" \
+ ${WRAPPER_LAUNCHER} "$@"
Oops, something went wrong.

0 comments on commit db311ab

Please sign in to comment.