2 * Copyright © 2014, 2017 Red Hat, Inc. and others. All rights reserved.
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
9 package org.opendaylight.ovsdb.lib.impl;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
15 public class OvsdbConnectionServiceConfigurator {
17 private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionServiceConfigurator.class);
19 private static final String JSON_RPC_DECODER_MAX_FRAME_LENGTH_PARAM = "json-rpc-decoder-max-frame-length";
20 private static final String USE_SSL_PARAM = "use-ssl";
21 private static final String OVSDB_RPC_TASK_TIMEOUT_PARAM = "ovsdb-rpc-task-timeout";
22 private static final String OVSDB_LISTENER_PORT_PARAM = "ovsdb-listener-port";
23 private final OvsdbConnectionService ovsdbconnection;
25 public OvsdbConnectionServiceConfigurator(OvsdbConnectionService ovsdbconnection) {
26 this.ovsdbconnection = ovsdbconnection;
29 public void setOvsdbRpcTaskTimeout(int timeout) {
30 ovsdbconnection.setOvsdbRpcTaskTimeout(timeout);
33 public void setUseSsl(boolean flag) {
34 ovsdbconnection.setUseSsl(flag);
37 public void setJsonRpcDecoderMaxFrameLength(int maxFrameLength) {
38 ovsdbconnection.setJsonRpcDecoderMaxFrameLength(maxFrameLength);
41 public void setOvsdbListenerIp(String ip) {
42 ovsdbconnection.setOvsdbListenerIp(ip);
45 public void setOvsdbListenerPort(int portNumber) {
46 ovsdbconnection.setOvsdbListenerPort(portNumber);
49 public void updateConfigParameter(Map<String, Object> configParameters) {
50 if (configParameters != null && !configParameters.isEmpty()) {
51 LOG.debug("Config parameters received : {}", configParameters.entrySet());
52 for (Map.Entry<String, Object> paramEntry : configParameters.entrySet()) {
53 if (paramEntry.getKey().equalsIgnoreCase(OVSDB_RPC_TASK_TIMEOUT_PARAM)) {
54 ovsdbconnection.setOvsdbRpcTaskTimeout(Integer.parseInt((String) paramEntry.getValue()));
55 } else if (paramEntry.getKey().equalsIgnoreCase(USE_SSL_PARAM)) {
56 ovsdbconnection.setUseSsl(Boolean.parseBoolean(paramEntry.getValue().toString()));