/*
 * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.client.config;

/**
 * TCP Socket options
 */
public class SocketOptions {

    /**
     * constant for kilobyte
     */
    public static final int KILO_BYTE = 1024;

    /**
     * default buffer size of Bytes
     */
    public static final int DEFAULT_BUFFER_SIZE_BYTE = 128 * KILO_BYTE;

    static final int DEFAULT_BUFFER_SIZE = 128;

    // socket options

    private boolean tcpNoDelay = true;

    private boolean keepAlive = true;

    private boolean reuseAddress = true;

    private int lingerSeconds = 3;

    private int bufferSize = DEFAULT_BUFFER_SIZE;

    /**
     * TCP_NODELAY socket option
     *
     * @return true if enabled
     */
    public boolean isTcpNoDelay() {
        return tcpNoDelay;
    }

    /**
     * Enable/disable TCP_NODELAY socket option.
     *
     * @param tcpNoDelay
     * @return
     */
    public SocketOptions setTcpNoDelay(boolean tcpNoDelay) {
        this.tcpNoDelay = tcpNoDelay;
        return this;
    }

    /**
     * SO_KEEPALIVE socket option
     *
     * @return true if enabled
     */
    public boolean isKeepAlive() {
        return keepAlive;
    }

    /**
     * Enable/disable SO_KEEPALIVE socket option.
     *
     * @param keepAlive enabled if true
     * @return SocketOptions configured
     */
    public SocketOptions setKeepAlive(boolean keepAlive) {
        this.keepAlive = keepAlive;
        return this;
    }

    /**
     * SO_REUSEADDR socket option.
     *
     * @return true if enabled
     */
    public boolean isReuseAddress() {
        return reuseAddress;
    }

    /**
     * Enable/disable the SO_REUSEADDR socket option.
     *
     * @param reuseAddress enabled if true
     * @return SocketOptions configured
     */
    public SocketOptions setReuseAddress(boolean reuseAddress) {
        this.reuseAddress = reuseAddress;
        return this;
    }

    /**
     * Gets SO_LINGER with the specified linger time in seconds
     * @return lingerSeconds value in seconds
     */
    public int getLingerSeconds() {
        return lingerSeconds;
    }

    /**
     * Enable/disable SO_LINGER with the specified linger time in seconds
     *
     * @param lingerSeconds value in seconds
     * @return SocketOptions configured
     */
    public SocketOptions setLingerSeconds(int lingerSeconds) {
        this.lingerSeconds = lingerSeconds;
        return this;
    }

    /**
     * Gets the SO_SNDBUF and SO_RCVBUF options to the specified value in KB
     * @return bufferSize KB value
     */
    public int getBufferSize() {
        return bufferSize;
    }

    /**
     * Sets the SO_SNDBUF and SO_RCVBUF options to the specified value in KB
     *
     * @param bufferSize KB value
     * @return SocketOptions configured
     */
    public SocketOptions setBufferSize(int bufferSize) {
        this.bufferSize = bufferSize;
        return this;
    }

}

@@ -975,22 +975,78 @@
 FER_SIZE
- = 128
+_IN_KB = 128;%0A%0A    static final int DEFAULT_LINGER_SECONDS = 3
 ;%0A%0A    /
@@ -1216,17 +1216,38 @@
 conds = 
-3
+DEFAULT_LINGER_SECONDS
 ;%0A%0A    p
@@ -1267,16 +1267,20 @@
 fferSize
+InKB
  = DEFAU
@@ -1293,16 +1293,22 @@
 FER_SIZE
+_IN_KB
 ;%0A%0A    /
@@ -2869,23 +2869,158 @@
 seconds%0A
+     * If set to a value of 0 or less then it is disabled.%0A     *%0A     * Default value is %7B@link SocketOptions#DEFAULT_LINGER_SECONDS%7D%0A
      *%0A
-
      * @
@@ -3297,38 +3297,14 @@
 tion
-s to the specified value in KB
+ value
 %0A   
@@ -3397,24 +3397,28 @@
 n bufferSize
+InKB
 ;%0A    %7D%0A%0A   
@@ -3641,24 +3641,24 @@
 fferSize) %7B%0A
-
         this
@@ -3668,16 +3668,20 @@
 fferSize
+InKB
  = buffe

Clean up socket options