Skip to content

Commit

Permalink
Remove ACM in C++ (#2067)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Apr 24, 2024
1 parent 60fbf3a commit cb549b2
Show file tree
Hide file tree
Showing 104 changed files with 182 additions and 6,728 deletions.
7 changes: 0 additions & 7 deletions cpp/config/glacier2router.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ Glacier2.Server.Endpoints=tcp -h localhost
#
Glacier2.PermissionsVerifier=DemoGlacier2Router/NullPermissionsVerifier

#
# The timeout for inactive sessions. If any client session is inactive
# for longer than this value, the session expires and is removed. The
# unit is seconds.
#
Glacier2.SessionTimeout=30

#
# Glacier2 always disables active connection management so there is no
# need to configure this manually. Connection retry does not need to
Expand Down
1 change: 0 additions & 1 deletion cpp/config/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<property name="Glacier2.Client.Endpoints" value="${client-endpoints}"/>
<property name="Glacier2.Server.Endpoints" value="${server-endpoints}"/>
<property name="Glacier2.InstanceName" value="${instance-name}"/>
<property name="Glacier2.SessionTimeout" value="${session-timeout}"/>
</properties>
</server>

Expand Down
98 changes: 0 additions & 98 deletions cpp/include/Ice/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,87 +46,6 @@ namespace Ice
BasedOnProxy
};

/**
* Specifies the close semantics for Active Connection Management.
*/
enum class ACMClose : std::uint8_t
{
/**
* Disables automatic connection closure.
*/
CloseOff,
/**
* Gracefully closes a connection that has been idle for the configured timeout period.
*/
CloseOnIdle,
/**
* Forcefully closes a connection that has been idle for the configured timeout period, but only if the
* connection has pending invocations.
*/
CloseOnInvocation,
/**
* Combines the behaviors of CloseOnIdle and CloseOnInvocation.
*/
CloseOnInvocationAndIdle,
/**
* Forcefully closes a connection that has been idle for the configured timeout period, regardless of whether
* the connection has pending invocations or dispatch.
*/
CloseOnIdleForceful
};

/**
* Specifies the heartbeat semantics for Active Connection Management.
*/
enum class ACMHeartbeat : std::uint8_t
{
/**
* Disables heartbeats.
*/
HeartbeatOff,
/**
* Send a heartbeat at regular intervals if the connection is idle and only if there are pending dispatch.
*/
HeartbeatOnDispatch,
/**
* Send a heartbeat at regular intervals when the connection is idle.
*/
HeartbeatOnIdle,
/**
* Send a heartbeat at regular intervals until the connection is closed.
*/
HeartbeatAlways
};

/**
* A collection of Active Connection Management configuration settings.
* \headerfile Ice/Ice.h
*/
struct ACM
{
/**
* A timeout value in seconds.
*/
int timeout;
/**
* The close semantics.
*/
ACMClose close;
/**
* The heartbeat semantics.
*/
ACMHeartbeat heartbeat;

/**
* Obtains a tuple containing all of the struct's data members.
* @return The data members in a tuple.
*/
std::tuple<const int&, const ACMClose&, const ACMHeartbeat&> ice_tuple() const
{
return std::tie(timeout, close, heartbeat);
}
};

/**
* Determines the behavior when manually closing a connection.
*/
Expand Down Expand Up @@ -338,23 +257,6 @@ namespace Ice
*/
std::future<void> heartbeatAsync();

/**
* Set the active connection management parameters.
* @param timeout The timeout value in seconds, must be &gt;= 0.
* @param close The close condition
* @param heartbeat The heartbeat condition
*/
virtual void setACM(
const std::optional<int>& timeout,
const std::optional<ACMClose>& close,
const std::optional<ACMHeartbeat>& heartbeat) = 0;

/**
* Get the ACM parameters.
* @return The ACM parameters.
*/
virtual ACM getACM() noexcept = 0;

/**
* Return the connection type. This corresponds to the endpoint type, i.e., "tcp", "udp", etc.
* @return The type of the connection.
Expand Down
31 changes: 0 additions & 31 deletions cpp/msbuild/ice.test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Ice\acm\msbuild\client\client.vcxproj", "{CD25A05C-228D-473F-A86F-6C2DD22085B4}"
ProjectSection(ProjectDependencies) = postProject
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ice", "Ice", "{2CAF9731-CB18-498C-A3EF-24F3D8A334AC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "acm", "acm", "{C6B8BC64-0F88-4C57-A12D-A43372141F67}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{2D52604F-E2AD-4586-BBD7-BD13536C702C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testcommon", "..\test\Common\msbuild\testcommon.vcxproj", "{C7223CC8-0AAA-470B-ACB3-12B9DE75525C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Ice\acm\msbuild\server\server.vcxproj", "{FC4AC0A5-84D5-461F-BE52-EA686F52773E}"
ProjectSection(ProjectDependencies) = postProject
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "adapterDeactivation", "adapterDeactivation", "{295C483A-8A84-4AEE-9F17-26B1A2422B2D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Ice\adapterDeactivation\msbuild\client\client.vcxproj", "{715411FA-34B3-4ABF-8476-3C84F5EFFFE5}"
Expand Down Expand Up @@ -1144,14 +1132,6 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Debug|Win32.ActiveCfg = Debug|Win32
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Debug|Win32.Build.0 = Debug|Win32
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Debug|x64.ActiveCfg = Debug|x64
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Debug|x64.Build.0 = Debug|x64
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Release|Win32.ActiveCfg = Release|Win32
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Release|Win32.Build.0 = Release|Win32
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Release|x64.ActiveCfg = Release|x64
{CD25A05C-228D-473F-A86F-6C2DD22085B4}.Release|x64.Build.0 = Release|x64
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C}.Debug|Win32.ActiveCfg = Debug|Win32
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C}.Debug|Win32.Build.0 = Debug|Win32
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C}.Debug|x64.ActiveCfg = Debug|x64
Expand All @@ -1160,14 +1140,6 @@ Global
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C}.Release|Win32.Build.0 = Release|Win32
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C}.Release|x64.ActiveCfg = Release|x64
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C}.Release|x64.Build.0 = Release|x64
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Debug|Win32.ActiveCfg = Debug|Win32
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Debug|Win32.Build.0 = Debug|Win32
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Debug|x64.ActiveCfg = Debug|x64
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Debug|x64.Build.0 = Debug|x64
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Release|Win32.ActiveCfg = Release|Win32
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Release|Win32.Build.0 = Release|Win32
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Release|x64.ActiveCfg = Release|x64
{FC4AC0A5-84D5-461F-BE52-EA686F52773E}.Release|x64.Build.0 = Release|x64
{715411FA-34B3-4ABF-8476-3C84F5EFFFE5}.Debug|Win32.ActiveCfg = Debug|Win32
{715411FA-34B3-4ABF-8476-3C84F5EFFFE5}.Debug|Win32.Build.0 = Debug|Win32
{715411FA-34B3-4ABF-8476-3C84F5EFFFE5}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -2653,10 +2625,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CD25A05C-228D-473F-A86F-6C2DD22085B4} = {C6B8BC64-0F88-4C57-A12D-A43372141F67}
{C6B8BC64-0F88-4C57-A12D-A43372141F67} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC}
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {2D52604F-E2AD-4586-BBD7-BD13536C702C}
{FC4AC0A5-84D5-461F-BE52-EA686F52773E} = {C6B8BC64-0F88-4C57-A12D-A43372141F67}
{295C483A-8A84-4AEE-9F17-26B1A2422B2D} = {2CAF9731-CB18-498C-A3EF-24F3D8A334AC}
{715411FA-34B3-4ABF-8476-3C84F5EFFFE5} = {295C483A-8A84-4AEE-9F17-26B1A2422B2D}
{5D38E70A-98C1-4B1D-BC0D-01BC114078C5} = {295C483A-8A84-4AEE-9F17-26B1A2422B2D}
Expand Down
16 changes: 0 additions & 16 deletions cpp/src/Glacier2/Glacier2Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ RouterService::start(int argc, char* argv[], int& status)
return false;
}

if (properties->getProperty("Glacier2.Client.ACM.Close").empty())
{
properties->setProperty("Glacier2.Client.ACM.Close", "4"); // Forcefull close on invocation and idle.
}

auto clientAdapter = communicator()->createObjectAdapter("Glacier2.Client");

//
Expand Down Expand Up @@ -450,22 +445,11 @@ RouterService::initializeCommunicator(
}
}

//
// Active connection management is permitted with Glacier2. For
// the client object adapter, the ACM timeout is set to the
// session timeout to ensure client connections are not closed
// prematurely,
//
// initData.properties->setProperty("Ice.ACM.Client", "0");
// initData.properties->setProperty("Ice.ACM.Server", "0");

//
// We do not need to set Ice.RetryIntervals to -1, i.e., we do
// not have to disable connection retry. It is safe for
// Glacier2 to retry outgoing connections to servers. Retry
// for incoming connections from clients must be disabled in
// the clients.
//

return Service::initializeCommunicator(argc, argv, initData, version);
}
Expand Down
8 changes: 5 additions & 3 deletions cpp/src/Glacier2/SessionRouterI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,13 +824,15 @@ SessionRouterI::destroySession(const ConnectionPtr& connection)
int64_t
SessionRouterI::getSessionTimeout(const Ice::Current& current) const
{
return current.con->getACM().timeout;
return getACMTimeout(current);
}

int
SessionRouterI::getACMTimeout(const Ice::Current& current) const
SessionRouterI::getACMTimeout(const Ice::Current&) const
{
return current.con->getACM().timeout;
// TODO: better way to retrieve idle timeout
int idleTimeout = _instance->properties()->getPropertyAsIntWithDefault("Ice.Connection.IdleTimeout", 60);
return _instance->properties()->getPropertyAsIntWithDefault("Glacier2.Client.Connection.IdleTimeout", idleTimeout);
}

void
Expand Down
21 changes: 9 additions & 12 deletions cpp/src/Glacier2Lib/SessionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,20 +450,22 @@ SessionHelperI::connected(const Glacier2::RouterPrx& router, const optional<Glac
//
Ice::ConnectionPtr conn = router->ice_getCachedConnection();
string category = router->getCategoryForClient();
int32_t acmTimeout = 0;
int32_t remoteIdleTimeout = 0;
try
{
acmTimeout = router->getACMTimeout();
remoteIdleTimeout = router->getACMTimeout();
}
catch (const Ice::OperationNotExistException&)
{
}

if (acmTimeout <= 0)
if (remoteIdleTimeout <= 0)
{
acmTimeout = static_cast<int32_t>(router->getSessionTimeout());
remoteIdleTimeout = static_cast<int32_t>(router->getSessionTimeout());
}

// TODO: verify remote idle timeout is compatible with local idle timeout

//
// We create the callback object adapter here because createObjectAdapter internally
// makes synchronous RPCs to the router. We can't create the OA on-demand when the
Expand Down Expand Up @@ -495,14 +497,9 @@ SessionHelperI::connected(const Glacier2::RouterPrx& router, const optional<Glac
_session = session;
_connected = true;

if (acmTimeout > 0)
{
Ice::ConnectionPtr connection = _router->ice_getCachedConnection();
assert(connection);
connection->setACM(acmTimeout, nullopt, Ice::ACMHeartbeat::HeartbeatAlways);
auto self = shared_from_this();
connection->setCloseCallback([self](Ice::ConnectionPtr) { self->destroy(); });
}
Ice::ConnectionPtr connection = _router->ice_getCachedConnection();
assert(connection);
connection->setCloseCallback([self = shared_from_this()](Ice::ConnectionPtr) { self->destroy(); });
}
}

Expand Down
Loading

0 comments on commit cb549b2

Please sign in to comment.