blob: 96321921ee7554aa5630bb844542e647c94a8e93 [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
11 * writes to a file database rather than a Cassandra cluster. Currently
12 * LinkStorageImpl is hardcoded to connect to a Cassandra cluster in its init
13 * method.
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}