Merge pull request #10 from simple-rules/ricl-log

split log per node
pull/11/head
7z7 7 years ago committed by GitHub
commit 86dbaad64b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      aws-code/transaction_generator.go
  2. 21
      benchmark_main.go
  3. 10
      deploy.sh

@ -110,16 +110,22 @@ func readConfigFile(configFile string) [][]string {
} }
func main() { func main() {
// Setup a stdout logger
h := log.CallerFileHandler(log.StdoutHandler)
log.Root().SetHandler(h)
configFile := flag.String("config_file", "local_config.txt", "file containing all ip addresses and config") configFile := flag.String("config_file", "local_config.txt", "file containing all ip addresses and config")
numTxsPerBatch := flag.Int("num_txs_per_batch", 10000, "number of transactions to send per message") numTxsPerBatch := flag.Int("num_txs_per_batch", 10000, "number of transactions to send per message")
timestamp := flag.String("timestamp", "latest", "timestamp of this execution")
flag.Parse() flag.Parse()
config := readConfigFile(*configFile) config := readConfigFile(*configFile)
leaders := getLeaders(&config) leaders := getLeaders(&config)
// Setup a logger to stdout and log file.
logFileName := fmt.Sprintf("./%v-tx-generator.log", *timestamp)
h := log.MultiHandler(
log.Must.FileHandler(logFileName, log.LogfmtFormat()),
log.StdoutHandler)
// In cases where you just want a stdout logger, use the following one instead.
// h := log.CallerFileHandler(log.StdoutHandler)
log.Root().SetHandler(h)
// Testing node to mirror the node data in consensus // Testing node to mirror the node data in consensus
dataNode := node.NewNode(&consensus.Consensus{}) dataNode := node.NewNode(&consensus.Consensus{})
dataNode.AddMoreFakeTransactions(10000) dataNode.AddMoreFakeTransactions(10000)

@ -10,7 +10,6 @@ import (
"harmony-benchmark/p2p" "harmony-benchmark/p2p"
"os" "os"
"strings" "strings"
"time"
) )
func getShardId(myIp, myPort string, config *[][]string) string { func getShardId(myIp, myPort string, config *[][]string) string {
@ -61,18 +60,10 @@ func readConfigFile(configFile string) [][]string {
} }
func main() { func main() {
// Setup a logger to stdout and log file.
logFileName := fmt.Sprintf("./%v.log", time.Now().Format("20060102150405"))
h := log.MultiHandler(
log.Must.FileHandler(logFileName, log.LogfmtFormat()),
log.StdoutHandler)
// In cases where you just want a stdout logger, use the following one instead.
// h := log.CallerFileHandler(log.StdoutHandler)
log.Root().SetHandler(h)
ip := flag.String("ip", "127.0.0.1", "IP of the node") ip := flag.String("ip", "127.0.0.1", "IP of the node")
port := flag.String("port", "9000", "port of the node.") port := flag.String("port", "9000", "port of the node.")
configFile := flag.String("config_file", "config.txt", "file containing all ip addresses") configFile := flag.String("config_file", "config.txt", "file containing all ip addresses")
timestamp := flag.String("timestamp", "latest", "timestamp of this execution")
flag.Parse() flag.Parse()
config := readConfigFile(*configFile) config := readConfigFile(*configFile)
@ -80,9 +71,19 @@ func main() {
peers := getPeers(*ip, *port, shardId, &config) peers := getPeers(*ip, *port, shardId, &config)
leader := getLeader(shardId, &config) leader := getLeader(shardId, &config)
// Setup a logger to stdout and log file.
logFileName := fmt.Sprintf("./%v-%v.log", *timestamp, *port)
h := log.MultiHandler(
log.Must.FileHandler(logFileName, log.LogfmtFormat()),
log.StdoutHandler)
// In cases where you just want a stdout logger, use the following one instead.
// h := log.CallerFileHandler(log.StdoutHandler)
log.Root().SetHandler(h)
consensus := consensus.NewConsensus(*ip, *port, shardId, peers, leader) consensus := consensus.NewConsensus(*ip, *port, shardId, peers, leader)
node := node.NewNode(&consensus) node := node.NewNode(&consensus)
// Assign closure functions to the consensus object // Assign closure functions to the consensus object
consensus.BlockVerifier = node.VerifyNewBlock consensus.BlockVerifier = node.VerifyNewBlock
consensus.OnConsensusDone = node.AddNewBlockToBlockchain consensus.OnConsensusDone = node.AddNewBlockToBlockchain

@ -1,9 +1,15 @@
timestamp() {
date +"%Y%m%d-%H%M%S"
}
t=`timestamp`
./kill_node.sh ./kill_node.sh
config=$1 config=$1
while IFS='' read -r line || [[ -n "$line" ]]; do while IFS='' read -r line || [[ -n "$line" ]]; do
IFS=' ' read ip port mode <<< $line IFS=' ' read ip port mode <<< $line
#echo $ip $port $mode $config #echo $ip $port $mode $config
go run ./benchmark_main.go -ip $ip -port $port -config_file $config& go run ./benchmark_main.go -ip $ip -port $port -config_file $config -timestamp $t&
done < $config done < $config
go run ./aws-code/transaction_generator.go -config_file $config go run ./aws-code/transaction_generator.go -config_file $config -timestamp $t
Loading…
Cancel
Save