Benchmark
[iotcloud.git] / version2 / src / java / light_fan_benchmark / BulbSwitch.java
1
2
3 import java.util.Scanner;
4 import iotcloud.*;
5
6 class BulbSwitch {
7     public static void main(String[] args) throws Exception {
8
9
10         System.out.println(Integer.parseInt(args[0]));
11
12         Table t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", Integer.parseInt(args[0]), -1);
13         t1.update();
14
15
16         String a = "bulb";
17         IoTString ia = new IoTString(a);
18         t1.createNewKey(ia, 321);
19
20
21         String valueA = "on";
22         IoTString iValueA = new IoTString(valueA);
23
24
25         String valueB = "off";
26         IoTString iValueB = new IoTString(valueB);
27
28         System.out.println("Starting System");
29
30         Scanner keyboard = new Scanner(System.in);
31
32
33         while (true) {
34
35
36             System.out.println("Enter 0 for off, 1 for on");
37             int myint = keyboard.nextInt();
38
39             if (myint == 0) {
40                 t1.update();
41                 t1.startTransaction();
42                 t1.addKV(ia, iValueB);
43                 t1.commitTransaction();
44
45             } else {
46                 t1.update();
47                 t1.startTransaction();
48                 t1.addKV(ia, iValueA);
49                 t1.commitTransaction();
50
51             }
52
53         }
54     }
55 }