diff --git a/src/app/orionld/orionld.cpp b/src/app/orionld/orionld.cpp index 97d22ae42f..3f9d83e952 100644 --- a/src/app/orionld/orionld.cpp +++ b/src/app/orionld/orionld.cpp @@ -250,6 +250,7 @@ bool socketService; unsigned short socketServicePort; bool distributed; char brokerId[136]; +char wip[512]; bool noNotifyFalseUpdate; bool idIndex; bool noswap; @@ -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!!!" @@ -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 }, @@ -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. diff --git a/src/lib/orionld/common/orionldState.cpp b/src/lib/orionld/common/orionldState.cpp index df95ca2624..43b06a2f0b 100644 --- a/src/lib/orionld/common/orionldState.cpp +++ b/src/lib/orionld/common/orionldState.cpp @@ -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; diff --git a/src/lib/orionld/common/orionldState.h b/src/lib/orionld/common/orionldState.h index c711c8acee..511b0b2ee9 100644 --- a/src/lib/orionld/common/orionldState.h +++ b/src/lib/orionld/common/orionldState.h @@ -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; @@ -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; diff --git a/src/lib/orionld/rest/orionldMhdConnectionInit.cpp b/src/lib/orionld/rest/orionldMhdConnectionInit.cpp index cc0a8df0ba..ff0f39310a 100644 --- a/src/lib/orionld/rest/orionldMhdConnectionInit.cpp +++ b/src/lib/orionld/rest/orionldMhdConnectionInit.cpp @@ -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) diff --git a/src/lib/orionld/serviceRoutines/orionldGetEntities.cpp b/src/lib/orionld/serviceRoutines/orionldGetEntities.cpp index 19b409fe61..dd2b309752 100644 --- a/src/lib/orionld/serviceRoutines/orionldGetEntities.cpp +++ b/src/lib/orionld/serviceRoutines/orionldGetEntities.cpp @@ -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 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap-errors.test b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap-errors.test index 3173980dd7..3d9bd964e4 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap-errors.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap-errors.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_GET.test b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_GET.test index 88444c40c7..10584019c0 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_GET.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_GET.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_crossed_registrations_multiple_forwarding.test b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_crossed_registrations_multiple_forwarding.test index f271dbc7e8..f7d4ea1c07 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_crossed_registrations_multiple_forwarding.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_crossed_registrations_multiple_forwarding.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_get.test b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_get.test index 5823352b97..70edcd3a86 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_get.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_entityMap_get.test @@ -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 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities-entity-split-over-many-brokers.test b/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities-entity-split-over-many-brokers.test index 9299cd7d72..0599aea9f1 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities-entity-split-over-many-brokers.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities-entity-split-over-many-brokers.test @@ -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 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities.test b/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities.test index cb23c8f85b..e921d0e3b4 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities.test @@ -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 diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_four_brokers_and_forwarding_loop_ALL-CONNECTED.test b/test/functionalTest/cases/0000_ngsild/ngsild_four_brokers_and_forwarding_loop_ALL-CONNECTED.test index a845868cbd..65ecba2ee7 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_four_brokers_and_forwarding_loop_ALL-CONNECTED.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_four_brokers_and_forwarding_loop_ALL-CONNECTED.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_1466.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_1466.test index b32825653b..5bfd38cdfd 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_issue_1466.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_1466.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_new_GET_entities-with-entityMap.test b/test/functionalTest/cases/0000_ngsild/ngsild_new_GET_entities-with-entityMap.test index d4f92c4383..41cc5cb38d 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_new_GET_entities-with-entityMap.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_new_GET_entities-with-entityMap.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_new_forward_q.test b/test/functionalTest/cases/0000_ngsild/ngsild_new_forward_q.test index 785e359eda..a24c8272a0 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_new_forward_q.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_new_forward_q.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop.test b/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop.test index 81cc753dce..a84c7242d1 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop_ALL-CONNECTED.test b/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop_ALL-CONNECTED.test index d4091ab05f..a7564cafdc 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop_ALL-CONNECTED.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_three_brokers_and_forwarding_loop_ALL-CONNECTED.test @@ -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-- diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_two_brokers_and_forwarding_loop_ALL-CONNECTED.test b/test/functionalTest/cases/0000_ngsild/ngsild_two_brokers_and_forwarding_loop_ALL-CONNECTED.test index 476331146d..fa9a554dde 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_two_brokers_and_forwarding_loop_ALL-CONNECTED.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_two_brokers_and_forwarding_loop_ALL-CONNECTED.test @@ -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--