Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame^] | 1 | package net.floodlightcontroller.linkdiscovery.internal; |
| 2 | |
| 3 | import java.util.Set; |
| 4 | |
| 5 | import com.thinkaurelius.titan.core.TitanGraph; |
| 6 | import com.tinkerpop.blueprints.TransactionalGraph.Conclusion; |
| 7 | import 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 | |
| 18 | public 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 | } |