blob: 0740e4eec05880fd39d890c320d7b29f6fb7161b [file] [log] [blame]
Yuta HIGUCHI41f2ec02014-10-27 09:54:43 -07001package org.onlab.onos.store.hz;
Yuta HIGUCHIb4139d82014-09-23 18:41:33 -07002
3import java.io.FileNotFoundException;
4import java.util.UUID;
5
6import com.hazelcast.config.Config;
7import com.hazelcast.config.FileSystemXmlConfig;
8import com.hazelcast.core.HazelcastInstance;
9
10/**
11 * Dummy StoreManager to use specified Hazelcast instance.
12 */
13public class TestStoreManager extends StoreManager {
14
15 /**
16 * Gets the Hazelcast Config for testing.
17 *
18 * @return
19 */
20 public static Config getTestConfig() {
21 Config config;
22 try {
23 config = new FileSystemXmlConfig(HAZELCAST_XML_FILE);
24 } catch (FileNotFoundException e) {
25 // falling back to default
26 config = new Config();
27 }
28 // avoid accidentally joining other cluster
29 config.getGroupConfig().setName(UUID.randomUUID().toString());
30 // quickly form single node cluster
31 config.getNetworkConfig().getJoin()
32 .getTcpIpConfig()
33 .setEnabled(true).setConnectionTimeoutSeconds(0);
34 config.getNetworkConfig().getJoin()
35 .getMulticastConfig()
36 .setEnabled(false);
37 return config;
38 }
39
40 /**
41 * Constructor.
42 *
43 * @param instance Hazelast instance to return on #getHazelcastInstance()
44 */
45 public TestStoreManager(HazelcastInstance instance) {
46 this.instance = instance;
47 }
48
Yuta HIGUCHIb4139d82014-09-23 18:41:33 -070049 @Override
50 public void activate() {
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070051 // Hazelcast setup removed from original code.
Yuta HIGUCHIb4139d82014-09-23 18:41:33 -070052 }
53}