1
0
Fork 0

Feature/detailed get maintenance feature (#6668)

* add local state output to _admin/actions
* test data generated from maintennace feature
* coordinators not needed for maintenance tests
This commit is contained in:
Kaveh Vahedipour 2018-10-01 14:51:14 +02:00 committed by Max Neunhöffer
parent 164b5be4fa
commit 3fd1375db5
14 changed files with 8363 additions and 6234 deletions

View File

@ -57,7 +57,7 @@ void DBServerAgencySync::work() {
_heartbeat->dispatchedJobResult(result);
}
Result getLocalCollections(VPackBuilder& collections) {
Result DBServerAgencySync::getLocalCollections(VPackBuilder& collections) {
using namespace arangodb::basics;
Result result;
@ -72,7 +72,6 @@ Result getLocalCollections(VPackBuilder& collections) {
return Result(TRI_ERROR_INTERNAL, "Failed to get feature database");
}
collections.clear();
VPackObjectBuilder c(&collections);
for (auto const& database : Databases::list()) {
@ -161,6 +160,7 @@ DBServerAgencySyncResult DBServerAgencySync::execute() {
LOG_TOPIC(DEBUG, Logger::MAINTENANCE) << "DBServerAgencySync::phaseOne done";
LOG_TOPIC(DEBUG, Logger::MAINTENANCE) << "DBServerAgencySync::phaseTwo";
local.clear();
glc = getLocalCollections(local);
// We intentionally refetch local collections here, such that phase 2
// can already see potential changes introduced by phase 1. The two

View File

@ -25,6 +25,8 @@
#define ARANGOD_CLUSTER_DB_SERVER_AGENCY_SYNC_H 1
#include "Basics/Common.h"
#include "Basics/Result.h"
#include "Basics/VelocyPackHelper.h"
namespace arangodb {
class HeartbeatThread;
@ -56,6 +58,12 @@ class DBServerAgencySync {
public:
void work();
/**
* @brief Get copy of current local state
* @param collections Builder to fill to
*/
static arangodb::Result getLocalCollections(VPackBuilder& collections);
private:
DBServerAgencySyncResult execute();

View File

@ -458,15 +458,20 @@ std::shared_ptr<Action> MaintenanceFeature::findReadyAction(
VPackBuilder MaintenanceFeature::toVelocyPack() const {
VPackBuilder vb;
toVelocyPack(vb);
return vb;
}
void MaintenanceFeature::toVelocyPack(VPackBuilder& vb) const {
READ_LOCKER(rLock, _actionRegistryLock);
{ VPackArrayBuilder ab(&vb);
for (auto const& action : _actionRegistry ) {
action->toVelocyPack(vb);
} // for
}
return vb;
} // MaintenanceFeature::toVelocyPack
#if 0

View File

@ -131,6 +131,9 @@ public:
/// @brief Create a VPackBuilder object with snapshot of current action registry
VPackBuilder toVelocyPack() const;
/// @brief Fill the envelope with snapshot of current action registry
void toVelocyPack(VPackBuilder& envelope) const;
/// @brief Returns json array of all MaintenanceActions within the deque
Result toJson(VPackBuilder & builder);

View File

@ -27,6 +27,7 @@
#include "Basics/StringUtils.h"
#include "Basics/conversions.h"
#include "Cluster/MaintenanceFeature.h"
#include "Cluster/DBServerAgencySync.h"
#include "Rest/HttpRequest.h"
#include "Rest/HttpResponse.h"
@ -152,10 +153,22 @@ bool MaintenanceRestHandler::parsePutBody(VPackSlice const & parameters) {
void MaintenanceRestHandler::getAction() {
// build the action
auto maintenance = ApplicationServer::getFeature<MaintenanceFeature>("Maintenance");
auto maintenance =
ApplicationServer::getFeature<MaintenanceFeature>("Maintenance");
VPackBuilder registry = maintenance->toVelocyPack();
generateResult(rest::ResponseCode::OK, registry.slice());
bool found;
std::string const& detailsStr = _request->value("details", found);
VPackBuilder builder;
{ VPackObjectBuilder o(&builder);
builder.add(VPackValue("registry"));
maintenance->toVelocyPack(builder);
if (found && StringUtils::boolean(detailsStr)) {
builder.add(VPackValue("state"));
DBServerAgencySync::getLocalCollections(builder);
}}
generateResult(rest::ResponseCode::OK, builder.slice());
} // MaintenanceRestHandler::getAction

View File

@ -77,17 +77,7 @@ for i in $servers; do
tmpfile=$shortname.tmp
outfile=$shortname.json
echo "{" >> $tmpfile
j=0
for i in $dbs; do
if [ $j -gt 0 ]; then
echo -n "," >> $tmpfile
fi
echo -n "\"$i\" :" >> $tmpfile
curl -s $endpoint/_db/$i/_admin/execute?returnAsJSON=true -d 'return require("@arangodb/cluster").getLocalInfo()'|jq .result >> $tmpfile
(( j++ ))
done
echo "}" >> $tmpfile
curl -s $endpoint/_admin/actions?details=true|jq .state >> $tmpfile
echo "R\"=(" > $outfile
cat $tmpfile | jq . >> $outfile
echo ")=\"" >> $outfile

View File

@ -1,242 +0,0 @@
R"=(
{
"foo": {
"foobar": {
"id": "1010083",
"name": "foobar",
"type": 3,
"status": 3,
"planId": "1010083",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010083/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 4,
"replicationFactor": 3,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "foobar/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
},
{
"fields": [
"_from",
"_to"
],
"id": "foobar/2",
"selectivityEstimate": 0.5,
"sparse": false,
"type": "edge",
"unique": false
}
]
},
"foobaz": {
"id": "1010088",
"name": "foobaz",
"type": 2,
"status": 3,
"planId": "1010088",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010088/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 6,
"replicationFactor": 2,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "foobaz/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
}
]
}
},
"_system": {
"bar": {
"id": "1010041",
"name": "bar",
"type": 3,
"status": 3,
"planId": "1010041",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010041/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 9,
"replicationFactor": 2,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "bar/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
},
{
"fields": [
"_from",
"_to"
],
"id": "bar/2",
"selectivityEstimate": 0.5,
"sparse": false,
"type": "edge",
"unique": false
},
{
"fields": [
"gi"
],
"geoJson": false,
"id": "bar/1010051",
"sparse": true,
"type": "geo",
"unique": false
},
{
"fields": [
"gij"
],
"geoJson": true,
"id": "bar/1010052",
"sparse": true,
"type": "geo",
"unique": false
},
{
"deduplicate": false,
"fields": [
"hi",
"_key"
],
"id": "bar/1010053",
"selectivityEstimate": 1,
"sparse": false,
"type": "hash",
"unique": true
},
{
"deduplicate": false,
"fields": [
"pi"
],
"id": "bar/1010054",
"selectivityEstimate": 1,
"sparse": true,
"type": "persistent",
"unique": false
},
{
"fields": [
"fi"
],
"id": "bar/2010132",
"minLength": 3,
"sparse": true,
"type": "fulltext",
"unique": false
},
{
"deduplicate": true,
"fields": [
"sli"
],
"id": "bar/1010055",
"selectivityEstimate": 1,
"sparse": false,
"type": "skiplist",
"unique": false
}
]
},
"baz": {
"id": "1010056",
"name": "baz",
"type": 2,
"status": 3,
"planId": "1010056",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010056/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 1,
"replicationFactor": 2,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "baz/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
}
]
}
}
}
)="

View File

@ -1,242 +0,0 @@
R"=(
{
"foo": {
"foobar": {
"id": "1010083",
"name": "foobar",
"type": 3,
"status": 3,
"planId": "1010083",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010083/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 4,
"replicationFactor": 3,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "foobar/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
},
{
"fields": [
"_from",
"_to"
],
"id": "foobar/2",
"selectivityEstimate": 0.5,
"sparse": false,
"type": "edge",
"unique": false
}
]
},
"foobaz": {
"id": "1010088",
"name": "foobaz",
"type": 2,
"status": 3,
"planId": "1010088",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010088/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 6,
"replicationFactor": 2,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "foobaz/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
}
]
}
},
"_system": {
"bar": {
"id": "1010041",
"name": "bar",
"type": 3,
"status": 3,
"planId": "1010041",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010041/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 9,
"replicationFactor": 2,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "bar/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
},
{
"fields": [
"_from",
"_to"
],
"id": "bar/2",
"selectivityEstimate": 0.5,
"sparse": false,
"type": "edge",
"unique": false
},
{
"fields": [
"gi"
],
"geoJson": false,
"id": "bar/1010051",
"sparse": true,
"type": "geo",
"unique": false
},
{
"fields": [
"gij"
],
"geoJson": true,
"id": "bar/1010052",
"sparse": true,
"type": "geo",
"unique": false
},
{
"deduplicate": false,
"fields": [
"hi",
"_key"
],
"id": "bar/1010053",
"selectivityEstimate": 1,
"sparse": false,
"type": "hash",
"unique": true
},
{
"deduplicate": false,
"fields": [
"pi"
],
"id": "bar/1010054",
"selectivityEstimate": 1,
"sparse": true,
"type": "persistent",
"unique": false
},
{
"fields": [
"fi"
],
"id": "bar/2010132",
"minLength": 3,
"sparse": true,
"type": "fulltext",
"unique": false
},
{
"deduplicate": true,
"fields": [
"sli"
],
"id": "bar/1010055",
"selectivityEstimate": 1,
"sparse": false,
"type": "skiplist",
"unique": false
}
]
},
"baz": {
"id": "1010056",
"name": "baz",
"type": 2,
"status": 3,
"planId": "1010056",
"theLeader": "",
"cacheEnabled": false,
"globallyUniqueId": "c1010056/",
"isSmart": false,
"isSystem": false,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional",
"lastValue": 0
},
"numberOfShards": 1,
"replicationFactor": 2,
"shardKeys": [
"_key"
],
"shardingStrategy": "hash",
"statusString": "loaded",
"waitForSync": false,
"indexes": [
{
"fields": [
"_key"
],
"id": "baz/0",
"selectivityEstimate": 1,
"sparse": false,
"type": "primary",
"unique": true
}
]
}
}
}
)="

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,56 @@
R"=(
{
"Health": {
"PRMR-e019be91-7012-4f29-b957-5e776b50fd00": {
"Endpoint": "tcp://[::1]:8630",
"PRMR-50478eb8-afe1-41b7-a78c-351bfe02b31c": {
"AdvertisedEndpoint": "",
"Timestamp": "2018-10-01T09:38:59Z",
"SyncStatus": "SERVING",
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"Status": "GOOD",
"Timestamp": "2018-08-24T16:01:15Z",
"ShortName": "DBServer0003",
"SyncStatus": "SERVING"
"Endpoint": "tcp://[::1]:11198"
},
"CRDN-63da8cf4-a3e9-4494-b708-8ced8fb3c981": {
"Endpoint": "tcp://[::1]:8531",
"PRMR-c18eb708-81bf-446f-977d-61b2c28e407c": {
"AdvertisedEndpoint": "",
"Timestamp": "2018-10-01T09:38:59Z",
"SyncStatus": "SERVING",
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"Status": "GOOD",
"Timestamp": "2018-08-24T16:01:15Z",
"ShortName": "Coordinator0001",
"SyncStatus": "SERVING"
},
"CRDN-6fde2d4e-e4dd-4ce0-8bec-2cb23d84d403": {
"Endpoint": "tcp://[::1]:8530",
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"Status": "GOOD",
"Timestamp": "2018-08-24T16:01:15Z",
"ShortName": "Coordinator0002",
"SyncStatus": "SERVING"
},
"PRMR-e05ce1ff-0e8c-4183-adf9-cfff25ad42e7": {
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"Status": "GOOD",
"Endpoint": "tcp://[::1]:8631",
"Timestamp": "2018-08-24T16:01:14Z",
"ShortName": "DBServer0001",
"SyncStatus": "SERVING"
},
"PRMR-a37809b4-ed91-40b7-8dad-39f1ee54cb67": {
"Endpoint": "tcp://[::1]:8629",
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"Status": "GOOD",
"Timestamp": "2018-08-24T16:01:15Z",
"ShortName": "DBServer0002",
"SyncStatus": "SERVING"
"Endpoint": "tcp://[::1]:11197"
},
"PRMR-f3a3c23f-6cc1-4d7e-ab17-e37fb662b4f5": {
"AdvertisedEndpoint": "",
"Timestamp": "2018-10-01T09:38:59Z",
"SyncStatus": "SERVING",
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"Status": "GOOD",
"ShortName": "DBServer0001",
"Endpoint": "tcp://[::1]:11196"
},
"CRDN-57234819-26be-4b6e-a91e-521527fbe208": {
"AdvertisedEndpoint": "",
"SyncStatus": "SERVING",
"Timestamp": "2018-10-01T09:39:00Z",
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"ShortName": "Coordinator0002",
"Status": "GOOD",
"Endpoint": "tcp://[::1]:11098"
},
"CRDN-4416fe9e-904c-4306-ad26-95c2b92c5020": {
"AdvertisedEndpoint": "",
"SyncStatus": "SERVING",
"Timestamp": "2018-10-01T09:39:01Z",
"Host": "ac8ddefc7d1f4364ba655b4debcd076f",
"ShortName": "Coordinator0001",
"Status": "GOOD",
"Endpoint": "tcp://[::1]:11097"
}
},
"DBServers": {},
"State": {
"Mode": "Normal",
"Timestamp": "2018-08-24T16:01:13Z"
"Timestamp": "2018-10-01T09:38:59Z"
},
"Shards": {}
}