Skip to content

Commit

Permalink
upgrade zookeeper and jackson version (#657)
Browse files Browse the repository at this point in the history
* fix bug: the monitor bash script in weevent-broker execute failed

* optimize client retry when upload failed

* optimize code

* issue #466: add common code/messsage for weevent-broker's restful response

* revert jsonRpc response

* optimize code format

* reset code

* issue #505: replace jsonrpc with rest for weevent-client

* remove timeout for jsonrpc

* resert code

* reset code

* optimize client

* optimize WeEventClient code

* add brokerRestfulUrl

* remove unused ERROR_CODE

* issue #545: add test for STOMP Protocol

* add jackson version

* optimize code

* issue #457: separate jms from weevent-client and provide a weevent-jms.jar

* remove defaultBrokerUrl

* remove unused @slf4j

* fix ci issue

* issue #458: provide an asynchronous publish interface in weevent-client

* optimize code

* optimize stompsend

* add weevent-jms in settings.gradle

* optimize stompsend

* merge upstream

* test ci

* optimize timeout

* add jboss

* test ci

* remove unused timeout

* add comment for repository jboss

* optimize jboss repository

* issue #563: integrate large file transfer function into weevent-governance

* remove unused property

* optimize code

* optimize deploy topic bash script

* add copy fisco credentials when execute install-governance.sh

* add test for FileController in weevent-governance

* copy fisco credentials

* add test for FileController

* add test for FileController

* optimize JsonHelper doc

* optimize code

* revert utils

* test ci

* test ci

* test ci

* test ci

* test ci

* test ci

* test ci

* test ci

* test ci

* test ci

* optimize code

* revert ci bash script

* revise subscribe interface for weevent-client

* optimize code

* fix download file Chinese name garbled

* fix bug: fileName is null when restart weevent-broker

* add check file is uploaded

* fix bug: add check file isUploaded, add table for file transport status

* optimize code

* optimize code

* format code

* fix bug: fix zk start failed bug

* upgarde web3sdk to 2.2.5

* optimize sql

* fix bug: check whether the npm command is installed before executing the build-web.sh

* fix bug: fix the problem of indirect dependence between subprojects

* fix bug: add open topic before publish/subscribe

* add check groupId exist when build IWeEventClient

* optimize validateGroupId

* optimize comment

* optimize code

* upgrade zookeeper and jackson
  • Loading branch information
anyspa authored Sep 2, 2020
1 parent cce8c26 commit 4ec4bb9
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 42 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ext {
// jmeter
jmeterVersion = "5.0"
// jackson
jacksonVersion = "2.9.10.1"
jacksonVersion = "2.11.2"

commonsNetVersion = "3.6"

Expand Down Expand Up @@ -167,6 +167,7 @@ allprojects {
resolutionStrategy {
// fix security bug
force "com.alibaba:fastjson:${fastjsonVersion}"
force "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
// force use netty
force "io.netty:netty-all:${nettyVersion}"
force "org.apache.zookeeper:zookeeper:${zookeeperVersion}"
Expand All @@ -182,6 +183,11 @@ allprojects {
implementation("org.apache.commons:commons-lang3:${apacheCommonsVersion.lang3}")
implementation("org.apache.commons:commons-collections4:${apacheCommonsVersion.collections4}")

// jackson
implementation("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")
implementation("com.fasterxml.jackson.core:jackson-core:${jacksonVersion}")
implementation("com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}")

// slf4j logger
implementation("org.slf4j:slf4j-api:${slf4jVersion}")

Expand Down
12 changes: 6 additions & 6 deletions project/build-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ function installFisco(){
function installZookeeper(){
#unzip file
cd ${current_path}/weevent-build/modules/zookeeper/
tar -zxf apache-zookeeper-3.6.0-bin.tar.gz
tar -zxf apache-zookeeper-3.6.1-bin.tar.gz

#modify configuration
sed -i '158s#\\#"-Dzookeeper.admin.enableServer=false" \\#' ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.0-bin/bin/zkServer.sh
cp ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.0-bin/conf/zoo_sample.cfg ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.0-bin/conf/zoo.cfg
sed -i '$a\dataDir=/tmp/zk_data' ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.0-bin/conf/zoo.cfg
sed -i '$a\dataLogDir=/tmp/zk_logs' ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.0-bin/conf/zoo.cfg
sed -i '158s#\\#"-Dzookeeper.admin.enableServer=false" \\#' ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.1-bin/bin/zkServer.sh
cp ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.1-bin/conf/zoo_sample.cfg ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.1-bin/conf/zoo.cfg
sed -i '$a\dataDir=/tmp/zk_data' ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.1-bin/conf/zoo.cfg
sed -i '$a\dataLogDir=/tmp/zk_logs' ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.1-bin/conf/zoo.cfg

#start zookeeper
cd ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.0-bin/bin/
cd ${current_path}/weevent-build/modules/zookeeper/apache-zookeeper-3.6.1-bin/bin/
bash zkServer.sh start
}

Expand Down
2 changes: 1 addition & 1 deletion weevent-build/bin/start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ -e ${current_path}/install-all.sh ]];then
fi

# start zookeeper first
cd ${current_path}/zookeeper/apache-zookeeper-3.6.0-bin/bin/
cd ${current_path}/zookeeper/apache-zookeeper-3.6.1-bin/bin/
./zkServer.sh start
cd ${current_path}
sleep 3
Expand Down
2 changes: 1 addition & 1 deletion weevent-build/bin/stop-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ do
done

# finally stop zookeeper
cd ${current_path}/zookeeper/apache-zookeeper-3.6.0-bin/bin/;
cd ${current_path}/zookeeper/apache-zookeeper-3.6.1-bin/bin/;
./zkServer.sh stop;

Binary file not shown.
10 changes: 5 additions & 5 deletions weevent-build/modules/zookeeper/install-zookeeper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ while [[ $# -ge 2 ]] ; do
done

configzookeeper(){
sed -i '/nohup/s/\\/"-Dzookeeper.admin.enableServer=false" \\/g' ${out_path}/apache-zookeeper-3.6.0-bin/bin/zkServer.sh
chmod +x ${out_path}/apache-zookeeper-3.6.0-bin/bin/zkServer.sh
cp ${out_path}/apache-zookeeper-3.6.0-bin/conf/zoo_sample.cfg ${out_path}/apache-zookeeper-3.6.0-bin/conf/zoo.cfg
sed -i '/dataDir=/cdataDir='${out_path}/apache-zookeeper-3.6.0-bin/zk_data ${out_path}/apache-zookeeper-3.6.0-bin/conf/zoo.cfg
sed -i '/nohup/s/\\/"-Dzookeeper.admin.enableServer=false" \\/g' ${out_path}/apache-zookeeper-3.6.1-bin/bin/zkServer.sh
chmod +x ${out_path}/apache-zookeeper-3.6.1-bin/bin/zkServer.sh
cp ${out_path}/apache-zookeeper-3.6.1-bin/conf/zoo_sample.cfg ${out_path}/apache-zookeeper-3.6.1-bin/conf/zoo.cfg
sed -i '/dataDir=/cdataDir='${out_path}/apache-zookeeper-3.6.1-bin/zk_data ${out_path}/apache-zookeeper-3.6.1-bin/conf/zoo.cfg
zookeeper_pre="clientPort="
zookeeper_string=${zookeeper_pre}${zookeeper_port}
sed -i 's/^clientPort=.*$/'$(echo ${zookeeper_pre}${zookeeper_port})'/' ${out_path}/apache-zookeeper-3.6.0-bin/conf/zoo.cfg
sed -i 's/^clientPort=.*$/'$(echo ${zookeeper_pre}${zookeeper_port})'/' ${out_path}/apache-zookeeper-3.6.1-bin/conf/zoo.cfg
}

function copy_file(){
Expand Down
2 changes: 1 addition & 1 deletion weevent-build/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function copy_install_file(){
cp -r ${top_path}/weevent-processor/dist/* ${out_path}/modules/processor

mkdir -p ${out_path}/modules/zookeeper
tar -zxf ${current_path}/modules/zookeeper/apache-zookeeper-3.6.0-bin.tar.gz -C ${out_path}/modules/zookeeper
tar -zxf ${current_path}/modules/zookeeper/apache-zookeeper-3.6.1-bin.tar.gz -C ${out_path}/modules/zookeeper
cp ${current_path}/modules/zookeeper/install-zookeeper.sh ${out_path}/modules/zookeeper
}

Expand Down
3 changes: 0 additions & 3 deletions weevent-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apply plugin: "io.spring.dependency-management"
apply plugin: "signing"

dependencies {
// jackson
implementation("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")

// stomp, see https://github.com/TooTallNate/Java-WebSocket
implementation("org.java-websocket:Java-WebSocket:${WebSocketVersion}")
implementation("org.springframework.data:spring-data-commons:${springBootVersion}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
import com.webank.weevent.file.service.FileChunksMeta;
import com.webank.weevent.file.service.FileChunksTransport;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
* FileChunks Tester.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import com.webank.weevent.client.BrokerException;
import com.webank.weevent.file.ftpclient.FtpClientService;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@Slf4j
public class FtpClientServiceTest {
private String ftpHost = "127.0.0.1";
Expand Down Expand Up @@ -43,7 +44,6 @@ public void testFtpService() {
}



@Test
@Ignore
public void testFtpUpLoad() throws BrokerException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.webank.weevent.file;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.webank.weevent.client.BrokerException;
import com.webank.weevent.client.SendResult;
import com.webank.weevent.core.config.FiscoConfig;
Expand All @@ -10,6 +14,7 @@
import com.webank.weevent.file.inner.DiskFiles;
import com.webank.weevent.file.service.FileChunksMeta;
import com.webank.weevent.file.service.WeEventFileClient;

import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Before;
Expand All @@ -18,10 +23,6 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

@Slf4j
public class WeEventFileClientTest {

Expand All @@ -38,7 +39,6 @@ public class WeEventFileClientTest {
private String passWd = "";



@Before
public void before() {
this.fiscoConfig = new FiscoConfig();
Expand Down Expand Up @@ -90,7 +90,7 @@ public void testPublishFileWithVerify() throws Exception {
weEventFileClient.openTransport4Sender(this.topicName, resource.getInputStream());

// handshake time delay for web3sdk
Thread.sleep(1000*10);
Thread.sleep(1000 * 10);

FileChunksMeta fileChunksMeta = weEventFileClient.publishFile(this.topicName,
new File("src/main/resources/ca.crt").getAbsolutePath(), true);
Expand Down Expand Up @@ -125,7 +125,7 @@ public void onException(Throwable e) {

@Test
public void testCloseTransport() {
WeEventFileClient weEventFileClient = new WeEventFileClient(this.groupId, this.localReceivePath,this.fileChunkSize, this.fiscoConfig);
WeEventFileClient weEventFileClient = new WeEventFileClient(this.groupId, this.localReceivePath, this.fileChunkSize, this.fiscoConfig);
weEventFileClient.closeTransport(this.topicName);
Assert.assertTrue(true);
}
Expand All @@ -142,24 +142,24 @@ public void testListFile() {
}



// new class for test status interface
static class Runner4PublishFile implements Runnable {
private final String topic;
private final WeEventFileClient weEventFileClient;

Runner4PublishFile(WeEventFileClient weEventFileClient, String topic){
Runner4PublishFile(WeEventFileClient weEventFileClient, String topic) {
this.weEventFileClient = weEventFileClient;
this.topic = topic;
}

@Override
public void run() {
//publish file
weEventFileClient.openTransport4Sender(this.topic);
try {
weEventFileClient.publishFile(topic,
new File("src/main/resources/bigfile.zip").getAbsolutePath(), true);
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}

Expand Down Expand Up @@ -203,12 +203,14 @@ static class Runner4Status implements Runnable {
private final String topic;
private final WeEventFileClient weEventFileClient;
private final boolean isSender;
Runner4Status(String groupId, String topic, WeEventFileClient weEventFileClient, boolean isSender){

Runner4Status(String groupId, String topic, WeEventFileClient weEventFileClient, boolean isSender) {
this.groupId = groupId;
this.topic = topic;
this.weEventFileClient = weEventFileClient;
this.isSender = isSender;
}

@Override
public void run() {
FileTransportStats fileTransportStats = weEventFileClient.status(topic);
Expand Down Expand Up @@ -241,28 +243,28 @@ public void run() {
@Ignore
public void testStatus4Sender() throws InterruptedException {
WeEventFileClient weEventFileClient = new WeEventFileClient(this.groupId, this.localReceivePath, this.fileChunkSize, this.fiscoConfig);
new Thread(new Runner4PublishFile(weEventFileClient, this.topicName),"thread publish").start();
new Thread(new Runner4PublishFile(weEventFileClient, this.topicName), "thread publish").start();
// thread delay for get sender status
System.out.println("sender delay 10s:");
Thread.sleep(1000*10);
Thread.sleep(1000 * 10);

System.out.println("begin get sender status:");
new Thread(new Runner4Status(this.groupId, this.topicName, weEventFileClient, true),"thread status").start();
Thread.sleep(1000*60*5);
new Thread(new Runner4Status(this.groupId, this.topicName, weEventFileClient, true), "thread status").start();
Thread.sleep(1000 * 60 * 5);
Assert.assertTrue(true);
}

@Test
@Ignore
public void testStatus4Receiver() throws InterruptedException {
WeEventFileClient weEventFileClient = new WeEventFileClient(this.groupId, this.localReceivePath, this.fileChunkSize, this.fiscoConfig);
new Thread(new Runner4SubscribeFile(weEventFileClient, this.topicName),"thread publish").start();
new Thread(new Runner4SubscribeFile(weEventFileClient, this.topicName), "thread publish").start();
// thread delay for get receiver status
System.out.println("receiver waiting sender publish file, delay 30s:");
Thread.sleep(1000 * 30);

System.out.println("begin get receiver status: ");
new Thread(new Runner4Status(this.groupId, this.topicName, weEventFileClient, false),"thread status").start();
new Thread(new Runner4Status(this.groupId, this.topicName, weEventFileClient, false), "thread status").start();

// main thread sleep, waiting for subscribe file
Thread.sleep(1000 * 60 * 5);
Expand Down Expand Up @@ -315,7 +317,7 @@ public void testGetDiskFiles() {
@Ignore
public void testPublishFileFromFtp() throws Exception {
FtpInfo ftpInfo = new FtpInfo(this.host, this.port, this.userName, this.passWd, "");
WeEventFileClient weEventFileClient = new WeEventFileClient(this.groupId, this.localReceivePath, ftpInfo, this.fileChunkSize, this.fiscoConfig);
WeEventFileClient weEventFileClient = new WeEventFileClient(this.groupId, this.localReceivePath, ftpInfo, this.fileChunkSize, this.fiscoConfig);

weEventFileClient.openTransport4Sender(topicName);
FileChunksMeta fileChunksMeta = weEventFileClient.publishFile(this.topicName, "./test/build_chain.sh", true);
Expand All @@ -342,7 +344,7 @@ public void onException(Throwable e) {
WeEventFileClient weEventFileClient = new WeEventFileClient(this.groupId, this.localReceivePath, ftpInfo, this.fileChunkSize, this.fiscoConfig);
weEventFileClient.openTransport4Receiver(this.topicName, fileListener);

Thread.sleep(1000*60*5);
Thread.sleep(1000 * 60 * 5);
Assert.assertTrue(true);
}

Expand Down

0 comments on commit 4ec4bb9

Please sign in to comment.