blob: c9d8821bf98ac473df407bb65108bd5b3c8840ba [file] [log] [blame]
Yuta HIGUCHIb4139d82014-09-23 18:41:33 -07001package org.onlab.onos.store.impl;
2
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
49 // Hazelcast setup removed from original code.
50 @Override
51 public void activate() {
52 setupKryoPool();
53 }
54}