Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update with input ui #14

Merged
merged 1 commit into from Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,2 +1,3 @@
node_modules
vars
vars
spec.yaml
22 changes: 15 additions & 7 deletions lib/libs.js
Expand Up @@ -99,7 +99,7 @@ exports.run = function run(CmdInfo,BatchTimeout,MaxMessageCount,AbsoluteMaxBytes

exports.sleep = function sleep(){
rs = process.spawnSync('sleep',['30']);
console.log(rs.status);
//console.log(rs.status);
if (rs.status !=0) {
console.log(rs);
console.log(rs.stderr.toString('utf-8'));
Expand All @@ -117,21 +117,27 @@ exports.startup = function startup(startup,TurnInfo){
'-n',
TurnInfo.Chaincode,
]);
console.log(rs.status);
if (rs.status !=0) {
console.log(rs.stderr.toString());
} else {
console.log('prepare success');
}
rs = process.spawnSync(path.resolve('./minifabric/')+startup,['up']);
if (rs.status !=0) {
console.log(rs.stderr.toString());
} else {
console.log('network start success');
}
console.log(rs.status);
//console.log(rs.status);
return rs.status;
}

exports.teardown = function teardown(teardown){
rs = process.spawnSync(path.resolve('./minifabric/')+teardown,['cleanup']);
console.log(rs.status);
if (rs.status !=0) {
console.log(rs);
console.log(rs.stderr.toString('utf-8'));
console.log(rs.stderr.toString());
} else {
console.log('network cleanup success');
}
return rs.status;
}
Expand All @@ -153,8 +159,10 @@ exports.tapeTPS = function tapeTPS(CmdInfo,tapeCmd){
'/config/config.yaml',
5000//CmdInfo.tapeConfig,CmdInfo.tapeCount
]);
if (rs.status != 0) {
if (rs.status !=0) {
console.log(rs.stderr.toString());
} else {
console.log('tape success');
}
str=rs.output.toString('utf-8',0);
str = str.substring(str.indexOf('tps:'));
Expand Down
37 changes: 32 additions & 5 deletions routes/api.js
Expand Up @@ -33,12 +33,39 @@ router.get('/run', function(req, res, next) {
CmdInfo = {
Chaincode:'sample',
}
BatchTimeout = [0.75,1,1.5,2];
MaxMessageCount = [10,40,80,120];
AbsoluteMaxBytes= [2];
PreferredMaxBytes= [256];
BatchTimeout = [];
console.log(req.query.BatchTimeout);
BatchTimeoutArray = req.query.BatchTimeout.toString().split(",");
BatchTimeoutArray.forEach(element => {
BatchTimeout.push(parseFloat(element));
});
console.log(BatchTimeout);
//
MaxMessageCount = [];
console.log(req.query.MaxMessageCount);
MaxMessageCountArray = req.query.MaxMessageCount.toString().split(",");
MaxMessageCountArray.forEach(element => {
MaxMessageCount.push(parseFloat(element));
});
console.log(MaxMessageCount);
//
AbsoluteMaxBytes = [];
console.log(req.query.AbsoluteMaxBytes);
AbsoluteMaxBytesArray = req.query.AbsoluteMaxBytes.toString().split(",");
AbsoluteMaxBytesArray.forEach(element => {
AbsoluteMaxBytes.push(parseFloat(element));
});
console.log(AbsoluteMaxBytes);
//
PreferredMaxBytes = [];
console.log(req.query.PreferredMaxBytes);
PreferredMaxBytesArray = req.query.PreferredMaxBytes.toString().split(",");
PreferredMaxBytesArray.forEach(element => {
PreferredMaxBytes.push(parseFloat(element));
});
console.log(PreferredMaxBytes);
libs.run(CmdInfo,BatchTimeout,MaxMessageCount,AbsoluteMaxBytes,PreferredMaxBytes);
//console.log(new Date().toString());
console.log(new Date().toString());
res.send(d.toString()+' success at '+new Date().toString());
});

Expand Down
22 changes: 15 additions & 7 deletions views/index/index.html
@@ -1,9 +1,17 @@
<head>
<!-- Load plotly.js into the DOM -->
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Input</title> 
</head>

<body>
<div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
<script src='./javascripts/index.js'></script>
</body>

<form action="./api/run">
BatchTimeout: <input type="text" name="BatchTimeout"><br>
MaxMessageCount: <input type="text" name="MaxMessageCount"><br>
AbsoluteMaxBytes: <input type="text" name="AbsoluteMaxBytes"><br>
PreferredMaxBytes: <input type="text" name="PreferredMaxBytes"><br>
<input type="submit" value="提交">
</form>
</body>
</html>