Merge pull request #58 from simple-rules/ricl-github

Ricl GitHub
pull/60/head
Richard Liu 6 years ago committed by GitHub
commit ed45ab85ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      agent/main.go
  2. 52
      aws-experiment-launch/experiment/commander/main.go
  3. 2
      kill_node.sh
  4. 24
      run_experiment.sh

@ -27,7 +27,6 @@ func logMemUsage() {
} }
} }
// TODO: @ricl, start another process for reporting.
func logCPUUsage() { func logCPUUsage() {
p, _ := process.NewProcess(pid) p, _ := process.NewProcess(pid)
for { for {
@ -37,6 +36,7 @@ func logCPUUsage() {
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
} }
} }
func main() { func main() {
_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.")
@ -45,7 +45,6 @@ func main() {
logFolder := flag.String("log_folder", "latest", "the folder collecting the logs of this execution") logFolder := flag.String("log_folder", "latest", "the folder collecting the logs of this execution")
flag.Parse() flag.Parse()
fmt.Print(*configFile)
ip = *_ip ip = *_ip
port = *_port port = *_port
pid = int32(*_pid) pid = int32(*_pid)

@ -1,3 +1,16 @@
/*
Commander has two modes to setup configuration: Local and S3.
Local Config Mode
The Default Mode.
Add `-mode local` or omit `-mode` to enter local config mode. In this mode, the `commander` will host the config file `config.txt` on the commander machine and `solider`s will download the config file from `http://{commander_ip}:{commander_port}/distribution_config.txt`.
Remote Config Mode
Add `-mode remote` to enter remote config mode. In this mode, the `soldier`s will download the config file from a remote URL (use `-config_url {url}` to set the URL).
*/
package main package main
import ( import (
@ -17,10 +30,13 @@ import (
) )
type commanderSetting struct { type commanderSetting struct {
ip string ip string
port string port string
mode string
// Options in s3 mode
configURL string configURL string
configs [][]string
configs [][]string
} }
type sessionInfo struct { type sessionInfo struct {
@ -35,13 +51,10 @@ var (
const ( const (
DistributionFileName = "distribution_config.txt" DistributionFileName = "distribution_config.txt"
DefaultConfigUrl = "https://s3-us-west-2.amazonaws.com/unique-bucket-bin/distribution_config.txt"
) )
func readConfigFile() [][]string { func readConfigFile() [][]string {
if err := utils.DownloadFile(DistributionFileName, setting.configURL); err != nil {
panic(err)
}
if result, err := configr.ReadConfigFile(DistributionFileName); err != nil { if result, err := configr.ReadConfigFile(DistributionFileName); err != nil {
panic(err) panic(err)
} else { } else {
@ -57,6 +70,13 @@ func handleCommand(command string) {
switch cmd := args[0]; cmd { switch cmd := args[0]; cmd {
case "config": case "config":
if setting.mode == "s3" {
// In s3 mode, download the config file from configURL first.
if err := utils.DownloadFile(DistributionFileName, setting.configURL); err != nil {
panic(err)
}
}
setting.configs = readConfigFile() setting.configs = readConfigFile()
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))
@ -82,10 +102,15 @@ func handleCommand(command string) {
} }
} }
func config(ip string, port string, configURL string) { func config(ip string, port string, mode string, configURL string) {
setting.ip = ip setting.ip = ip
setting.port = port setting.port = port
setting.configURL = configURL setting.mode = mode
if mode == "local" {
setting.configURL = fmt.Sprintf("http://%s:%s/%s", ip, port, DistributionFileName)
} else {
setting.configURL = configURL
}
} }
func dictateNodes(command string) { func dictateNodes(command string) {
@ -181,6 +206,10 @@ func jsonResponse(w http.ResponseWriter, code int, message string) {
} }
func serve() { func serve() {
if setting.mode == "local" {
// Only host config file if in local mode
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 {
@ -192,10 +221,11 @@ func serve() {
func main() { func main() {
ip := flag.String("ip", "127.0.0.1", "The ip of commander, i.e. this machine") ip := flag.String("ip", "127.0.0.1", "The ip of commander, i.e. this machine")
port := flag.String("port", "8080", "The port which the commander uses to communicate with soldiers") port := flag.String("port", "8080", "The port which the commander uses to communicate with soldiers")
configURL := flag.String("config_url", "https://s3-us-west-2.amazonaws.com/unique-bucket-bin/distribution_config.txt", "The config URL") mode := flag.String("mode", "local", "The config mode, local or s3")
configURL := flag.String("config_url", DefaultConfigUrl, "The config URL")
flag.Parse() flag.Parse()
config(*ip, *port, *configURL) config(*ip, *port, *mode, *configURL)
go serve() go serve()

@ -1,4 +1,4 @@
for pid in `/bin/ps -fu $USER| grep "benchmark\|txgen" | grep -v "grep" | awk '{print $2}'`; for pid in `/bin/ps -fu $USER| grep "benchmark\|txgen\|soldier\|commander" | grep -v "grep" | awk '{print $2}'`;
do do
echo 'Killed process: '$pid echo 'Killed process: '$pid
kill -9 $pid kill -9 $pid

@ -0,0 +1,24 @@
# Kill nodes if any
./kill_node.sh
go build -o bin/benchmark
go build -o bin/txgen client/txgen/main.go
go build -o bin/commander aws-experiment-launch/experiment/commander/main.go
go build -o bin/soldier aws-experiment-launch/experiment/soldier/main.go
cd bin
# Create a tmp folder for logs
t=`date +"%Y%m%d-%H%M%S"`
log_folder="tmp_log/log-$t"
mkdir -p $log_folder
# For each of the nodes, start soldier
config=distribution_config.txt
while IFS='' read -r line || [[ -n "$line" ]]; do
IFS=' ' read ip port mode shardId <<< $line
#echo $ip $port $mode
./soldier -ip $ip -port $port&
done < $config
./commander
Loading…
Cancel
Save