Skip to content
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

Upgrade DataStorm to use a Default OA for OutgoingConnections #3355

Merged
merged 5 commits into from
Jan 14, 2025

Conversation

pepone
Copy link
Member

@pepone pepone commented Jan 14, 2025

This PR upgrades DataStorm implementation to use setDefaultObjectAdapter to set a default object adapter for outgoing connections. See #3337

@@ -210,15 +210,15 @@ namespace Ice
* @return The object adapter associated by default with new outgoing connections.
* @see Connection::getAdapter
*/
[[nodiscard]] ObjectAdapterPtr getDefaultObjectAdapter() const noexcept;
[[nodiscard]] ObjectAdapterPtr getDefaultObjectAdapter() const;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because it can throw CommunicatorDestroyedExcetion

@@ -19,6 +19,12 @@ using namespace Ice;
Instance::Instance(CommunicatorPtr communicator, function<void(function<void()> call)> customExecutor)
: _communicator(std::move(communicator))
{
if (_communicator->getDefaultObjectAdapter() != nullptr)
Copy link
Member Author

@pepone pepone Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wont catch some cases where the application set a default OA after starting the Node. For those we need to relay in the documentation.

Node n2(Ice::initialize(initData));
n2.getCommunicator()->destroy();
Ice::CommunicatorHolder communicatorHolder(Ice::initialize(initData));
Node n2(communicatorHolder.communicator());
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code would destroy the communicator before destroying the node, which now results in CommunicatorDestroyerException thrown from DataStormI::Instance::destroy.

@@ -179,6 +186,7 @@ Instance::destroy(bool ownsCommunicator)
timer->destroy();
}

_communicator->setDefaultObjectAdapter(nullptr);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would throw CommunicatorDestroyedException exception if the application destroys the communicator before destroying the node. I believe this is acceptable, as the application should not destroy the communicator passed to a DataStorm node before destroying the node itself.

cout << "testing send time discard policy... " << flush;
{
writers.update(false); // Not ready
vector<tuple<Ice::CommunicatorHolder, Node, Topic<string, int>, SingleKeyWriter<string, int>>> w;
vector<WriterHolder> w;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid the undefined destruction order of tuples, we don't want the communicator to be destroyed before than the node.

@@ -19,6 +19,12 @@ using namespace Ice;
Instance::Instance(CommunicatorPtr communicator, function<void(function<void()> call)> customExecutor)
: _communicator(std::move(communicator))
{
if (_communicator->getDefaultObjectAdapter() != nullptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our usual style is if (_communicator->getDefaultObjectAdapter()) ...

@@ -36,8 +36,8 @@ void ::Writer::run(int argc, char* argv[])
// Communicators shared with DataStorm must have a property set that can use the "DataStorm" opt-in prefix.
Ice::InitializationData initData;
initData.properties = make_shared<Ice::Properties>(vector<string>{"DataStorm"});
Node n2(Ice::initialize(initData));
n2.getCommunicator()->destroy();
Ice::CommunicatorHolder communicatorHolder(Ice::initialize(initData));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use {} for ctors.

@pepone pepone merged commit e570ced into zeroc-ice:main Jan 14, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants