blob: 32a80b2c4ea0005b29d38f041e105a15af607707 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/storage/distributor/operations/operation.h>
#include <vespa/storage/distributor/operation_sequencer.h>
#include <memory>
namespace storage::distributor {
class PendingMessageTracker;
class VisitorOperation;
class OperationOwner;
class UuidGenerator;
/**
* Operation starting indirection for a visitor operation that has the semantics
* of an exclusive bucket lock. Such operations can only resolve to a single
* super-bucket/sub-bucket pair and care should be taken to avoid starving client
* operations through long-running locks.
*
* Operation starting may be deferred to the PendingMessageTracker if there are
* pending operations to the sub-bucket when onStart is called. If so, the deferred
* operation start takes place automatically and immediately when all pending
* bucket operations have completed. These will be started in the context of the
* OperationOwner provided to the operation.
*/
class ReadForWriteVisitorOperationStarter
: public Operation,
public std::enable_shared_from_this<ReadForWriteVisitorOperationStarter>
{
std::shared_ptr<VisitorOperation> _visitor_op;
OperationSequencer& _operation_sequencer;
OperationOwner& _stable_operation_owner;
PendingMessageTracker& _message_tracker;
UuidGenerator& _uuid_generator;
public:
ReadForWriteVisitorOperationStarter(std::shared_ptr<VisitorOperation> visitor_op,
OperationSequencer& operation_sequencer,
OperationOwner& stable_operation_owner,
PendingMessageTracker& message_tracker,
UuidGenerator& uuid_generator);
~ReadForWriteVisitorOperationStarter() override;
const char* getName() const noexcept override { return "ReadForWriteVisitorOperationStarter"; }
void onClose(DistributorStripeMessageSender& sender) override;
void onStart(DistributorStripeMessageSender& sender) override;
void onReceive(DistributorStripeMessageSender& sender,
const std::shared_ptr<api::StorageReply> & msg) override;
private:
bool bucket_has_pending_merge(const document::Bucket&, const PendingMessageTracker& tracker) const;
};
}
|