FabricJavaPool 0.0.2 Release

Release Note:

  • Create new FabricConnection as connection.
  • FabricConnection able to query and invoke to target fabric network.
  • Defined exception if query or invoke response different between target peers.
  • Load configuration from file.

Sample usage:

Gradle

	implementation group: 'com.github.samyuan1990', name:'FabricJavaPool', version: '0.0.2'

For SNAPSHOT version

   repositories {
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
	implementation group: 'com.github.samyuan1990', name:'FabricJavaPool', version: '0.0.2-SNAPSHOT'

Pool config

Fabric network config file in json format and file path as configNetworkPath.

configNetworkPath=./src/test/resources/Networkconfig.json
maxTotal=10
maxIdle=8
minIdle=2
maxWaitMillis=1000

Get Connection

        ObjectPool<FabricConnection>  fabricConnectionPool = new FabricJavaPool(TestUtil.getUser(), TestUtil.myChannel);
        // By Default it will read pool config from ./resources/FabricJavaPool.properties
        try {
            FabricConnection fabricConnection = fabricConnectionPool.borrowObject();
            FabricConnection fabricConnection2 = fabricConnectionPool.borrowObject();
            String rs = fabricConnection.query(TestUtil.chaincodeID, "query", "a");
            String rs2 = fabricConnection2.query(TestUtil.chaincodeID, "query", "a");
            }
            fabricConnectionPool.returnObject(fabricConnection);
            fabricConnectionPool.returnObject(fabricConnection2);
        } catch (Exception e) {
            e.printStackTrace();
        }

Make ChainCode

        ChaincodeID cci = Util.generateChainCodeID(TestUtil.myCC, TestUtil.myCCVersion);

Query

FabricConnection myConnection = myChannelPool.borrowObject();
ExecuteResult rs = myConnection.query(cci, "query", "a");
Assert.assertEquals("90", rs.getResult());

Invoke

FabricConnection myConnection = myChannelPool.borrowObject();
ExecuteResult rs = myConnection.invoke(cci, "query", "a");
Assert.assertEquals("90", rs.getResult());

Query or Invoke exception

                myConnection.invoke(TestUtil.chaincodeID, "error", "a");
            } catch (RunTimeException e) {
                Assert.assertEquals(ChaincodeResponse.Status.FAILURE, e.getStatus());
                Assert.assertEquals(Util.errorHappenDuringQuery, e.getMsg());

Query or Invoke exception due to chaincode results are different on peers

            myConnection.query(TestUtil.chaincodeID, "query", "a");
        } catch (RunTimeException e) {
            Assert.assertEquals(ChaincodeResponse.Status.SUCCESS, e.getStatus());
            Assert.assertEquals(Util.resultOnPeersDiff, e.getMsg());
        }

Change log:

https://github.com/SamYuan1990/FabricJavaPool/issues/11
https://github.com/SamYuan1990/FabricJavaPool/issues/12
https://github.com/SamYuan1990/FabricJavaPool/issues/13
https://github.com/SamYuan1990/FabricJavaPool/issues/17

Sample project for usage:

https://github.com/SamYuan1990/fabric-java-spring

Latest performance test for Sample project:

Description for the test
Pool without cache:
在这里插入图片描述
在这里插入图片描述

Label# SamplesAverageMedian90% Line95% Line99% LineMinMaxError %ThroughputReceived KB/secSent KB/sec
Home Page224942525313338101120.000%374.8000570.2745.02
TOTAL224942525313338101120.000%374.8000570.2745.02
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值