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

@ -180,7 +180,7 @@ func handleLogCommand(w *bufio.Writer) {
files, err := ioutil.ReadDir(globalSession.logFolder) files, err := ioutil.ReadDir(globalSession.logFolder)
if err != nil { 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 return
} }

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