-
Notifications
You must be signed in to change notification settings - Fork 51
SocketOptions configuration is missing - Need to set tcp read/write buffer sizes #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
00af240
129103c
582e8ef
1eb713f
eae4546
a1fe056
7e08b76
aacf35f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| #ifndef HAZELCAST_CLIENT_CONFIG_SOCKETOPTIONS_H_ | ||
| #define HAZELCAST_CLIENT_CONFIG_SOCKETOPTIONS_H_ | ||
|
|
||
| #include "hazelcast/util/HazelcastDll.h" | ||
|
|
||
| #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) | ||
| #pragma warning(push) | ||
| #pragma warning(disable: 4251) //for dll export | ||
| #endif | ||
|
|
||
| namespace hazelcast { | ||
| namespace client { | ||
| namespace config { | ||
| /** | ||
| * TCP Socket options | ||
| */ | ||
| class HAZELCAST_API SocketOptions { | ||
| public: | ||
| /** | ||
| * constant for kilobyte | ||
| */ | ||
| static const int KILO_BYTE = 1024; | ||
|
|
||
| /** | ||
| * default buffer size of Bytes | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also this one
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| */ | ||
| static const int DEFAULT_BUFFER_SIZE_BYTE = 128 * KILO_BYTE; | ||
|
|
||
| SocketOptions(); | ||
|
|
||
| /** | ||
| * TCP_NODELAY socket option | ||
| * | ||
| * @return true if enabled | ||
| */ | ||
| bool isTcpNoDelay() const; | ||
|
|
||
| /** | ||
| * Enable/disable TCP_NODELAY socket option. | ||
| * | ||
| * @param tcpNoDelay | ||
| */ | ||
| SocketOptions &setTcpNoDelay(bool tcpNoDelay); | ||
|
|
||
| /** | ||
| * SO_KEEPALIVE socket option | ||
| * | ||
| * @return true if enabled | ||
| */ | ||
| bool isKeepAlive() const; | ||
|
|
||
| /** | ||
| * Enable/disable SO_KEEPALIVE socket option. | ||
| * | ||
| * @param keepAlive enabled if true | ||
| * @return SocketOptions configured | ||
| */ | ||
| SocketOptions &setKeepAlive(bool keepAlive); | ||
|
|
||
| /** | ||
| * SO_REUSEADDR socket option. | ||
| * | ||
| * @return true if enabled | ||
| */ | ||
| bool isReuseAddress() const; | ||
|
|
||
| /** | ||
| * Enable/disable the SO_REUSEADDR socket option. | ||
| * | ||
| * @param reuseAddress enabled if true | ||
| * @return SocketOptions configured | ||
| */ | ||
| SocketOptions &setReuseAddress(bool reuseAddress); | ||
|
|
||
| /** | ||
| * Gets SO_LINGER with the specified linger time in seconds | ||
| * @return lingerSeconds value in seconds | ||
| */ | ||
| int getLingerSeconds() const; | ||
|
|
||
| /** | ||
| * Enable/disable SO_LINGER with the specified linger time in seconds | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What value disables
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added doc: |
||
| * | ||
| * if set to a value of 0 or less then it is disabled. | ||
| * | ||
| * Default value is 3. | ||
| * | ||
| * @param lingerSeconds value in seconds | ||
| * @return SocketOptions configured | ||
| */ | ||
| SocketOptions &setLingerSeconds(int lingerSeconds); | ||
|
|
||
| /** | ||
| * If set to 0 or less, then it is not set on the socket. | ||
| * | ||
| * The default value is DEFAULT_BUFFER_SIZE_BYTE | ||
| * | ||
| * Gets the SO_SNDBUF and SO_RCVBUF options value in bytes | ||
| * @return bufferSize Number of bytes | ||
| */ | ||
| int getBufferSizeInBytes() const; | ||
|
|
||
| /** | ||
| * If set to 0 or less, then it is not set on the socket. | ||
| * | ||
| * The default value is DEFAULT_BUFFER_SIZE_BYTE | ||
| * | ||
| * Sets the SO_SNDBUF and SO_RCVBUF options to the specified value in bytes | ||
| * | ||
| * @param bufferSize Number of bytes | ||
| * @return SocketOptions configured | ||
| */ | ||
| SocketOptions &setBufferSizeInBytes(int bufferSize); | ||
|
|
||
| private: | ||
| // socket options | ||
|
|
||
| bool tcpNoDelay; | ||
|
|
||
| bool keepAlive; | ||
|
|
||
| bool reuseAddress; | ||
|
|
||
| int lingerSeconds; | ||
|
|
||
| int bufferSize; | ||
|
|
||
| }; | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) | ||
| #pragma warning(pop) | ||
| #endif | ||
|
|
||
| #endif /* HAZELCAST_CLIENT_CONFIG_SOCKETOPTIONS_H_ */ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we dont need this comment, it doesnt say more than the variable name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are from Java client documentation. If needed we need to change both. I think it can stay.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they are not even used in Java :) I sent a cleanup PR for that
https://github.com/hazelcast/hazelcast/pull/14147/filesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As they are part of API we cant change them I guess. If there isnt any check like checkstyle for CPP we shouldnt have them here. They are probably there in Java because of checkstyle(otherwise the build fails).