diff --git a/src/lib/logMsg/traceLevels.h b/src/lib/logMsg/traceLevels.h index 7266e5a07a..30aeee3ed8 100644 --- a/src/lib/logMsg/traceLevels.h +++ b/src/lib/logMsg/traceLevels.h @@ -72,37 +72,45 @@ typedef enum TraceLevels LmtRegCache = 60, // Registration Cache // - // Distributed Operations + // Distributed Operations - requests // - LmtDistOpMsgs = 70, // Deprecated, still in use though ... - LmtDistOpRequest, // ONLY the verb, path, and body of a distributed request - LmtDistOpResponse, // ONLY the body and status code of the response to a distributed request - LmtDistOp207, // Merging of the final 207 response + LmtDistOpRequest = 70, // ONLY the verb, path, and body of a distributed request + LmtDistOpRequestHeaders, // HTTP headers of distributed requests + LmtDistOpRequestParams, // URL parameters of distributed requests + + // + // Distributed Operations - responses + // + LmtDistOpResponse = 80, // ONLY the body and status code of the response to a distributed request LmtDistOpResponseBuf, // Specific debugging of the incoming response of a distributed message LmtDistOpResponseDetail, // Details on responses to distributed requests LmtDistOpResponseHeaders, // HTTP headers of responses to distributed requests - LmtDistOpRequestHeaders, // HTTP headers of request of distributed requests - LmtDistOpList, // Linked list of DistOps + + // + // Distributed Operations - misc + // + LmtDistOpList = 90, // Linked list of DistOps LmtDistOpAttributes, // The union of attributes URL-Param / Registered Attributes LmtDistOpMerge, // Merge of responses from forwsrded requests (GET /entities) LmtDistOpLoop, // Loop detection in forwarded messages + LmtDistOp207, // Merging of the final 207 response // // Context // - LmtContexts = 82, // Contexts + LmtContexts = 100, // Contexts LmtContextTree, // Context Tree LmtContextCache, // Context Cache LmtContextDownload, // Context Download LmtCoreContext, // Core Context // GeoJSON - LmtGeoJSON = 90, // GeoJSON ... everything (for now) + LmtGeoJSON = 110, // GeoJSON ... everything (for now) // // Pernot sub-cache // - LmtPernot = 100, // Periodic Notification Subscription cache + LmtPernot = 120, // Periodic Notification Subscription cache LmtPernotLoop, // Pernot loop, when each sub is triggered in time LmtPernotLoopTimes, // Pernot loop, details on timestamps LmtPernotFlush, // Pernot flush to DB @@ -111,7 +119,7 @@ typedef enum TraceLevels // // Pagination // - LmtEntityMap = 110, // The arrays of registrations per entity - distributed GET /entities + LmtEntityMap = 130, // The arrays of registrations per entity - distributed GET /entities LmtEntityMapRetrieve, // Retrieval of an entity map LmtEntityMapDetail, // Details of the entity-registration maps diff --git a/src/lib/orionld/forwarding/distOpRequests.cpp b/src/lib/orionld/forwarding/distOpRequests.cpp index 48978f433b..ffa99f5b08 100644 --- a/src/lib/orionld/forwarding/distOpRequests.cpp +++ b/src/lib/orionld/forwarding/distOpRequests.cpp @@ -138,7 +138,7 @@ DistOp* distOpRequests(char* entityId, char* entityType, DistOpType operation, K // Send the forwarded request and await all responses if ((distOpP->regP != NULL) && (distOpP->error == false)) { - if (distOpSend(distOpP, dateHeader, xff, false) == 0) + if (distOpSend(distOpP, dateHeader, xff, false, NULL) == 0) { distOpP->error = false; orionldState.distOp.requests += 1; diff --git a/src/lib/orionld/forwarding/distOpResponses.cpp b/src/lib/orionld/forwarding/distOpResponses.cpp index 0a79e4caea..e14b5a8749 100644 --- a/src/lib/orionld/forwarding/distOpResponses.cpp +++ b/src/lib/orionld/forwarding/distOpResponses.cpp @@ -280,7 +280,7 @@ void entityResponseAccumulate(DistOp* distOpP, KjNode* responseBody, KjNode* suc } else if (httpResponseCode == 0) { - LM_T(LmtDistOpMsgs, ("%s: Seems like the request wasn't even sent ... (%s)", distOpP->regP->regId, distOpP->regP->ipAndPort)); + LM_T(LmtDistOpResponse, ("%s: Seems like the request wasn't even sent ... (%s)", distOpP->regP->regId, distOpP->regP->ipAndPort)); int statusCode = 500; const char* title = "Unable to send distributed request"; @@ -292,9 +292,9 @@ void entityResponseAccumulate(DistOp* distOpP, KjNode* responseBody, KjNode* suc distOpFailure(responseBody, distOpP, title, detail, statusCode, NULL); } else if (httpResponseCode == 200) - LM_T(LmtDistOpMsgs, ("Reg %s: unexpected status code %d (using the accumulator?)", distOpP->regP->regId, httpResponseCode)); + LM_W(("%s: unexpected status code %d (using the accumulator?)", distOpP->regP->regId, httpResponseCode)); else - LM_W(("Reg %s: unexpected status code %d", distOpP->regP->regId, httpResponseCode)); + LM_W(("%s: unexpected status code %d", distOpP->regP->regId, httpResponseCode)); } diff --git a/src/lib/orionld/forwarding/distOpSend.cpp b/src/lib/orionld/forwarding/distOpSend.cpp index 698b7afff2..3318e9f5ce 100644 --- a/src/lib/orionld/forwarding/distOpSend.cpp +++ b/src/lib/orionld/forwarding/distOpSend.cpp @@ -38,10 +38,12 @@ extern "C" #include "logMsg/logMsg.h" // LM_* +#include "common/globals.h" // NGSI_LD_V1 #include "orionld/common/orionldState.h" // orionldState #include "orionld/common/tenantList.h" // tenant0 #include "orionld/context/orionldCoreContext.h" // orionldCoreContextP #include "orionld/context/orionldContextItemAliasLookup.h" // orionldContextItemAliasLookup +#include "orionld/q//qRender.h" // qRender #include "orionld/forwarding/DistOp.h" // DistOp #include "orionld/forwarding/distOpSend.h" // Own interface @@ -153,7 +155,7 @@ char* urlCompose(ForwardUrlParts* urlPartsP, KjNode* endpointP) // // uriParamAdd - // -void uriParamAdd(ForwardUrlParts* urlPartsP, const char* key, const char* value, int totalLen) +static void uriParamAdd(ForwardUrlParts* urlPartsP, const char* key, const char* value, int totalLen) { SList* sListP = (SList*) kaAlloc(&orionldState.kalloc, sizeof(SList)); @@ -171,6 +173,8 @@ void uriParamAdd(ForwardUrlParts* urlPartsP, const char* key, const char* value, sListP->sLen = snprintf(sListP->sP, sLen, "%s=%s", key, value); } + LM_T(LmtDistOpRequestParams, ("DistOp Request URL Param: %s", sListP->sP)); + sListP->next = NULL; if (urlPartsP->params == NULL) @@ -325,7 +329,7 @@ void bodyCompact(DistOpType operation, KjNode* requestBody, OrionldContext* fwdC // // distOpSend - // -bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedForHeader, bool local) +bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedForHeader, bool local, const char* entityIds) { // // Figure out the @context to use for the forwarded request @@ -389,6 +393,7 @@ bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedF // // Add URI Params // + LM_T(LmtDistOpRequestParams, ("%s: ---- URL Parameters for %s ------------------------", distOpP->regP->regId, distOpP->id)); if (orionldState.verb == GET) { if (distOpP->attrsParam != NULL) @@ -405,12 +410,26 @@ bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedF else uriParamAdd(&urlParts, "options=sysAttrs", NULL, 16); - if ((distOpP->operation == DoQueryEntity) && (distOpP->entityId != NULL)) - uriParamAdd(&urlParts, "id", distOpP->entityId, -1); + if (distOpP->operation == DoQueryEntity) + { + if (entityIds != NULL) + uriParamAdd(&urlParts, "id", entityIds, -1); + else if (distOpP->entityId != NULL) + uriParamAdd(&urlParts, "id", distOpP->entityId, -1); + } if (local == true) uriParamAdd(&urlParts, "local=true", NULL, 10); + if (distOpP->qNode != NULL) + { + char buf[256]; + qRender(distOpP->qNode, NGSI_LD_V1, buf, sizeof(buf), NULL); + LM_T(LmtDistOpRequestParams, ("DistOp %s has a Q: %s", distOpP->regP->regId, buf)); + if (orionldState.uriParams.q != NULL) + LM_T(LmtDistOpRequestParams, ("The initial request alsao has a 'q'")); + } + // // If we know the Entity Type, we pass that piece of information as well // @@ -433,6 +452,8 @@ bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedF LM_T(LmtDistOpRequestHeaders, ("%s: orionldState.uriParams.q: '%s'", distOpP->regP->regId, orionldState.uriParams.qCopy)); } + LM_T(LmtDistOpRequestParams, ("%s: ---- End of URL Parameters -----------------", distOpP->regP->regId)); + // // Compose the entire URL and pass it to CURL // @@ -585,7 +606,7 @@ bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedF struct curl_slist* sP = headers; while (sP != NULL) { - LM_T(LmtDistOpMsgs, ("FWD: Added header '%s'", sP->data)); + LM_T(LmtDistOpRequest, ("FWD: Added header '%s'", sP->data)); sP = sP->next; } #endif diff --git a/src/lib/orionld/forwarding/distOpSend.h b/src/lib/orionld/forwarding/distOpSend.h index d4485390c2..a4c2c57355 100644 --- a/src/lib/orionld/forwarding/distOpSend.h +++ b/src/lib/orionld/forwarding/distOpSend.h @@ -33,6 +33,6 @@ // // distOpSend - // -extern bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedForHeader, bool local); +extern bool distOpSend(DistOp* distOpP, const char* dateHeader, const char* xForwardedForHeader, bool local, const char* entityIds); #endif // SRC_LIB_ORIONLD_FORWARDING_DISTOPSEND_H_ diff --git a/src/lib/orionld/forwarding/distOpsSend.cpp b/src/lib/orionld/forwarding/distOpsSend.cpp index b3bfe8aeca..af81c562dc 100644 --- a/src/lib/orionld/forwarding/distOpsSend.cpp +++ b/src/lib/orionld/forwarding/distOpsSend.cpp @@ -51,7 +51,7 @@ int distOpsSend(DistOp* distOpList, bool local) { distOpP->onlyIds = true; - if (distOpSend(distOpP, dateHeader, xff, local) == 0) + if (distOpSend(distOpP, dateHeader, xff, local, NULL) == 0) distOpP->error = false; else distOpP->error = true; @@ -118,7 +118,7 @@ int distOpsSend2(DistOpListItem* distOpList) { distOpP->onlyIds = false; - if (distOpSend(distOpP, dateHeader, xff, false) == 0) + if (distOpSend(distOpP, dateHeader, xff, false, doItemP->entityIds) == 0) distOpP->error = false; else distOpP->error = true; diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteAttribute.cpp b/src/lib/orionld/serviceRoutines/orionldDeleteAttribute.cpp index 5d4192769d..3adfa87ff0 100644 --- a/src/lib/orionld/serviceRoutines/orionldDeleteAttribute.cpp +++ b/src/lib/orionld/serviceRoutines/orionldDeleteAttribute.cpp @@ -95,7 +95,7 @@ static DistOp* distributedDelete(KjNode* responseBody, char* entityId, char* ent char dateHeader[70]; snprintf(dateHeader, sizeof(dateHeader), "Date: %s", orionldState.requestTimeString); - if (distOpSend(distOpP, dateHeader, xff, false) == 0) + if (distOpSend(distOpP, dateHeader, xff, false, NULL) == 0) { ++forwards; distOpP->error = false; diff --git a/src/lib/orionld/serviceRoutines/orionldDeleteEntity.cpp b/src/lib/orionld/serviceRoutines/orionldDeleteEntity.cpp index 376401a228..12297e7ec3 100644 --- a/src/lib/orionld/serviceRoutines/orionldDeleteEntity.cpp +++ b/src/lib/orionld/serviceRoutines/orionldDeleteEntity.cpp @@ -122,7 +122,7 @@ static DistOp* distributedDelete(char* entityId, char* entityTypeExpanded, char* char dateHeader[70]; snprintf(dateHeader, sizeof(dateHeader), "Date: %s", orionldState.requestTimeString); - if (distOpSend(distOpP, dateHeader, xff, false) == 0) + if (distOpSend(distOpP, dateHeader, xff, false, NULL) == 0) { ++forwards; distOpP->error = false; diff --git a/src/lib/orionld/serviceRoutines/orionldGetEntity.cpp b/src/lib/orionld/serviceRoutines/orionldGetEntity.cpp index 97d18a4291..c9ba2dd89b 100644 --- a/src/lib/orionld/serviceRoutines/orionldGetEntity.cpp +++ b/src/lib/orionld/serviceRoutines/orionldGetEntity.cpp @@ -190,7 +190,7 @@ bool orionldGetEntity(void) if (distOpP->regP != NULL) { LM_T(LmtDistOpAttributes, ("distOp::attrsParam: '%s'", distOpP->attrsParam)); - if (distOpSend(distOpP, dateHeader, xff, false) == 0) + if (distOpSend(distOpP, dateHeader, xff, false, NULL) == 0) { ++forwards; distOpP->error = false; diff --git a/src/lib/orionld/serviceRoutines/orionldPatchEntity.cpp b/src/lib/orionld/serviceRoutines/orionldPatchEntity.cpp index 6cc498d7f2..ad819f829e 100644 --- a/src/lib/orionld/serviceRoutines/orionldPatchEntity.cpp +++ b/src/lib/orionld/serviceRoutines/orionldPatchEntity.cpp @@ -203,15 +203,15 @@ static bool attributeLookup(KjNode* dbAttrsP, char* attrName) // void rawResponse(DistOp* distOpList, const char* what) { - LM_T(LmtDistOpMsgs, ("=============== rawResponse: %s", what)); + LM_T(LmtSR, ("=============== rawResponse: %s", what)); for (DistOp* distOpP = distOpList; distOpP != NULL; distOpP = distOpP->next) { if (distOpP->rawResponse != NULL) - LM_T(LmtDistOpMsgs, ("%s: rawResponse: '%s'", distOpP->regP->regId, distOpP->rawResponse)); + LM_T(LmtSR, ("%s: rawResponse: '%s'", distOpP->regP->regId, distOpP->rawResponse)); else - LM_T(LmtDistOpMsgs, ("%s: rawResponse: NULL", distOpP->regP->regId)); + LM_T(LmtSR, ("%s: rawResponse: NULL", distOpP->regP->regId)); } - LM_T(LmtDistOpMsgs, ("====================================================================")); + LM_T(LmtSR, ("====================================================================")); } #endif diff --git a/src/lib/orionld/serviceRoutines/orionldPatchEntity2.cpp b/src/lib/orionld/serviceRoutines/orionldPatchEntity2.cpp index cf30b323a9..6efc1b905f 100644 --- a/src/lib/orionld/serviceRoutines/orionldPatchEntity2.cpp +++ b/src/lib/orionld/serviceRoutines/orionldPatchEntity2.cpp @@ -605,7 +605,7 @@ bool orionldPatchEntity2(void) { char body[1024]; kjFastRender(distOpP->requestBody, body); - LM_T(LmtDistOpMsgs, ("Registration '%s': %s", distOpP->regP->regId, body)); + LM_T(LmtSR, ("Registration '%s': %s", distOpP->regP->regId, body)); } #endif } diff --git a/src/lib/orionld/serviceRoutines/orionldPostBatchDelete.cpp b/src/lib/orionld/serviceRoutines/orionldPostBatchDelete.cpp index 41cb414453..5574d3b8ea 100644 --- a/src/lib/orionld/serviceRoutines/orionldPostBatchDelete.cpp +++ b/src/lib/orionld/serviceRoutines/orionldPostBatchDelete.cpp @@ -478,7 +478,7 @@ bool orionldPostBatchDelete(void) char dateHeader[70]; snprintf(dateHeader, sizeof(dateHeader), "Date: %s", orionldState.requestTimeString); - if (distOpSend(distReqP, dateHeader, xff, false) == 0) + if (distOpSend(distReqP, dateHeader, xff, false, NULL) == 0) { ++forwards; distReqP->error = false; 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 ce78156413..765332f88f 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_forward_get_entities.test @@ -629,46 +629,6 @@ Link: