aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/bmcluster/storage_reply_error_checker.cpp
blob: 3a57a8d204ff3ae7a8541067574f278d7b51796f (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "storage_reply_error_checker.h"
#include <vespa/storageapi/messageapi/storagereply.h>

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

namespace search::bmcluster {

StorageReplyErrorChecker::StorageReplyErrorChecker()
    : _errors(0u)
{
}

StorageReplyErrorChecker::~StorageReplyErrorChecker() = default;

void
StorageReplyErrorChecker::check_error(const storage::api::StorageMessage &msg)
{
    auto reply = dynamic_cast<const storage::api::StorageReply*>(&msg);
    if (reply != nullptr) {
        if (reply->getResult().failed()) {
            if (++_errors <= 10) {
                LOG(info, "reply '%s', return code '%s'", reply->toString().c_str(), reply->getResult().toString().c_str());
            }
        }
    } else {
        ++_errors;
    }
}

}