Skip to content

Commit

Permalink
Add DataStorm properties to config/PropertyNames.xml (#2933)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone authored Oct 21, 2024
1 parent aac2e84 commit a4f3760
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 54 deletions.
15 changes: 15 additions & 0 deletions config/PropertyNames.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,19 @@
<property name="Trace.RoutingTable" languages="cpp" default="0" />
<property name="Trace.Session" languages="cpp" default="0" />
</section>

<section name="DataStorm">
<property name="Node.ConnectTo" languages="cpp" />
<property name="Node.Multicast" class="ObjectAdapter" languages="cpp" />
<property name="Node.Multicast.Enabled" default="1" languages="cpp" />
<property name="Node.RetryCount" default="6" languages="cpp" />
<property name="Node.RetryDelay" default="500" languages="cpp" />
<property name="Node.RetryMultiplier" default="2" languages="cpp" />
<property name="Node.Server" class="ObjectAdapter" languages="cpp" />
<property name="Node.Server.Enabled" default="1" languages="cpp" />
<property name="Node.Server.ForwardDiscoveryToMulticast" default="0" languages="cpp" />
<property name="Trace.Data" default="0" languages="cpp" />
<property name="Trace.Session" default="0" languages="cpp" />
<property name="Trace.Topic" default="0" languages="cpp" />
</section>
</properties>
56 changes: 20 additions & 36 deletions cpp/src/DataStorm/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,23 @@ Instance::Instance(const Ice::CommunicatorPtr& communicator) : _communicator(com
{
Ice::PropertiesPtr properties = _communicator->getProperties();

if (properties->getPropertyAsIntWithDefault("DataStorm.Node.Server.Enabled", 1) > 0)
if (properties->getIcePropertyAsInt("DataStorm.Node.Server.Enabled") > 0)
{
properties->setProperty("DataStorm.Node.Adapters.Server.ThreadPool.SizeMax", "1");
properties->setProperty("DataStorm.Node.Adapters.Server.Endpoints", "tcp");

const string pfx = "DataStorm.Node.Server";
auto props = properties->getPropertiesForPrefix(pfx);
for (const auto& p : props)
if (properties->getIceProperty("DataStorm.Node.Server.Endpoints").empty())
{
if (p.first != "DataStorm.Node.Server.Enabled" &&
p.first != "DataStorm.Node.Server.ForwardDiscoveryToMulticast")
{
properties->setProperty("DataStorm.Node.Adapters.Server" + p.first.substr(pfx.length()), p.second);
}
properties->setProperty("DataStorm.Node.Server.Endpoints", "tcp");
}
properties->setProperty("DataStorm.Node.Server.ThreadPool.SizeMax", "1");

try
{
_adapter = _communicator->createObjectAdapter("DataStorm.Node.Adapters.Server");
_adapter = _communicator->createObjectAdapter("DataStorm.Node.Server");
}
catch (const Ice::LocalException& ex)
{
ostringstream os;
os << "failed to listen on server endpoints `";
os << properties->getProperty("DataStorm.Node.Adapters.Server.Endpoints") << "':\n";
os << properties->getIceProperty("DataStorm.Node.Server.Endpoints") << "':\n";
os << ex.what();
throw invalid_argument(os.str());
}
Expand All @@ -53,42 +45,34 @@ Instance::Instance(const Ice::CommunicatorPtr& communicator) : _communicator(com
_adapter = _communicator->createObjectAdapter("");
}

if (properties->getPropertyAsIntWithDefault("DataStorm.Node.Multicast.Enabled", 1) > 0)
if (properties->getIcePropertyAsInt("DataStorm.Node.Multicast.Enabled") > 0)
{
properties->setProperty("DataStorm.Node.Adapters.Multicast.Endpoints", "udp -h 239.255.0.1 -p 10000");
// Set the published host to the multicast address, ensuring that proxies are created with the multicast
// address.
properties->setProperty("DataStorm.Node.Adapters.Multicast.PublishedHost", "239.255.0.1");
properties->setProperty("DataStorm.Node.Adapters.Multicast.ProxyOptions", "-d");
properties->setProperty("DataStorm.Node.Adapters.Multicast.ThreadPool.SizeMax", "1");

const string pfx = "DataStorm.Node.Multicast";
auto props = properties->getPropertiesForPrefix(pfx);
for (const auto& p : props)
if (properties->getIceProperty("DataStorm.Node.Multicast.Endpoints").empty())
{
if (p.first != "DataStorm.Node.Multicast.Enabled")
{
properties->setProperty("DataStorm.Node.Adapters.Multicast" + p.first.substr(pfx.length()), p.second);
}
properties->setProperty("DataStorm.Node.Multicast.Endpoints", "udp -h 239.255.0.1 -p 10000");
// Set the published host to the multicast address, ensuring that proxies are created with the multicast
// address.
properties->setProperty("DataStorm.Node.Multicast.PublishedHost", "239.255.0.1");
}
properties->setProperty("DataStorm.Node.Multicast.ThreadPool.SizeMax", "1");

try
{
_multicastAdapter = _communicator->createObjectAdapter("DataStorm.Node.Adapters.Multicast");
_multicastAdapter = _communicator->createObjectAdapter("DataStorm.Node.Multicast");
}
catch (const Ice::LocalException& ex)
{
ostringstream os;
os << "failed to listen on multicast endpoints `";
os << properties->getProperty("DataStorm.Node.Adapters.Server.Endpoints") << "':\n";
os << properties->getIceProperty("DataStorm.Node.Multicast.Endpoints") << "':\n";
os << ex.what();
throw invalid_argument(os.str());
}
}

_retryDelay = chrono::milliseconds(properties->getPropertyAsIntWithDefault("DataStorm.Node.RetryDelay", 500));
_retryMultiplier = properties->getPropertyAsIntWithDefault("DataStorm.Node.RetryMultiplier", 2);
_retryCount = properties->getPropertyAsIntWithDefault("DataStorm.Node.RetryCount", 6);
_retryDelay = chrono::milliseconds(properties->getIcePropertyAsInt("DataStorm.Node.RetryDelay"));
_retryMultiplier = properties->getIcePropertyAsInt("DataStorm.Node.RetryMultiplier");
_retryCount = properties->getIcePropertyAsInt("DataStorm.Node.RetryCount");

//
// Create a collocated object adapter with a random name to prevent user configuration
Expand All @@ -104,7 +88,7 @@ Instance::Instance(const Ice::CommunicatorPtr& communicator) : _communicator(com
_executor = make_shared<CallbackExecutor>();
_connectionManager = make_shared<ConnectionManager>(_executor);
_timer = make_shared<IceInternal::Timer>();
_traceLevels = make_shared<TraceLevels>(_communicator);
_traceLevels = make_shared<TraceLevels>(properties, _communicator->getLogger());
}

void
Expand All @@ -125,7 +109,7 @@ Instance::init()
if (_multicastAdapter)
{
auto lookup = _multicastAdapter->add<DataStormContract::LookupPrx>(lookupI, {"Lookup", "DataStorm"});
_lookup = lookup->ice_collocationOptimized(false);
_lookup = lookup->ice_collocationOptimized(false)->ice_datagram();
}

_adapter->activate();
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/DataStorm/NodeSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ NodeSessionManager::NodeSessionManager(const shared_ptr<Instance>& instance, con
_traceLevels(instance->getTraceLevels()),
_nodePrx(node->getProxy()),
_forwardToMulticast(
instance->getCommunicator()->getProperties()->getPropertyAsInt(
instance->getCommunicator()->getProperties()->getIcePropertyAsInt(
"DataStorm.Node.Server.ForwardDiscoveryToMulticast") > 0),
_retryCount(0),
_forwarder(instance->getCollocatedForwarder()->add<LookupPrx>([this](Ice::ByteSeq e, const Ice::Current& c)
Expand All @@ -80,7 +80,7 @@ NodeSessionManager::init()
}

auto communicator = instance->getCommunicator();
auto connectTo = communicator->getProperties()->getProperty("DataStorm.Node.ConnectTo");
const string connectTo = communicator->getProperties()->getIceProperty("DataStorm.Node.ConnectTo");
if (!connectTo.empty())
{
connect(LookupPrx{communicator, "DataStorm/Lookup:" + connectTo}, _nodePrx);
Expand Down
15 changes: 5 additions & 10 deletions cpp/src/DataStorm/TraceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@
using namespace std;
using namespace DataStormI;

TraceLevels::TraceLevels(Ice::CommunicatorPtr communicator)
: topic(0),
TraceLevels::TraceLevels(const Ice::PropertiesPtr& properties, const Ice::LoggerPtr& logger)
: topic(properties->getIcePropertyAsInt("DataStorm.Trace.Topic")),
topicCat("Topic"),
data(0),
data(properties->getIcePropertyAsInt("DataStorm.Trace.Data")),
dataCat("Data"),
session(0),
session(properties->getIcePropertyAsInt("DataStorm.Trace.Session")),
sessionCat("Session"),
logger(communicator->getLogger())
logger(logger)
{
auto properties = communicator->getProperties();
const string keyBase = "DataStorm.Trace.";
const_cast<int&>(topic) = properties->getPropertyAsInt(keyBase + topicCat);
const_cast<int&>(data) = properties->getPropertyAsInt(keyBase + dataCat);
const_cast<int&>(session) = properties->getPropertyAsInt(keyBase + sessionCat);
}
2 changes: 1 addition & 1 deletion cpp/src/DataStorm/TraceUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace DataStormI
class TraceLevels
{
public:
TraceLevels(Ice::CommunicatorPtr);
TraceLevels(const Ice::PropertiesPtr&, const Ice::LoggerPtr&);

const int topic;
const char* topicCat;
Expand Down
29 changes: 27 additions & 2 deletions cpp/src/Ice/PropertyNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,31 @@ const PropertyArray PropertyNames::Glacier2Props
24
};

const std::array<PropertyArray, 14> PropertyNames::validProps =
const Property DataStormPropsData[] =
{
Property{"Node.ConnectTo", "", false, false, nullptr},
Property{"Node.Multicast", "", false, false, &PropertyNames::ObjectAdapterProps},
Property{"Node.Multicast.Enabled", "1", false, false, nullptr},
Property{"Node.RetryCount", "6", false, false, nullptr},
Property{"Node.RetryDelay", "500", false, false, nullptr},
Property{"Node.RetryMultiplier", "2", false, false, nullptr},
Property{"Node.Server", "", false, false, &PropertyNames::ObjectAdapterProps},
Property{"Node.Server.Enabled", "1", false, false, nullptr},
Property{"Node.Server.ForwardDiscoveryToMulticast", "0", false, false, nullptr},
Property{"Trace.Data", "0", false, false, nullptr},
Property{"Trace.Session", "0", false, false, nullptr},
Property{"Trace.Topic", "0", false, false, nullptr}
};

const PropertyArray PropertyNames::DataStormProps
{
"DataStorm",
false,
DataStormPropsData,
12
};

const std::array<PropertyArray, 15> PropertyNames::validProps =
{
IceProps,
IceMXProps,
Expand All @@ -554,5 +578,6 @@ const std::array<PropertyArray, 14> PropertyNames::validProps =
IceStormProps,
IceStormAdminProps,
IceBTProps,
Glacier2Props
Glacier2Props,
DataStormProps
};
3 changes: 2 additions & 1 deletion cpp/src/Ice/PropertyNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ namespace IceInternal
static const PropertyArray IceStormAdminProps;
static const PropertyArray IceBTProps;
static const PropertyArray Glacier2Props;
static const PropertyArray DataStormProps;

static const std::array<PropertyArray, 14> validProps;
static const std::array<PropertyArray, 15> validProps;
};
}

Expand Down
8 changes: 7 additions & 1 deletion csharp/src/Ice/Internal/PropertyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ internal sealed class PropertyNames
false,
[]);

internal static PropertyArray DataStormProps = new(
"DataStorm",
false,
[]);

internal static PropertyArray[] validProps =
[
IceProps,
Expand All @@ -290,6 +295,7 @@ internal sealed class PropertyNames
IceStormProps,
IceStormAdminProps,
IceBTProps,
Glacier2Props
Glacier2Props,
DataStormProps
];
}
9 changes: 8 additions & 1 deletion java/src/Ice/src/main/java/com/zeroc/Ice/PropertyNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ final class PropertyNames
new Property[] {
});

public static final PropertyArray DataStormProps = new PropertyArray(
"DataStorm",
false,
new Property[] {
});

public static final PropertyArray validProps[] =
{
IceProps,
Expand All @@ -310,6 +316,7 @@ final class PropertyNames
IceStormProps,
IceStormAdminProps,
IceBTProps,
Glacier2Props
Glacier2Props,
DataStormProps
};
}
4 changes: 4 additions & 0 deletions js/src/Ice/PropertyNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ PropertyNames.IceBTProps = new PropertyArray("IceBT", false, [
PropertyNames.Glacier2Props = new PropertyArray("Glacier2", false, [
]);

PropertyNames.DataStormProps = new PropertyArray("DataStorm", false, [
]);

PropertyNames.validProps = [
PropertyNames.IceProps,
PropertyNames.IceMXProps,
Expand All @@ -127,4 +130,5 @@ PropertyNames.validProps = [
PropertyNames.IceStormAdminProps,
PropertyNames.IceBTProps,
PropertyNames.Glacier2Props,
PropertyNames.DataStormProps,
];
2 changes: 2 additions & 0 deletions scripts/DataStormUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def getEffectiveProps(self, current, props):
props = DataStormProcess.getEffectiveProps(self, current, props)
if ("DataStorm.Node.Multicast.Enabled", 1) in props.items():
props["DataStorm.Node.Multicast.Endpoints"] = f"udp -h 239.255.0.1 -p {current.driver.getTestPort(20)}"
props["DataStorm.Node.Multicast.PublishedHost"] = "239.255.0.1"
elif not any(key.startswith("DataStorm.Node.") for key in props):
# Default properties for tests that don't specify any DataStorm.Node.* properties
props.update(
Expand All @@ -57,6 +58,7 @@ def getEffectiveProps(self, current, props):
props = DataStormProcess.getEffectiveProps(self, current, props)
if ("DataStorm.Node.Multicast.Enabled", 1) in props.items():
props["DataStorm.Node.Multicast.Endpoints"] = f"udp -h 239.255.0.1 -p {current.driver.getTestPort(20)}"
props["DataStorm.Node.Multicast.PublishedHost"] = "239.255.0.1"
elif not any(key.startswith("DataStorm.Node.") for key in props):
# Default properties for tests that don't specify any DataStorm.Node.* properties
props.update(
Expand Down

0 comments on commit a4f3760

Please sign in to comment.