Skip to content

Commit

Permalink
ftClient is nack in the game. Only, it's still not working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli committed Sep 25, 2024
1 parent 9b86833 commit 052a076
Show file tree
Hide file tree
Showing 29 changed files with 2,119 additions and 81 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ if (error EQUAL 0)
ADD_SUBDIRECTORY(src/lib/metricsMgr)
ADD_SUBDIRECTORY(src/lib/logSummary)
ADD_SUBDIRECTORY(src/app/orionld)
# ADD_SUBDIRECTORY(test/functionalTest/ftClient)
ADD_SUBDIRECTORY(test/functionalTest/ftClient)
else ()
MESSAGE("cmake: NOT OK")
endif (error EQUAL 0)
22 changes: 22 additions & 0 deletions config/DDS_ENABLER_CONFIGURATION.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# DDS configuration
dds:
# Domain ID
domain: 0

# Allowed topics
allowlist:
- name: "*"

# Blocked topics
blocklist:
- name: "add_blocked_topics_list_here"

# DDS Enabler configuration
ddsenabler:

#Specs configuration
specs:
threads: 12
logging:
stdout: false
verbosity: info
19 changes: 11 additions & 8 deletions src/lib/orionld/common/traceLevels.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
//
typedef enum OrionldTraceLevels
{
StMhdInit = 100,
StRequest = 200,
StDds = 201,
StDdsPublish = 202,
StDump = 203,
StDdsDump = 204,
StDdsConfig = 205,
StSR = 206
StMhdInit = 100,
StRequest = 200,
StDds = 201,
StDdsPublish = 202,
StDdsNotification = 203,
StDdsLibInfo = 204,
StDdsLibDebug = 205,
StDump = 206,
StDdsDump = 207,
StDdsConfig = 208,
StSR = 209
} OrionldTraceLevels;

#endif // SRC_LIB_ORIONLD_COMMON_TRACELEVELS_H_
1 change: 1 addition & 0 deletions src/lib/orionld/dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SET (SOURCES
ddsInit.cpp
ddsConfigLoad.cpp
kjTreeLog.cpp
ddsCategoryToKlogSeverity.cpp
)

# Include directories
Expand Down
43 changes: 43 additions & 0 deletions src/lib/orionld/dds/ddsCategoryToKlogSeverity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* Copyright 2024 FIWARE Foundation e.V.
*
* This file is part of Orion-LD Context Broker.
*
* Orion-LD Context Broker is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Orion-LD Context Broker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
* General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/.
*
* For those usages not covered by this license please contact with
* orionld at fiware dot org
*
* Author: Ken Zangelin
*/
#include "orionld/common/traceLevels.h" // StDdsLibInfo, StDdsLibDebug


// -----------------------------------------------------------------------------
//
// ddsCategoryToKlogSeverity -
//
char ddsCategoryToKlogSeverity(int ddsCategory, int* levelP)
{
switch (ddsCategory)
{
case 0: return 'E'; // DDS Error => KLog Error
case 1: return 'W'; // DDS Warning => KLog Warning
case 2: *levelP = StDdsLibInfo; return 'T'; // DDS Info => KLog Trace
}

*levelP = StDdsLibDebug;
return 'T'; // DDS Unknown => KLog Trace
}
37 changes: 37 additions & 0 deletions src/lib/orionld/dds/ddsCategoryToKlogSeverity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef SRC_LIB_ORIONLD_DDS_DDSCATEGORYTOKLOGSEVERITY_H_
#define SRC_LIB_ORIONLD_DDS_DDSCATEGORYTOKLOGSEVERITY_H_

/*
*
* Copyright 2024 FIWARE Foundation e.V.
*
* This file is part of Orion-LD Context Broker.
*
* Orion-LD Context Broker is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Orion-LD Context Broker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
* General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/.
*
* For those usages not covered by this license please contact with
* orionld at fiware dot org
*
* Author: Ken Zangelin
*/



// -----------------------------------------------------------------------------
//
// ddsCategoryToKlogSeverity -
//
extern char ddsCategoryToKlogSeverity(int ddsCategory, int* levelP);

#endif // SRC_LIB_ORIONLD_DDS_DDSCATEGORYTOKLOGSEVERITY_H_
30 changes: 23 additions & 7 deletions src/lib/orionld/dds/ddsInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C"
#include "orionld/common/traceLevels.h" // kjTreeLog2
#include "orionld/common/orionldState.h" // ddsEnablerConfigFile, ddsConfigFile
#include "orionld/kjTree/kjNavigate.h" // kjNavigate
#include "orionld/dds/ddsCategoryToKlogSeverity.h" // ddsCategoryToKlogSeverity
#include "orionld/dds/ddsConfigLoad.h" // ddsConfigLoad
#include "orionld/dds/kjTreeLog.h" // kjTreeLog2
#include "orionld/dds/ddsInit.h" // Own interface
Expand All @@ -49,14 +50,29 @@ extern "C"
//
DdsOperationMode ddsOpMode;

//
// 3 callbacks for DDS:
//
// typedef void (*DdsLogFunc)(conat char* fileName, int lineNo, const char* funcName, int category, const char* msg);
// typedef void (*DdsTypeNotification)(const char* topicTypeName, const char* topicName, const char* typeId);
// typedef void (*DdsNotification)(const char* topicTypeName, const char* topicName, const char* json, double publishTime);


void ddsNotification(const char* typeName, const char* topicName, const char* json, double publishTime)
{
KT_T(StDds, "Got a notification on %s:%s (json: %s)", typeName, topicName, json);
}



void ddsTypeNotification(const char* typeName, const char* topicName, const char* serializedType)
{
KT_T(StDds, "Got a type notification ('%s', '%s', '%s')", typeName, topicName, serializedType);
}


void ddsLog(const char* fileName, int lineNo, const char* funcName, int category, const char* msg)
{
int level = 0;
char severity = ddsCategoryToKlogSeverity(category, &level);

ktOut(fileName, lineNo, funcName, severity, level, msg);
}


// -----------------------------------------------------------------------------
//
Expand All @@ -69,7 +85,7 @@ int ddsInit(Kjson* kjP, DdsOperationMode _ddsOpMode)
{
ddsOpMode = _ddsOpMode; // Not yet in use ... invent usage or remove !

eprosima::ddsenabler::init_dds_enabler(ddsEnablerConfigFile);
eprosima::ddsenabler::init_dds_enabler(ddsEnablerConfigFile, ddsNotification, ddsTypeNotification, ddsLog);

//
// DDS Configuration File
Expand Down
12 changes: 4 additions & 8 deletions src/lib/orionld/dds/ddsPublish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ extern "C"



// -----------------------------------------------------------------------------
//
// namespaces ... (to be removed!)
//
using namespace eprosima::fastdds::dds;



// -----------------------------------------------------------------------------
//
// ddsPublishAttribute -
Expand All @@ -59,6 +51,7 @@ void ddsPublishAttribute
KjNode* attributeP
)
{
#if 0
char* topicName = attributeP->name;
NgsildPublisher* publisherP = new NgsildPublisher(topicType);

Expand Down Expand Up @@ -89,6 +82,7 @@ void ddsPublishAttribute

KT_V("Deleting publisher");
delete publisherP;
#endif
}


Expand All @@ -105,6 +99,7 @@ void ddsPublishEntity
KjNode* entityP
)
{
#if 0
KT_V("Publishing the attributes of the entity '%s' in DDS", entityId);
for (KjNode* attributeP = entityP->value.firstChildP; attributeP != NULL; attributeP = attributeP->next)
{
Expand All @@ -115,4 +110,5 @@ void ddsPublishEntity

ddsPublishAttribute(topicType, entityType, entityId, attributeP);
}
#endif
}
2 changes: 1 addition & 1 deletion src/lib/orionld/legacyDriver/legacyPatchAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ bool kjAttributeToNgsiContextAttribute(ContextAttribute* caP, KjNode* inAttribut

if (timestamp < 0)
{
*detailP = errorString;
*detailP = kaStrdup(&orionldState.kalloc, errorString);
return false;
}
else
Expand Down
1 change: 1 addition & 0 deletions src/lib/orionld/types/OrionldMimeType.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*
* Author: Ken Zangelin
*/
#include <cstdint> // Standard types (int32_t, etc ?)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@ ftClientStart -t 0-5000
echo "01. Ask FT to publish an entity urn:E1 on topic 'P1'"
echo "===================================================="
payload='{
"https://uri.etsi.org/ngsi-ld/default-context/P1": 1
"s": "abc"
}'
orionCurl --url '/dds/pub?ddsTopicType=xyz&entityId=urn:e1&entityType=T' --port $FT_PORT --payload "$payload"
orionCurl --url '/dds/pub?ddsTopicType=xyz&entityId=urn:e1&entityType=T&ddsTopicName=P1' --port $FT_PORT --payload "$payload"
echo
echo


echo "02. Ask FT to publish an entity urn:E2 on topic 'P2'"
echo "===================================================="
payload='{
"https://uri.etsi.org/ngsi-ld/default-context/P2": 2
"i": 2
}'
orionCurl --url '/dds/pub?ddsTopicType=xyz&xyz&entityId=urn:e2' --port $FT_PORT --payload "$payload"
orionCurl --url '/dds/pub?ddsTopicType=xyz&xyz&entityId=urn:e2&ddsTopicName=P2' --port $FT_PORT --payload "$payload"
echo
echo


echo "03. Ask FT to publish an entity urn:E3 on topic 'P3'"
echo "===================================================="
payload='{
"https://uri.etsi.org/ngsi-ld/default-context/P3": 3
"f": 3.14
}'
orionCurl --url '/dds/pub?ddsTopicType=xyzxyz&entityId=urn:e1' --port $FT_PORT --payload "$payload"
orionCurl --url '/dds/pub?ddsTopicType=xyzxyz&entityId=urn:e1&ddsTopicName=P3' --port $FT_PORT --payload "$payload"
echo
echo

Expand Down
14 changes: 10 additions & 4 deletions test/functionalTest/ftClient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ SET (SOURCES
getDdsDump.cpp
postDdsSub.cpp
postDdsPub.cpp
ddsPublish.cpp
NgsildSampleTypeObjectSupport.cxx
NgsildSamplePubSubTypes.cxx
NgsildPublisher.cpp
DdsNotificationSender.cpp
)

SET (COMMON_STATIC_LIBS
Expand Down Expand Up @@ -81,10 +86,11 @@ SET (STATIC_LIBS
)

SET (DYNAMIC_LIBS
fastrtps.so
fastcdr.so
foonathan_memory-0.7.3.so
tinyxml2.so
fastdds
fastcdr
foonathan_memory-0.7.3
ddsenabler
tinyxml2
crypto.so
ssl.so
pthread.so
Expand Down
64 changes: 64 additions & 0 deletions test/functionalTest/ftClient/DdsNotificationSender.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
*
* Copyright 2024 FIWARE Foundation e.V.
*
* This file is part of Orion-LD Context Broker.
*
* Orion-LD Context Broker is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Orion-LD Context Broker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
* General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/.
*
* For those usages not covered by this license please contact with
* orionld at fiware dot org
*
*/
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/publisher/DataWriter.hpp>
#include <fastdds/dds/publisher/DataWriterListener.hpp>
#include <fastdds/dds/publisher/Publisher.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>

extern "C"
{
#include "ktrace/kTrace.h" // trace messages - ktrace library
#include "kjson/KjNode.h" // KjNode
}

#include "orionld/common/traceLevels.h" // Trace Levels
#include "ftClient/NgsildPublisher.h" // The class



// -----------------------------------------------------------------------------
//
// DdsNotificationSender::on_publication_matched -
//
void DdsNotificationSender::on_publication_matched(DataWriter*, const PublicationMatchedStatus& info)
{
// FIXME: Don't Publish until entering here! (mutex)
KT_V("info.current_count_change: %d", info.current_count_change);
if (info.current_count_change == 1)
{
matched_ = info.total_count;
KT_T(StDds, "Publisher matched.");
ready_ = true;
}
else if (info.current_count_change == -1)
{
matched_ = info.total_count;
KT_T(StDds, "Publisher unmatched.");
ready_ = false;
}
else
KT_T(StDds, "'%d' is not a valid value for PublicationMatchedStatus current count change.", info.total_count);
}
Loading

0 comments on commit 052a076

Please sign in to comment.