2 * Copyright © 2019 FRINX s.r.o. 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
8 package org.opendaylight.restconf.nb.rfc8040.streams;
10 import static com.google.common.base.Preconditions.checkArgument;
12 import com.google.common.base.MoreObjects;
15 * Restconf configuration holder and verifier.
17 public class Configuration {
19 private static final int MAX_FRAGMENT_LENGTH = 65535;
21 private final int maximumFragmentLength;
22 private final int idleTimeout;
23 private final int heartbeatInterval;
24 private final boolean useSSE;
27 * Creation of the restconf configuration holder with verification of input parameters.
29 * @param maximumFragmentLength Maximum web-socket fragment length in number of Unicode code units (characters)
30 * (exceeded message length leads to fragmentation of messages).
31 * @param idleTimeout Maximum idle time of web-socket session before the session is closed (milliseconds).
32 * @param heartbeatInterval Interval in milliseconds between sending of ping control frames.
33 * @param useSSE when is true use SSE else use WS
35 public Configuration(final int maximumFragmentLength, final int idleTimeout, final int heartbeatInterval,
36 final boolean useSSE) {
37 checkArgument(idleTimeout > 0, "Idle timeout must be specified by positive value.");
38 checkArgument(maximumFragmentLength >= 0 && maximumFragmentLength < MAX_FRAGMENT_LENGTH,
39 "Maximum fragment length must be disabled (0) or specified by positive value less than 64 KB.");
40 checkArgument(heartbeatInterval >= 0, "Heartbeat ping interval must be "
41 + "disabled (0) or specified by positive value.");
43 this.maximumFragmentLength = maximumFragmentLength;
44 this.idleTimeout = idleTimeout;
45 this.heartbeatInterval = heartbeatInterval;
49 public int getMaximumFragmentLength() {
50 return maximumFragmentLength;
53 public int getIdleTimeout() {
57 public int getHeartbeatInterval() {
58 return heartbeatInterval;
64 * @return true in situation when we use SSE. False in situation when we use WS
66 public boolean isUseSSE() {
71 public String toString() {
72 return MoreObjects.toStringHelper(this)
73 .add("maximumFragmentLength", maximumFragmentLength)
74 .add("idleTimeout", idleTimeout)
75 .add("heartbeatInterval", heartbeatInterval)
76 .add("useSSE", useSSE)