blob: 87c7b42c0dd38db319433bf0903d15e38ddc743a [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Yuta HIGUCHI41f2ec02014-10-27 09:54:43 -070016package org.onlab.onos.store.hz;
Yuta HIGUCHIb4139d82014-09-23 18:41:33 -070017
18import java.io.FileNotFoundException;
19import java.util.UUID;
20
21import com.hazelcast.config.Config;
22import com.hazelcast.config.FileSystemXmlConfig;
23import com.hazelcast.core.HazelcastInstance;
24
25/**
26 * Dummy StoreManager to use specified Hazelcast instance.
27 */
28public class TestStoreManager extends StoreManager {
29
30 /**
31 * Gets the Hazelcast Config for testing.
32 *
33 * @return
34 */
35 public static Config getTestConfig() {
36 Config config;
37 try {
38 config = new FileSystemXmlConfig(HAZELCAST_XML_FILE);
39 } catch (FileNotFoundException e) {
40 // falling back to default
41 config = new Config();
42 }
43 // avoid accidentally joining other cluster
44 config.getGroupConfig().setName(UUID.randomUUID().toString());
45 // quickly form single node cluster
46 config.getNetworkConfig().getJoin()
47 .getTcpIpConfig()
48 .setEnabled(true).setConnectionTimeoutSeconds(0);
49 config.getNetworkConfig().getJoin()
50 .getMulticastConfig()
51 .setEnabled(false);
52 return config;
53 }
54
55 /**
56 * Constructor.
57 *
58 * @param instance Hazelast instance to return on #getHazelcastInstance()
59 */
60 public TestStoreManager(HazelcastInstance instance) {
61 this.instance = instance;
62 }
63
Yuta HIGUCHIb4139d82014-09-23 18:41:33 -070064 @Override
65 public void activate() {
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070066 // Hazelcast setup removed from original code.
Yuta HIGUCHIb4139d82014-09-23 18:41:33 -070067 }
68}