HIGUCHI Yuta | 0813793 | 2013-06-17 14:11:50 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.core.internal; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 2 | |
| 3 | import java.util.Set; |
| 4 | |
HIGUCHI Yuta | 6bfb480 | 2013-06-14 17:02:02 -0700 | [diff] [blame] | 5 | |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 6 | import com.thinkaurelius.titan.core.TitanGraph; |
| 7 | import com.tinkerpop.blueprints.TransactionalGraph.Conclusion; |
| 8 | import com.tinkerpop.blueprints.Vertex; |
| 9 | |
| 10 | /** |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 11 | * Seam that allows me to set up a testable instance of LinkStorageImpl that |
Jonathan Hart | 627f10c | 2013-01-16 14:20:03 -0800 | [diff] [blame] | 12 | * writes to a file database rather than a Cassandra cluster. |
| 13 | * It seems the init() API on LinkStorageImpl might change so I won't rely |
| 14 | * on it yet. |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 15 | * |
| 16 | * @author jono |
| 17 | * |
| 18 | */ |
| 19 | |
Yuta HIGUCHI | e2eb7fc | 2013-10-14 10:00:55 -0700 | [diff] [blame] | 20 | @SuppressWarnings("deprecation") |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 21 | public class TestableLinkStorageImpl extends LinkStorageImpl { |
HIGUCHI Yuta | dfdd418 | 2013-06-11 17:00:39 -0700 | [diff] [blame] | 22 | protected TitanGraph graph; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 23 | |
Jonathan Hart | c86a2ea | 2013-01-15 22:39:42 -0800 | [diff] [blame] | 24 | public TestableLinkStorageImpl(TitanGraph graph){ |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 25 | this.graph = graph; |
| 26 | } |
| 27 | |
| 28 | @Override |
yoshi | 2fd4c7e | 2013-11-22 15:47:55 -0800 | [diff] [blame] | 29 | public void init(final String dbStore, final String conf){ |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 30 | Set<String> s = graph.getIndexedKeys(Vertex.class); |
| 31 | if (!s.contains("dpid")) { |
| 32 | graph.createKeyIndex("dpid", Vertex.class); |
| 33 | graph.stopTransaction(Conclusion.SUCCESS); |
| 34 | } |
| 35 | if (!s.contains("type")) { |
| 36 | graph.createKeyIndex("type", Vertex.class); |
| 37 | graph.stopTransaction(Conclusion.SUCCESS); |
| 38 | } |
| 39 | |
| 40 | } |
| 41 | } |