Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into java-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
externl committed Dec 9, 2024
2 parents 30905fa + 449081a commit 8fa5e11
Show file tree
Hide file tree
Showing 40 changed files with 273 additions and 171 deletions.
8 changes: 8 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,41 @@
"apos",
"autoreleasepool",
"Blobject",
"Browsable",
"cacerts",
"datagram",
"datagrams",
"decoratee",
"demangled",
"demangles",
"DTLS",
"finalizer",
"finalizers",
"icegrid",
"icegridadmin",
"icegridnode",
"icestorm",
"istr",
"jgoodies",
"LMDB",
"nohup",
"nullopt",
"oneway",
"ostr",
"PKCS",
"Postamble",
"reloadable",
"RFCOMM",
"soversion",
"Stringifier",
"Syscall",
"Truststore",
"twoway",
"unmarshal",
"unmarshaling",
"upcall",
"upcalls",
"unregisters",
"zeroc"
],
"flagWords": [
Expand Down
8 changes: 0 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
"Make.*": "makefile"
},
"C_Cpp.default.cppStandard": "c++20",
"cSpell.words": [
"Browsable",
"istr",
"ostr",
"soversion",
"unregisters",
"Upcall"
],
"[java]": {
"editor.defaultFormatter": "josevseb.google-java-format-for-vs-code"
},
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PackageDescription
let iceUtilSources: [String] = [
"src/Ice/ConsoleUtil.cpp",
"src/Ice/CtrlCHandler.cpp",
"src/Ice/Demangle.cpp",
"src/Ice/Exception.cpp",
"src/Ice/FileUtil.cpp",
"src/Ice/LocalException.cpp",
Expand Down
3 changes: 2 additions & 1 deletion cpp/include/DataStorm/InternalT.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include "Config.h"
#include "Ice/Demangle.h"
#include "Ice/Ice.h"
#include "InternalI.h"
#include "Types.h"
Expand Down Expand Up @@ -91,7 +92,7 @@ namespace DataStormI
static std::string toString(const T& value)
{
std::ostringstream os;
os << typeid(value).name() << '(' << &value << ')';
os << IceInternal::demangle(typeid(value).name()) << '(' << &value << ')';
return os.str();
}
};
Expand Down
17 changes: 17 additions & 0 deletions cpp/include/Ice/Demangle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) ZeroC, Inc.

#ifndef ICE_DEMANGLE_H
#define ICE_DEMANGLE_H

#include "Config.h"
#include <string>

namespace IceInternal
{
/// Demangles a C++ type type.
/// @param name The possibly mangled type name, as returned by typeid().name().
/// @return The demangled name.
ICE_API std::string demangle(const char* name);
}

#endif
14 changes: 7 additions & 7 deletions cpp/include/Ice/FactoryTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace IceInternal
class ICE_API FactoryTable final
{
public:
FactoryTable() = default;
FactoryTable() noexcept = default;

FactoryTable(const FactoryTable&) = delete;
FactoryTable& operator=(const FactoryTable&) = delete;
Expand Down Expand Up @@ -71,14 +71,14 @@ namespace IceInternal
class ICE_API FactoryTableInit
{
public:
FactoryTableInit();
FactoryTableInit() noexcept;
~FactoryTableInit();
};

class ICE_API CompactIdInit
{
public:
CompactIdInit(std::string_view, int);
CompactIdInit(std::string_view, int) noexcept;
~CompactIdInit();

private:
Expand All @@ -88,27 +88,27 @@ namespace IceInternal
template<class E> class DefaultUserExceptionFactoryInit
{
public:
DefaultUserExceptionFactoryInit(std::string_view tId) : typeId(tId)
DefaultUserExceptionFactoryInit(const char* tId) noexcept : typeId(tId)
{
factoryTable->addExceptionFactory(typeId, defaultUserExceptionFactory<E>);
}

~DefaultUserExceptionFactoryInit() { factoryTable->removeExceptionFactory(typeId); }

const std::string_view typeId;
const char* typeId;
};

template<class O> class DefaultValueFactoryInit
{
public:
DefaultValueFactoryInit(std::string_view tId) : typeId(tId)
DefaultValueFactoryInit(const char* tId) noexcept : typeId(tId)
{
factoryTable->addValueFactory(typeId, defaultValueFactory<O>);
}

~DefaultValueFactoryInit() { factoryTable->removeValueFactory(typeId); }

const std::string_view typeId;
const char* typeId;
};
}

Expand Down
3 changes: 2 additions & 1 deletion cpp/include/Ice/Ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

# include "Communicator.h"
# include "Connection.h"
# include "CtrlCHandler.h"
# include "Demangle.h"
# include "ImplicitContext.h"
# include "Initialize.h"
# include "Instrumentation.h"
Expand All @@ -48,7 +50,6 @@
# include "VersionFunctions.h"

// Generated header files:
# include "CtrlCHandler.h"
# include "Ice/EndpointTypes.h"
# include "Ice/Locator.h"
# include "Ice/Metrics.h"
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/StreamHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace Ice
{
IceInternal::Ex::throwMarshalException(__FILE__, __LINE__, "enumerator out of range");
}
v = static_cast<T>(value);
v = static_cast<T>(value); // NOLINT
}
};

Expand Down
2 changes: 0 additions & 2 deletions cpp/src/DataStorm/CallbackExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

namespace DataStormI
{
class DataElementI;

class CallbackExecutor final
{
public:
Expand Down
21 changes: 20 additions & 1 deletion cpp/src/DataStorm/Contract.ice
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ module DataStormContract
}
sequence<ElementSpecAck> ElementSpecAckSeq;

/// The base interface for publisher and subscriber sessions.
///
/// This interface enables nodes to exchange topic and element information, as well as data samples.
///
/// @see PublisherSession
/// @see SubscriberSession
interface Session
{
/// Announces new and existing topics to the peer.
Expand All @@ -254,14 +260,19 @@ module DataStormContract

/// Attaches a local topic to a remote topic when a session receives a topic announcement from a peer.
///
/// This method is called if the session is interested in the announced topic, which occurs when:
/// This operation is called if the session is interested in the announced topic, which occurs when:
///
/// - The session has a reader for a topic that the peer has a writer for, or
/// - The session has a writer for a topic that the peer has a reader for.
///
/// @param topic The TopicSpec object describing the topic being attached to the remote topic.
void attachTopic(TopicSpec topic);

/// Detaches a topic from the session.
///
/// This operation is called by the topic on listener sessions when the topic is being destroyed.
///
/// @param topic The ID of the topic to detach.
void detachTopic(long topic);

void attachTags(long topic, ElementInfoSeq tags, bool initialize);
Expand Down Expand Up @@ -289,13 +300,21 @@ module DataStormContract

void initSamples(long topic, DataSamplesSeq samples);

/// Notifies the peer that the session is being disconnected.
///
/// This operation is called by the DataStorm node during shutdown to inform established sessions of the disconnection.
///
/// For sessions established through a relay node, this operation is invoked by the relay node if the connection
/// between the relay node and the target node is lost.
void disconnected();
}

/// The PublisherSession servant is hosted by the publisher node and is accessed by the subscriber node.
interface PublisherSession extends Session
{
}

/// The SubscriberSession servant is hosted by the subscriber node and is accessed by the publisher node.
interface SubscriberSession extends Session
{
/// Queue a sample with the subscribers of the topic element.
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 @@ -199,7 +199,7 @@ NodeI::createSession(
// Must be called before connected
s->confirmCreateSessionAsync(
self->_proxy,
session->getProxy<PublisherSessionPrx>(),
Ice::uncheckedCast<PublisherSessionPrx>(session->getProxy()),
nullptr,
[self, subscriber, session](auto ex)
{ self->removePublisherSession(*subscriber, session, ex); });
Expand Down Expand Up @@ -330,7 +330,7 @@ NodeI::createPublisherSession(
{
p->createSessionAsync(
self->_proxy,
session->getProxy<SubscriberSessionPrx>(),
Ice::uncheckedCast<SubscriberSessionPrx>(session->getProxy()),
false,
nullptr,
[=](exception_ptr ex) { self->removeSubscriberSession(publisher, session, ex); });
Expand Down
1 change: 0 additions & 1 deletion cpp/src/DataStorm/NodeSessionI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ namespace
if (node->ice_getEndpoints().empty() && node->ice_getAdapterId().empty())
{
shared_ptr<NodeSessionI> nodeSession = _nodeSessionManager->createOrGet(node, current.con, false);
assert(nodeSession);
node = nodeSession->getPublicNode();
if (session)
{
Expand Down
19 changes: 9 additions & 10 deletions cpp/src/DataStorm/SessionI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,21 @@ namespace
}

SessionI::SessionI(shared_ptr<Instance> instance, shared_ptr<NodeI> parent, NodePrx node, SessionPrx proxy)
: _instance(std::move(instance)),
_traceLevels(_instance->getTraceLevels()),
_parent(std::move(parent)),
_proxy(std::move(proxy)),
_node(std::move(node)),
_destroyed(false),
_sessionInstanceId(0),
_retryCount(0)
: _instance{std::move(instance)},
_traceLevels{_instance->getTraceLevels()},
_parent{std::move(parent)},
_proxy{std::move(proxy)},
_id{Ice::identityToString(_proxy->ice_getIdentity())},
_node{std::move(node)},
_destroyed{false},
_sessionInstanceId{0},
_retryCount{0}
{
}

void
SessionI::init()
{
_id = Ice::identityToString(_proxy->ice_getIdentity());

// Even though the node register a default servant for sessions, we still need to register the session servant
// explicitly here to ensure collocation works. The default servant from the node is used for facet calls.
_instance->getObjectAdapter()->add(
Expand Down
35 changes: 27 additions & 8 deletions cpp/src/DataStorm/SessionI.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace DataStormI
auto p = _elements.find(id);
if (p != _elements.end())
{
ElementSubscribers tmp(std::move(p->second));
ElementSubscribers tmp{std::move(p->second)};
_elements.erase(p);
return tmp;
}
Expand Down Expand Up @@ -285,10 +285,7 @@ namespace DataStormI
std::optional<DataStormContract::SessionPrx> getSession() const;
bool checkSession();

template<typename T = DataStormContract::SessionPrx> std::optional<T> getProxy() const
{
return Ice::uncheckedCast<T>(_proxy);
}
DataStormContract::SessionPrx getProxy() const { return _proxy; }

DataStormContract::NodePrx getNode() const;
void setNode(DataStormContract::NodePrx);
Expand Down Expand Up @@ -389,21 +386,43 @@ namespace DataStormI
const std::shared_ptr<Instance> _instance;
std::shared_ptr<TraceLevels> _traceLevels;
mutable std::mutex _mutex;

// The parent node that created this session.
std::shared_ptr<NodeI> _parent;
std::string _id;

// The proxy representing this session instance.
DataStormContract::SessionPrx _proxy;

// The stringified identity of the session.
std::string _id;

// The proxy to the peer node that established the session.
DataStormContract::NodePrx _node;

// Indicates whether the session has been destroyed.
bool _destroyed;

// The instance ID of the session, incremented each time the session is reconnected.
int _sessionInstanceId;

// The number of attempts made to reconnect the session.
int _retryCount;

// A retry task, scheduled if an attempt to reconnect the session is underway; nullptr if no retry is scheduled.
IceInternal::TimerTaskPtr _retryTask;

// Keeps track of the topics that this session is subscribed to. The key represents the topic ID in the remote
// node. The TopicSubscribers object contains the subscribers for the remote topic.
// Tracks the topics this session is subscribed to.
// - Key: The topic ID on the remote node.
// - Value: A `TopicSubscribers` object containing the subscribers for the remote topic.
std::map<std::int64_t, TopicSubscribers> _topics;

// The lock of the topic being processed by the callback function. See runWithTopics.
std::unique_lock<std::mutex>* _topicLock;

// The proxy to the peer session, or `std::nullopt` if the session is disconnected.
std::optional<DataStormContract::SessionPrx> _session;

// The connection to the peer node, or `nullptr` if the session is disconnected.
Ice::ConnectionPtr _connection;
};

Expand Down
Loading

0 comments on commit 8fa5e11

Please sign in to comment.