Check for the SHARD Status before opening the OVSDB port/HwvtepSouthboundProvider...
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepSouthboundProviderConfigurator.java
1 /*
2  * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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 package org.opendaylight.ovsdb.hwvtepsouthbound;
9
10 import java.util.Map;
11
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 /**
16  * Helper to let Blueprint XML configure {@link HwvtepSouthboundProvider}.
17  *
18  * @author Chandra Shekar S
19  */
20 public class HwvtepSouthboundProviderConfigurator {
21
22     private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundProviderConfigurator.class);
23
24     private static final String SHARD_STATUS_CHECK_RETRY_COUNT = "shard-status-check-retry-count";
25
26     private final HwvtepSouthboundProvider hwvtepSouthboundProvider;
27
28     public HwvtepSouthboundProviderConfigurator(HwvtepSouthboundProvider hwvtepSouthboundProvider) {
29         this.hwvtepSouthboundProvider = hwvtepSouthboundProvider;
30     }
31
32     public void setShardStatusCheckRetryCount(int retryCount) {
33         hwvtepSouthboundProvider.setShardStatusCheckRetryCount(retryCount);
34     }
35
36
37
38     public void updateConfigParameter(Map<String, Object> configParameters) {
39         if (configParameters != null && !configParameters.isEmpty()) {
40             LOG.debug("Config parameters received : {}", configParameters.entrySet());
41             for (Map.Entry<String, Object> paramEntry : configParameters.entrySet()) {
42                 if (paramEntry.getKey().equalsIgnoreCase(SHARD_STATUS_CHECK_RETRY_COUNT)) {
43                     hwvtepSouthboundProvider
44                             .setShardStatusCheckRetryCount(Integer.parseInt((String) paramEntry.getValue()));
45                 }
46             }
47         }
48     }
49 }