mirror of https://github.com/Icinga/icinga2.git
parent
bb333b535b
commit
fb98d3edef
|
@ -25,7 +25,8 @@
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include "redis/rediswriter.hpp"
|
#include "redis/rediswriter.hpp"
|
||||||
#include "hiredis/hiredis.h"
|
#include "hiredis/hiredis.h"
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -179,18 +180,22 @@ void RedisConnection::DisconnectCallback(const redisAsyncContext *c, int status)
|
||||||
rc->m_Connected = false;
|
rc->m_Connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RedisConnection::ExecuteQuery(const std::vector<String>& query, redisCallbackFn *fn, void *privdata)
|
void RedisConnection::ExecuteQuery(std::vector<String> query, redisCallbackFn *fn, void *privdata)
|
||||||
{
|
{
|
||||||
m_RedisConnectionWorkQueue.Enqueue([this, query, fn, privdata]() {
|
auto queryPtr (std::make_shared<decltype(query)>(std::move(query)));
|
||||||
SendMessageInternal(query, fn, privdata);
|
|
||||||
|
m_RedisConnectionWorkQueue.Enqueue([this, queryPtr, fn, privdata]() {
|
||||||
|
SendMessageInternal(*queryPtr, fn, privdata);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RedisConnection::ExecuteQueries(const std::vector<std::vector<String> >& queries, redisCallbackFn *fn, void *privdata)
|
RedisConnection::ExecuteQueries(std::vector<std::vector<String>> queries, redisCallbackFn *fn, void *privdata)
|
||||||
{
|
{
|
||||||
m_RedisConnectionWorkQueue.Enqueue([this, queries, fn, privdata]() {
|
auto queriesPtr (std::make_shared<decltype(queries)>(std::move(queries)));
|
||||||
SendMessagesInternal(queries, fn, privdata);
|
|
||||||
|
m_RedisConnectionWorkQueue.Enqueue([this, queriesPtr, fn, privdata]() {
|
||||||
|
SendMessagesInternal(*queriesPtr, fn, privdata);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,9 @@ namespace icinga
|
||||||
|
|
||||||
bool IsConnected();
|
bool IsConnected();
|
||||||
|
|
||||||
void ExecuteQuery(const std::vector<String>& query, redisCallbackFn *fn = NULL, void *privdata = NULL);
|
void ExecuteQuery(std::vector<String> query, redisCallbackFn *fn = NULL, void *privdata = NULL);
|
||||||
|
|
||||||
void ExecuteQueries(const std::vector<std::vector<String> >& queries, redisCallbackFn *fn = NULL,
|
void ExecuteQueries(std::vector<std::vector<String>> queries, redisCallbackFn *fn = NULL,
|
||||||
void *privdata = NULL);
|
void *privdata = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -166,7 +166,7 @@ void RedisWriter::UpdateAllConfigObjects()
|
||||||
|
|
||||||
if (transaction.size() > 1) {
|
if (transaction.size() > 1) {
|
||||||
transaction.push_back({"EXEC"});
|
transaction.push_back({"EXEC"});
|
||||||
m_Rcon->ExecuteQueries(transaction);
|
m_Rcon->ExecuteQueries(std::move(transaction));
|
||||||
transaction = {{"MULTI"}};
|
transaction = {{"MULTI"}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ void RedisWriter::UpdateAllConfigObjects()
|
||||||
|
|
||||||
if (transaction.size() > 1) {
|
if (transaction.size() > 1) {
|
||||||
transaction.push_back({"EXEC"});
|
transaction.push_back({"EXEC"});
|
||||||
m_Rcon->ExecuteQueries(transaction);
|
m_Rcon->ExecuteQueries(std::move(transaction));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Rcon->ExecuteQuery({"PUBLISH", "icinga:config:dump", lcType});
|
m_Rcon->ExecuteQuery({"PUBLISH", "icinga:config:dump", lcType});
|
||||||
|
@ -249,7 +249,7 @@ void RedisWriter::DeleteKeys(const std::vector<String>& keys) {
|
||||||
query.emplace_back(key);
|
query.emplace_back(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Rcon->ExecuteQuery(query);
|
m_Rcon->ExecuteQuery(std::move(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<String> RedisWriter::GetTypeObjectKeys(const String& type)
|
std::vector<String> RedisWriter::GetTypeObjectKeys(const String& type)
|
||||||
|
@ -679,7 +679,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtime
|
||||||
|
|
||||||
if (transaction.size() > 1) {
|
if (transaction.size() > 1) {
|
||||||
transaction.push_back({"EXEC"});
|
transaction.push_back({"EXEC"});
|
||||||
m_Rcon->ExecuteQueries(transaction);
|
m_Rcon->ExecuteQueries(std::move(transaction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1008,7 +1008,7 @@ void RedisWriter::SendStatusUpdate(const ConfigObject::Ptr& object)
|
||||||
streamadd.emplace_back(kv.second);
|
streamadd.emplace_back(kv.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Rcon->ExecuteQuery(streamadd);
|
m_Rcon->ExecuteQuery(std::move(streamadd));
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr RedisWriter::SerializeState(const Checkable::Ptr& checkable)
|
Dictionary::Ptr RedisWriter::SerializeState(const Checkable::Ptr& checkable)
|
||||||
|
|
Loading…
Reference in New Issue