blob: 8411b22f6a1501b0685c0e1fbb3da45b6aa41cd8 [file] [log] [blame]
HIGUCHI Yuta08137932013-06-17 14:11:50 -07001package net.onrc.onos.ofcontroller.core.internal;
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -08002
3import java.util.Set;
4
HIGUCHI Yuta6bfb4802013-06-14 17:02:02 -07005
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -08006import com.thinkaurelius.titan.core.TitanGraph;
7import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
8import com.tinkerpop.blueprints.Vertex;
9
10/**
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080011 * Seam that allows me to set up a testable instance of LinkStorageImpl that
Jonathan Hart627f10c2013-01-16 14:20:03 -080012 * 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 Hartb7e3d2c2013-01-15 18:45:19 -080015 *
16 * @author jono
17 *
18 */
19
Yuta HIGUCHIe2eb7fc2013-10-14 10:00:55 -070020@SuppressWarnings("deprecation")
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080021public class TestableLinkStorageImpl extends LinkStorageImpl {
HIGUCHI Yutadfdd4182013-06-11 17:00:39 -070022 protected TitanGraph graph;
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080023
Jonathan Hartc86a2ea2013-01-15 22:39:42 -080024 public TestableLinkStorageImpl(TitanGraph graph){
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080025 this.graph = graph;
26 }
27
28 @Override
yoshi2fd4c7e2013-11-22 15:47:55 -080029 public void init(final String dbStore, final String conf){
Jonathan Hartb7e3d2c2013-01-15 18:45:19 -080030 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}