Skip to content

Commit 4eff463

Browse files
mbwhitejt-nti
authored andcommitted
[FAB-16315] Improved Load Ability
A fairly sizeable CR for improving the load handling ability of the Java chaincode. This required a rework of the threading model within the core shim layer. Plus adding configuration and metrics to support this. The configuration is a simple Java props file should the need be to ever modify the default thread pool settings. Metrics are basic stats on the thread pool are written to the log Change-Id: I31b05585a0aa650f7e2a7e2b0389799e90adc2c3 Signed-off-by: Matthew B. White <[email protected]> (cherry picked from commit baaaef8)
1 parent 90ba345 commit 4eff463

File tree

53 files changed

+2488
-2072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2488
-2072
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*.swp
55
.gradletasknamecache
66
.classpath
7-
/bin/
7+
**/bin/
88
/build/
99
build/*
1010

build.gradle

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,7 @@
66

77
apply plugin: 'idea'
88
apply plugin: 'eclipse-wtp'
9-
apply plugin: 'com.dorongold.task-tree'
109
version = '2.0.0-SNAPSHOT'
11-
12-
buildscript {
13-
repositories {
14-
maven {
15-
url "https://plugins.gradle.org/m2/"
16-
}
17-
}
18-
dependencies {
19-
classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.4"
20-
}
21-
}
22-
23-
2410
allprojects {
2511
repositories {
2612
mavenCentral()
@@ -44,11 +30,16 @@ subprojects {
4430
dependencies {
4531
compile 'commons-cli:commons-cli:1.4'
4632
compile 'commons-logging:commons-logging:1.2'
33+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
34+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
4735

48-
testCompile 'junit:junit:4.12'
4936
testCompile 'org.hamcrest:hamcrest-library:1.3'
5037
testCompile 'org.mockito:mockito-core:2.23.0'
5138
testCompile 'com.github.stefanbirkner:system-rules:1.17.0'
39+
40+
testCompileOnly 'junit:junit:4.12'
41+
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1'
42+
testCompile 'org.assertj:assertj-core:3.9.1'
5243
}
5344

5445
if (!it.name.equals('fabric-chaincode-protos')) {
@@ -57,6 +48,10 @@ subprojects {
5748
}
5849
}
5950

51+
test {
52+
useJUnitPlatform()
53+
}
54+
6055
}
6156

6257
task printVersionName() {

fabric-chaincode-docker/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

fabric-chaincode-example-sacc/src/main/java/org/hyperledger/fabric/example/SimpleAsset.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public Response init(ChaincodeStub stub) {
2727
if (args.size() != 2) {
2828
ResponseUtils.newErrorResponse("Incorrect arguments. Expecting a key and a value");
2929
}
30+
3031
// Set up any variables or assets here by calling stub.putState()
3132
// We store the key and the value on the ledger
3233
stub.putStringState(args.get(0), args.get(1));
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
package org.hyperleder.fabric.shim.integration;
7+
8+
import org.hyperleder.fabric.shim.integration.DockerCompose.DockerComposeBuilder;
9+
10+
public class FabricState {
11+
12+
private static FabricState state;
13+
14+
public static FabricState getState(){
15+
if (state==null){
16+
state = new FabricState();
17+
}
18+
19+
return state;
20+
}
21+
22+
private boolean started = false;
23+
24+
public synchronized void start(){
25+
if (!this.started) {
26+
27+
// create the docker-compose command
28+
DockerComposeBuilder composebuilder = DockerCompose.newBuilder()
29+
.file("src/test/resources/first-network/docker-compose-cli.yaml");
30+
31+
// close down anything running...
32+
composebuilder.duplicate().down().build().run();
33+
34+
// ...and bring up
35+
DockerCompose compose = composebuilder.up().detach().build();
36+
compose.run();
37+
38+
this.started = true;
39+
} else {
40+
System.out.println("Fabric already started....");
41+
}
42+
}
43+
44+
45+
}

fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SACCIntegrationTest.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,7 @@ public static void setUp() throws Exception {
3232
String s = currentRelativePath.toAbsolutePath().toString();
3333
System.out.println("Current relative path is: " + s);
3434

35-
// create the docker-compose command
36-
DockerComposeBuilder composebuilder = DockerCompose.newBuilder()
37-
.file("src/test/resources/first-network/docker-compose-cli.yaml");
38-
39-
// close down anything running...
40-
composebuilder.duplicate().down().build().run();
41-
42-
// ...and bring up
43-
DockerCompose compose = composebuilder.up().detach().build();
44-
compose.run();
35+
FabricState.getState().start();
4536

4637
// the cli container contains a script that does the channel create, joing
4738
// and chaincode install/instantiate

fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/SBECCIntegrationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class SBECCIntegrationTest {
2828
@BeforeClass
2929
public static void setUp() throws Exception {
3030

31+
FabricState.getState().start();
32+
3133
// Call the inbuilt script to install/instantiate
3234
DockerBuilder dockerBuilder = new Docker.DockerBuilder();
3335
Docker docker = dockerBuilder.exec().container("cli").script("./scripts/script-sbe.sh").build();

fabric-chaincode-integration-test/src/test/resources/first-network/base/peer-base.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ services:
2323
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
2424
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
2525
- CORE_CHAINCODE_JAVA_RUNTIME=hyperledger/fabric-javaenv:amd64-latest
26-
- CORE_CHAINCODE_EXECUTETIMEOUT=300s
26+
- CORE_CHAINCODE_EXECUTETIMEOUT=400s
2727
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
2828
command: peer node start

fabric-chaincode-protos/bin/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

fabric-chaincode-shim/bin/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)