Skip to content

Commit

Permalink
New Connection properties are now Ice.Connection.Client.*, Ice.Connec… (
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Aug 23, 2024
1 parent aa7f689 commit c0f42fc
Show file tree
Hide file tree
Showing 57 changed files with 281 additions and 300 deletions.
26 changes: 16 additions & 10 deletions CHANGELOG-3.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG
Idle is never a good state. To prevent connections from becoming idle, Ice ensures there is regular write activity on
established connections: if there is no write on a connection for idle timeout / 2, Ice sends a heartbeat on this
connection. A heartbeat is a one-way, unacknowledged, ValidateConnection message. The default idle timeout is
60 seconds. You can change this value with the configuration property `Ice.Connection.IdleTimeout` (the unit is
seconds). You can also override this value for a specific object adapter with the configuration property
60 seconds. You can change this value with the configuration property `Ice.Connection.Client.IdleTimeout` (for client
connections) or `Ice.Connection.Server.IdleTimeout` (for server connections). The unit for this timeout is seconds.
You can also override this value for a specific object adapter with the configuration property
`AdapterName.Connection.IdleTimeout`. Our general recommendation is to keep things simple: use the same value
(typically the default) for all your Ice applications. In particular, the idle timeout is not negotiated during
connection establishment and an idle timeout mismatch may result in untimely connection aborts.
Expand All @@ -31,8 +32,9 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG
you can set the property `Ice.ACM.Heartbeat` to 3, and make sure the `Ice.ACM.Timeout` property matches your idle
timeout (the default for the ACM timeout is 60 seconds, just like the default idle timeout). If you are unable to
change the configuration of your older Ice application, you can switch off the idle detection on the Ice 3.8 side
by setting `Ice.Connection.EnableIdleCheck` to 0. You can also switch off the idle check for just a specific object
adapter by setting `AdapterName.Connection.EnableIdleCheck` to 0.
by setting `Ice.Connection.Client.EnableIdleCheck` or `Ice.Connection.Server.EnableIdleCheck` to 0. You can also
switch off the idle check for just a specific object adapter by setting `AdapterName.Connection.EnableIdleCheck` to
0.
- **Interop with IceRPC**\
IceRPC uses the same idle timeout and idle check mechanism for connections that use the `ice` protocol.
- Inactivity timeout\
Expand All @@ -42,20 +44,24 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG
above) does not count as application-level activity. When a connection remains inactive for more than the inactivity
timeout, this connection is closed gracefully. Inactive is a good state: the connection is healthy but unused, so we
shut it down to reclaim resources. The default inactivity timeout is 300 seconds. You can change this default by
setting `Ice.Connection.InactivityTimeout` (the unit is seconds). You can also override this value for a specific
object adapter with the configuration property `AdapterName.Connection.InactivityTimeout`.\
setting `Ice.Connection.Client.InactivityTimeout` (for client connections) or
`Ice.Connection.Server.InactivityTimeout` (for server connections). The unit for this timeout is seconds. You
can also override this value for a specific object adapter with the configuration property
`AdapterName.Connection.InactivityTimeout`.\
Note: make sure your inactivity timeout is greater than your idle timeout, as the implementation of the inactivity
timeout relies on a smaller idle timeout value. If you disable your idle timeout by setting it to 0 or very large
value (not something we recommend), you will effectively disable your inactivity timeout as well.
- Connect timeout\
A connection establishment fails if it takes more than connect timeout to complete. The default connect timeout is 10
seconds. You can change this value by setting `Ice.Connection.ConnectTimeout` (the unit is seconds). You can also
seconds. You can change this value by setting `Ice.Connection.Client.ConnectTimeout` (for client connections) or
`Ice.Connection.Server.ConnectTimeout` (for server connections). The unit for this timeout is seconds. You can also
override this value for a specific object adapter with the configuration property
`AdapterName.Connection.ConnectTimeout`.
- Close timeout\
A graceful connection closure transitions to an ungraceful connection closure if it takes more than close timeout to
complete. The default close timeout is 10 seconds. You can change this value by setting `Ice.Connection.CloseTimeout`
(the unit is seconds). You can also override this value for a specific object adapter with the configuration
A graceful connection closure transitions to connection abort if it takes more than close timeout to complete. The
default close timeout is 10 seconds. You can change this value by setting `Ice.Connection.Client.CloseTimeout` (for
client connections) or `Ice.Connection.Server.CloseTimeout` (for server connections). The unit for this timeout is
seconds, as usual. You can also override this value for a specific object adapter with the configuration
property `AdapterName.Connection.CloseTimeout`.

- Simplify proxy creation.
Expand Down
5 changes: 3 additions & 2 deletions config/PropertyNames.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ generated from the section label.
<suffix name="Context.[any]" />
</class>

<class name="connection" prefix-only="false">
<class name="connection" prefix-only="true">
<suffix name="CloseTimeout" default="10" />
<suffix name="ConnectTimeout" default="10" />
<suffix name="EnableIdleCheck" default="1" />
Expand Down Expand Up @@ -264,7 +264,8 @@ generated from the section label.
<property name="ClassGraphDepthMax" default="10" />
<property name="Compression.Level" default="1" />
<property name="Config" />
<property name="Connection" class="connection"/>
<property name="Connection.Client" class="connection" />
<property name="Connection.Server" class="connection" />
<property name="ConsoleListener" default="1" />
<property name="Default.CollocationOptimized" default="1" />
<property name="Default.EncodingVersion" default="1.1"/>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Glacier2/SessionRouterI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ SessionRouterI::getSessionTimeout(const Ice::Current& current) const
int
SessionRouterI::getACMTimeout(const Ice::Current&) const
{
int idleTimeout = _instance->properties()->getIcePropertyAsInt("Ice.Connection.IdleTimeout");
int idleTimeout = _instance->properties()->getIcePropertyAsInt("Ice.Connection.Server.IdleTimeout");
return _instance->properties()->getPropertyAsIntWithDefault("Glacier2.Client.Connection.IdleTimeout", idleTimeout);
}

Expand Down
10 changes: 5 additions & 5 deletions cpp/src/Ice/ConnectionOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace Ice
/// Represents a property bag used to configure client and server connections.
struct ConnectionOptions
{
std::chrono::seconds connectTimeout = std::chrono::seconds(10);
std::chrono::seconds closeTimeout = std::chrono::seconds(10);
std::chrono::seconds idleTimeout = std::chrono::seconds(60);
bool enableIdleCheck = true;
std::chrono::seconds inactivityTimeout = std::chrono::seconds(300);
std::chrono::seconds connectTimeout;
std::chrono::seconds closeTimeout;
std::chrono::seconds idleTimeout;
bool enableIdleCheck;
std::chrono::seconds inactivityTimeout;
};
}

Expand Down
91 changes: 48 additions & 43 deletions cpp/src/Ice/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,29 +487,33 @@ IceInternal::Instance::pluginManager() const
ConnectionOptions
IceInternal::Instance::serverConnectionOptions(const string& adapterName) const
{
ConnectionOptions connectionOptions = _clientConnectionOptions;

if (!adapterName.empty())
{
// Override if any of these properties are set, otherwise keep previous value.
const PropertiesPtr& properties = _initData.properties;

connectionOptions.connectTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
adapterName + ".Connection.ConnectTimeout",
static_cast<int>(connectionOptions.connectTimeout.count())));
connectionOptions.closeTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
adapterName + ".Connection.CloseTimeout",
static_cast<int>(connectionOptions.closeTimeout.count())));
connectionOptions.idleTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
adapterName + ".Connection.IdleTimeout",
static_cast<int>(connectionOptions.idleTimeout.count())));
connectionOptions.enableIdleCheck = properties->getPropertyAsIntWithDefault(
adapterName + ".Connection.EnableIdleCheck",
connectionOptions.enableIdleCheck ? 1 : 0) > 0;
connectionOptions.inactivityTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
adapterName + ".Connection.InactivityTimeout",
static_cast<int>(connectionOptions.inactivityTimeout.count())));
}
assert(!adapterName.empty());
string propertyPrefix = adapterName + ".Connection";

const PropertiesPtr& properties = _initData.properties;

ConnectionOptions connectionOptions;

connectionOptions.connectTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
propertyPrefix + ".ConnectTimeout",
static_cast<int>(_serverConnectionOptions.connectTimeout.count())));

connectionOptions.closeTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
propertyPrefix + ".CloseTimeout",
static_cast<int>(_serverConnectionOptions.closeTimeout.count())));

connectionOptions.idleTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
propertyPrefix + ".IdleTimeout",
static_cast<int>(_serverConnectionOptions.idleTimeout.count())));

connectionOptions.enableIdleCheck = properties->getPropertyAsIntWithDefault(
propertyPrefix + ".EnableIdleCheck",
_serverConnectionOptions.enableIdleCheck ? 1 : 0) > 0;

connectionOptions.inactivityTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
propertyPrefix + ".InactivityTimeout",
static_cast<int>(_serverConnectionOptions.inactivityTimeout.count())));

return connectionOptions;
}

Expand Down Expand Up @@ -1099,26 +1103,8 @@ IceInternal::Instance::initialize(const Ice::CommunicatorPtr& communicator)
const_cast<DefaultsAndOverridesPtr&>(_defaultsAndOverrides) =
make_shared<DefaultsAndOverrides>(_initData.properties, _initData.logger);

{
const PropertiesPtr& properties = _initData.properties;
ConnectionOptions& connectionOptions = const_cast<ConnectionOptions&>(_clientConnectionOptions);

connectionOptions.connectTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
"Ice.Connection.ConnectTimeout",
static_cast<int>(connectionOptions.connectTimeout.count())));
connectionOptions.closeTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
"Ice.Connection.CloseTimeout",
static_cast<int>(connectionOptions.closeTimeout.count())));
connectionOptions.idleTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
"Ice.Connection.IdleTimeout",
static_cast<int>(connectionOptions.idleTimeout.count())));
connectionOptions.enableIdleCheck = properties->getPropertyAsIntWithDefault(
"Ice.Connection.EnableIdleCheck",
connectionOptions.enableIdleCheck ? 1 : 0) > 0;
connectionOptions.inactivityTimeout = chrono::seconds(properties->getPropertyAsIntWithDefault(
"Ice.Connection.InactivityTimeout",
static_cast<int>(connectionOptions.inactivityTimeout.count())));
}
const_cast<ConnectionOptions&>(_clientConnectionOptions) = readConnectionOptions("Ice.Connection.Client");
const_cast<ConnectionOptions&>(_serverConnectionOptions) = readConnectionOptions("Ice.Connection.Server");

{
int32_t num = _initData.properties->getIcePropertyAsInt("Ice.MessageSizeMax");
Expand Down Expand Up @@ -1850,6 +1836,25 @@ IceInternal::Instance::getBufSizeWarnInternal(int16_t type)
return info;
}

ConnectionOptions
IceInternal::Instance::readConnectionOptions(const string& propertyPrefix) const
{
const PropertiesPtr& properties = _initData.properties;
ConnectionOptions connectionOptions;

connectionOptions.connectTimeout =
chrono::seconds(properties->getIcePropertyAsInt(propertyPrefix + ".ConnectTimeout"));

connectionOptions.closeTimeout = chrono::seconds(properties->getIcePropertyAsInt(propertyPrefix + ".CloseTimeout"));
connectionOptions.idleTimeout = chrono::seconds(properties->getIcePropertyAsInt(propertyPrefix + ".IdleTimeout"));
connectionOptions.enableIdleCheck = properties->getIcePropertyAsInt(propertyPrefix + ".EnableIdleCheck") > 0;

connectionOptions.inactivityTimeout =
chrono::seconds(properties->getIcePropertyAsInt(propertyPrefix + ".InactivityTimeout"));

return connectionOptions;
}

void
IceInternal::Instance::setSndBufSizeWarn(int16_t type, int size)
{
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/Ice/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace IceInternal
void initialize(const Ice::CommunicatorPtr&);
void finishSetup(int&, const char*[], const Ice::CommunicatorPtr&);
void destroy();

friend class Ice::Communicator;

void updateConnectionObservers();
Expand All @@ -135,6 +136,8 @@ namespace IceInternal

BufSizeWarnInfo getBufSizeWarnInternal(std::int16_t type);

Ice::ConnectionOptions readConnectionOptions(const std::string& propertyPrefix) const;

enum State
{
StateActive,
Expand All @@ -151,6 +154,7 @@ namespace IceInternal
const Ice::ToStringMode _toStringMode; // Immutable, not reset by destroy()
const bool _acceptClassCycles; // Immutable, not reset by destroy()
Ice::ConnectionOptions _clientConnectionOptions;
Ice::ConnectionOptions _serverConnectionOptions;
RouterManagerPtr _routerManager;
LocatorManagerPtr _locatorManager;
ReferenceFactoryPtr _referenceFactory;
Expand Down
Loading

0 comments on commit c0f42fc

Please sign in to comment.