Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
* Move all benchmark relative code into a new benchmark module
* Add hadoop style shell scripts for benchmark
  • Loading branch information
coderplay committed Jul 15, 2015
1 parent 9c3c87a commit 4b06089
Show file tree
Hide file tree
Showing 41 changed files with 659 additions and 165 deletions.
6 changes: 0 additions & 6 deletions bin/client/clientcommon.sh

This file was deleted.

2 changes: 0 additions & 2 deletions bin/client/nettyrpc.sh

This file was deleted.

2 changes: 0 additions & 2 deletions bin/client/nettysimple.sh

This file was deleted.

2 changes: 0 additions & 2 deletions bin/server/nettyserver.sh

This file was deleted.

2 changes: 0 additions & 2 deletions bin/server/servercommon.sh

This file was deleted.

7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ project(':lightningrpc-common') {

}


project(':lightningrpc-netty') {
dependencies {
compile project(':lightningrpc-common')
compile 'io.netty:netty-all:4.0.29.Final'
}
}

project(':lightningrpc-benchmark') {
dependencies {
compile project(':lightningrpc-netty')
}
}

8 changes: 4 additions & 4 deletions gradle/convention.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def docTasks = [:]
}

githubPages {
repoUri = "[email protected]:TangoMe/${rootProject.githubProjectName}.git"
repoUri = "[email protected]:coderplay/${rootProject.githubProjectName}.git"
pages {
docTasks.each { shortName, docTask ->
from(docTask.outputs.files) {
Expand All @@ -110,12 +110,12 @@ task releaseTarGz(type: Tar, dependsOn: subprojects.assemble) {
into "${baseName}"
compression = Compression.GZIP
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(project.file("bin")) { into "bin/" }
from(project.file("conf")) { into "conf/" }
from(project.file("logs")) { into "logs/" }
from 'LICENSE'
from 'README.md'
subprojects.each { child ->
from(child.file("bin")) { into "bin/" }
from(child.file("conf")) { into "conf/" }
from(child.file("logs")) { into "logs/" }
from(child.jar.archivePath)
from(child.configurations.runtime) { into("lib/") }
}
Expand Down
18 changes: 9 additions & 9 deletions gradle/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
// Closure to configure all the POM with extra info, common to all projects
pom.project {
name "${project.name}"
description "${project.name} developed by TangoMe"
description "${project.name} developed by Min Zhou"
developers {
developer {
id 'tangogithub'
name 'TangoMe Open Source Development'
email '[email protected]'
id 'mzhou'
name 'Min Zhou Open Source Development'
email '[email protected]'
}
}
licenses {
Expand All @@ -54,15 +54,15 @@ task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
distribution 'repo'
}
}
url "https://github.com/TangoMe/${rootProject.githubProjectName}"
url "https://github.com/coderplay/${rootProject.githubProjectName}"
scm {
connection "scm:git:[email protected]:TangoMe/${rootProject.githubProjectName}.git"
url "scm:git:[email protected]:TangoMe/${rootProject.githubProjectName}.git"
developerConnection "scm:git:[email protected]:TangoMe/${rootProject.githubProjectName}.git"
connection "scm:git:[email protected]:coderplay/${rootProject.githubProjectName}.git"
url "scm:git:[email protected]:coderplay/${rootProject.githubProjectName}.git"
developerConnection "scm:git:[email protected]:coderplay/${rootProject.githubProjectName}.git"
}
issueManagement {
system 'github'
url "https://github.com/TangoMe/${rootProject.githubProjectName}/issues"
url "https://github.com/coderplay/${rootProject.githubProjectName}/issues"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions gradle/minzhou-oss.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apply from: 'http://artifacts.minzhou.info/gradle-minzhou-local/artifactory.gradle'
2 changes: 1 addition & 1 deletion gradle/release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: 'release'
doFirst {
startParameter.projectProperties = [status: project.status, preferredStatus: project.status]
}
startParameter.addInitScript( file('gradle/tango-oss.gradle') )
startParameter.addInitScript( file('gradle/mzhou-oss.gradle') )
startParameter.getExcludedTaskNames().add('check')
tasks = [ 'build', value ]
}
Expand Down
1 change: 0 additions & 1 deletion gradle/tango-oss.gradle

This file was deleted.

261 changes: 261 additions & 0 deletions lightningrpc-benchmark/bin/benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
#!/usr/bin/env bash

# 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.


# The Benchmark command script
#
# Environment Variables
#
# JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
#
# BENCHMARK_CLASSPATH Extra Java CLASSPATH entries.
#
# BENCHMARK_USER_CLASSPATH_FIRST When defined, the BENCHMARK_CLASSPATH is
# added in the beginning of the global
# classpath. Can be defined, for example,
# by doing
# export BENCHMARK_USER_CLASSPATH_FIRST=true
#
# BENCHMARK_SERVER_HEAPSIZE The maximum amount of heap to use, in MB.
# Default is 1000.
#
# BENCHMARK_CLIENT_HEAPSIZE The maximum amount of heap to use, in MB.
# Default is 1000.
#
# BENCHMARK_OPTS Extra Java runtime options.
#
# BENCHMARK_CONF_DIR Alternate conf dir. Default is ${BENCHMARK_HOME}/conf.
#
#

bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

. "$bin"/benchmark-config.sh

cygwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
esac

function print_usage() {
echo "Usage: benchmark [--config confdir] COMMAND"
echo "where COMMAND is one of:"
echo " server run the benchmark server"
echo " client run the benchmark rpc client"
echo " simple-client run the benchmark simple client"
echo " classpath prints the class path needed to get the"
echo " Benchmark jar and the required libraries"
echo " or"
echo " CLASSNAME run the class named CLASSNAME"
echo "Most commands print help when invoked w/o parameters."
}

# if no args specified, show usage
if [ $# = 0 ]; then
print_usage
exit 1
fi

# get arguments
COMMAND=$1
shift

if [ "$COMMAND" == "--help" ] || [ "$COMMAND" == "-help" ] || [ "$COMMAND" == "-h" ] ; then
print_usage
exit
fi

if [ -f "${BENCHMARK_CONF_DIR}/benchmark-env.sh" ]; then
. "${BENCHMARK_CONF_DIR}/benchmark-env.sh"
fi

# some Java parameters
if [ "$JAVA_HOME" != "" ]; then
#echo "run java in $JAVA_HOME"
JAVA_HOME=$JAVA_HOME
fi

if [ "$JAVA_HOME" = "" ]; then
echo "Error: JAVA_HOME is not set."
exit 1
fi

JAVA=$JAVA_HOME/bin/java
JAVA_BENCHMARK_SERVER_HEAP_MAX=-Xmx1024m
JAVA_ICF_SERVER_HEAP_MAX=-Xmx1024m
JAVA_CONN_SERVER_HEAP_MAX=-Xmx1024m

# check envvars which might override default args
if [ "$BENCHMARK_SERVER_HEAPSIZE" != "" ]; then
#echo "run with heapsize $BENCHMARK_SERVER_HEAPSIZE"
JAVA_BENCHMARK_SERVER_HEAP_MAX="-Xmx""$BENCHMARK_SERVER_HEAPSIZE""m"
#echo $JAVA_SERVER_HEAP_MAX
fi
if [ "$BENCHMARK_ICF_SERVER_HEAPSIZE" != "" ]; then
#echo "run with heapsize $BENCHMARK_ICF_SERVER_HEAPSIZE"
JAVA_ICF_SERVER_HEAP_MAX="-Xmx""$BENCHMARK_ICF_SERVER_HEAPSIZE""m"
#echo JAVA_ICF_SERVER_HEAP_MAX
fi
if [ "$BENCHMARK_CONN_SERVER_HEAPSIZE" != "" ]; then
#echo "run with heapsize $BENCHMARK_CONN_SERVER_HEAPSIZE"
JAVA_CONN_SERVER_HEAP_MAX="-Xmx""$BENCHMARK_CONN_SERVER_HEAPSIZE""m"
#echo JAVA_CONN_SERVER_HEAP_MAX
fi

##############################################################################
# Find and Set Benchmark CLASSPATH
##############################################################################

# BENCHMARK_BASE_CLASSPATH initially contains $BENCHMARK_CONF_DIR
BENCHMARK_BASE_CLASSPATH="${BENCHMARK_CONF_DIR}"

# for developers, add Benchmark classes to BENCHMARK_BASE_CLASSPATH
if [ -d "$BENCHMARK_HOME/target/classes" ]; then
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_BASE_CLASSPATH}:$BENCHMARK_HOME/target/classes
fi
if [ -d "$BENCHMARK_HOME/target/test/classes" ]; then
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_BASE_CLASSPATH}:$BENCHMARK_HOME/target/test/classes
fi

# so that filenames w/ spaces are handled correctly in loops below
IFS=$'\n'

# Benchmark Jar Directory
BENCHMARK_JAR_DIRS="$BENCHMARK_HOME
${BENCHMARK_HOME}/lib"

for d in $BENCHMARK_JAR_DIRS; do
for j in `find $d/*.jar ! -name "*test*"`; do
BENCHMARK_BASE_CLASSPATH=$BENCHMARK_BASE_CLASSPATH:$j
done
done

# add user-specified CLASSPATH last
if [ "$BENCHMARK_CLASSPATH" != "" ]; then
if [ "$BENCHMARK_USER_CLASSPATH_FIRST" != "" ]; then
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_CLASSPATH}:${BENCHMARK_BASE_CLASSPATH}
else
BENCHMARK_BASE_CLASSPATH=${BENCHMARK_BASE_CLASSPATH}:${BENCHMARK_CLASSPATH}
fi
fi

export BENCHMARK_BASE_CLASSPATH

CLASSPATH="${BENCHMARK_BASE_CLASSPATH}:${CLASSPATH}"

##############################################################################
# Benchmark Home Configuration End
##############################################################################

# restore ordinary behaviour
unset IFS

# default log directory & file
if [ "$BENCHMARK_LOG_DIR" = "" ]; then
BENCHMARK_LOG_DIR="$BENCHMARK_HOME/logs"
fi
if [ "$BENCHMARK_LOGFILE" = "" ]; then
BENCHMARK_LOGFILE='benchmark.log'
fi

# default policy file for service-level authorization
if [ "$BENCHMARK_POLICYFILE" = "" ]; then
BENCHMARK_POLICYFILE="benchmark-policy.xml"
fi

# Disable IPv6 Support for network performance
BENCHMARK_OPTS="$BENCHMARK_OPTS -Djava.net.preferIPv4Stack=true"

# figure out which class to run
if [ "$COMMAND" = "classpath" ] ; then
if $cygwin; then
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
fi
echo $CLASSPATH
exit
elif [ "$COMMAND" = "server" ] ; then
CLASS='info.minzhou.lightning.rpc.netty.benchmark.NettyBenchmarkServer"
BENCHMARK_OPTS="$BENCHMARK_OPTS $JAVA_BENCHMARK_SERVER_HEAP_MAX $BENCHMARK_SERVER_OPTS"
elif [ "$COMMAND" = "client" ] ; then
CLASS="info.minzhou.lightning.rpc.netty.benchmark.NettyRPCBenchmarkClient"
BENCHMARK_OPTS="$BENCHMARK_OPTS $JAVA_CLIENT_HEAP_MAX $BENCHMARK_CLIENT_OPTS"
elif [ "$COMMAND" = "simple-client" ] ; then
CLASS="info.minzhou.lightning.rpc.netty.benchmark.NettySimpleBenchmarkClient"
BENCHMARK_OPTS="$BENCHMARK_OPTS $JAVA_CLIENT_HEAP_MAX $BENCHMARK_CLIENT_OPTS"
elif [ "$COMMAND" = "version" ] ; then
CLASS='info.minzhou.lightning.rpc.VersionInfo'
BENCHMARK_ROOT_LOGGER_APPENDER="${BENCHMARK_ROOT_LOGGER_APPENDER:-NullAppender}"
BENCHMARK_OPTS="$BENCHMARK_OPTS $BENCHMARK_CLI_OPTS"
else
CLASS=$COMMAND
fi
# cygwin path translation
if $cygwin; then
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
BENCHMARK_HOME=`cygpath -w "$BENCHMARK_HOME"`
BENCHMARK_LOG_DIR=`cygpath -w "$BENCHMARK_LOG_DIR"`
TOOL_PATH=`cygpath -p -w "$TOOL_PATH"`
fi
# setup 'java.library.path' for native-benchmark code if necessary
JAVA_LIBRARY_PATH=''
if [ -d "${BENCHMARK_HOME}/build/native" -o -d "${BENCHMARK_HOME}/lib/native" ]; then
JAVA_PLATFORM=`CLASSPATH=${CLASSPATH} ${JAVA} -Xmx32m ${BENCHMARK_JAVA_PLATFORM_OPTS} org.apache.benchmark.util.PlatformName | sed -e "s/ /_/g"`
if [ -d "$BENCHMARK_HOME/build/native" ]; then
JAVA_LIBRARY_PATH=${BENCHMARK_HOME}/build/native/${JAVA_PLATFORM}/lib
fi
if [ -d "${BENCHMARK_HOME}/lib/native" ]; then
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${BENCHMARK_HOME}/lib/native/${JAVA_PLATFORM}
else
JAVA_LIBRARY_PATH=${BENCHMARK_HOME}/lib/native/${JAVA_PLATFORM}
fi
fi
fi
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${HDFS_LIBRARY_PATH}
else
JAVA_LIBRARY_PATH=${HDFS_LIBRARY_PATH}
fi
# cygwin path translation
if $cygwin; then
JAVA_LIBRARY_PATH=`cygpath -p "$JAVA_LIBRARY_PATH"`
fi
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.log.dir=$BENCHMARK_LOG_DIR"
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.log.file=$BENCHMARK_LOGFILE"
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.home.dir=$BENCHMARK_HOME"
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.id.str=$BENCHMARK_IDENT_STRING"
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.root.logger.appender=${BENCHMARK_ROOT_LOGGER_APPENDER:-console}"
if [ "x$BENCHMARK_ROOT_LOGGER_LEVEL" != "x" ]; then
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.root.logger.level=${BENCHMARK_ROOT_LOGGER_LEVEL}"
fi
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
BENCHMARK_OPTS="$BENCHMARK_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
fi
BENCHMARK_OPTS="$BENCHMARK_OPTS -Dbenchmark.policy.file=$BENCHMARK_POLICYFILE"
# run it
export CLASSPATH=$CLASSPATH
exec "$JAVA" -Dproc_$COMMAND $BENCHMARK_OPTS $CLASS $BENCHMARK_DAEMON_MODE "$@"
Loading

0 comments on commit 4b06089

Please sign in to comment.