5370173235729dc1019634c34abd4197bfff599e
[goDBhammer.git] / src / benchcontroller.go
1 // the benchmark controller
2
3 package benchcontroller
4
5 import (
6         //"./dbconnector";
7         "fmt";
8         "time";
9         "strings";
10         "strconv";
11         "os";
12 )
13
14 type BenchControllerConfig struct {
15         id int;
16         nclients int;
17         datamult int;
18         dbtype string;
19         dbhost string;
20         dbuser string;
21         dbpass string;
22         dbname string;
23 }
24
25 func CreateController()(contConfig *BenchControllerConfig)
26 {
27         bcConfig := new(BenchControllerConfig);
28         
29         return bcConfig;
30 }
31
32 func MainLoop(conf *BenchControllerConfig, commInChan chan string, commOutChan chan string)
33 {
34         for {
35                 time.Sleep(1000000000);
36                 i := <-commInChan;
37                 
38                 fmt.Printf("coms: %s\n", i);
39                 
40                 calls := strings.Split(i, ":", 0);
41                 
42                 fmt.Printf("stuff 1: %s, stuff 2: %s\n", calls[0], calls[1]);
43                 
44                 switch calls[0] {
45                         case "configure":
46                                 // this means shutdown
47                                 os.Stdout.WriteString("time for a conf\n");
48                                 conf.id = 0;
49                                 
50                                 
51                                 var esink os.Error;
52                                 
53                                 conf.nclients, esink = strconv.Atoi(calls[7]);
54                                 conf.datamult, esink = strconv.Atoi(calls[6]);
55                                 
56                                 if esink != os.ECHILD {
57                                         // i need to do something with esink or the bollocks compiler screws itself
58                                 }
59                                 conf.dbtype = calls[1];
60                                 conf.dbhost = calls[2];
61                                 conf.dbuser = calls[3];
62                                 conf.dbpass = calls[4];
63                                 conf.dbname = calls[5];
64                                 
65                         case "asdf":
66                                 // get ready to bench - start the clients
67                                 os.Stdout.WriteString("ready clients\n");
68                         case "qwer":
69                                 // start the clients
70                                 os.Stdout.WriteString("start clients\n");
71                 }
72         }
73 }