237-es7-fix - Add functions for getting ES version
This commit is contained in:
parent
46be31644b
commit
df2696e49a
2 changed files with 31 additions and 1 deletions
|
|
@ -47,8 +47,36 @@ bool checkES(ES& es)
|
||||||
if(doCurl(curl_request).empty())
|
if(doCurl(curl_request).empty())
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string getESVersion(ES& es)
|
||||||
|
{
|
||||||
|
graphene::utilities::CurlRequest curl_request;
|
||||||
|
curl_request.handler = es.curl;
|
||||||
|
curl_request.url = es.elasticsearch_url;
|
||||||
|
curl_request.auth = es.auth;
|
||||||
|
curl_request.type = "GET";
|
||||||
|
|
||||||
|
fc::variant response = fc::json::from_string(doCurl(curl_request));
|
||||||
|
|
||||||
|
return response["version"]["number"].as_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkESVersion7OrAbove(ES& es, bool& result) noexcept
|
||||||
|
{
|
||||||
|
static const int64_t version_7 = 7;
|
||||||
|
try {
|
||||||
|
const auto es_version = graphene::utilities::getESVersion(es);
|
||||||
|
auto dot_pos = es_version.find('.');
|
||||||
|
result = ( std::stoi(es_version.substr(0,dot_pos)) >= version_7 );
|
||||||
|
}
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
wlog( "Unable to get ES version, assuming it is 7 or above" );
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::string simpleQuery(ES& es)
|
const std::string simpleQuery(ES& es)
|
||||||
{
|
{
|
||||||
graphene::utilities::CurlRequest curl_request;
|
graphene::utilities::CurlRequest curl_request;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ namespace graphene { namespace utilities {
|
||||||
bool SendBulk(ES& es);
|
bool SendBulk(ES& es);
|
||||||
const std::vector<std::string> createBulk(const fc::mutable_variant_object& bulk_header, const std::string& data);
|
const std::vector<std::string> createBulk(const fc::mutable_variant_object& bulk_header, const std::string& data);
|
||||||
bool checkES(ES& es);
|
bool checkES(ES& es);
|
||||||
|
const std::string getESVersion(ES& es);
|
||||||
|
void checkESVersion7OrAbove(ES& es, bool& result) noexcept;
|
||||||
const std::string simpleQuery(ES& es);
|
const std::string simpleQuery(ES& es);
|
||||||
bool deleteAll(ES& es);
|
bool deleteAll(ES& es);
|
||||||
bool handleBulkResponse(long http_code, const std::string& CurlReadBuffer);
|
bool handleBulkResponse(long http_code, const std::string& CurlReadBuffer);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue