This is an automated email from the ASF dual-hosted git repository.
elserj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new be131d6 RATIS-480. Update scripts to work in both dev checkouts and
binary tarball
be131d6 is described below
commit be131d6b5a24bc87a709f4f93692d965a549c5cf
Author: Josh Elser <[email protected]>
AuthorDate: Tue Feb 5 14:50:56 2019 -0500
RATIS-480. Update scripts to work in both dev checkouts and binary tarball
Signed-off-by: Mukul Kumar Singh <[email protected]>
---
ratis-assembly/src/main/assembly/bin.xml | 23 ++++++++++++++---------
ratis-examples/pom.xml | 8 --------
ratis-examples/src/main/bin/client.sh | 16 ++++++++++++++--
ratis-examples/src/main/bin/common.sh | 11 ++++++++++-
ratis-examples/src/main/bin/server.sh | 2 +-
ratis-examples/src/main/bin/start-all.sh | 28 +++++++++++++++++++++++++---
6 files changed, 64 insertions(+), 24 deletions(-)
diff --git a/ratis-assembly/src/main/assembly/bin.xml
b/ratis-assembly/src/main/assembly/bin.xml
index 3c9e918..42d9d60 100644
--- a/ratis-assembly/src/main/assembly/bin.xml
+++ b/ratis-assembly/src/main/assembly/bin.xml
@@ -25,18 +25,15 @@
<formats>
<format>tar.gz</format>
</formats>
- <moduleSets>
- <moduleSet>
- <useAllReactorProjects>true</useAllReactorProjects>
+ <dependencySets>
+ <dependencySet>
<includes>
<include>org.apache.ratis:ratis-examples</include>
</includes>
- <binaries>
- <outputDirectory>examples/lib</outputDirectory>
- <includeDependencies>false</includeDependencies>
- <unpack>false</unpack>
- </binaries>
- </moduleSet>
+ <outputDirectory>examples/lib</outputDirectory>
+ </dependencySet>
+ </dependencySets>
+ <moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
@@ -93,5 +90,13 @@
<fileMode>0644</fileMode>
<directoryMode>0755</directoryMode>
</fileSet>
+ <fileSet>
+
<directory>${project.basedir}/../ratis-examples/src/main/resources</directory>
+ <outputDirectory>examples/conf</outputDirectory>
+ <includes>
+ <include>log4j.properties</include>
+ </includes>
+ <fileMode>644</fileMode>
+ </fileSet>
</fileSets>
</assembly>
diff --git a/ratis-examples/pom.xml b/ratis-examples/pom.xml
index e6ec90c..cccd0fa 100644
--- a/ratis-examples/pom.xml
+++ b/ratis-examples/pom.xml
@@ -128,14 +128,6 @@
<build>
<plugins>
<plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>*.jar</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
diff --git a/ratis-examples/src/main/bin/client.sh
b/ratis-examples/src/main/bin/client.sh
index edcaaea..35b9e0b 100755
--- a/ratis-examples/src/main/bin/client.sh
+++ b/ratis-examples/src/main/bin/client.sh
@@ -15,9 +15,21 @@
# limitations under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+USAGE="client.sh <example> <command>"
+
+if [ "$#" -lt 2 ]; then
+ echo "$USAGE"
+ exit 1
+fi
+
source $DIR/common.sh
-subcommand=$1
+# One of the examples, e.g. "filestore" or "arithmetic"
+example="$1"
+shift
+
+subcommand="$1"
shift
-java -jar $ARTIFACT $subcommand "$@"
+java ${LOGGER_OPTS} -jar $ARTIFACT "$example" "$subcommand" $QUORUM_OPTS "$@"
diff --git a/ratis-examples/src/main/bin/common.sh
b/ratis-examples/src/main/bin/common.sh
index 480ac54..76176a4 100755
--- a/ratis-examples/src/main/bin/common.sh
+++ b/ratis-examples/src/main/bin/common.sh
@@ -36,4 +36,13 @@ else
fi
fi
-echo ${ARTIFACT}
+echo "Found ${ARTIFACT}"
+
+QUORUM_OPTS="--peers n0:localhost:6000,n1:localhost:6001,n2:localhost:6002"
+
+CONF_DIR="$DIR/../conf"
+if [[ -d "${CONF_DIR}" ]]; then
+ LOGGER_OPTS="-Dlog4j.configuration=file:${CONF_DIR}/log4j.properties"
+else
+ LOGGER_OPTS="-Dlog4j.configuration=file:${DIR}/../resources/log4j.properties"
+fi
diff --git a/ratis-examples/src/main/bin/server.sh
b/ratis-examples/src/main/bin/server.sh
index 64b99f1..faf63b2 100755
--- a/ratis-examples/src/main/bin/server.sh
+++ b/ratis-examples/src/main/bin/server.sh
@@ -16,5 +16,5 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/common.sh
-java -jar $ARTIFACT "$@"
+java ${LOGGER_OPTS} -jar $ARTIFACT "$@"
diff --git a/ratis-examples/src/main/bin/start-all.sh
b/ratis-examples/src/main/bin/start-all.sh
index 923ff04..82a8759 100755
--- a/ratis-examples/src/main/bin/start-all.sh
+++ b/ratis-examples/src/main/bin/start-all.sh
@@ -15,9 +15,31 @@
# limitations under the License.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+USAGE="start-all.sh <example> <subcommand>"
+
+if [ "$#" -ne 2 ]; then
+ echo "$USAGE"
+ exit 1
+fi
+
source $DIR/common.sh
-$DIR/server.sh n0 &
-$DIR/server.sh n1 &
-$DIR/server.sh n2 &
+# One of the examples, e.g. "filestore" or "arithmetic"
+example="$1"
+shift
+
+subcommand="$1"
+shift
+
+# Find a tmpdir, defaulting to what the environment tells us
+tmp="${TMPDIR:-/tmp}"
+
+echo "Starting 3 Ratis servers with '${example}' with directories in '${tmp}'
as local storage"
+
+# The ID needs to be kept in sync with QUORUM_OPTS
+$DIR/server.sh "$example" "$subcommand" --id n0 --storage "${tmp}/n0"
$QUORUM_OPTS &
+$DIR/server.sh "$example" "$subcommand" --id n1 --storage "${tmp}/n1"
$QUORUM_OPTS &
+$DIR/server.sh "$example" "$subcommand" --id n2 --storage "${tmp}/n2"
$QUORUM_OPTS &
+
echo "Waiting for the servers"