blob: 0d429e6bb285c48099768f89a3ca976ba613f420 [file] [log] [blame]
Jonathan Hart627f10c2013-01-16 14:20:03 -08001package net.floodlightcontroller.core.internal;
2
3import java.util.Set;
4
5import com.thinkaurelius.titan.core.TitanGraph;
6import com.tinkerpop.blueprints.Vertex;
7import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
8
9/**
10 * Seam that allows me to set up a testable instance of SwitchStorageImpl that
11 * writes to a file database rather than a Cassandra cluster.
12 * It seems the init() API on SwitchStorageImpl might change so I won't rely
13 * on it yet.
14 *
15 * @author jono
16 *
17 */
18
19public class TestableSwitchStorageImpl extends SwitchStorageImpl {
20
21 public TestableSwitchStorageImpl(TitanGraph graph){
22 this.graph = graph;
23 }
24
25 @Override
26 public void init(String conf){
27 Set<String> s = graph.getIndexedKeys(Vertex.class);
28 if (!s.contains("dpid")) {
29 graph.createKeyIndex("dpid", Vertex.class);
30 graph.stopTransaction(Conclusion.SUCCESS);
31 }
32 if (!s.contains("type")) {
33 graph.createKeyIndex("type", Vertex.class);
34 graph.stopTransaction(Conclusion.SUCCESS);
35 }
36
37 }
38}