8000 big reformat · arangodb/arangodb@5f5b6fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f5b6fb

Browse files
committed
big reformat
1 parent 2a6add0 commit 5f5b6fb

File tree

1,243 files changed

+29110
-35423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,243 files changed

+29110
-35423
lines changed

arangod/Actions/ActionFeature.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ using namespace arangodb::options;
3535
ActionFeature* ActionFeature::ACTION = nullptr;
3636

3737
ActionFeature::ActionFeature(application_features::ApplicationServer* server)
38-
: ApplicationFeature(server, "Action"),
39-
_allowUseDatabase(false) {
38+
: ApplicationFeature(server, "Action"), _allowUseDatabase(false) {
4039
setOptional(true);
4140
requiresElevatedPrivileges(false);
4241
startsAfter("Logger");
@@ -55,14 +54,12 @@ void ActionFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
5554
void ActionFeature::start() {
5655
ACTION = this;
5756

58-
V8DealerFeature* dealer =
57+
V8DealerFeature* dealer =
5958
ApplicationServer::getFeature<V8DealerFeature>("V8Dealer");
6059

61-
dealer->defineContextUpdate(
62-
[](v8::Isolate* isolate, v8::Handle<v8::Context> context, size_t) {
63-
TRI_InitV8Actions(isolate, context);
64-
},
65-
nullptr);
60+
dealer->defineContextUpdate([](v8::Isolate* isolate, v8::Handle<v8::Context> context,
61+
size_t) { TRI_InitV8Actions(isolate, context); },
62+
nullptr);
6663
}
6764

6865
void ActionFeature::unprepare() {

arangod/Actions/ActionFeature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ class ActionFeature final : public application_features::ApplicationFeature {
4444
private:
4545
bool _allowUseDatabase;
4646
};
47-
}
47+
} // namespace arangodb
4848

4949
#endif

arangod/Actions/RestActionHandler.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ using namespace arangodb;
3434
using namespace arangodb::basics;
3535
using namespace arangodb::rest;
3636

37-
RestActionHandler::RestActionHandler(GeneralRequest* request,
38-
GeneralResponse* response)
39-
: RestVocbaseBaseHandler(request, response),
40-
_action(nullptr),
41-
_dataLock(),
42-
_data(nullptr) {
37+
RestActionHandler::RestActionHandler(GeneralRequest* request, GeneralResponse* response)
38+
: RestVocbaseBaseHandler(request, response), _action(nullptr), _dataLock(), _data(nullptr) {
4339
_action = TRI_LookupActionVocBase(request);
4440
}
4541

@@ -99,8 +95,8 @@ bool RestActionHandler::cancel() {
9995
////////////////////////////////////////////////////////////////////////////////
10096

10197
TRI_action_result_t RestActionHandler::executeAction() {
102-
TRI_action_result_t result = _action->execute(
103-
_vocbase, _request.get(), _response.get(), &_dataLock, &_data);
98+
TRI_action_result_t result =
99+
_action->execute(_vocbase, _request.get(), _response.get(), &_dataLock, &_data);
104100

105101
if (!result.isValid) {
106102
if (result.canceled) {

arangod/Actions/RestActionHandler.h

-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ class RestActionHandler : public RestVocbaseBaseHandler {
5353
// data for cancelation
5454
void* _data;
5555
};
56-
}
56+
} // namespace arangodb
5757

5858
#endif

arangod/Actions/actions.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ static ReadWriteLock ActionsLock;
5454
/// @brief defines an action
5555
////////////////////////////////////////////////////////////////////////////////
5656

57-
TRI_action_t* TRI_DefineActionVocBase(std::string const& name,
58-
TRI_action_t* action) {
57+
TRI_action_t* TRI_DefineActionVocBase(std::string const& name, TRI_action_t* action) {
5958
std::string url = name;
6059

6160
while (!url.empty() && url[0] == '/') {
@@ -64,7 +63,7 @@ TRI_action_t* TRI_DefineActionVocBase(std::string const& name,
6463

6564
action->_url = url;
6665
action->_urlParts = StringUtils::split(url, "/").size();
67-
66+
6867
std::unordered_map<std::string, TRI_action_t*>* which;
6968

7069
WRITE_LOCKER(writeLocker, ActionsLock);
@@ -88,7 +87,9 @@ TRI_action_t* TRI_DefineActionVocBase(std::string const& name,
8887
}
8988

9089
// some debug output
91-
LOG_TOPIC(DEBUG, arangodb::Logger::FIXME) << "created JavaScript " << (action->_isPrefix ? "prefix " : "") << " action '" << url << "'";
90+
LOG_TOPIC(DEBUG, arangodb::Logger::FIXME)
91+
<< "created JavaScript " << (action->_isPrefix ? "prefix " : "")
92+
<< " action '" << url << "'";
9293

9394
// return old or new action description
9495
return action;
@@ -155,11 +156,11 @@ void TRI_CleanupActions() {
155156

156157
void TRI_VisitActions(std::function<void(TRI_action_t*)> const& visitor) {
157158
READ_LOCKER(writeLocker, ActionsLock);
158-
159+
159160
for (auto& it : Actions) {
160161
visitor(it.second);
161162
}
162-
163+
163164
for (auto& it : PrefixActions) {
164165
visitor(it.second);
165166
}

arangod/Actions/actions.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct TRI_vocbase_t;
3232
namespace arangodb {
3333
class GeneralRequest;
3434
class GeneralResponse;
35-
}
35+
} // namespace arangodb
3636

3737
////////////////////////////////////////////////////////////////////////////////
3838
/// @brief action result
@@ -52,20 +52,15 @@ class TRI_action_result_t {
5252

5353
class TRI_action_t {
5454
public:
55-
TRI_action_t()
56-
: _urlParts(0),
57-
_isPrefix(false),
58-
_allowUseDatabase(false) {}
55+
TRI_action_t() : _urlParts(0), _isPrefix(false), _allowUseDatabase(false) {}
5956

6057
virtual ~TRI_action_t() {}
6158

6259
virtual void visit(void*) = 0;
6360

64-
virtual TRI_action_result_t execute(TRI_vocbase_t*,
65-
arangodb::GeneralRequest*,
61+
virtual TRI_action_result_t execute(TRI_vocbase_t*, arangodb::GeneralRequest*,
6662
arangodb::GeneralResponse*,
67-
arangodb::Mutex* dataLock,
68-
void** data) = 0;
63+
arangodb::Mutex* dataLock, void** data) = 0;
6964

7065
virtual bool cancel(arangodb::Mutex* dataLock, void** data) = 0;
7166

@@ -81,8 +76,7 @@ class TRI_action_t {
8176
/// @brief defines an action
8277
////////////////////////////////////////////////////////////////////////////////
8378

84-
TRI_action_t* TRI_DefineActionVocBase(std::string const& name,
85-
TRI_action_t* action);
79+
TRI_action_t* TRI_DefineActionVocBase(std::string const& name, TRI_action_t* action);
8680

8781
////////////////////////////////////////////////////////////////////////////////
8882
/// @brief looks up an action

arangod/Agency/AddFollower.cpp

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ using namespace arangodb::consensus;
3131
AddFollower::AddFollower(Node const& snapshot, AgentInterface* agent,
3232
std::string const& jobId, std::string const& creator,
3333
std::string const& database,
34-
std::string const& collection,
35-
std::string const& shard)
34+
std::string const& collection, std::string const& shard)
3635
: Job(NOTFOUND, snapshot, agent, jobId, creator),
3736
_database(database),
3837
_collection(collection),
@@ -59,15 +58,14 @@ AddFollower::AddFollower(Node const& snapshot, AgentInterface* agent,
5958

6059
AddFollower::~AddFollower() {}
6160

62-
void AddFollower::run() {
63-
runHelper("", _shard);
64-
}
61+
void AddFollower::run() { runHelper("", _shard); }
6562

6663
bool AddFollower::create(std::shared_ptr<VPackBuilder> envelope) {
67-
LOG_TOPIC(INFO, Logger::SUPERVISION) << "Todo: AddFollower(s) "
68-
<< " to shard " << _shard << " in collection " << _collection;
64+
LOG_TOPIC(INFO, Logger::SUPERVISION)
65+
<< "Todo: AddFollower(s) "
66+
<< " to shard " << _shard << " in collection " << _collection;
6967

70-
bool selfCreate = (envelope == nullptr); // Do we create ourselves?
68+
bool selfCreate = (envelope == nullptr); // Do we create ourselves?
7169

7270
if (selfCreate) {
7371
_jb = std::make_shared<Builder>();
@@ -85,7 +83,8 @@ bool AddFollower::create(std::shared_ptr<VPackBuilder> envelope) {
8583
std::string path = toDoPrefix + _jobId;
8684

8785
_jb->add(VPackValue(path));
88-
{ VPackObjectBuilder guard(_jb.get());
86+
{
87+
VPackObjectBuilder guard(_jb.get());
8988
_jb->add("creator", VPackValue(_creator));
9089
_jb->add("type", VPackValue("addFollower"));
9190
_jb->add("database", VPackValue(_database));
@@ -131,7 +130,7 @@ bool AddFollower::start() {
131130
"collection must not have 'distributeShardsLike' attribute");
132131
return false;
133132
}
134-
133+
135134
// Look at Plan:
136135
std::string planPath =
137136
planColPrefix + _database + "/" + _collection + "/shards/" + _shard;
@@ -151,17 +150,18 @@ bool AddFollower::start() {
151150

152151
// Check that the shard is not locked:
153152
if (_snapshot.has(blockedShardsPrefix + _shard)) {
154-
LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "shard " << _shard
155-
<< " is currently locked, not starting AddFollower job " << _jobId;
153+
LOG_TOPIC(DEBUG, Logger::SUPERVISION)
154+
<< "shard " << _shard
155+
<< " is currently locked, not starting AddFollower job " << _jobId;
156156
return false;
157157
}
158158

159159
// Now find some new servers to add:
160160
auto available = Job::availableServers(_snapshot);
161161
// Remove those already in Plan:
162162
for (VPackSlice server : VPackArrayIterator(planned)) {
163-
available.erase(std::remove(available.begin(), available.end(),
164-
server.copyString()), available.end());
163+
available.erase(std::remove(available.begin(), available.end(), server.copyString()),
164+
available.end());
165165
}
166166
// Remove those that are not in state "GOOD":
167167
auto it = available.begin();
@@ -175,9 +175,9 @@ bool AddFollower::start() {
175175

176176
// Check that we have enough:
177177
if (available.size() < desiredReplFactor - actualReplFactor) {
178-
LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "shard " << _shard
179-
<< " does not have enough candidates to add followers, waiting, jobId="
180-
<< _jobId;
178+
LOG_TOPIC(DEBUG, Logger::SUPERVISION)
179+
<< "shard " << _shard
180+
<< " does not have enough candidates to add followers, waiting, jobId=" << _jobId;
181181
return false;
182182
}
183183

@@ -194,14 +194,15 @@ bool AddFollower::start() {
194194
}
195195

196196
// Now we can act, simply add all in chosen to all plans for all shards:
197-
std::vector<Job::shard_t> shardsLikeMe
198-
= clones(_snapshot, _database, _collection, _shard);
197+
std::vector<Job::shard_t> shardsLikeMe =
198+
clones(_snapshot, _database, _collection, _shard);
199199

200200
// Copy todo to finished:
201201
Builder todo, trx;
202202

203203
// Get todo entry
204-
{ VPackArrayBuilder guard(&todo);
204+
{
205+
VPackArrayBuilder guard(&todo);
205206
// When create() was done with the current snapshot, then the job object
206207
// will not be in the snapshot under ToDo, but in this case we find it
207208
// in _jb:
@@ -211,8 +212,8 @@ bool AddFollower::start() {
211212
} catch (std::exception const&) {
212213
// Just in case, this is never going to happen, since we will only
213214
// call the start() method if the job is already in ToDo.
214-
LOG_TOPIC(INFO, Logger::SUPERVISION)
215-
<< "Failed to get key " + toDoPrefix + _jobId + " from agency snapshot";
215+
LOG_TOPIC(INFO, Logger::SUPERVISION) << "Failed to get key " + toDoPrefix + _jobId +
216+
" from agency snapshot";
216217
return false;
217218
}
218219
} else {
@@ -221,60 +222,64 @@ bool AddFollower::start() {
221222
} catch (std::exception const& e) {
222223
// Just in case, this is never going to happen, since when _jb is
223224
// set, then the current job is stored under ToDo.
224-
LOG_TOPIC(WARN, Logger::SUPERVISION) << e.what() << ": "
225-
<< __FILE__ << ":" << __LINE__;
225+
LOG_TOPIC(WARN, Logger::SUPERVISION)
226+
<< e.what() << ": " << __FILE__ << ":" << __LINE__;
226227
return false;
227228
}
228229
}
229230
}
230-
231+
231232
// Enter pending, remove todo, block toserver
232-
{ VPackArrayBuilder listOfTransactions(&trx);
233+
{
234+
VPackArrayBuilder listOfTransactions(&trx);
233235

234-
{ VPackObjectBuilder objectForMutation(&trx);
236+
{
237+
VPackObjectBuilder objectForMutation(&trx);
235238

236239
addPutJobIntoSomewhere(trx, "Finished", todo.slice()[0]);
237240
addRemoveJobFromSomewhere(trx, "ToDo", _jobId);
238241

239242
// --- Plan changes
240243
doForAllShards(_snapshot, _database, shardsLikeMe,
241-
[&trx, &chosen](Slice plan, Slice current, std::string& planPath) {
242-
trx.add(VPackValue(planPath));
243-
{ VPackArrayBuilder serverList(&trx);
244-
for (auto const& srv : VPackArrayIterator(plan)) {
245-
trx.add(srv);
246-
}
247-
for (auto const& srv : chosen) {
248-
trx.add(VPackValue(srv));
249-
}
250-
}
251-
});
244+
[&trx, &chosen](Slice plan, Slice current, std::string& planPath) {
245+
trx.add(VPackValue(planPath));
246+
{
247+
VPackArrayBuilder serverList(&trx);
248+
for (auto const& srv : VPackArrayIterator(plan)) {
249+
trx.add(srv);
250+
}
251+
for (auto const& srv : chosen) {
252+
trx.add(VPackValue(srv));
253+
}
254+
}
255+
});
252256

253257
addIncreasePlanVersion(trx);
254258
} // mutation part of transaction done
255259
// Preconditions
256-
{ VPackObjectBuilder precondition(&trx);
260+
{
261+
VPackObjectBuilder precondition(&trx);
257262
// --- Check that Planned servers are still as we expect
258263
addPreconditionUnchanged(trx, planPath, planned);
259264
addPreconditionShardNotBlocked(trx, _shard);
260265
for (auto const& srv : chosen) {
261266
addPreconditionServerGood(trx, srv);
262267
}
263-
} // precondition done
264-
} // array for transaction done
265-
268+
} // precondition done
269+
} // array for transaction done
270+
266271
// Transact to agency
267272
write_ret_t res = singleWriteTransaction(_agent, trx);
268273

269274
if (res.accepted && res.indices.size() == 1 && res.indices[0]) {
270275
_status = FINISHED;
271-
LOG_TOPIC(INFO, Logger::SUPERVISION)
272-
<< "Pending: Addfollower(s) to shard " << _shard << " in collection "
273-
<< _collection;
276+
LOG_TOPIC(INFO, Logger::SUPERVISION) << "Pending: Addfollower(s) to shard " << _shard
277+
<< " in collection " << _collection;
274278
return true;
275279
}
276280

277-
LOG_TOPIC(INFO, Logger::SUPERVISION) << "Start precondition failed for AddFollower " + _jobId;
281+
LOG_TOPIC(INFO, Logger::SUPERVISION)
282+
<< "Start precondition failed for AddFollower " + _jobId;
278283
return false;
279284
}
280285

@@ -283,20 +288,19 @@ JOB_STATUS AddFollower::status() {
283288
return _status;
284289
}
285290

286-
TRI_ASSERT(false); // PENDING is not an option for this job, since it
287-
// travels directly from ToDo to Finished or Failed
291+
TRI_ASSERT(false); // PENDING is not an option for this job, since it
292+
// travels directly from ToDo to Finished or Failed
288293
return _status;
289294
}
290295

291296
arangodb::Result AddFollower::abort() {
292-
293297
// We can assume that the job is in ToDo or not there:
294298
if (_status == NOTFOUND || _status == FINISHED || _status == FAILED) {
295299
return Result(TRI_ERROR_SUPERVISION_GENERAL_FAILURE,
296300
"Failed aborting addFollower job beyond pending stage");
297301
}
298302

299-
Result result;
303+
Result result;
300304
// Can now only be TODO or PENDING
301305
if (_status == TODO) {
302306
finish("", "", false, "job aborted");
@@ -305,6 +309,4 @@ arangodb::Result AddFollower::abort() {
305309

306310
TRI_ASSERT(false); // cannot happen, since job moves directly to FINISHED
307311
return result;
308-
309312
}
310-

0 commit comments

Comments
 (0)
0