Jonathan Hart | 627f10c | 2013-01-16 14:20:03 -0800 | [diff] [blame^] | 1 | package net.floodlightcontroller.core.internal; |
| 2 | |
| 3 | import java.util.Set; |
| 4 | |
| 5 | import com.thinkaurelius.titan.core.TitanGraph; |
| 6 | import com.tinkerpop.blueprints.Vertex; |
| 7 | import com.tinkerpop.blueprints.TransactionalGraph.Conclusion; |
| 8 | |
| 9 | /** |
| 10 | * Seam that allows me to set up a testable instance of SwitchStorageImpl that |
| 11 | * writes to a file database rather than a Cassandra cluster. |
| 12 | * It seems the init() API on SwitchStorageImpl might change so I won't rely |
| 13 | * on it yet. |
| 14 | * |
| 15 | * @author jono |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | public class TestableSwitchStorageImpl extends SwitchStorageImpl { |
| 20 | |
| 21 | public TestableSwitchStorageImpl(TitanGraph graph){ |
| 22 | 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 | } |