blob: 6b47ad675aad2ccf0ad634610f7e26650f9a79c6 [file] [log] [blame]
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -08001package net.floodlightcontroller.linkdiscovery.internal;
2
3import java.util.Set;
4
HIGUCHI Yuta2d011582013-06-15 01:47:11 -07005import net.onrc.onos.ofcontroller.core.internal.LinkStorageImpl;
HIGUCHI Yuta6bfb4802013-06-14 17:02:02 -07006
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -08007import com.thinkaurelius.titan.core.TitanGraph;
8import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
9import com.tinkerpop.blueprints.Vertex;
10
11/**
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080012 * Seam that allows me to set up a testable instance of LinkStorageImpl that
Jonathan Hart627f10c2013-01-16 14:20:03 -080013 * writes to a file database rather than a Cassandra cluster.
14 * It seems the init() API on LinkStorageImpl might change so I won't rely
15 * on it yet.
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080016 *
17 * @author jono
18 *
19 */
20
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080021public class TestableLinkStorageImpl extends LinkStorageImpl {
HIGUCHI Yutadfdd4182013-06-11 17:00:39 -070022 protected TitanGraph graph;
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080023
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080024 public TestableLinkStorageImpl(TitanGraph graph){
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080025 this.graph = graph;
26 }
27
28 @Override
29 public void init(String conf){
30 Set<String> s = graph.getIndexedKeys(Vertex.class);
31 if (!s.contains("dpid")) {
32 graph.createKeyIndex("dpid", Vertex.class);
33 graph.stopTransaction(Conclusion.SUCCESS);
34 }
35 if (!s.contains("type")) {
36 graph.createKeyIndex("type", Vertex.class);
37 graph.stopTransaction(Conclusion.SUCCESS);
38 }
39
40 }
41}