BUG-2138: Create DistributedShardFrontend
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / MockConfiguration.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.datastore.utils;
10
11 import java.util.Arrays;
12 import java.util.Collections;
13 import java.util.HashMap;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.stream.Collectors;
17 import javax.annotation.Nonnull;
18 import org.opendaylight.controller.cluster.access.concepts.MemberName;
19 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
20 import org.opendaylight.controller.cluster.datastore.config.ModuleConfig;
21 import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
22 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
23
24 public class MockConfiguration extends ConfigurationImpl {
25     public MockConfiguration() {
26         this(Collections.singletonMap("default", Arrays.asList("member-1", "member-2")));
27     }
28
29     public MockConfiguration(final Map<String, List<String>> shardMembers) {
30         super(configuration -> {
31             Map<String, ModuleConfig.Builder> retMap = new HashMap<>();
32             for (Map.Entry<String, List<String>> e : shardMembers.entrySet()) {
33                 String shardName = e.getKey();
34                 retMap.put(shardName,
35                     ModuleConfig.builder(shardName).shardConfig(
36                         shardName, e.getValue().stream().map(MemberName::forName).collect(Collectors.toList())));
37             }
38
39             return retMap;
40         });
41     }
42
43     @Override
44     public ShardStrategy getStrategyForPrefix(@Nonnull final DOMDataTreeIdentifier prefix) {
45         return null;
46     }
47 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.