edits
[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.rebuild(); // update
14
15
16         String a = "bulb";
17         String b = "fan";
18         IoTString ib = new IoTString(b);
19         IoTString ia = new IoTString(a);
20
21         t1.createNewKey(ia, 321);
22
23
24         String valueA = "on";
25         String valueB = "off";
26         IoTString iValueA = new IoTString(valueA);
27         IoTString iValueB = new IoTString(valueB);
28
29
30
31         System.out.println("Starting System");
32         Scanner keyboard = new Scanner(System.in);
33
34         while (true) {
35
36
37             System.out.println("Enter 0 for off, 1 for on for bulb");
38             System.out.println("Enter 3 for off, 2 for on for fan");
39             int myint = keyboard.nextInt();
40
41             if (myint == 0) {
42                 t1.update();
43                 t1.startTransaction();
44                 t1.addKV(ia, iValueB);
45                 t1.commitTransaction();
46
47             } else if (myint == 1) {
48                 t1.update();
49                 t1.startTransaction();
50                 t1.addKV(ia, iValueA);
51                 t1.commitTransaction();
52             }
53             else if (myint == 2) {
54                 t1.update();
55                 t1.startTransaction();
56                 t1.addKV(ib, iValueA);
57                 t1.commitTransaction();
58             }
59             else if (myint == 3) {
60                 t1.update();
61                 t1.startTransaction();
62                 t1.addKV(ib, iValueB);
63                 t1.commitTransaction();
64             }
65
66         }
67     }
68 }