| 432 | } |
| 433 | |
| 434 | void ElasticsearchWriter::Flush() |
| 435 | { |
| 436 | /* Flush can be called from 1) Timeout 2) Threshold 3) on shutdown/reload. */ |
| 437 | if (m_DataBuffer.empty()) |
| 438 | return; |
| 439 | |
| 440 | /* Ensure you hold a lock against m_DataBuffer so that things |
| 441 | * don't go missing after creating the body and clearing the buffer. |
| 442 | */ |
| 443 | String body = boost::algorithm::join(m_DataBuffer, "\n"); |
| 444 | m_DataBuffer.clear(); |
| 445 | |
| 446 | /* Elasticsearch 6.x requires a new line. This is compatible to 5.x. |
| 447 | * Tested with 6.0.0 and 5.6.4. |
| 448 | */ |
| 449 | body += "\n"; |
| 450 | |
| 451 | SendRequest(body); |
| 452 | } |
| 453 | |
| 454 | void ElasticsearchWriter::SendRequest(const String& body) |
| 455 | { |