2017-05-26 04:48:44 +08:00
|
|
|
/*
|
|
|
|
* StorageServerInterface.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FDBCLIENT_STORAGESERVERINTERFACE_H
|
|
|
|
#define FDBCLIENT_STORAGESERVERINTERFACE_H
|
|
|
|
#pragma once
|
|
|
|
|
2018-10-20 01:30:13 +08:00
|
|
|
#include "fdbclient/FDBTypes.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbrpc/Locality.h"
|
|
|
|
#include "fdbrpc/QueueModel.h"
|
|
|
|
#include "fdbrpc/fdbrpc.h"
|
|
|
|
#include "fdbrpc/LoadBalance.actor.h"
|
2020-07-10 07:39:15 +08:00
|
|
|
#include "fdbrpc/Stats.h"
|
2019-08-01 23:39:52 +08:00
|
|
|
#include "fdbrpc/TimedRequest.h"
|
2021-03-06 03:28:15 +08:00
|
|
|
#include "fdbrpc/TSSComparison.h"
|
2021-03-05 11:29:18 +08:00
|
|
|
#include "fdbclient/CommitTransaction.h"
|
2021-08-11 09:07:36 +08:00
|
|
|
#include "fdbclient/TagThrottle.actor.h"
|
2021-03-06 03:28:15 +08:00
|
|
|
#include "flow/UnitTest.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-08-29 05:40:50 +08:00
|
|
|
// Dead code, removed in the next protocol version
|
|
|
|
struct VersionReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 3;
|
|
|
|
|
|
|
|
Version version;
|
|
|
|
VersionReply() = default;
|
|
|
|
explicit VersionReply(Version version) : version(version) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, version);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct StorageServerInterface {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 15302073;
|
|
|
|
enum { BUSY_ALLOWED = 0, BUSY_FORCE = 1, BUSY_LOCAL = 2 };
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
enum { LocationAwareLoadBalance = 1 };
|
2018-11-03 04:15:09 +08:00
|
|
|
enum { AlwaysFresh = 0 };
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
LocalityData locality;
|
|
|
|
UID uniqueID;
|
2021-05-13 02:53:20 +08:00
|
|
|
Optional<UID> tssPairID;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
RequestStream<struct GetValueRequest> getValue;
|
|
|
|
RequestStream<struct GetKeyRequest> getKey;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// Throws a wrong_shard_server if the keys in the request or result depend on data outside this server OR if a large
|
|
|
|
// selector offset prevents all data from being read in one range read
|
2017-05-26 04:48:44 +08:00
|
|
|
RequestStream<struct GetKeyValuesRequest> getKeyValues;
|
|
|
|
|
|
|
|
RequestStream<struct GetShardStateRequest> getShardState;
|
|
|
|
RequestStream<struct WaitMetricsRequest> waitMetrics;
|
|
|
|
RequestStream<struct SplitMetricsRequest> splitMetrics;
|
2019-07-26 07:27:32 +08:00
|
|
|
RequestStream<struct GetStorageMetricsRequest> getStorageMetrics;
|
2017-05-26 04:48:44 +08:00
|
|
|
RequestStream<ReplyPromise<Void>> waitFailure;
|
|
|
|
RequestStream<struct StorageQueuingMetricsRequest> getQueuingMetrics;
|
|
|
|
|
|
|
|
RequestStream<ReplyPromise<KeyValueStoreType>> getKeyValueStoreType;
|
|
|
|
RequestStream<struct WatchValueRequest> watchValue;
|
2020-05-09 07:37:35 +08:00
|
|
|
RequestStream<struct ReadHotSubRangeRequest> getReadHotRanges;
|
2020-06-19 00:37:49 +08:00
|
|
|
RequestStream<struct SplitRangeRequest> getRangeSplitPoints;
|
2021-08-11 12:28:25 +08:00
|
|
|
RequestStream<struct GetKeyValuesStreamRequest> getKeyValuesStream;
|
2021-08-14 05:27:15 +08:00
|
|
|
RequestStream<struct ChangeFeedStreamRequest> changeFeedStream;
|
|
|
|
RequestStream<struct OverlappingChangeFeedsRequest> overlappingChangeFeeds;
|
|
|
|
RequestStream<struct ChangeFeedPopRequest> changeFeedPop;
|
2020-06-19 00:37:49 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
explicit StorageServerInterface(UID uid) : uniqueID(uid) {}
|
|
|
|
StorageServerInterface() : uniqueID(deterministicRandom()->randomUniqueID()) {}
|
2019-08-27 04:53:54 +08:00
|
|
|
NetworkAddress address() const { return getValue.getEndpoint().getPrimaryAddress(); }
|
2020-04-11 04:45:16 +08:00
|
|
|
NetworkAddress stableAddress() const { return getValue.getEndpoint().getStableAddress(); }
|
2020-03-13 01:18:53 +08:00
|
|
|
Optional<NetworkAddress> secondaryAddress() const { return getValue.getEndpoint().addresses.secondaryAddress; }
|
2017-05-26 04:48:44 +08:00
|
|
|
UID id() const { return uniqueID; }
|
2021-05-13 02:53:20 +08:00
|
|
|
bool isTss() const { return tssPairID.present(); }
|
2017-05-26 04:48:44 +08:00
|
|
|
std::string toString() const { return id().shortString(); }
|
2020-02-05 10:23:39 +08:00
|
|
|
template <class Ar>
|
2020-03-13 01:18:53 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-05-23 07:35:01 +08:00
|
|
|
// StorageServerInterface is persisted in the database, so changes here have to be versioned carefully!
|
2021-03-11 02:06:03 +08:00
|
|
|
// To change this serialization, ProtocolVersion::ServerListValue must be updated, and downgrades need to be
|
|
|
|
// considered
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-05-02 12:37:19 +08:00
|
|
|
if (ar.protocolVersion().hasSmallEndpoints()) {
|
2021-03-06 03:28:15 +08:00
|
|
|
if (ar.protocolVersion().hasTSS()) {
|
2021-05-13 02:53:20 +08:00
|
|
|
serializer(ar, uniqueID, locality, getValue, tssPairID);
|
2021-03-06 03:28:15 +08:00
|
|
|
} else {
|
|
|
|
serializer(ar, uniqueID, locality, getValue);
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
if (Ar::isDeserializing) {
|
|
|
|
getKey = RequestStream<struct GetKeyRequest>(getValue.getEndpoint().getAdjustedEndpoint(1));
|
|
|
|
getKeyValues = RequestStream<struct GetKeyValuesRequest>(getValue.getEndpoint().getAdjustedEndpoint(2));
|
|
|
|
getShardState =
|
|
|
|
RequestStream<struct GetShardStateRequest>(getValue.getEndpoint().getAdjustedEndpoint(3));
|
|
|
|
waitMetrics = RequestStream<struct WaitMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(4));
|
|
|
|
splitMetrics = RequestStream<struct SplitMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(5));
|
|
|
|
getStorageMetrics =
|
|
|
|
RequestStream<struct GetStorageMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(6));
|
|
|
|
waitFailure = RequestStream<ReplyPromise<Void>>(getValue.getEndpoint().getAdjustedEndpoint(7));
|
|
|
|
getQueuingMetrics =
|
|
|
|
RequestStream<struct StorageQueuingMetricsRequest>(getValue.getEndpoint().getAdjustedEndpoint(8));
|
|
|
|
getKeyValueStoreType =
|
|
|
|
RequestStream<ReplyPromise<KeyValueStoreType>>(getValue.getEndpoint().getAdjustedEndpoint(9));
|
|
|
|
watchValue = RequestStream<struct WatchValueRequest>(getValue.getEndpoint().getAdjustedEndpoint(10));
|
|
|
|
getReadHotRanges =
|
|
|
|
RequestStream<struct ReadHotSubRangeRequest>(getValue.getEndpoint().getAdjustedEndpoint(11));
|
|
|
|
getRangeSplitPoints =
|
|
|
|
RequestStream<struct SplitRangeRequest>(getValue.getEndpoint().getAdjustedEndpoint(12));
|
2021-06-20 00:47:13 +08:00
|
|
|
getKeyValuesStream =
|
2021-08-10 01:05:56 +08:00
|
|
|
RequestStream<struct GetKeyValuesStreamRequest>(getValue.getEndpoint().getAdjustedEndpoint(13));
|
2021-08-14 05:27:15 +08:00
|
|
|
changeFeedStream =
|
2021-10-20 04:56:52 +08:00
|
|
|
RequestStream<struct ChangeFeedStreamRequest>(getValue.getEndpoint().getAdjustedEndpoint(14));
|
2021-08-14 05:27:15 +08:00
|
|
|
overlappingChangeFeeds =
|
2021-10-20 04:56:52 +08:00
|
|
|
RequestStream<struct OverlappingChangeFeedsRequest>(getValue.getEndpoint().getAdjustedEndpoint(15));
|
2021-08-14 05:27:15 +08:00
|
|
|
changeFeedPop =
|
2021-10-20 04:56:52 +08:00
|
|
|
RequestStream<struct ChangeFeedPopRequest>(getValue.getEndpoint().getAdjustedEndpoint(16));
|
2020-05-02 12:37:19 +08:00
|
|
|
}
|
2019-01-29 11:38:13 +08:00
|
|
|
} else {
|
2020-05-02 12:37:19 +08:00
|
|
|
ASSERT(Ar::isDeserializing);
|
|
|
|
if constexpr (is_fb_function<Ar>) {
|
|
|
|
ASSERT(false);
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
serializer(ar,
|
|
|
|
uniqueID,
|
|
|
|
locality,
|
|
|
|
getValue,
|
|
|
|
getKey,
|
|
|
|
getKeyValues,
|
|
|
|
getShardState,
|
|
|
|
waitMetrics,
|
|
|
|
splitMetrics,
|
|
|
|
getStorageMetrics,
|
|
|
|
waitFailure,
|
|
|
|
getQueuingMetrics,
|
|
|
|
getKeyValueStoreType);
|
2021-03-06 03:28:15 +08:00
|
|
|
if (ar.protocolVersion().hasWatches()) {
|
2021-03-11 02:06:03 +08:00
|
|
|
serializer(ar, watchValue);
|
2021-03-06 03:28:15 +08:00
|
|
|
}
|
2019-01-29 11:38:13 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator==(StorageServerInterface const& s) const { return uniqueID == s.uniqueID; }
|
|
|
|
bool operator<(StorageServerInterface const& s) const { return uniqueID < s.uniqueID; }
|
2017-05-26 04:48:44 +08:00
|
|
|
void initEndpoints() {
|
2020-05-02 12:37:19 +08:00
|
|
|
std::vector<std::pair<FlowReceiver*, TaskPriority>> streams;
|
|
|
|
streams.push_back(getValue.getReceiver(TaskPriority::LoadBalancedEndpoint));
|
|
|
|
streams.push_back(getKey.getReceiver(TaskPriority::LoadBalancedEndpoint));
|
|
|
|
streams.push_back(getKeyValues.getReceiver(TaskPriority::LoadBalancedEndpoint));
|
|
|
|
streams.push_back(getShardState.getReceiver());
|
|
|
|
streams.push_back(waitMetrics.getReceiver());
|
|
|
|
streams.push_back(splitMetrics.getReceiver());
|
|
|
|
streams.push_back(getStorageMetrics.getReceiver());
|
|
|
|
streams.push_back(waitFailure.getReceiver());
|
|
|
|
streams.push_back(getQueuingMetrics.getReceiver());
|
|
|
|
streams.push_back(getKeyValueStoreType.getReceiver());
|
|
|
|
streams.push_back(watchValue.getReceiver());
|
2020-05-09 07:37:35 +08:00
|
|
|
streams.push_back(getReadHotRanges.getReceiver());
|
2020-07-01 05:28:15 +08:00
|
|
|
streams.push_back(getRangeSplitPoints.getReceiver());
|
2021-08-10 01:05:56 +08:00
|
|
|
streams.push_back(getKeyValuesStream.getReceiver(TaskPriority::LoadBalancedEndpoint));
|
2021-08-14 05:27:15 +08:00
|
|
|
streams.push_back(changeFeedStream.getReceiver());
|
|
|
|
streams.push_back(overlappingChangeFeeds.getReceiver());
|
|
|
|
streams.push_back(changeFeedPop.getReceiver());
|
2020-05-20 06:35:57 +08:00
|
|
|
FlowTransport::transport().addEndpoints(streams);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-16 12:13:44 +08:00
|
|
|
struct StorageInfo : NonCopyable, public ReferenceCounted<StorageInfo> {
|
|
|
|
Tag tag;
|
|
|
|
StorageServerInterface interf;
|
|
|
|
StorageInfo() : tag(invalidTag) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ServerCacheInfo {
|
2021-02-11 05:45:06 +08:00
|
|
|
std::vector<Tag> tags; // all tags in both primary and remote DC for the key-range
|
2018-02-01 09:35:48 +08:00
|
|
|
std::vector<Reference<StorageInfo>> src_info;
|
|
|
|
std::vector<Reference<StorageInfo>> dest_info;
|
2019-04-23 02:55:04 +08:00
|
|
|
|
|
|
|
void populateTags() {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (tags.size())
|
|
|
|
return;
|
2019-04-23 02:55:04 +08:00
|
|
|
|
|
|
|
for (const auto& info : src_info) {
|
|
|
|
tags.push_back(info->tag);
|
|
|
|
}
|
|
|
|
for (const auto& info : dest_info) {
|
|
|
|
tags.push_back(info->tag);
|
|
|
|
}
|
|
|
|
uniquify(tags);
|
|
|
|
}
|
2017-12-16 12:13:44 +08:00
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct GetValueReply : public LoadBalancedReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 1378929;
|
2017-05-26 04:48:44 +08:00
|
|
|
Optional<Value> value;
|
2020-01-15 04:33:17 +08:00
|
|
|
bool cached;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-01-15 04:33:17 +08:00
|
|
|
GetValueReply() : cached(false) {}
|
|
|
|
GetValueReply(Optional<Value> value, bool cached) : value(value), cached(cached) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-01-27 12:56:59 +08:00
|
|
|
serializer(ar, LoadBalancedReply::penalty, LoadBalancedReply::error, value, cached);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-12-01 02:46:04 +08:00
|
|
|
struct GetValueRequest : TimedRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 8454530;
|
2020-07-08 00:06:13 +08:00
|
|
|
SpanID spanContext;
|
2017-05-26 04:48:44 +08:00
|
|
|
Key key;
|
|
|
|
Version version;
|
2020-04-11 04:29:28 +08:00
|
|
|
Optional<TagSet> tags;
|
2017-05-26 04:48:44 +08:00
|
|
|
Optional<UID> debugID;
|
|
|
|
ReplyPromise<GetValueReply> reply;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
GetValueRequest() {}
|
2020-07-08 00:06:13 +08:00
|
|
|
GetValueRequest(SpanID spanContext, const Key& key, Version ver, Optional<TagSet> tags, Optional<UID> debugID)
|
|
|
|
: spanContext(spanContext), key(key), version(ver), tags(tags), debugID(debugID) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-07-08 00:06:13 +08:00
|
|
|
serializer(ar, key, version, tags, debugID, reply, spanContext);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-29 05:40:50 +08:00
|
|
|
struct WatchValueReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 3;
|
|
|
|
|
|
|
|
Version version;
|
2020-01-27 12:56:59 +08:00
|
|
|
bool cached = false;
|
2019-08-29 05:40:50 +08:00
|
|
|
WatchValueReply() = default;
|
|
|
|
explicit WatchValueReply(Version version) : version(version) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-01-27 12:56:59 +08:00
|
|
|
serializer(ar, version, cached);
|
2019-08-29 05:40:50 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct WatchValueRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 14747733;
|
2020-07-08 00:06:13 +08:00
|
|
|
SpanID spanContext;
|
2017-05-26 04:48:44 +08:00
|
|
|
Key key;
|
|
|
|
Optional<Value> value;
|
|
|
|
Version version;
|
2020-04-11 04:29:28 +08:00
|
|
|
Optional<TagSet> tags;
|
2017-05-26 04:48:44 +08:00
|
|
|
Optional<UID> debugID;
|
2019-08-29 05:40:50 +08:00
|
|
|
ReplyPromise<WatchValueReply> reply;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
WatchValueRequest() {}
|
|
|
|
WatchValueRequest(SpanID spanContext,
|
|
|
|
const Key& key,
|
|
|
|
Optional<Value> value,
|
|
|
|
Version ver,
|
|
|
|
Optional<TagSet> tags,
|
2020-07-08 00:06:13 +08:00
|
|
|
Optional<UID> debugID)
|
|
|
|
: spanContext(spanContext), key(key), value(value), version(ver), tags(tags), debugID(debugID) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-07-08 00:06:13 +08:00
|
|
|
serializer(ar, key, value, version, tags, debugID, reply, spanContext);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GetKeyValuesReply : public LoadBalancedReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 1783066;
|
2017-05-26 04:48:44 +08:00
|
|
|
Arena arena;
|
2019-07-16 05:46:00 +08:00
|
|
|
VectorRef<KeyValueRef, VecSerStrategy::String> data;
|
2017-05-26 04:48:44 +08:00
|
|
|
Version version; // useful when latestVersion was requested
|
|
|
|
bool more;
|
2020-01-27 12:56:59 +08:00
|
|
|
bool cached = false;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-11-13 05:01:29 +08:00
|
|
|
GetKeyValuesReply() : version(invalidVersion), more(false), cached(false) {}
|
2019-06-21 04:57:56 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-01-27 12:56:59 +08:00
|
|
|
serializer(ar, LoadBalancedReply::penalty, LoadBalancedReply::error, data, version, more, cached, arena);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-12-01 02:46:04 +08:00
|
|
|
struct GetKeyValuesRequest : TimedRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 6795746;
|
2020-07-08 00:06:13 +08:00
|
|
|
SpanID spanContext;
|
2017-05-26 04:48:44 +08:00
|
|
|
Arena arena;
|
|
|
|
KeySelectorRef begin, end;
|
2021-03-11 02:06:03 +08:00
|
|
|
Version version; // or latestVersion
|
2017-05-26 04:48:44 +08:00
|
|
|
int limit, limitBytes;
|
2019-07-09 02:52:25 +08:00
|
|
|
bool isFetchKeys;
|
2020-04-11 04:29:28 +08:00
|
|
|
Optional<TagSet> tags;
|
2017-05-26 04:48:44 +08:00
|
|
|
Optional<UID> debugID;
|
|
|
|
ReplyPromise<GetKeyValuesReply> reply;
|
|
|
|
|
2019-07-04 02:14:32 +08:00
|
|
|
GetKeyValuesRequest() : isFetchKeys(false) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-07-08 00:06:13 +08:00
|
|
|
serializer(ar, begin, end, version, limit, limitBytes, isFetchKeys, tags, debugID, reply, spanContext, arena);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-20 00:47:13 +08:00
|
|
|
struct GetKeyValuesStreamReply : public ReplyPromiseStreamReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 1783066;
|
|
|
|
Arena arena;
|
|
|
|
VectorRef<KeyValueRef, VecSerStrategy::String> data;
|
|
|
|
Version version; // useful when latestVersion was requested
|
|
|
|
bool more;
|
|
|
|
bool cached = false;
|
|
|
|
|
|
|
|
GetKeyValuesStreamReply() : version(invalidVersion), more(false), cached(false) {}
|
|
|
|
GetKeyValuesStreamReply(GetKeyValuesReply r)
|
|
|
|
: arena(r.arena), data(r.data), version(r.version), more(r.more), cached(r.cached) {}
|
|
|
|
|
|
|
|
int expectedSize() const { return sizeof(GetKeyValuesStreamReply) + data.expectedSize(); }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2021-09-16 14:54:38 +08:00
|
|
|
serializer(ar,
|
|
|
|
ReplyPromiseStreamReply::acknowledgeToken,
|
|
|
|
ReplyPromiseStreamReply::sequence,
|
|
|
|
data,
|
|
|
|
version,
|
|
|
|
more,
|
|
|
|
cached,
|
|
|
|
arena);
|
2021-06-20 00:47:13 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GetKeyValuesStreamRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 6795746;
|
|
|
|
SpanID spanContext;
|
|
|
|
Arena arena;
|
|
|
|
KeySelectorRef begin, end;
|
|
|
|
Version version; // or latestVersion
|
|
|
|
int limit, limitBytes;
|
|
|
|
bool isFetchKeys;
|
|
|
|
Optional<TagSet> tags;
|
|
|
|
Optional<UID> debugID;
|
|
|
|
ReplyPromiseStream<GetKeyValuesStreamReply> reply;
|
|
|
|
|
|
|
|
GetKeyValuesStreamRequest() : isFetchKeys(false) {}
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, begin, end, version, limit, limitBytes, isFetchKeys, tags, debugID, reply, spanContext, arena);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct GetKeyReply : public LoadBalancedReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 11226513;
|
2017-05-26 04:48:44 +08:00
|
|
|
KeySelector sel;
|
2020-01-15 04:33:17 +08:00
|
|
|
bool cached;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-01-15 04:33:17 +08:00
|
|
|
GetKeyReply() : cached(false) {}
|
|
|
|
GetKeyReply(KeySelector sel, bool cached) : sel(sel), cached(cached) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-01-27 12:56:59 +08:00
|
|
|
serializer(ar, LoadBalancedReply::penalty, LoadBalancedReply::error, sel, cached);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-12-01 02:46:04 +08:00
|
|
|
struct GetKeyRequest : TimedRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 10457870;
|
2020-07-08 00:06:13 +08:00
|
|
|
SpanID spanContext;
|
2017-05-26 04:48:44 +08:00
|
|
|
Arena arena;
|
|
|
|
KeySelectorRef sel;
|
2021-03-11 02:06:03 +08:00
|
|
|
Version version; // or latestVersion
|
2020-04-11 04:29:28 +08:00
|
|
|
Optional<TagSet> tags;
|
2020-03-21 02:23:11 +08:00
|
|
|
Optional<UID> debugID;
|
2017-05-26 04:48:44 +08:00
|
|
|
ReplyPromise<GetKeyReply> reply;
|
|
|
|
|
|
|
|
GetKeyRequest() {}
|
2021-03-11 02:06:03 +08:00
|
|
|
GetKeyRequest(SpanID spanContext,
|
|
|
|
KeySelectorRef const& sel,
|
|
|
|
Version version,
|
|
|
|
Optional<TagSet> tags,
|
2020-07-08 00:06:13 +08:00
|
|
|
Optional<UID> debugID)
|
|
|
|
: spanContext(spanContext), sel(sel), version(version), debugID(debugID) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2020-07-08 00:06:13 +08:00
|
|
|
serializer(ar, sel, version, tags, debugID, reply, spanContext, arena);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-29 05:40:50 +08:00
|
|
|
struct GetShardStateReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 0;
|
|
|
|
|
|
|
|
Version first;
|
|
|
|
Version second;
|
|
|
|
GetShardStateReply() = default;
|
|
|
|
GetShardStateReply(Version first, Version second) : first(first), second(second) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, first, second);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct GetShardStateRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 15860168;
|
2021-03-11 02:06:03 +08:00
|
|
|
enum waitMode { NO_WAIT = 0, FETCHING = 1, READABLE = 2 };
|
2020-02-05 10:23:39 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
KeyRange keys;
|
|
|
|
int32_t mode;
|
2019-08-29 05:40:50 +08:00
|
|
|
ReplyPromise<GetShardStateReply> reply;
|
2017-05-26 04:48:44 +08:00
|
|
|
GetShardStateRequest() {}
|
2021-03-11 02:06:03 +08:00
|
|
|
GetShardStateRequest(KeyRange const& keys, waitMode mode) : keys(keys), mode(mode) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, keys, mode, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StorageMetrics {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 13622226;
|
2021-03-11 02:06:03 +08:00
|
|
|
int64_t bytes = 0; // total storage
|
2019-06-01 07:34:18 +08:00
|
|
|
// FIXME: currently, neither of bytesPerKSecond or iosPerKSecond are actually used in DataDistribution calculations.
|
|
|
|
// This may change in the future, but this comment is left here to avoid any confusion for the time being.
|
2021-03-11 02:06:03 +08:00
|
|
|
int64_t bytesPerKSecond = 0; // network bandwidth (average over 10s)
|
2020-01-16 01:33:27 +08:00
|
|
|
int64_t iosPerKSecond = 0;
|
2020-01-17 10:37:47 +08:00
|
|
|
int64_t bytesReadPerKSecond = 0;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
static const int64_t infinity = 1LL << 60;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool allLessOrEqual(const StorageMetrics& rhs) const {
|
2019-08-30 05:44:16 +08:00
|
|
|
return bytes <= rhs.bytes && bytesPerKSecond <= rhs.bytesPerKSecond && iosPerKSecond <= rhs.iosPerKSecond &&
|
|
|
|
bytesReadPerKSecond <= rhs.bytesReadPerKSecond;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
void operator+=(const StorageMetrics& rhs) {
|
2017-05-26 04:48:44 +08:00
|
|
|
bytes += rhs.bytes;
|
|
|
|
bytesPerKSecond += rhs.bytesPerKSecond;
|
|
|
|
iosPerKSecond += rhs.iosPerKSecond;
|
2019-08-30 05:44:16 +08:00
|
|
|
bytesReadPerKSecond += rhs.bytesReadPerKSecond;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
void operator-=(const StorageMetrics& rhs) {
|
2017-05-26 04:48:44 +08:00
|
|
|
bytes -= rhs.bytes;
|
|
|
|
bytesPerKSecond -= rhs.bytesPerKSecond;
|
|
|
|
iosPerKSecond -= rhs.iosPerKSecond;
|
2019-08-30 05:44:16 +08:00
|
|
|
bytesReadPerKSecond -= rhs.bytesReadPerKSecond;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
template <class F>
|
2021-03-11 02:06:03 +08:00
|
|
|
void operator*=(F f) {
|
2017-05-26 04:48:44 +08:00
|
|
|
bytes *= f;
|
|
|
|
bytesPerKSecond *= f;
|
|
|
|
iosPerKSecond *= f;
|
2019-08-30 05:44:16 +08:00
|
|
|
bytesReadPerKSecond *= f;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2019-08-30 05:44:16 +08:00
|
|
|
bool allZero() const { return !bytes && !bytesPerKSecond && !iosPerKSecond && !bytesReadPerKSecond; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2019-08-30 05:44:16 +08:00
|
|
|
serializer(ar, bytes, bytesPerKSecond, iosPerKSecond, bytesReadPerKSecond);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void negate() { operator*=(-1.0); }
|
2021-03-11 02:06:03 +08:00
|
|
|
StorageMetrics operator-() const {
|
|
|
|
StorageMetrics x(*this);
|
|
|
|
x.negate();
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
StorageMetrics operator+(const StorageMetrics& r) const {
|
|
|
|
StorageMetrics x(*this);
|
|
|
|
x += r;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
StorageMetrics operator-(const StorageMetrics& r) const {
|
|
|
|
StorageMetrics x(r);
|
|
|
|
x.negate();
|
|
|
|
x += *this;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
template <class F>
|
|
|
|
StorageMetrics operator*(F f) const {
|
|
|
|
StorageMetrics x(*this);
|
|
|
|
x *= f;
|
|
|
|
return x;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator==(StorageMetrics const& rhs) const {
|
2019-08-30 05:44:16 +08:00
|
|
|
return bytes == rhs.bytes && bytesPerKSecond == rhs.bytesPerKSecond && iosPerKSecond == rhs.iosPerKSecond &&
|
|
|
|
bytesReadPerKSecond == rhs.bytesReadPerKSecond;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString() const {
|
2021-03-11 02:06:03 +08:00
|
|
|
return format("Bytes: %lld, BPerKSec: %lld, iosPerKSec: %lld, BReadPerKSec: %lld",
|
|
|
|
bytes,
|
|
|
|
bytesPerKSecond,
|
|
|
|
iosPerKSecond,
|
|
|
|
bytesReadPerKSecond);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WaitMetricsRequest {
|
|
|
|
// Waits for any of the given minimum or maximum metrics to be exceeded, and then returns the current values
|
|
|
|
// Send a reversed range for min, max to receive an immediate report
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 1795961;
|
2017-05-26 04:48:44 +08:00
|
|
|
Arena arena;
|
|
|
|
KeyRangeRef keys;
|
|
|
|
StorageMetrics min, max;
|
|
|
|
ReplyPromise<StorageMetrics> reply;
|
|
|
|
|
|
|
|
WaitMetricsRequest() {}
|
2021-03-11 02:06:03 +08:00
|
|
|
WaitMetricsRequest(KeyRangeRef const& keys, StorageMetrics const& min, StorageMetrics const& max)
|
|
|
|
: keys(arena, keys), min(min), max(max) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, keys, min, max, reply, arena);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SplitMetricsReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 11530792;
|
2017-05-26 04:48:44 +08:00
|
|
|
Standalone<VectorRef<KeyRef>> splits;
|
|
|
|
StorageMetrics used;
|
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, splits, used);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SplitMetricsRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 10463876;
|
2017-05-26 04:48:44 +08:00
|
|
|
Arena arena;
|
|
|
|
KeyRangeRef keys;
|
|
|
|
StorageMetrics limits;
|
|
|
|
StorageMetrics used;
|
|
|
|
StorageMetrics estimated;
|
|
|
|
bool isLastShard;
|
|
|
|
ReplyPromise<SplitMetricsReply> reply;
|
|
|
|
|
|
|
|
SplitMetricsRequest() {}
|
2021-03-11 02:06:03 +08:00
|
|
|
SplitMetricsRequest(KeyRangeRef const& keys,
|
|
|
|
StorageMetrics const& limits,
|
|
|
|
StorageMetrics const& used,
|
|
|
|
StorageMetrics const& estimated,
|
|
|
|
bool isLastShard)
|
|
|
|
: keys(arena, keys), limits(limits), used(used), estimated(estimated), isLastShard(isLastShard) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, keys, limits, used, estimated, isLastShard, reply, arena);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-13 05:27:34 +08:00
|
|
|
// Should always be used inside a `Standalone`.
|
|
|
|
struct ReadHotRangeWithMetrics {
|
|
|
|
KeyRangeRef keys;
|
2021-02-05 08:20:18 +08:00
|
|
|
// density refers to the ratio of bytes sent(because of the read) and bytes on disk.
|
2021-02-05 09:31:05 +08:00
|
|
|
// For example if key range [A, B) and [B, C) respectively has byte size 100 bytes on disk.
|
|
|
|
// Key range [A,B) was read 30 times.
|
|
|
|
// The density for key range [A,C) is 30 * 100 / 200 = 15
|
2020-08-13 05:27:34 +08:00
|
|
|
double density;
|
2021-02-05 08:20:18 +08:00
|
|
|
// How many bytes of data was sent in a period of time because of read requests.
|
2020-08-13 05:27:34 +08:00
|
|
|
double readBandwidth;
|
|
|
|
|
2020-08-13 06:47:32 +08:00
|
|
|
ReadHotRangeWithMetrics() = default;
|
2020-08-13 05:27:34 +08:00
|
|
|
ReadHotRangeWithMetrics(KeyRangeRef const& keys, double density, double readBandwidth)
|
|
|
|
: keys(keys), density(density), readBandwidth(readBandwidth) {}
|
|
|
|
|
|
|
|
ReadHotRangeWithMetrics(Arena& arena, const ReadHotRangeWithMetrics& rhs)
|
|
|
|
: keys(arena, rhs.keys), density(rhs.density), readBandwidth(rhs.readBandwidth) {}
|
|
|
|
|
2020-12-27 06:30:44 +08:00
|
|
|
int expectedSize() const { return keys.expectedSize() + sizeof(density) + sizeof(readBandwidth); }
|
2020-08-13 05:27:34 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, keys, density, readBandwidth);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-20 08:02:42 +08:00
|
|
|
struct ReadHotSubRangeReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 10424537;
|
2020-08-13 05:27:34 +08:00
|
|
|
Standalone<VectorRef<ReadHotRangeWithMetrics>> readHotRanges;
|
2019-12-20 08:02:42 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-01-13 07:30:36 +08:00
|
|
|
serializer(ar, readHotRanges);
|
2019-12-20 08:02:42 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
struct ReadHotSubRangeRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 10259266;
|
|
|
|
Arena arena;
|
|
|
|
KeyRangeRef keys;
|
|
|
|
ReplyPromise<ReadHotSubRangeReply> reply;
|
|
|
|
|
|
|
|
ReadHotSubRangeRequest() {}
|
|
|
|
ReadHotSubRangeRequest(KeyRangeRef const& keys) : keys(arena, keys) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, keys, reply, arena);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-19 00:37:49 +08:00
|
|
|
struct SplitRangeReply {
|
2020-08-08 05:03:42 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 11813134;
|
2020-06-19 00:37:49 +08:00
|
|
|
// If the given range can be divided, contains the split points.
|
|
|
|
// If the given range cannot be divided(for exmaple its total size is smaller than the chunk size), this would be
|
|
|
|
// empty
|
|
|
|
Standalone<VectorRef<KeyRef>> splitPoints;
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, splitPoints);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
struct SplitRangeRequest {
|
2020-08-08 05:03:42 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 10725174;
|
2020-06-19 00:37:49 +08:00
|
|
|
Arena arena;
|
|
|
|
KeyRangeRef keys;
|
|
|
|
int64_t chunkSize;
|
|
|
|
ReplyPromise<SplitRangeReply> reply;
|
|
|
|
|
|
|
|
SplitRangeRequest() {}
|
|
|
|
SplitRangeRequest(KeyRangeRef const& keys, int64_t chunkSize) : keys(arena, keys), chunkSize(chunkSize) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, keys, chunkSize, reply, arena);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
struct ChangeFeedStreamReply : public ReplyPromiseStreamReply {
|
2021-08-11 12:28:25 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 1783066;
|
|
|
|
Arena arena;
|
|
|
|
VectorRef<MutationsAndVersionRef> mutations;
|
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
ChangeFeedStreamReply() {}
|
2021-08-11 12:28:25 +08:00
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
int expectedSize() const { return sizeof(ChangeFeedStreamReply) + mutations.expectedSize(); }
|
2021-08-11 12:28:25 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2021-10-10 12:18:13 +08:00
|
|
|
serializer(ar, ReplyPromiseStreamReply::acknowledgeToken, ReplyPromiseStreamReply::sequence, mutations, arena);
|
2021-08-11 12:28:25 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
struct ChangeFeedStreamRequest {
|
2021-08-11 12:28:25 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 6795746;
|
|
|
|
SpanID spanContext;
|
|
|
|
Arena arena;
|
|
|
|
Key rangeID;
|
|
|
|
Version begin = 0;
|
|
|
|
Version end = 0;
|
2021-09-02 05:35:51 +08:00
|
|
|
KeyRange range;
|
2021-08-14 05:27:15 +08:00
|
|
|
ReplyPromiseStream<ChangeFeedStreamReply> reply;
|
2021-08-11 12:28:25 +08:00
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
ChangeFeedStreamRequest() {}
|
2021-08-11 12:28:25 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2021-09-02 05:35:51 +08:00
|
|
|
serializer(ar, rangeID, begin, end, range, reply, spanContext, arena);
|
2021-08-11 12:28:25 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
struct ChangeFeedPopRequest {
|
2021-03-06 03:46:33 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 10726174;
|
|
|
|
Key rangeID;
|
|
|
|
Version version;
|
2021-09-03 12:11:44 +08:00
|
|
|
KeyRange range;
|
2021-03-06 03:46:33 +08:00
|
|
|
ReplyPromise<Void> reply;
|
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
ChangeFeedPopRequest() {}
|
2021-09-03 12:11:44 +08:00
|
|
|
ChangeFeedPopRequest(Key const& rangeID, Version version, KeyRange const& range)
|
|
|
|
: rangeID(rangeID), version(version), range(range) {}
|
2021-03-06 03:46:33 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2021-09-03 12:11:44 +08:00
|
|
|
serializer(ar, rangeID, version, range, reply);
|
2021-03-06 03:46:33 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-21 15:44:51 +08:00
|
|
|
struct OverlappingChangeFeedEntry {
|
|
|
|
Key rangeId;
|
|
|
|
KeyRange range;
|
|
|
|
bool stopped = false;
|
|
|
|
|
|
|
|
bool operator==(const OverlappingChangeFeedEntry& r) const {
|
|
|
|
return rangeId == r.rangeId && range == r.range && stopped == r.stopped;
|
|
|
|
}
|
|
|
|
|
|
|
|
OverlappingChangeFeedEntry() {}
|
|
|
|
OverlappingChangeFeedEntry(Key const& rangeId, KeyRange const& range, bool stopped)
|
|
|
|
: rangeId(rangeId), range(range), stopped(stopped) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, rangeId, range, stopped);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
struct OverlappingChangeFeedsReply {
|
2021-08-10 01:05:56 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 11815134;
|
2021-10-21 15:44:51 +08:00
|
|
|
std::vector<OverlappingChangeFeedEntry> rangeIds;
|
2021-08-10 01:05:56 +08:00
|
|
|
bool cached;
|
|
|
|
Arena arena;
|
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
OverlappingChangeFeedsReply() : cached(false) {}
|
2021-10-21 15:44:51 +08:00
|
|
|
explicit OverlappingChangeFeedsReply(std::vector<OverlappingChangeFeedEntry> const& rangeIds)
|
2021-08-10 01:05:56 +08:00
|
|
|
: rangeIds(rangeIds), cached(false) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, rangeIds, arena);
|
|
|
|
}
|
|
|
|
};
|
2021-10-21 15:44:51 +08:00
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
struct OverlappingChangeFeedsRequest {
|
2021-08-10 01:05:56 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 10726174;
|
|
|
|
KeyRange range;
|
2021-09-02 05:35:51 +08:00
|
|
|
Version minVersion;
|
2021-08-14 05:27:15 +08:00
|
|
|
ReplyPromise<OverlappingChangeFeedsReply> reply;
|
2021-08-10 01:05:56 +08:00
|
|
|
|
2021-08-14 05:27:15 +08:00
|
|
|
OverlappingChangeFeedsRequest() {}
|
|
|
|
explicit OverlappingChangeFeedsRequest(KeyRange const& range) : range(range) {}
|
2021-08-10 01:05:56 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2021-09-02 05:35:51 +08:00
|
|
|
serializer(ar, range, minVersion, reply);
|
2021-08-10 01:05:56 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-26 07:27:32 +08:00
|
|
|
struct GetStorageMetricsReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 15491478;
|
2017-05-26 04:48:44 +08:00
|
|
|
StorageMetrics load;
|
2020-02-21 03:21:03 +08:00
|
|
|
StorageMetrics available;
|
2017-05-26 04:48:44 +08:00
|
|
|
StorageMetrics capacity;
|
2019-07-26 07:27:32 +08:00
|
|
|
double bytesInputRate;
|
2020-04-04 10:04:43 +08:00
|
|
|
int64_t versionLag;
|
|
|
|
double lastUpdate;
|
2019-07-26 07:27:32 +08:00
|
|
|
|
|
|
|
GetStorageMetricsReply() : bytesInputRate(0) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-04-04 10:04:43 +08:00
|
|
|
serializer(ar, load, available, capacity, bytesInputRate, versionLag, lastUpdate);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-26 07:27:32 +08:00
|
|
|
struct GetStorageMetricsRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 13290999;
|
2019-07-26 07:27:32 +08:00
|
|
|
ReplyPromise<GetStorageMetricsReply> reply;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StorageQueuingMetricsReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 7633366;
|
2017-05-26 04:48:44 +08:00
|
|
|
double localTime;
|
2021-03-11 02:06:03 +08:00
|
|
|
int64_t instanceID; // changes if bytesDurable and bytesInput reset
|
2017-05-26 04:48:44 +08:00
|
|
|
int64_t bytesDurable, bytesInput;
|
|
|
|
StorageBytes storageBytes;
|
2019-02-01 03:49:23 +08:00
|
|
|
Version version; // current storage server version
|
|
|
|
Version durableVersion; // latest version durable on storage server
|
|
|
|
double cpuUsage;
|
|
|
|
double diskUsage;
|
2019-03-02 05:14:18 +08:00
|
|
|
double localRateLimit;
|
2020-04-17 05:43:22 +08:00
|
|
|
Optional<TransactionTag> busiestTag;
|
2020-03-21 02:23:11 +08:00
|
|
|
double busiestTagFractionalBusyness;
|
|
|
|
double busiestTagRate;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2021-03-11 02:06:03 +08:00
|
|
|
serializer(ar,
|
|
|
|
localTime,
|
|
|
|
instanceID,
|
|
|
|
bytesDurable,
|
|
|
|
bytesInput,
|
|
|
|
version,
|
|
|
|
storageBytes,
|
|
|
|
durableVersion,
|
|
|
|
cpuUsage,
|
|
|
|
diskUsage,
|
|
|
|
localRateLimit,
|
|
|
|
busiestTag,
|
|
|
|
busiestTagFractionalBusyness,
|
|
|
|
busiestTagRate);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-17 06:00:12 +08:00
|
|
|
struct StorageQueuingMetricsRequest {
|
|
|
|
// SOMEDAY: Send threshold value to avoid polling faster than the information changes?
|
|
|
|
constexpr static FileIdentifier file_identifier = 3978640;
|
|
|
|
ReplyPromise<struct StorageQueuingMetricsReply> reply;
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, reply);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
#endif
|