This is an automated email from the ASF dual-hosted git repository.
szetszwo 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 66d79c3 RATIS-517. Examples cannot be run after assembly.
66d79c3 is described below
commit 66d79c3af427b4bae58802c9d6e5761fc0f6fea2
Author: Tsz Wo Nicholas Sze <[email protected]>
AuthorDate: Tue Apr 9 10:46:16 2019 +0800
RATIS-517. Examples cannot be run after assembly.
---
BUILDING.md | 4 +-
README.md | 44 +-----------------
pom.xml | 15 +++++-
ratis-examples/README.md | 87 +++++++++++++++++++++++++++++++++++
ratis-examples/pom.xml | 24 ++++++++--
ratis-examples/src/main/bin/common.sh | 28 +++++++----
6 files changed, 142 insertions(+), 60 deletions(-)
diff --git a/BUILDING.md b/BUILDING.md
index ca2e526..9011254 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -32,8 +32,8 @@ See the next section for more info.
All bundled thirdparty dependencies are centralized in the *ratis-thirdparty*
module
and the *ratis-thirdparty-hadoop* module.
-These modules are located in a separated repository
(https://github.com/apache/incubator-ratis-thirdparty)
-but not attached to the core Apache Ratis repository
(https://git-wip-us.apache.org/repos/asf?p=incubator-ratis.git)
+These modules are located in a separated repository
(https://gitbox.apache.org/repos/asf?p=incubator-ratis-thirdparty.git)
+but not attached to the core Apache Ratis repository
(https://gitbox.apache.org/repos/asf/incubator-ratis.git)
as they only need to change when one of these dependencies are changed.
All dependencies included in ratis-thirdparty/ratis-thirdparty-hadoop
must be relocated to a different package to ensure no downstream classpath
pollution.
diff --git a/README.md b/README.md
index 0e19693..d94f1a5 100644
--- a/README.md
+++ b/README.md
@@ -20,48 +20,8 @@ The paper introduces Raft and states its motivations in
following words:
Ratis aims to make raft available as a java library that can be used by any
system that needs to use a replicated log. It provides pluggability for state
machine implementations to manage replicated states. It also provides
pluggability for Raft log, and rpc implementations to make it easy for
integration with other projects. Another important goal is to support high
throughput data ingest so that it can be used for more general data replication
use cases.
-# Usage
-
-Compile the repository using `mvn clean package -DskipTests`
-
-## FileStore
-
-### Server
-To spawn the FileStoreStateMachineServer, use `bin/server.sh filestore server
--id <selfid> --storage <storage_dir> --peers <id:ip_address,...>`
-
-selfid is the id of the instance being spwaned, this should be one of the ids
in the peer list.
-
-For example `ratis-examples/src/main/bin/server.sh filestore server --id n0
--storage /tmp/data --peers
n0:172.26.32.224:6000,n1:172.26.32.225:6001,n2:172.26.32.226:6002`
-
-### Client
-
-To spawn the FileStoreStateMachine client, use `bin/client.sh filestore
loadgen --size <file_size> --numFiles <num_files> --peers <id:ip_address,...>`
-
-Where, file_size is the size of the file to be generated in bytes, num_files
is the number of files to be generated.
-
-For example `ratis-examples/src/main/bin/client.sh filestore loadgen --size
1048576 --numFiles 1000 --peers
n0:172.26.32.224:6000,n1:172.26.32.225:6001,n2:172.26.32.226:6002`
-
-## Arithmetic
-
-### Server
-To spawn the ArithmeticStateMachineServer, use `bin/server.sh arithmetic
server --id <selfid> --storage <storage_dir> --peers <id:ip_address,...>`
-
-selfid is the id of the instance being spwaned, this should be one of the ids
in the peer list.
-
-For example `ratis-examples/src/main/bin/server.sh arithmetic server --id n0
--storage /tmp/data --peers
n0:172.26.32.224:6000,n1:172.26.32.225:6001,n2:172.26.32.226:6002`
-
-### Client
-
-To spawn the ArithmeticStateMachine client, use `bin/client.sh arithmetic get
--name b --peers <id:ip_address,...>`
-
-Where, b is the name of the variable.
-
-For example `ratis-examples/src/main/bin/client.sh arithmetic get --name b
--peers n0:172.26.32.224:6000,n1:172.26.32.225:6001,n2:172.26.32.226:6002`
-
-PS: the peer is a id, ipaddress pair seperated by ':', for eg.
n0:172.26.32.224:6000
-
-### Pre-Setup Vagrant Pseudo Cluster
-One can see the interactions of a three server Ratis cluster with a
load-generator running against it by using the `run_all_tests.sh` script found
in [dev-support/vagrant/]. See the [dev-support/vagrant/README.md] for more on
dependencies and what is setup. This will allow one to try a fully setup three
server Ratis cluster on a single VM image, preventing resource contention with
your development host and allowing failure injection too.
+* To build the artifacts, see [BUILDING.md](BUILDING.md).
+* To run the examples, see
[ratis-examples/README.md](ratis-examples/README.md).
# Reference
[1] _Diego Ongaro and John Ousterhout. 2014. In search of an understandable
consensus algorithm. In Proceedings of the 2014 USENIX conference on USENIX
Annual Technical Conference (USENIX ATC'14), Garth Gibson and Nickolai
Zeldovich (Eds.). USENIX Association, Berkeley, CA, USA, 305-320._
diff --git a/pom.xml b/pom.xml
index 8d002e5..ca7fcb4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -142,7 +142,7 @@
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
<maven-deploy-plugin.version>2.8.1</maven-deploy-plugin.version>
- <maven-install-plugin.version>2.5.1</maven-install-plugin.version>
+ <maven-install-plugin.version>3.0.0-M1</maven-install-plugin.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version>
<maven-pdf-plugin.version>1.2</maven-pdf-plugin.version>
@@ -154,6 +154,8 @@
<maven-surefire-plugin.version>3.0.0-M1</maven-surefire-plugin.version>
<protobuf-maven-plugin.version>0.5.1</protobuf-maven-plugin.version>
+ <license-maven-plugin.version>1.19</license-maven-plugin.version>
+ <copy-rename-maven-plugin.version>1.0</copy-rename-maven-plugin.version>
<!--
! Can be removed if changing to ASF parent version 19
@@ -415,6 +417,17 @@
<version>${build-helper-maven-plugin.version}</version>
</plugin>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>${license-maven-plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>com.coderplus.maven.plugins</groupId>
+ <artifactId>copy-rename-maven-plugin</artifactId>
+ <version>${copy-rename-maven-plugin.version}</version>
+ </plugin>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin.version}</version>
diff --git a/ratis-examples/README.md b/ratis-examples/README.md
new file mode 100644
index 0000000..eadf040
--- /dev/null
+++ b/ratis-examples/README.md
@@ -0,0 +1,87 @@
+<!--
+ 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. See accompanying LICENSE file.
+-->
+
+# Apache Ratis Examples
+
+#### Building and Running The Examples
+
+Compile the repository using `mvn clean package -DskipTests` under the project
root directory;
+see also [BUILDING.md](../BUILDING.md).
+
+All the scripts for running the examples are located in the
[ratis-examples/src/main/bin](src/main/bin) directory,
+
+## Example 1: FileStore
+
+**FileStore** is file service supporting *read*, *write* and *delete*
operations.
+The **FileStoreStateMachine** is implemented using the asynchronous
event-driven model.
+The source code is located in
+*
[ratis-examples/src/main/java/org/apache/ratis/examples/filestore/](src/main/java/org/apache/ratis/examples/filestore).
+
+
+#### Server
+To spawn a *FileStore* server, run
+* `server.sh filestore server --id <SELF_ID> --storage <STORAGE_DIR> --peers
<ID:IP_ADDRESS,...>`
+
+where `<SELF_ID>`, which must be in the peer list, is the id of the instance
being spawned.
+
+For example `ratis-examples/src/main/bin/server.sh filestore server --id n0
--storage /tmp/data --peers
n0:xx.xx.xx.xx:6000,n1:yy.yy.yy.yy:6001,n2:zz.zz.zz.zz:6002`
+
+#### Client
+
+To spawn a *FileStore* load generation client, run
+* `client.sh filestore loadgen --size <FILE_SIZE> --numFiles <NUM_FILES>
--peers <ID:IP_ADDRESS,...>`
+
+where `<FILE_SIZE>` is the size of the files to be generated in bytes,
+`<NUM_FILES>` is the number of files to be generated.
+
+For example `ratis-examples/src/main/bin/client.sh filestore loadgen --size
1048576 --numFiles 1000 --peers
n0:xx.xx.xx.xx:6000,n1:yy.yy.yy.yy:6001,n2:zz.zz.zz.zz:6002`
+
+## Example 2: Arithmetic
+
+**Arithmetic** is an implementation of a replicated state machine.
+A *variable map* is stored in the *ArithmeticStateMachine* which supports
*assign* or *get* operations.
+Clients may assign a variable to a value by specifying either the value or a
formula to compute the value.
+
+In
[TestArithemetic](src/test/java/org/apache/ratis/examples/arithmetic/TestArithmetic.java),
+it uses Arithmetic to solve *Pythagorean* equation and compute π using
Gauss–Legendre algorithm.
+
+The source code is located in
+*
[ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/](src/main/java/org/apache/ratis/examples/arithmetic).
+
+#### Server
+To spawn an *Arithmetic* server, run
+* `server.sh arithmetic server --id <SELF_ID> --storage <STORAGE_DIR> --peers
<ID:IP_ADDRESS,...>`
+
+where `<SELF_ID>`, which must be in the peer list, is the id of the instance
being spawned.
+
+For example `ratis-examples/src/main/bin/server.sh arithmetic server --id n0
--storage /tmp/data --peers
n0:xx.xx.xx.xx:6000,n1:yy.yy.yy.yy:6001,n2:zz.zz.zz.zz:6002`
+
+#### Client
+
+To run an *Arithmetic* client command, run
+* `client.sh arithmetic get --name <VAR> --peers <ID:IP_ADDRESS,...>`
+
+or
+* `client.sh arithmetic assign --name <VAR> --value <VALUE> --peers
<ID:IP_ADDRESS,...>`
+
+where `<VAR>` is the name of the variable and `<VALUE>` is the value to be
assigned.
+
+For example `ratis-examples/src/main/bin/client.sh arithmetic get --name b
--peers n0:xx.xx.xx.xx:6000,n1:yy.yy.yy.yy:6001,n2:zz.zz.zz.zz:6002`
+
+## Pre-Setup Vagrant Pseudo Cluster
+One can see the interactions of a three server Ratis cluster with a
load-generator running against it
+by using the `run_all_tests.sh` script found in
[dev-support/vagrant/](../dev-support/vagrant).
+See the [dev-support/vagrant/README.md](../dev-support/vagrant/README.md) for
more on dependencies and what is setup.
+This will allow one to try a fully setup three server Ratis cluster on a
single VM image,
+preventing resource contention with your development host and allowing failure
injection too.
diff --git a/ratis-examples/pom.xml b/ratis-examples/pom.xml
index 72bebe2..e6ec90c 100644
--- a/ratis-examples/pom.xml
+++ b/ratis-examples/pom.xml
@@ -148,10 +148,8 @@
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
- <transformer
-
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.apache.ratis.examples.common.Runner
- </mainClass>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+
<mainClass>org.apache.ratis.examples.common.Runner</mainClass>
</transformer>
</transformers>
<filters>
@@ -171,7 +169,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
- <version>1.10</version>
<configuration>
<canUpdateCopyright>false</canUpdateCopyright>
<roots>
@@ -179,6 +176,23 @@
</roots>
</configuration>
</plugin>
+ <plugin>
+ <groupId>com.coderplus.maven.plugins</groupId>
+ <artifactId>copy-rename-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-file</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+
<sourceFile>target/${project.artifactId}-${project.version}-shaded.jar</sourceFile>
+
<destinationFile>target/${project.artifactId}-${project.version}.jar</destinationFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/ratis-examples/src/main/bin/common.sh
b/ratis-examples/src/main/bin/common.sh
index 0bcaea2..480ac54 100755
--- a/ratis-examples/src/main/bin/common.sh
+++ b/ratis-examples/src/main/bin/common.sh
@@ -14,18 +14,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-LIBDIR="$DIR/../lib"
+LIB_DIR=${SCRIPT_DIR}/../lib
-if [ -d "$LIBDIR" ]; then
- ARTIFACT=`ls -1 $DIR/../lib/*.jar`
+if [[ -d "$LIB_DIR" ]]; then
+ #release directory layout
+ LIB_DIR=`cd ${LIB_DIR} > /dev/null; pwd`
+ ARTIFACT=`ls -1 ${LIB_DIR}/*.jar`
else
-#development startup
- ARTIFACT=`ls -1 $DIR/../../../target/ratis-examples-*.jar | grep -v test |
grep -v javadoc | grep -v sources`
- echo $ARTIFACT
- if [ ! -f "$ARTIFACT" ]; then
- echo "Jar file is missing. Please do a full build (mvn clean package)
first."
+ #development directory layout
+ EXAMPLES_DIR=${SCRIPT_DIR}/../../../
+ if [[ -d "$EXAMPLES_DIR" ]]; then
+ EXAMPLES_DIR=`cd ${EXAMPLES_DIR} > /dev/null; pwd`
+ fi
+ JAR_PREFIX=`basename ${EXAMPLES_DIR}`
+ ARTIFACT=`ls -1 ${EXAMPLES_DIR}/target/${JAR_PREFIX}-*.jar | grep -v test |
grep -v javadoc | grep -v sources | grep -v shaded`
+ if [[ ! -f "$ARTIFACT" ]]; then
+ echo "Jar file is missing. Please do a full build (mvn clean package
-DskipTests) first."
exit -1
fi
-fi
\ No newline at end of file
+fi
+
+echo ${ARTIFACT}