aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/distributormessagesender.cpp
blob: 1d02aae4a83d0f73d0cabd64219f828dbb988317 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "distributormessagesender.h"
#include <vespa/storageapi/messageapi/storagecommand.h>

namespace storage::distributor {

uint64_t
DistributorMessageSender::sendToNode(const lib::NodeType& nodeType, uint16_t node,
                                     const std::shared_ptr<api::StorageCommand> & cmd, bool useDocumentAPI)
{
    cmd->setSourceIndex(getDistributorIndex());
    const auto *cluster_np = cluster_context().cluster_name_ptr();
    cmd->setAddress(useDocumentAPI
                    ? api::StorageMessageAddress::createDocApi(cluster_np, nodeType, node)
                    : api::StorageMessageAddress::create(cluster_np, nodeType, node));
    uint64_t msgId = cmd->getMsgId();
    sendCommand(cmd);
    return msgId;
}

}