fix conflict

pull/46/head
Minh Doan 6 years ago
commit 5958362d37
  1. 31
      aws-experiment-launch/experiment/commander/main.go
  2. 2
      aws-experiment-launch/experiment/soldier/main.go
  3. 11
      aws-experiment-launch/userdata-soldier.sh

@ -59,7 +59,7 @@ func handleCommand(command string) {
if setting.configs != nil {
log.Printf("The loaded config has %v nodes\n", len(setting.configs))
} else {
log.Println("failed to read config file")
log.Println("Failed to read config file")
}
case "init":
session.id = time.Now().Format("150405-20060102")
@ -72,11 +72,9 @@ func handleCommand(command string) {
}
log.Println("New session", session.id)
count := dictateNodes(fmt.Sprintf("init %v %v %v %v", setting.ip, setting.port, setting.configURL, session.id))
log.Printf("Finished init with %v nodes\n", count)
dictateNodes(fmt.Sprintf("init %v %v %v %v", setting.ip, setting.port, setting.configURL, session.id))
case "ping", "kill", "log", "log2":
count := dictateNodes(command)
log.Printf("Finished %v with %v nodes\n", cmd, count)
dictateNodes(command)
default:
log.Println("Unknown command")
}
@ -88,23 +86,24 @@ func config(ip string, port string, configURL string) {
setting.configURL = configURL
}
func dictateNodes(command string) int {
result_chan := make(chan int)
func dictateNodes(command string) {
resultChan := make(chan int)
for _, config := range setting.configs {
ip := config[0]
port := "1" + config[1] // the port number of solider is "1" + node port
addr := strings.Join([]string{ip, port}, ":")
go func(result_chan chan int) {
result_chan <- dictateNode(addr, command)
}(result_chan)
go func(resultChan chan int) {
resultChan <- dictateNode(addr, command)
}(resultChan)
}
count := len(setting.configs)
res := 0
for ; count > 0; count -= 1 {
res += <-result_chan
for ; count > 0; count-- {
res += <-resultChan
}
return res
log.Printf("Finished %s with %v nodes\n", command, res)
}
func dictateNode(addr string, command string) int {
@ -134,9 +133,8 @@ func dictateNode(addr string, command string) int {
} else {
return 1
}
} else {
return 0
}
return 0
}
func handleUploadRequest(w http.ResponseWriter, r *http.Request) {
@ -181,12 +179,12 @@ func jsonResponse(w http.ResponseWriter, code int, message string) {
}
func serve() {
http.Handle("/", http.FileServer(http.Dir("./")))
http.HandleFunc("/upload", handleUploadRequest)
err := http.ListenAndServe(":"+setting.port, nil)
if err != nil {
log.Fatalf("Failed to setup server! Error: %s", err.Error())
}
log.Printf("Start to host upload endpoint at http://%s:%s/upload\n", setting.ip, setting.port)
}
func main() {
@ -197,7 +195,6 @@ func main() {
config(*ip, *port, *configURL)
log.Println("Start to host config files at http://" + setting.ip + ":" + setting.port)
go serve()
scanner := bufio.NewScanner(os.Stdin)

@ -180,7 +180,7 @@ func handleLogCommand(w *bufio.Writer) {
files, err := ioutil.ReadDir(globalSession.logFolder)
if err != nil {
logAndReply(w, fmt.Sprintf("Failed to create log folder. Error: %s", err.Error()))
logAndReply(w, fmt.Sprintf("Failed to read log folder. Error: %s", err.Error()))
return
}

@ -3,12 +3,9 @@ yum install ruby -y
cd /home/ec2-user/
curl http://unique-bucket-bin.s3.amazonaws.com/txgen -o txgen
curl http://unique-bucket-bin.s3.amazonaws.com/soldier -o soldier
curl http://unique-bucket-bin.s3.amazonaws.com/commander -o commander
curl http://unique-bucket-bin.s3.amazonaws.com/benchmark -o benchmark
curl http://unique-bucket-bin.s3.amazonaws.com/kill_node.sh -o kill_node.sh
chmod +x ./soldier
chmod +x ./txgen
chmod +x ./benchmark
chmod +x ./commander
chmod +x ./kill_node.sh
echo "* soft nproc 65535" | sudo tee -a /etc/security/limits.conf
@ -24,9 +21,11 @@ echo "session required pam_limits.so" | sudo tee -a /etc/pam.d/common-session
# Get My IP
ip=`curl http://169.254.169.254/latest/meta-data/public-ipv4`
SOLDIER_PORT=9000
# Kill existing soldier
NODE_PORT=9000
SOLDIER_PORT=1$NODE_PORT
# Kill existing soldier/node
fuser -k -n tcp $SOLDIER_PORT
fuser -k -n tcp $NODE_PORT
# Run soldier
./soldier -ip $ip -port $SOLDIER_PORT > soldier_log 2>&1 &
./soldier -ip $ip -port $NODE_PORT > soldier_log 2>&1 &

Loading…
Cancel
Save