aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/operations/operation.cpp
blob: f60dc8eecff9eb86f5c18598f1dd5fb7fd9500c3 (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
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "operation.h"
#include <vespa/storage/common/distributorcomponent.h>
#include <vespa/storageapi/messageapi/storagecommand.h>
#include <vespa/storageapi/messageapi/storagereply.h>
#include <vespa/vespalib/util/stringfmt.h>

#include <vespa/log/log.h>
LOG_SETUP(".distributor.callback");

namespace storage::distributor {

Operation::Operation()
    : _startTime(),
      _cancel_scope()
{
}

Operation::~Operation() = default;

std::string
Operation::getStatus() const
{
    return vespalib::make_string("%s (started %s)", getName(), vespalib::to_string(_startTime).c_str());
}

void
Operation::start(DistributorStripeMessageSender& sender, vespalib::system_time startTime)
{
    _startTime = startTime;
    onStart(sender);
}

void
Operation::start(DistributorStripeMessageSender& sender)
{
    start(sender, vespalib::system_time());
}

void
Operation::copyMessageSettings(const api::StorageCommand& source, api::StorageCommand& target)
{
    target.getTrace().setLevel(source.getTrace().getLevel());
    target.setTimeout(source.getTimeout());
    target.setPriority(source.getPriority());
}

void Operation::cancel(DistributorStripeMessageSender& sender, const CancelScope& cancel_scope) {
    _cancel_scope.merge(cancel_scope);
    on_cancel(sender, cancel_scope);
}

void
Operation::on_blocked()
{
}

void
Operation::on_throttled()
{
}

}