Skip to content

Commit

Permalink
Removed buffered mode and _ovrd from Glacier2 (#2807)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Sep 27, 2024
1 parent aa38119 commit 2846e40
Show file tree
Hide file tree
Showing 31 changed files with 59 additions and 1,860 deletions.
6 changes: 0 additions & 6 deletions config/PropertyNames.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,7 @@ generated from the section label.
<section name="Glacier2">
<property name="AddConnectionContext" languages="cpp" default="0" />
<property name="Client" languages="cpp" class="objectadapter"/>
<property name="Client.Buffered" languages="cpp" default="1" />
<property name="Client.ForwardContext" languages="cpp" default="0" />
<property name="Client.SleepTime" languages="cpp" default="0" />
<property name="Client.Trace.Override" languages="cpp" default="0" />
<property name="Client.Trace.Reject" languages="cpp" default="0" />
<property name="Client.Trace.Request" languages="cpp" default="0" />
<property name="CryptPasswords" languages="cpp" />
Expand All @@ -540,10 +537,7 @@ generated from the section label.
<property name="SSLPermissionsVerifier" class="proxy" languages="cpp" />
<property name="RoutingTable.MaxSize" languages="cpp" default="1000" />
<property name="Server" class="objectadapter" languages="cpp" />
<property name="Server.Buffered" languages="cpp" default="1" />
<property name="Server.ForwardContext" languages="cpp" default="0" />
<property name="Server.SleepTime" languages="cpp" default="0" />
<property name="Server.Trace.Override" languages="cpp" default="0" />
<property name="Server.Trace.Request" languages="cpp" default="0" />
<property name="SessionManager" class="proxy" languages="cpp" />
<property name="SSLSessionManager" class="proxy" languages="cpp" />
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 @@ -553,18 +553,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Glacier2\
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "override", "override", "{5EE5BF6D-076E-490D-B31D-E01AD72EE103}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Glacier2\override\msbuild\client\client.vcxproj", "{3C394401-8E95-475B-8B35-B90A7CCAE578}"
ProjectSection(ProjectDependencies) = postProject
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "..\test\Glacier2\override\msbuild\server\server.vcxproj", "{E1510790-AF0B-4FFE-B6AA-B75119793AFC}"
ProjectSection(ProjectDependencies) = postProject
{C7223CC8-0AAA-470B-ACB3-12B9DE75525C} = {C7223CC8-0AAA-470B-ACB3-12B9DE75525C}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "router", "router", "{416598FC-0620-4246-8012-6BB99446C2EF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "..\test\Glacier2\router\msbuild\client\client.vcxproj", "{7CB05069-58C9-4C7D-A6A6-DBFB1CE7C58C}"
Expand Down Expand Up @@ -1875,22 +1863,6 @@ Global
{814690FE-2C4F-4EF4-82CB-720BC4C8FF9B}.Release|Win32.Build.0 = Release|Win32
{814690FE-2C4F-4EF4-82CB-720BC4C8FF9B}.Release|x64.ActiveCfg = Release|x64
{814690FE-2C4F-4EF4-82CB-720BC4C8FF9B}.Release|x64.Build.0 = Release|x64
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Debug|Win32.ActiveCfg = Debug|Win32
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Debug|Win32.Build.0 = Debug|Win32
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Debug|x64.ActiveCfg = Debug|x64
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Debug|x64.Build.0 = Debug|x64
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Release|Win32.ActiveCfg = Release|Win32
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Release|Win32.Build.0 = Release|Win32
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Release|x64.ActiveCfg = Release|x64
{3C394401-8E95-475B-8B35-B90A7CCAE578}.Release|x64.Build.0 = Release|x64
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Debug|Win32.ActiveCfg = Debug|Win32
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Debug|Win32.Build.0 = Debug|Win32
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Debug|x64.ActiveCfg = Debug|x64
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Debug|x64.Build.0 = Debug|x64
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Release|Win32.ActiveCfg = Release|Win32
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Release|Win32.Build.0 = Release|Win32
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Release|x64.ActiveCfg = Release|x64
{E1510790-AF0B-4FFE-B6AA-B75119793AFC}.Release|x64.Build.0 = Release|x64
{7CB05069-58C9-4C7D-A6A6-DBFB1CE7C58C}.Debug|Win32.ActiveCfg = Debug|Win32
{7CB05069-58C9-4C7D-A6A6-DBFB1CE7C58C}.Debug|Win32.Build.0 = Debug|Win32
{7CB05069-58C9-4C7D-A6A6-DBFB1CE7C58C}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -2829,9 +2801,6 @@ Global
{5F5555CC-6370-44BE-9234-8B86F71245B8} = {4CE3B59A-59E3-4182-82BE-A92BD4FC9657}
{14C78FC0-F80C-425F-A504-1DD264BCDD01} = {5F5555CC-6370-44BE-9234-8B86F71245B8}
{814690FE-2C4F-4EF4-82CB-720BC4C8FF9B} = {5F5555CC-6370-44BE-9234-8B86F71245B8}
{5EE5BF6D-076E-490D-B31D-E01AD72EE103} = {4CE3B59A-59E3-4182-82BE-A92BD4FC9657}
{3C394401-8E95-475B-8B35-B90A7CCAE578} = {5EE5BF6D-076E-490D-B31D-E01AD72EE103}
{E1510790-AF0B-4FFE-B6AA-B75119793AFC} = {5EE5BF6D-076E-490D-B31D-E01AD72EE103}
{416598FC-0620-4246-8012-6BB99446C2EF} = {4CE3B59A-59E3-4182-82BE-A92BD4FC9657}
{7CB05069-58C9-4C7D-A6A6-DBFB1CE7C58C} = {416598FC-0620-4246-8012-6BB99446C2EF}
{3BD0D95D-8DC6-4A07-B4D9-72EC85C4C97A} = {416598FC-0620-4246-8012-6BB99446C2EF}
Expand Down
192 changes: 50 additions & 142 deletions cpp/src/Glacier2/Blobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace
constexpr string_view clientForwardContext = "Glacier2.Client.ForwardContext";
constexpr string_view serverTraceRequest = "Glacier2.Server.Trace.Request";
constexpr string_view clientTraceRequest = "Glacier2.Client.Trace.Request";
constexpr string_view serverTraceOverride = "Glacier2.Server.Trace.Override";
constexpr string_view clientTraceOverride = "Glacier2.Client.Trace.Override";
}

Glacier2::Blobject::Blobject(shared_ptr<Instance> instance, ConnectionPtr reverseConnection, const Context& context)
Expand All @@ -30,35 +28,8 @@ Glacier2::Blobject::Blobject(shared_ptr<Instance> instance, ConnectionPtr revers
_requestTraceLevel(
_reverseConnection ? _instance->properties()->getIcePropertyAsInt(serverTraceRequest)
: _instance->properties()->getIcePropertyAsInt(clientTraceRequest)),
_overrideTraceLevel(
reverseConnection ? _instance->properties()->getIcePropertyAsInt(serverTraceOverride)
: _instance->properties()->getIcePropertyAsInt(clientTraceOverride)),
_context(context)
{
auto t = _reverseConnection ? _instance->serverRequestQueueThread() : _instance->clientRequestQueueThread();
if (t)
{
const_cast<shared_ptr<RequestQueue>&>(_requestQueue) =
make_shared<RequestQueue>(t, _instance, _reverseConnection);
}
}

void
Glacier2::Blobject::destroy()
{
if (_requestQueue)
{
_requestQueue->destroy();
}
}

void
Glacier2::Blobject::updateObserver(const shared_ptr<Glacier2::Instrumentation::SessionObserver>& observer)
{
if (_requestQueue)
{
_requestQueue->updateObserver(observer);
}
}

void
Expand Down Expand Up @@ -163,14 +134,6 @@ Glacier2::Blobject::invoke(
out << "reverse ";
}
out << "routing";
if (_requestQueue)
{
out << " (buffered)";
}
else
{
out << " (not buffered)";
}
if (_reverseConnection)
{
out << "\nidentity = " << _instance->communicator()->identityToString(proxy->ice_getIdentity());
Expand All @@ -192,131 +155,76 @@ Glacier2::Blobject::invoke(
}
}

if (_requestQueue)
try
{
//
// If we are in buffered mode, we create a new request and add
// it to the request queue. If the request is twoway, we use
// AMI.
//
function<void(bool, pair<const byte*, const byte*>)> amiResponse = nullptr;
function<void(bool)> amiSent = nullptr;

bool override;
try
if (proxy->ice_isTwoway())
{
override = _requestQueue->addRequest(
make_shared<
Request>(proxy, inParams, current, _forwardContext, _context, std::move(response), exception));
amiResponse = std::move(response);
}
catch (const ObjectNotExistException&)
else
{
exception(current_exception());
return;
// For oneway requests, we want the dispatch to complete only once the request has been forwarded (sent).
// This ensures proper flow control / back pressure through the Glacier2 router.
amiSent = [amdResponse = std::move(response)](bool) { amdResponse(true, {nullptr, nullptr}); };
}

if (override && _overrideTraceLevel >= 1)
if (_forwardContext)
{
Trace out(_instance->logger(), "Glacier2");
if (_reverseConnection)
{
out << "reverse ";
}
out << "routing override";
if (_reverseConnection)
if (_context.size() > 0)
{
out << "\nidentity = " << _instance->communicator()->identityToString(proxy->ice_getIdentity());
Context ctx = current.ctx;
ctx.insert(_context.begin(), _context.end());
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
exception,
std::move(amiSent),
ctx);
}
else
{
out << "\nproxy = " << proxy;
}
out << "\noperation = " << current.operation;
out << "\ncontext = ";
Context::const_iterator q = current.ctx.begin();
while (q != current.ctx.end())
{
out << q->first << '/' << q->second;
if (++q != current.ctx.end())
{
out << ", ";
}
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
exception,
std::move(amiSent),
current.ctx);
}
}
}
else
{
//
// If we are in not in buffered mode, we send the request directly.
//

try
else
{
function<void(bool, pair<const byte*, const byte*>)> amiResponse = nullptr;
function<void(bool)> amiSent = nullptr;

if (proxy->ice_isTwoway())
{
amiResponse = std::move(response);
}
else
{
amiSent = [amdResponse = std::move(response)](bool) { amdResponse(true, {nullptr, nullptr}); };
}

if (_forwardContext)
if (_context.size() > 0)
{
if (_context.size() > 0)
{
Context ctx = current.ctx;
ctx.insert(_context.begin(), _context.end());
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
std::move(exception),
std::move(amiSent),
ctx);
}
else
{
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
std::move(exception),
std::move(amiSent),
current.ctx);
}
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
exception,
std::move(amiSent),
_context);
}
else
{
if (_context.size() > 0)
{
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
std::move(exception),
std::move(amiSent),
_context);
}
else
{
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
std::move(exception),
std::move(amiSent));
}
proxy->ice_invokeAsync(
current.operation,
current.mode,
inParams,
std::move(amiResponse),
exception,
std::move(amiSent));
}
}
catch (const LocalException&)
{
exception(current_exception());
}
}
catch (const LocalException&)
{
exception(current_exception());
}
}
8 changes: 0 additions & 8 deletions cpp/src/Glacier2/Blobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@

#include "Ice/Ice.h"
#include "Instance.h"
#include "RequestQueue.h"

namespace Glacier2
{
class Blobject : public Ice::BlobjectArrayAsync, public std::enable_shared_from_this<Blobject>
{
public:
Blobject(std::shared_ptr<Instance>, Ice::ConnectionPtr, const Ice::Context&);

void destroy();

virtual void updateObserver(const std::shared_ptr<Instrumentation::SessionObserver>&);

void invokeException(std::exception_ptr, std::function<void(std::exception_ptr)>&&);

protected:
Expand All @@ -36,8 +30,6 @@ namespace Glacier2
private:
const bool _forwardContext;
const int _requestTraceLevel;
const int _overrideTraceLevel;
const std::shared_ptr<RequestQueue> _requestQueue;
const Ice::Context _context;
};
}
Expand Down
32 changes: 0 additions & 32 deletions cpp/src/Glacier2/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
using namespace std;
using namespace Glacier2;

namespace
{
constexpr string_view serverSleepTime = "Glacier2.Server.SleepTime";
constexpr string_view clientSleepTime = "Glacier2.Client.SleepTime";
constexpr string_view serverBuffered = "Glacier2.Server.Buffered";
constexpr string_view clientBuffered = "Glacier2.Client.Buffered";
}

Glacier2::Instance::Instance(
shared_ptr<Ice::Communicator> communicator,
Ice::ObjectAdapterPtr clientAdapter,
Expand All @@ -29,20 +21,6 @@ Glacier2::Instance::Instance(
_serverAdapter(std::move(serverAdapter)),
_proxyVerifier(make_shared<ProxyVerifier>(_communicator))
{
if (_properties->getIcePropertyAsInt(serverBuffered) > 0)
{
auto sleepTime = chrono::milliseconds(_properties->getIcePropertyAsInt(serverSleepTime));
const_cast<shared_ptr<RequestQueueThread>&>(_serverRequestQueueThread) =
make_shared<RequestQueueThread>(sleepTime);
}

if (_properties->getIcePropertyAsInt(clientBuffered) > 0)
{
auto sleepTime = chrono::milliseconds(_properties->getIcePropertyAsInt(clientSleepTime));
const_cast<shared_ptr<RequestQueueThread>&>(_clientRequestQueueThread) =
make_shared<RequestQueueThread>(sleepTime);
}

//
// If an Ice metrics observer is setup on the communicator, also enable metrics for Glacier2.
//
Expand All @@ -57,16 +35,6 @@ Glacier2::Instance::Instance(
void
Glacier2::Instance::destroy()
{
if (_clientRequestQueueThread)
{
_clientRequestQueueThread->destroy();
}

if (_serverRequestQueueThread)
{
_serverRequestQueueThread->destroy();
}

_sessionRouter = nullptr;
}

Expand Down
Loading

0 comments on commit 2846e40

Please sign in to comment.