blob: 223b8a16a44cb9991ce0563f295a2983ed04d29f [file] [log] [blame]
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -08001package net.floodlightcontroller.linkdiscovery.internal;
2
3import java.util.Set;
4
5import com.thinkaurelius.titan.core.TitanGraph;
6import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
7import com.tinkerpop.blueprints.Vertex;
8
9/**
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080010 * Seam that allows me to set up a testable instance of LinkStorageImpl that
Jonathan Hart627f10c2013-01-16 14:20:03 -080011 * writes to a file database rather than a Cassandra cluster.
12 * It seems the init() API on LinkStorageImpl might change so I won't rely
13 * on it yet.
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080014 *
15 * @author jono
16 *
17 */
18
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080019public class TestableLinkStorageImpl extends LinkStorageImpl {
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080020
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080021 public TestableLinkStorageImpl(TitanGraph graph){
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080022 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}