Skip to content

Commit

Permalink
Allow configuring DataStorm node name (#3357)
Browse files Browse the repository at this point in the history
* Add DataStorm.Node.Name property
  • Loading branch information
pepone authored Jan 15, 2025
1 parent 71e8946 commit 1ec5b46
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions config/PropertyNames.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
</section>

<section name="DataStorm" opt-in="true">
<property name="Node.Name" languages="cpp" />
<property name="Node.ConnectTo" languages="cpp" />
<property name="Node.Multicast" class="ObjectAdapter" languages="cpp" />
<property name="Node.Multicast.Enabled" default="1" languages="cpp" />
Expand Down
7 changes: 6 additions & 1 deletion cpp/src/DataStorm/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ Instance::init()

_topicFactory = make_shared<TopicFactoryI>(self);

_node = make_shared<NodeI>(self);
string name = _communicator->getProperties()->getIceProperty("DataStorm.Node.Name");
if (name.empty())
{
name = generateUUID();
}
_node = make_shared<NodeI>(self, std::move(name));
_node->init();

_nodeSessionManager = make_shared<NodeSessionManager>(self, _node);
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/DataStorm/NodeI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ namespace
};
}

NodeI::NodeI(const shared_ptr<Instance>& instance)
NodeI::NodeI(const shared_ptr<Instance>& instance, std::string name)
: _instance(instance),
_proxy{instance->getObjectAdapter()->createProxy<NodePrx>(Identity{.name = generateUUID(), .category = ""})},
_proxy{instance->getObjectAdapter()->createProxy<NodePrx>(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<PublisherSessionPrx>(
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/DataStorm/NodeI.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace DataStormI
class NodeI final : public virtual DataStormContract::Node, public std::enable_shared_from_this<NodeI>
{
public:
NodeI(const std::shared_ptr<Instance>&);
NodeI(const std::shared_ptr<Instance>&, std::string);
~NodeI() final;

void init();
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/Ice/PropertyNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -588,7 +589,7 @@ const PropertyArray PropertyNames::DataStormProps
.prefixOnly=false,
.isOptIn=true,
.properties=DataStormPropsData,
.length=18
.length=19
};

const std::array<PropertyArray, 15> PropertyNames::validProps =
Expand Down
36 changes: 30 additions & 6 deletions cpp/test/DataStorm/reliability/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 1ec5b46

Please sign in to comment.