2020-07-15 15:37:41 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GrvProxyInterface.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
2020-07-30 02:19:29 +08:00
|
|
|
* Copyright 2013-2020 Apple Inc. and the FoundationDB project authors
|
2020-07-15 15:37:41 +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
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2020-07-30 02:19:29 +08:00
|
|
|
#ifndef FDBCLIENT_GRVPROXYINTERFACE_H
|
|
|
|
#define FDBCLIENT_GRVPROXYINTERFACE_H
|
2020-07-15 15:37:41 +08:00
|
|
|
#pragma once
|
2021-10-06 06:34:51 +08:00
|
|
|
#include "flow/FileIdentifier.h"
|
|
|
|
#include "fdbrpc/fdbrpc.h"
|
|
|
|
#include "fdbclient/FDBTypes.h"
|
2020-07-15 15:37:41 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// GrvProxy is proxy primarily specializing on serving GetReadVersion. It also serves health metrics since it
|
|
|
|
// communicates with RateKeeper to gather health information of the cluster.
|
2020-07-15 15:37:41 +08:00
|
|
|
struct GrvProxyInterface {
|
|
|
|
constexpr static FileIdentifier file_identifier = 8743216;
|
2020-09-11 08:44:15 +08:00
|
|
|
enum { LocationAwareLoadBalance = 1 };
|
|
|
|
enum { AlwaysFresh = 1 };
|
2020-07-15 15:37:41 +08:00
|
|
|
|
|
|
|
Optional<Key> processId;
|
|
|
|
bool provisional;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
RequestStream<struct GetReadVersionRequest>
|
|
|
|
getConsistentReadVersion; // Returns a version which (1) is committed, and (2) is >= the latest version reported
|
|
|
|
// committed (by a commit response) when this request was sent
|
|
|
|
// (at some point between when this request is sent and when its response is received, the latest version reported
|
|
|
|
// committed)
|
2020-07-15 15:37:41 +08:00
|
|
|
RequestStream<ReplyPromise<Void>> waitFailure; // reports heartbeat to master.
|
2021-03-11 02:06:03 +08:00
|
|
|
RequestStream<struct GetHealthMetricsRequest> getHealthMetrics;
|
2020-07-15 15:37:41 +08:00
|
|
|
|
|
|
|
UID id() const { return getConsistentReadVersion.getEndpoint().token; }
|
|
|
|
std::string toString() const { return id().shortString(); }
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator==(GrvProxyInterface const& r) const { return id() == r.id(); }
|
|
|
|
bool operator!=(GrvProxyInterface const& r) const { return id() != r.id(); }
|
2020-07-15 15:37:41 +08:00
|
|
|
NetworkAddress address() const { return getConsistentReadVersion.getEndpoint().getPrimaryAddress(); }
|
2021-06-29 12:45:02 +08:00
|
|
|
NetworkAddressList addresses() const { return getConsistentReadVersion.getEndpoint().addresses; }
|
2020-07-15 15:37:41 +08:00
|
|
|
|
|
|
|
template <class Archive>
|
|
|
|
void serialize(Archive& ar) {
|
|
|
|
serializer(ar, processId, provisional, getConsistentReadVersion);
|
2021-03-11 02:06:03 +08:00
|
|
|
if (Archive::isDeserializing) {
|
|
|
|
waitFailure =
|
|
|
|
RequestStream<ReplyPromise<Void>>(getConsistentReadVersion.getEndpoint().getAdjustedEndpoint(1));
|
|
|
|
getHealthMetrics = RequestStream<struct GetHealthMetricsRequest>(
|
|
|
|
getConsistentReadVersion.getEndpoint().getAdjustedEndpoint(2));
|
2020-07-15 15:37:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void initEndpoints() {
|
|
|
|
std::vector<std::pair<FlowReceiver*, TaskPriority>> streams;
|
|
|
|
streams.push_back(getConsistentReadVersion.getReceiver(TaskPriority::ReadSocket));
|
|
|
|
streams.push_back(waitFailure.getReceiver());
|
|
|
|
streams.push_back(getHealthMetrics.getReceiver());
|
|
|
|
FlowTransport::transport().addEndpoints(streams);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-30 02:19:29 +08:00
|
|
|
#endif // FDBCLIENT_GRVPROXYINTERFACE_H
|