From 9f0fe0855cef541405f73f892fd894d98e44a1cd Mon Sep 17 00:00:00 2001 From: shaozhuguang Date: Fri, 9 Aug 2019 09:08:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ump=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/com/jd/blockchain/AppTest.java | 20 ++++ .../src/test/java/com/jd/blockchain/AppTest.java | 20 ++++ source/deployment/deployment-peer/pom.xml | 7 +- .../src/main/resources/assembly.xml | 12 +- .../src/main/resources/scripts/jump-start.sh | 9 ++ .../src/main/resources/scripts/jump-stop.sh | 16 +++ source/manager/pom.xml | 49 ++------- source/manager/ump-booter/pom.xml | 67 +++++++++++ .../main/java/com/jd/blockchain/ump/UmpBooter.java | 14 +-- source/manager/ump-service/pom.xml | 5 + .../ump-service/src/main/resources/bftsmart.config | 122 +++++++++++++++++++++ .../ump-service/src/main/resources/mq.config | 0 source/pom.xml | 14 +++ .../src/test/java/com/jd/blockchain/AppTest.java | 20 ++++ 14 files changed, 315 insertions(+), 60 deletions(-) create mode 100644 source/crypto/crypto-composite/src/test/java/com/jd/blockchain/AppTest.java create mode 100644 source/deployment/deployment-autotest/src/test/java/com/jd/blockchain/AppTest.java create mode 100644 source/deployment/deployment-peer/src/main/resources/scripts/jump-start.sh create mode 100644 source/deployment/deployment-peer/src/main/resources/scripts/jump-stop.sh create mode 100644 source/manager/ump-service/src/main/resources/bftsmart.config create mode 100644 source/manager/ump-service/src/main/resources/mq.config create mode 100644 source/tools/tools-joiner/src/test/java/com/jd/blockchain/AppTest.java diff --git a/source/crypto/crypto-composite/src/test/java/com/jd/blockchain/AppTest.java b/source/crypto/crypto-composite/src/test/java/com/jd/blockchain/AppTest.java new file mode 100644 index 00000000..941b907f --- /dev/null +++ b/source/crypto/crypto-composite/src/test/java/com/jd/blockchain/AppTest.java @@ -0,0 +1,20 @@ +package com.jd.blockchain; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/source/deployment/deployment-autotest/src/test/java/com/jd/blockchain/AppTest.java b/source/deployment/deployment-autotest/src/test/java/com/jd/blockchain/AppTest.java new file mode 100644 index 00000000..941b907f --- /dev/null +++ b/source/deployment/deployment-autotest/src/test/java/com/jd/blockchain/AppTest.java @@ -0,0 +1,20 @@ +package com.jd.blockchain; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/source/deployment/deployment-peer/pom.xml b/source/deployment/deployment-peer/pom.xml index d5f818ac..941178c7 100644 --- a/source/deployment/deployment-peer/pom.xml +++ b/source/deployment/deployment-peer/pom.xml @@ -17,20 +17,19 @@ com.jd.blockchain - manager + runtime-modular ${project.version} com.jd.blockchain - runtime-modular + runtime-modular-booter ${project.version} com.jd.blockchain - runtime-modular-booter + ump-booter ${project.version} - com.jd.blockchain storage-composite diff --git a/source/deployment/deployment-peer/src/main/resources/assembly.xml b/source/deployment/deployment-peer/src/main/resources/assembly.xml index e68857e2..9ad916a2 100644 --- a/source/deployment/deployment-peer/src/main/resources/assembly.xml +++ b/source/deployment/deployment-peer/src/main/resources/assembly.xml @@ -36,7 +36,6 @@ com.jd.blockchain:runtime-modular com.jd.blockchain:runtime-modular-booter com.jd.blockchain:peer - com.jd.blockchain:manager com.jd.blockchain:deployment-peer @@ -53,10 +52,19 @@ com.jd.blockchain:runtime-modular com.jd.blockchain:runtime-modular-booter com.jd.blockchain:peer - com.jd.blockchain:manager com.jd.blockchain:deployment-peer + + + false + true + ext + + com.jd.blockchain:ump-booter + + + diff --git a/source/deployment/deployment-peer/src/main/resources/scripts/jump-start.sh b/source/deployment/deployment-peer/src/main/resources/scripts/jump-start.sh new file mode 100644 index 00000000..a31a5b28 --- /dev/null +++ b/source/deployment/deployment-peer/src/main/resources/scripts/jump-start.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +HOME=$(cd `dirname $0`;cd ../; pwd) +UMP=$(ls $HOME/ext | grep ump-booter-) +if [ ! -n "UMP" ]; then + echo "Unified Management Platform Is Null !!!" +else + nohup java -jar -server -Djump.log=$HOME $HOME/ext/$UMP $* >$HOME/bin/jump.out 2>&1 & +fi \ No newline at end of file diff --git a/source/deployment/deployment-peer/src/main/resources/scripts/jump-stop.sh b/source/deployment/deployment-peer/src/main/resources/scripts/jump-stop.sh new file mode 100644 index 00000000..b7155c88 --- /dev/null +++ b/source/deployment/deployment-peer/src/main/resources/scripts/jump-stop.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +#启动Home路径 +BOOT_HOME=$(cd `dirname $0`;cd ../; pwd) + +#获取进程PID +PID=`ps -ef | grep $BOOT_HOME/ext/ump-booter | grep -v grep | awk '{print $2}'` + +#通过Kill命令将进程杀死 +if [ -z "$PID" ]; then + echo "Unable to find UMP PID. stop aborted." +else + echo "Start to kill PID = $PID ..." + kill -9 $PID + echo "Unified Management Platform has been stopped ..." +fi \ No newline at end of file diff --git a/source/manager/pom.xml b/source/manager/pom.xml index cd6c9205..a56f3423 100644 --- a/source/manager/pom.xml +++ b/source/manager/pom.xml @@ -2,52 +2,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + ump-booter + ump-web + ump-service + ump-model + com.jd.blockchain jdchain-root 1.1.0-SNAPSHOT manager - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - - org.springframework.boot - spring-boot-starter-log4j2 - - - - org.springframework.boot - spring-boot-starter-security - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - + pom \ No newline at end of file diff --git a/source/manager/ump-booter/pom.xml b/source/manager/ump-booter/pom.xml index 63461b0f..69ae2ff4 100644 --- a/source/manager/ump-booter/pom.xml +++ b/source/manager/ump-booter/pom.xml @@ -33,6 +33,24 @@ + com.jd.blockchain + ump-web + ${project.version} + + + + com.jd.blockchain + ump-service + ${project.version} + + + + com.jd.blockchain + ump-model + ${project.version} + + + org.springframework.boot spring-boot-starter-log4j2 @@ -57,4 +75,53 @@ test + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-assembly-plugin + + + make-assembly + package + + single + + + jump + + src/main/resources/assembly.xml + + + + + + + + + + ${project.basedir}/libs + BOOT-INF/lib/ + + *.jar + + + + ${project.basedir}/src/main/resources + BOOT-INF/classes/ + + log4j2-jump.xml + *.txt + *.properties + + + + + diff --git a/source/manager/ump-booter/src/main/java/com/jd/blockchain/ump/UmpBooter.java b/source/manager/ump-booter/src/main/java/com/jd/blockchain/ump/UmpBooter.java index 97656b03..4bf8d7ae 100644 --- a/source/manager/ump-booter/src/main/java/com/jd/blockchain/ump/UmpBooter.java +++ b/source/manager/ump-booter/src/main/java/com/jd/blockchain/ump/UmpBooter.java @@ -30,22 +30,12 @@ public class UmpBooter { private static final String CONFIG_PROP_DB_URL_DEFAULT = "rocksdb://#project#/jumpdb"; public static void main(String[] args) { - try { - startServer(server(args)); - System.out.println("Server Start SUCCESS !!!"); - } catch (Exception e) { - e.printStackTrace(); - System.err.printf("Server Start FAIL -> %s, Exit JVM !!!", e.toString()); - // 正常退出 - System.exit(0); - } + startServer(server(args)); + System.out.println("Unified Management Platform Server Start SUCCESS !!!"); } private static void startServer(Server server) { - System.out.printf("server.address = %s, server.port = %s, db.url = %s \r\n", - server.host, server.port, server.dbUrl); - List argList = new ArrayList<>(); argList.add(String.format("--server.address=%s", server.host)); argList.add(String.format("--server.port=%s", server.port)); diff --git a/source/manager/ump-service/pom.xml b/source/manager/ump-service/pom.xml index 99b5f2c4..b01c60cc 100644 --- a/source/manager/ump-service/pom.xml +++ b/source/manager/ump-service/pom.xml @@ -93,6 +93,11 @@ + com.google.guava + guava + + + org.apache.httpcomponents httpclient diff --git a/source/manager/ump-service/src/main/resources/bftsmart.config b/source/manager/ump-service/src/main/resources/bftsmart.config new file mode 100644 index 00000000..5ec6e530 --- /dev/null +++ b/source/manager/ump-service/src/main/resources/bftsmart.config @@ -0,0 +1,122 @@ + +# Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags +# +# 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. + +############################################ +####### Communication Configurations ####### +############################################ + +#HMAC algorithm used to authenticate messages between processes (HmacMD5 is the default value) +#This parameter is not currently being used +#system.authentication.hmacAlgorithm = HmacSHA1 + +#Specify if the communication system should use a thread to send data (true or false) +system.communication.useSenderThread = true + +#Force all processes to use the same public/private keys pair and secret key. This is useful when deploying experiments +#and benchmarks, but must not be used in production systems. +system.communication.defaultkeys = true + +############################################ +### Replication Algorithm Configurations ### +############################################ + +#Number of servers in the group +system.servers.num = 4 + +#Maximum number of faulty replicas +system.servers.f = 1 + +#Timeout to asking for a client request +system.totalordermulticast.timeout = 2000 + + +#Maximum batch size (in number of messages) +system.totalordermulticast.maxbatchsize = 400 + +#Number of nonces (for non-determinism actions) generated +system.totalordermulticast.nonces = 10 + +#if verification of leader-generated timestamps are increasing +#it can only be used on systems in which the network clocks +#are synchronized +system.totalordermulticast.verifyTimestamps = false + +#Quantity of messages that can be stored in the receive queue of the communication system +system.communication.inQueueSize = 500000 + +# Quantity of messages that can be stored in the send queue of each replica +system.communication.outQueueSize = 500000 + +#Set to 1 if SMaRt should use signatures, set to 0 if otherwise +system.communication.useSignatures = 0 + +#Set to 1 if SMaRt should use MAC's, set to 0 if otherwise +system.communication.useMACs = 1 + +#Set to 1 if SMaRt should use the standard output to display debug messages, set to 0 if otherwise +system.debug = 0 + +#Print information about the replica when it is shutdown +system.shutdownhook = true + +############################################ +###### State Transfer Configurations ####### +############################################ + +#Activate the state transfer protocol ('true' to activate, 'false' to de-activate) +system.totalordermulticast.state_transfer = true + +#Maximum ahead-of-time message not discarded +system.totalordermulticast.highMark = 10000 + +#Maximum ahead-of-time message not discarded when the replica is still on EID 0 (after which the state transfer is triggered) +system.totalordermulticast.revival_highMark = 10 + +#Number of ahead-of-time messages necessary to trigger the state transfer after a request timeout occurs +system.totalordermulticast.timeout_highMark = 200 + +############################################ +###### Log and Checkpoint Configurations ### +############################################ + +system.totalordermulticast.log = true +system.totalordermulticast.log_parallel = false +system.totalordermulticast.log_to_disk = false +system.totalordermulticast.sync_log = false + +#Period at which BFT-SMaRt requests the state to the application (for the state transfer state protocol) +system.totalordermulticast.checkpoint_period = 1000 +system.totalordermulticast.global_checkpoint_period = 120000 + +system.totalordermulticast.checkpoint_to_disk = false +system.totalordermulticast.sync_ckp = false + + +############################################ +###### Reconfiguration Configurations ###### +############################################ + +#Replicas ID for the initial view, separated by a comma. +# The number of replicas in this parameter should be equal to that specified in 'system.servers.num' +system.initial.view = 0,1,2,3 + +#The ID of the trust third party (TTP) +system.ttp.id = 7002 + +#This sets if the system will function in Byzantine or crash-only mode. Set to "true" to support Byzantine faults +system.bft = true + +#Custom View Storage; +#view.storage.handler=bftsmart.reconfiguration.views.DefaultViewStorage \ No newline at end of file diff --git a/source/manager/ump-service/src/main/resources/mq.config b/source/manager/ump-service/src/main/resources/mq.config new file mode 100644 index 00000000..e69de29b diff --git a/source/pom.xml b/source/pom.xml index 867606b1..2e93f9ba 100644 --- a/source/pom.xml +++ b/source/pom.xml @@ -43,6 +43,8 @@ 0.8.1-SNAPSHOT 0.0.8.RELEASE 0.7.0.RELEASE + 1.0.0-SNAPSHOT + 2.4 @@ -116,6 +118,18 @@ ${explorer.version} + + com.jd.blockchain + ump-explorer + ${ump-explorer.version} + + + + commons-io + commons-io + ${commons-io.version} + + junit diff --git a/source/tools/tools-joiner/src/test/java/com/jd/blockchain/AppTest.java b/source/tools/tools-joiner/src/test/java/com/jd/blockchain/AppTest.java new file mode 100644 index 00000000..941b907f --- /dev/null +++ b/source/tools/tools-joiner/src/test/java/com/jd/blockchain/AppTest.java @@ -0,0 +1,20 @@ +package com.jd.blockchain; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +}