From 1ec5b46781ae2ceb0153d0d83da6cf5f03f73114 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 15 Jan 2025 14:52:46 +0100 Subject: [PATCH] Allow configuring DataStorm node name (#3357) * Add DataStorm.Node.Name property --- config/PropertyNames.xml | 1 + cpp/src/DataStorm/Instance.cpp | 7 ++++- cpp/src/DataStorm/NodeI.cpp | 4 +-- cpp/src/DataStorm/NodeI.h | 2 +- cpp/src/Ice/PropertyNames.cpp | 3 ++- cpp/test/DataStorm/reliability/test.py | 36 +++++++++++++++++++++----- 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 4065b58e0e3..4211839a601 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -399,6 +399,7 @@
+ diff --git a/cpp/src/DataStorm/Instance.cpp b/cpp/src/DataStorm/Instance.cpp index f729dbca655..fc3d0fc4ba2 100644 --- a/cpp/src/DataStorm/Instance.cpp +++ b/cpp/src/DataStorm/Instance.cpp @@ -108,7 +108,12 @@ Instance::init() _topicFactory = make_shared(self); - _node = make_shared(self); + string name = _communicator->getProperties()->getIceProperty("DataStorm.Node.Name"); + if (name.empty()) + { + name = generateUUID(); + } + _node = make_shared(self, std::move(name)); _node->init(); _nodeSessionManager = make_shared(self, _node); diff --git a/cpp/src/DataStorm/NodeI.cpp b/cpp/src/DataStorm/NodeI.cpp index 6a352b0b151..54ab9f62716 100644 --- a/cpp/src/DataStorm/NodeI.cpp +++ b/cpp/src/DataStorm/NodeI.cpp @@ -46,9 +46,9 @@ namespace }; } -NodeI::NodeI(const shared_ptr& instance) +NodeI::NodeI(const shared_ptr& instance, std::string name) : _instance(instance), - _proxy{instance->getObjectAdapter()->createProxy(Identity{.name = generateUUID(), .category = ""})}, + _proxy{instance->getObjectAdapter()->createProxy(Identity{.name = std::move(name), .category = ""})}, // The subscriber and publisher collocated forwarders are initalized here to avoid using a nullable proxy. These // objects are only used after the node is initialized and are removed in destroy implementation. _publisherForwarder{instance->getCollocatedForwarder()->add( diff --git a/cpp/src/DataStorm/NodeI.h b/cpp/src/DataStorm/NodeI.h index b7f6e9594dd..095d3b48200 100644 --- a/cpp/src/DataStorm/NodeI.h +++ b/cpp/src/DataStorm/NodeI.h @@ -22,7 +22,7 @@ namespace DataStormI class NodeI final : public virtual DataStormContract::Node, public std::enable_shared_from_this { public: - NodeI(const std::shared_ptr&); + NodeI(const std::shared_ptr&, std::string); ~NodeI() final; void init(); diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index e366a4e3d15..863d7eff3c8 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -562,6 +562,7 @@ const PropertyArray PropertyNames::Glacier2Props const Property DataStormPropsData[] = { + Property{"Node.Name", "", false, false, nullptr}, Property{"Node.ConnectTo", "", false, false, nullptr}, Property{"Node.Multicast", "", false, false, &PropertyNames::ObjectAdapterProps}, Property{"Node.Multicast.Enabled", "1", false, false, nullptr}, @@ -588,7 +589,7 @@ const PropertyArray PropertyNames::DataStormProps .prefixOnly=false, .isOptIn=true, .properties=DataStormPropsData, - .length=18 + .length=19 }; const std::array PropertyNames::validProps = diff --git a/cpp/test/DataStorm/reliability/test.py b/cpp/test/DataStorm/reliability/test.py index cd7405f776b..ff7f46d2849 100644 --- a/cpp/test/DataStorm/reliability/test.py +++ b/cpp/test/DataStorm/reliability/test.py @@ -81,17 +81,41 @@ ] testcases = [] -for (name, readerProps, writerProps, nodeProps, node2Props, reversedStart) in props: +for (name, clientProps, serverProps, nodeProps, node2Props, reversedStart) in props: if reversedStart: name += " (reversed start order)" - c = Reader(props=writerProps) if reversedStart else Writer(props=readerProps) - s = Writer(props=readerProps) if reversedStart else Reader(props=writerProps) + + readerProps = dict(serverProps) + writerProps = dict(clientProps) + else: + readerProps = dict(clientProps) + writerProps = dict(serverProps) + + readerProps["DataStorm.Node.Name"] = "reader-app" + writerProps["DataStorm.Node.Name"] = "writer-app" + + if nodeProps: + nodeProps["DataStorm.Node.Name"] = "relay-node-1" + + if node2Props: + node2Props["DataStorm.Node.Name"] = "relay-node-2" + + reader = Reader(props=readerProps) + writer = Writer(props=writerProps) + + if reversedStart: + client = writer + server = reader + else: + client = reader + server = writer + if node2Props: nodes = [Node(desc="node1", props=nodeProps), Node(desc="node2", props=node2Props)] - testcases.append(NodeTestCase(name=name, client=c, server=s, nodes=nodes, traceProps=traceProps)) + testcases.append(NodeTestCase(name=name, client=client, server=server, nodes=nodes, traceProps=traceProps)) elif nodeProps: - testcases.append(NodeTestCase(name=name, client=c, server=s, nodeProps=nodeProps, traceProps=traceProps)) + testcases.append(NodeTestCase(name=name, client=client, server=server, nodeProps=nodeProps, traceProps=traceProps)) else: - testcases.append(ClientServerTestCase(name=name, client=c, server=s, traceProps=traceProps)) + testcases.append(ClientServerTestCase(name=name, client=client, server=server, traceProps=traceProps)) TestSuite(__file__, testcases)