From 9b12ded071272846ea82adfcc94c6bc08e3aec74 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Mon, 16 Nov 2009 00:56:27 +1100 Subject: [PATCH] various updates. --- src/benchcontroller.go | 38 +++++++++++++++++++++++++++++++------- src/webconnector.go | 30 +++++++++++++++++++----------- 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/benchcontroller.go b/src/benchcontroller.go index 6bd48a3..5370173 100644 --- a/src/benchcontroller.go +++ b/src/benchcontroller.go @@ -6,11 +6,15 @@ import ( //"./dbconnector"; "fmt"; "time"; + "strings"; + "strconv"; + "os"; ) type BenchControllerConfig struct { id int; nclients int; + datamult int; dbtype string; dbhost string; dbuser string; @@ -33,17 +37,37 @@ func MainLoop(conf *BenchControllerConfig, commInChan chan string, commOutChan c fmt.Printf("coms: %s\n", i); - /*switch i { - case 1: + calls := strings.Split(i, ":", 0); + + fmt.Printf("stuff 1: %s, stuff 2: %s\n", calls[0], calls[1]); + + switch calls[0] { + case "configure": // this means shutdown - os.Stdout.WriteString("shutdown\n"); - return; - case 2: + os.Stdout.WriteString("time for a conf\n"); + conf.id = 0; + + + var esink os.Error; + + conf.nclients, esink = strconv.Atoi(calls[7]); + conf.datamult, esink = strconv.Atoi(calls[6]); + + if esink != os.ECHILD { + // i need to do something with esink or the bollocks compiler screws itself + } + conf.dbtype = calls[1]; + conf.dbhost = calls[2]; + conf.dbuser = calls[3]; + conf.dbpass = calls[4]; + conf.dbname = calls[5]; + + case "asdf": // get ready to bench - start the clients os.Stdout.WriteString("ready clients\n"); - case 3: + case "qwer": // start the clients os.Stdout.WriteString("start clients\n"); - }*/ + } } } \ No newline at end of file diff --git a/src/webconnector.go b/src/webconnector.go index 80a333f..de43ec6 100644 --- a/src/webconnector.go +++ b/src/webconnector.go @@ -38,16 +38,21 @@ func ServerResponder(c *http.Conn, req *http.Request) { func beginPage(c *http.Conn, req *http.Request) { - header(c); - io.WriteString(c, "

Starting hammer

"); - //dbhost := req.FormValue("dbhost"); - //dbuser := req.FormValue("dbuser"); - //dbpass := req.FormValue("dbpass"); - //dbname := req.FormValue("dbname"); - //nthreads := req.FormValue("nthreads"); - //dbmult := req.FormValue("dbmult"); - - footer(c); + + if req.Method != "GET" { + http.Redirect(c, "/begin", 301); + } else { + header(c); + io.WriteString(c, "

Starting hammer

"); + //dbhost := req.FormValue("dbhost"); + //dbuser := req.FormValue("dbuser"); + //dbpass := req.FormValue("dbpass"); + //dbname := req.FormValue("dbname"); + //nthreads := req.FormValue("nthreads"); + //dbmult := req.FormValue("dbmult"); + + footer(c); + } } @@ -61,6 +66,7 @@ func confirmPage(c *http.Conn, req *http.Request) dbname := req.FormValue("dbname"); nthreads := req.FormValue("nthreads"); dbmult := req.FormValue("dbmult"); + var dbtype string; io.WriteString(c, "You are trying to perform a benchmark with the following values:
"); io.WriteString(c, ""); @@ -81,8 +87,10 @@ func confirmPage(c *http.Conn, req *http.Request) io.WriteString(c, ""); io.WriteString(c, ""); + dbtype = "mysql"; + footer(c); - comout <- fmt.Sprintf("configure:%s:%s:%s:%s:%s:%s", dbhost, dbuser, dbpass, dbname, dbmult, nthreads); + comout <- fmt.Sprintf("configure:%s:%s:%s:%s:%s:%s:%s", dbtype, dbhost, dbuser, dbpass, dbname, dbmult, nthreads); } -- 1.7.0.4