summaryrefslogtreecommitdiffstats
path: root/plugins/omelasticsearch/omelasticsearch.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-07-30 11:01:11 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-07-30 11:01:11 +0200
commit575686bd68a47fc5d9f59c1ed610f6680e1bb6fa (patch)
tree366c700164a16e8e2fb8200c637fae9f51bb4c06 /plugins/omelasticsearch/omelasticsearch.c
parent71121003e273dc9fb2d6dd2aac427fb2c6329d23 (diff)
downloadrsyslog-575686bd68a47fc5d9f59c1ed610f6680e1bb6fa.tar.gz
rsyslog-575686bd68a47fc5d9f59c1ed610f6680e1bb6fa.tar.bz2
rsyslog-575686bd68a47fc5d9f59c1ed610f6680e1bb6fa.zip
omelasticsearch: mileston: bulk reply is parsed
Diffstat (limited to 'plugins/omelasticsearch/omelasticsearch.c')
-rw-r--r--plugins/omelasticsearch/omelasticsearch.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/plugins/omelasticsearch/omelasticsearch.c b/plugins/omelasticsearch/omelasticsearch.c
index b49caf38..04113170 100644
--- a/plugins/omelasticsearch/omelasticsearch.c
+++ b/plugins/omelasticsearch/omelasticsearch.c
@@ -382,6 +382,53 @@ finalize_it:
}
static inline rsRetVal
+checkResultBulkmode(instanceData *pData, cJSON *root)
+{
+ int i;
+ int numitems;
+ cJSON *items;
+ cJSON *item;
+ cJSON *create;
+ cJSON *ok;
+ DEFiRet;
+
+ items = cJSON_GetObjectItem(root, "items");
+ if(items == NULL || items->type != cJSON_Array) {
+ DBGPRINTF("omelasticsearch: error in elasticsearch reply: "
+ "bulkmode insert does not return array, reply is: %s\n",
+ pData->reply);
+ ABORT_FINALIZE(RS_RET_DATAFAIL);
+ }
+ numitems = cJSON_GetArraySize(items);
+DBGPRINTF("omelasticsearch: %d items in reply\n", numitems);
+ for(i = 0 ; i < numitems ; ++i) {
+ item = cJSON_GetArrayItem(items, i);
+ if(item == NULL) {
+ DBGPRINTF("omelasticsearch: error in elasticsearch reply: "
+ "cannot obtain reply array item %d\n", i);
+ ABORT_FINALIZE(RS_RET_DATAFAIL);
+ }
+ create = cJSON_GetObjectItem(item, "create");
+ if(create == NULL || create->type != cJSON_Object) {
+ DBGPRINTF("omelasticsearch: error in elasticsearch reply: "
+ "cannot obtain 'create' item for #%d\n", i);
+ ABORT_FINALIZE(RS_RET_DATAFAIL);
+ }
+ ok = cJSON_GetObjectItem(create, "ok");
+ if(ok == NULL || ok->type != cJSON_True) {
+ DBGPRINTF("omelasticsearch: error in elasticsearch reply: "
+ "item ok (%p) not ok\n", ok);
+ ABORT_FINALIZE(RS_RET_DATAFAIL);
+ }
+dbgprintf("omelasticsearch: item %d is OK\n", i);
+ }
+
+finalize_it:
+ RETiRet;
+}
+
+
+static inline rsRetVal
checkResult(instanceData *pData)
{
cJSON *root;
@@ -395,8 +442,7 @@ checkResult(instanceData *pData)
}
if(pData->bulkmode) {
- //TODO: implement
- //iRet = checkResultBulkmode(pData, root);
+ iRet = checkResultBulkmode(pData, root);
} else {
ok = cJSON_GetObjectItem(root, "ok");
if(ok == NULL || ok->type != cJSON_True) {