Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/wip #1498

Merged
merged 4 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/app/orionld/orionld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ bool socketService;
unsigned short socketServicePort;
bool distributed;
char brokerId[136];
char wip[512];
bool noNotifyFalseUpdate;
bool idIndex;
bool noswap;
Expand Down Expand Up @@ -335,6 +336,7 @@ bool triggerOperation = false;
#define SOCKET_SERVICE_PORT_DESC "port to receive new socket service connections"
#define DISTRIBUTED_DESC "turn on distributed operation"
#define BROKER_ID_DESC "identity of this broker instance for registrations - for the Via header"
#define WIP_DESC "Enable concepts that are 'Work In Progress' (e.g. -wip entityMaps)"
#define FORWARDING_DESC "turn on distributed operation (deprecated)"
#define ID_INDEX_DESC "automatic mongo index on _id.id"
#define NOSWAP_DESC "no swapping - for testing only!!!"
Expand Down Expand Up @@ -437,12 +439,13 @@ PaArgument paArgs[] =
{ "-troePwd", troePwd, "TROE_PWD", PaString, PaOpt, _i "password", PaNL, PaNL, TROE_HOST_PWD },
{ "-troePoolSize", &troePoolSize, "TROE_POOL_SIZE", PaInt, PaOpt, 10, 0, 1000, TROE_POOL_DESC },
{ "-noNotifyFalseUpdate", &noNotifyFalseUpdate, "NO_NOTIFY_FALSE_UPDATE", PaBool, PaOpt, false, false, true, NO_NOTIFY_FALSE_UPDATE_DESC },
{ "-triggerOperation", &triggerOperation, "TRIGGER_OPERATION", PaBool, PaHid, false, false, true, TRIGGER_OPERATION_DESC },
{ "-experimental", &experimental, "EXPERIMENTAL", PaBool, PaOpt, false, false, true, EXPERIMENTAL_DESC },
{ "-mongocOnly", &mongocOnly, "MONGOCONLY", PaBool, PaOpt, false, false, true, MONGOCONLY_DESC },
{ "-cSubCounters", &cSubCounters, "CSUB_COUNTERS", PaInt, PaOpt, 20, 0, PaNL, CSUBCOUNTERS_DESC },
{ "-distributed", &distributed, "DISTRIBUTED", PaBool, PaOpt, false, false, true, DISTRIBUTED_DESC },
{ "-brokerId", &brokerId, "BROKER_ID", PaStr, PaOpt, _i "", PaNL, PaNL, BROKER_ID_DESC },
{ "-wip", wip, "WIP", PaStr, PaHid, _i "", PaNL, PaNL, WIP_DESC },
{ "-triggerOperation", &triggerOperation, "TRIGGER_OPERATION", PaBool, PaHid, false, false, true, TRIGGER_OPERATION_DESC },
{ "-forwarding", &distributed, "FORWARDING", PaBool, PaHid, false, false, true, FORWARDING_DESC },
{ "-socketService", &socketService, "SOCKET_SERVICE", PaBool, PaHid, false, false, true, SOCKET_SERVICE_DESC },
{ "-ssPort", &socketServicePort, "SOCKET_SERVICE_PORT", PaUShort, PaHid, 1027, PaNL, PaNL, SOCKET_SERVICE_PORT_DESC },
Expand Down Expand Up @@ -1068,6 +1071,12 @@ int main(int argC, char* argV[])
lmTraceLevelSet(LmtCurl, true);
}

if (wip[0] != 0)
{
if (strcmp(wip, "entityMaps") == 0)
entityMapsEnabled = true;
}

#if 0
//
// Uncomment this piece of code and run the functests (-ld) to make sure everything works "more or less" with the Legacy Driver disabled.
Expand Down
3 changes: 2 additions & 1 deletion src/lib/orionld/common/orionldState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ char hostHeaderNoLF[128];
char hostHeader[256]; // Host: xxx
size_t hostHeaderLen;
PernotSubCache pernotSubCache;
EntityMap* entityMaps = NULL; // Used by GET /entities in the distributed case, for pagination
EntityMap* entityMaps = NULL; // Used by GET /entities in the distributed case, for pagination
bool entityMapsEnabled = false;



Expand Down
2 changes: 2 additions & 0 deletions src/lib/orionld/common/orionldState.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ typedef struct OrionldStateIn
char* legacy; // Use legacy mongodb driver / mongoBackend
bool performance;
bool aerOS; // Special treatment for aerOS specific features
char* wip;

// Incoming payload
char* payload;
Expand Down Expand Up @@ -622,6 +623,7 @@ extern bool noCache; // From orionld.cpp
extern uint32_t cSubCounters; // Number of subscription counter updates before flush from sub-cache to DB
extern PernotSubCache pernotSubCache;
extern EntityMap* entityMaps; // Used by GET /entities in the distributed case, for pagination
extern bool entityMapsEnabled;

extern char localIpAndPort[135]; // Local address for X-Forwarded-For (from orionld.cpp)
extern unsigned long long inReqPayloadMaxSize;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/orionld/rest/orionldMhdConnectionInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ static MHD_Result orionldHttpHeaderReceive(void* cbDataP, MHD_ValueKind kind, co
}
else if (strcasecmp(key, "Performance") == 0)
orionldState.in.performance = true;
else if (strcasecmp(key, "ORIONLD-WIP") == 0)
orionldState.in.wip = (char*) value;
else if (strcasecmp(key, "aerOS") == 0)
{
if (strcasecmp(value, "true") == 0)
Expand Down
19 changes: 19 additions & 0 deletions src/lib/orionld/serviceRoutines/orionldGetEntities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,25 @@ bool orionldGetEntities(void)
if (pCheckQueryParams(id, type, idPattern, q, geometry, attrs, local, orionldState.in.entityMap, &qNode, &geoInfo) == false)
return false;

//
// Distributed GET /entities, using the concept "entityMaps" is disabled by default.
// To turn it on, please start Orion-LD with the CLI option:
// -wip entityMaps
// Or, the env var:
// export ORIONLD_WIP=entityMaps
//
if (entityMapsEnabled == false)
orionldState.distributed = false;

//
// Entity Maps can be turned on using the HTTP header ORIONLD-WIP
//
if (orionldState.in.wip != NULL)
{
if (strcmp(orionldState.in.wip, "entityMaps") == 0)
orionldState.distributed = true;
}

if (orionldState.in.entityMap != NULL)
{
// No query params can be used when asking for pages in an entity map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Error handling for entity maps
dbInit CB
dbInit CP1
export CB_TRACELEVELS=${CB_TRACELEVELS:-70-79,110,200}
orionldStart CB -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental

--SHELL--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GET /entities with Entity Map
dbInit CB
dbInit CP1
#export CB_TRACELEVELS=${CB_TRACELEVELS:-31,70-79,80,110}
orionldStart CB -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental

--SHELL--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ GET /entities with Entity Map using crossed registrations
dbInit CB
dbInit CP1
dbInit CP2
orionldStart CB -experimental -forwarding
orionldStart CP1 -experimental -forwarding
orionldStart CP2 -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental -forwarding -wip entityMaps
orionldStart CP2 -experimental -forwarding -wip entityMaps

--SHELL--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dbInit CP1
dbInit CP2
dbInit CP3
dbInit CP4
orionldStart CB -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental
orionldStart CP2 -experimental
orionldStart CP3 -experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dbInit CP1
dbInit CP2
dbInit CP3
dbInit CP4
orionldStart CB -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental
orionldStart CP2 -experimental
orionldStart CP3 -experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dbInit CB
dbInit CP1
dbInit CP2
dbInit CP3
orionldStart CB -forwarding -experimental
orionldStart CB -forwarding -experimental -wip entityMaps
orionldStart CP1 -experimental
orionldStart CP2 -experimental
orionldStart CP3 -experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ dbInit CB
dbInit CP1
dbInit CP2
dbInit CP3
orionldStart CB -experimental -forwarding
orionldStart CP1 -experimental -forwarding
orionldStart CP2 -experimental -forwarding
orionldStart CP3 -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental -forwarding -wip entityMaps
orionldStart CP2 -experimental -forwarding -wip entityMaps
orionldStart CP3 -experimental -forwarding -wip entityMaps

--SHELL--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Issue #1466 - crash with distributed GET /entities on entity type
--SHELL-INIT--
dbInit CB
dbInit CP1
orionldStart CB -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental

--SHELL--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GET /entities with Entity Map
dbInit CB
dbInit CP1
export CB_TRACELEVELS=${CB_TRACELEVELS:-31,70-79,80}
orionldStart CB -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental

--SHELL--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ HTTP header test for forwarding of 'q'

--SHELL-INIT--
dbInit CB
orionldStart CB -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
accumulatorStart --pretty-print --url /ngsi-ld/v1/entities 127.0.0.1 ${LISTENER_PORT}

--SHELL--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Registration ring with three cascading registrations
dbInit CB
dbInit CP1
dbInit CP2
orionldStart CB -experimental -forwarding
orionldStart CP1 -experimental -forwarding
orionldStart CP2 -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental -forwarding -wip entityMaps
orionldStart CP2 -experimental -forwarding -wip entityMaps

--SHELL--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ GET /entities with three brokers all connected via registrations
dbInit CB
dbInit CP1
dbInit CP2
orionldStart CB -experimental -forwarding
orionldStart CP1 -experimental -forwarding
orionldStart CP2 -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental -forwarding -wip entityMaps
orionldStart CP2 -experimental -forwarding -wip entityMaps

--SHELL--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh

--NAME--
GET /entities with three brokers all connected via registrations
GET /entities with two brokers all connected via registrations

--SHELL-INIT--
dbInit CB
dbInit CP1
orionldStart CB -experimental -forwarding
orionldStart CP1 -experimental -forwarding
orionldStart CB -experimental -forwarding -wip entityMaps
orionldStart CP1 -experimental -forwarding -wip entityMaps

--SHELL--

Expand Down
Loading