blob: 0cd15dec1d27f8c53a739c3a602e7c95f4724ba5 [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/**
10 * Seam that allows me to set up a mock of LinkStorageImpl that writes to a
11 * file database rather than a Cassandra cluster. Currently LinkStorageImpl
12 * is hardcoded to connect to a Cassandra cluster in its init method.
13 *
14 * @author jono
15 *
16 */
17
18public class MockLinkStorageImpl extends LinkStorageImpl {
19
20 public MockLinkStorageImpl(TitanGraph graph){
21 this.graph = graph;
22 }
23
24 @Override
25 public void init(String conf){
26 Set<String> s = graph.getIndexedKeys(Vertex.class);
27 if (!s.contains("dpid")) {
28 graph.createKeyIndex("dpid", Vertex.class);
29 graph.stopTransaction(Conclusion.SUCCESS);
30 }
31 if (!s.contains("type")) {
32 graph.createKeyIndex("type", Vertex.class);
33 graph.stopTransaction(Conclusion.SUCCESS);
34 }
35
36 }
37}