aboutsummaryrefslogtreecommitdiffstats
path: root/ydb/core/viewer/json_pdiskinfo.h
blob: aea0ef4a83a600d370bafc3761a0101513b34515 (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
#pragma once
#include <library/cpp/actors/core/actor_bootstrapped.h>
#include <library/cpp/actors/core/interconnect.h>
#include <library/cpp/actors/core/mon.h>
#include <ydb/core/protos/services.pb.h>
#include <ydb/core/node_whiteboard/node_whiteboard.h>
#include "json_wb_req.h"

namespace NKikimr {
namespace NViewer {

template <>
struct TWhiteboardInfo<TEvWhiteboard::TEvPDiskStateResponse> {
    using TResponseType = TEvWhiteboard::TEvPDiskStateResponse;
    using TElementType = NKikimrWhiteboard::TPDiskStateInfo;
    using TElementKeyType = std::pair<ui32, ui32>;

    static constexpr bool StaticNodesOnly = true;

    static ::google::protobuf::RepeatedPtrField<TElementType>* GetElementsField(TResponseType* response) {
        return response->Record.MutablePDiskStateInfo();
    }

    static std::pair<ui32, ui32> GetElementKey(const TElementType& type) {
        return std::make_pair(type.GetNodeId(), type.GetPDiskId());
    }

    static TString GetDefaultMergeField() {
        return "NodeId,PDiskId";
    }

    static THolder<TResponseType> MergeResponses(TMap<ui32, THolder<TResponseType>>& responses, const TString& fields = GetDefaultMergeField()) {
        if (fields == GetDefaultMergeField()) {
            return TWhiteboardMerger<TResponseType>::MergeResponsesElementKey(responses);
        } else {
            return TWhiteboardMerger<TResponseType>::MergeResponses(responses, fields);
        }
    }
};

using TJsonPDiskInfo = TJsonWhiteboardRequest<TEvWhiteboard::TEvPDiskStateRequest, TEvWhiteboard::TEvPDiskStateResponse>;

template <>
struct TJsonRequestSummary<TJsonPDiskInfo> {
    static TString GetSummary() { 
        return "\"PDisk information\"";
    }
};

template <>
struct TJsonRequestDescription<TJsonPDiskInfo> {
    static TString GetDescription() { 
        return "\"Returns PDisk information\"";
    }
};

}
}