various updates.
authorPaul J R <me@pjr.cc>
Sun, 15 Nov 2009 13:56:27 +0000 (00:56 +1100)
committerPaul J R <me@pjr.cc>
Sun, 15 Nov 2009 13:56:27 +0000 (00:56 +1100)
src/benchcontroller.go
src/webconnector.go

index 6bd48a3..5370173 100644 (file)
@@ -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
index 80a333f..de43ec6 100644 (file)
@@ -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, "<h1>Starting hammer</h1>");
-       //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, "<h1>Starting hammer</h1>");
+               //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:<br>");
        io.WriteString(c, "<table border=\"1\">");
@@ -81,8 +87,10 @@ func confirmPage(c *http.Conn, req *http.Request)
        io.WriteString(c, "<input type=\"submit\" name=\"Begin\" value=\"Begin\">");
        io.WriteString(c, "</form>");
        
+       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);
 
 }