2017-05-26 04:48:44 +08:00
|
|
|
/*
|
|
|
|
* ResolverInterface.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 FDBSERVER_RESOLVERINTERFACE_H
|
|
|
|
#define FDBSERVER_RESOLVERINTERFACE_H
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "fdbclient/FDBTypes.h"
|
|
|
|
|
|
|
|
struct ResolverInterface {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 1755944;
|
2017-05-26 04:48:44 +08:00
|
|
|
enum { LocationAwareLoadBalance = 1 };
|
2018-11-03 04:15:09 +08:00
|
|
|
enum { AlwaysFresh = 1 };
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
LocalityData locality;
|
|
|
|
UID uniqueID;
|
|
|
|
RequestStream< struct ResolveTransactionBatchRequest > resolve;
|
|
|
|
RequestStream< struct ResolutionMetricsRequest > metrics;
|
|
|
|
RequestStream< struct ResolutionSplitRequest > split;
|
|
|
|
|
|
|
|
RequestStream<ReplyPromise<Void>> waitFailure;
|
|
|
|
|
2019-05-11 05:01:52 +08:00
|
|
|
ResolverInterface() : uniqueID( deterministicRandom()->randomUniqueID() ) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
UID id() const { return uniqueID; }
|
|
|
|
std::string toString() const { return id().shortString(); }
|
|
|
|
bool operator == ( ResolverInterface const& r ) const { return id() == r.id(); }
|
|
|
|
bool operator != ( ResolverInterface const& r ) const { return id() != r.id(); }
|
2018-10-31 04:44:37 +08:00
|
|
|
NetworkAddress address() const { return resolve.getEndpoint().getPrimaryAddress(); }
|
2017-05-26 04:48:44 +08:00
|
|
|
void initEndpoints() {
|
2019-06-25 17:47:35 +08:00
|
|
|
metrics.getEndpoint( TaskPriority::ResolutionMetrics );
|
|
|
|
split.getEndpoint( TaskPriority::ResolutionMetrics );
|
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, uniqueID, locality, resolve, metrics, split, waitFailure);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StateTransactionRef {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 6150271;
|
2017-05-26 04:48:44 +08:00
|
|
|
StateTransactionRef() {}
|
|
|
|
StateTransactionRef(const bool committed, VectorRef<MutationRef> const& mutations) : committed(committed), mutations(mutations) {}
|
|
|
|
StateTransactionRef(Arena &p, const StateTransactionRef &toCopy) : committed(toCopy.committed), mutations(p, toCopy.mutations) {}
|
|
|
|
bool committed;
|
|
|
|
VectorRef<MutationRef> mutations;
|
|
|
|
size_t expectedSize() const {
|
|
|
|
return mutations.expectedSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Archive>
|
|
|
|
void serialize(Archive& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, committed, mutations);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ResolveTransactionBatchReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 15472264;
|
2017-05-26 04:48:44 +08:00
|
|
|
Arena arena;
|
|
|
|
VectorRef<uint8_t> committed;
|
|
|
|
Optional<UID> debugID;
|
|
|
|
VectorRef<VectorRef<StateTransactionRef>> stateMutations; // [version][transaction#] -> (committed, [mutation#])
|
|
|
|
|
|
|
|
template <class Archive>
|
|
|
|
void serialize(Archive& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, committed, stateMutations, arena, debugID);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ResolveTransactionBatchRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 16462858;
|
2017-05-26 04:48:44 +08:00
|
|
|
Arena arena;
|
|
|
|
|
|
|
|
Version prevVersion;
|
|
|
|
Version version; // FIXME: ?
|
|
|
|
Version lastReceivedVersion;
|
|
|
|
VectorRef<CommitTransactionRef> transactions;
|
|
|
|
VectorRef<int> txnStateTransactions; // Offsets of elements of transactions that have (transaction subsystem state) mutations
|
|
|
|
ReplyPromise<ResolveTransactionBatchReply> reply;
|
|
|
|
Optional<UID> debugID;
|
|
|
|
|
|
|
|
template <class Archive>
|
|
|
|
void serialize(Archive& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, prevVersion, version, lastReceivedVersion, transactions, txnStateTransactions, reply, arena, debugID);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-29 05:40:50 +08:00
|
|
|
struct ResolutionMetricsReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 3;
|
|
|
|
|
|
|
|
int64_t value;
|
|
|
|
ResolutionMetricsReply() = default;
|
|
|
|
explicit ResolutionMetricsReply(int64_t value) : value(value) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct ResolutionMetricsRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 11663527;
|
2019-08-29 05:40:50 +08:00
|
|
|
ReplyPromise<ResolutionMetricsReply> reply;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Archive>
|
|
|
|
void serialize(Archive& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ResolutionSplitReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 12137765;
|
2017-05-26 04:48:44 +08:00
|
|
|
Key key;
|
|
|
|
int64_t used;
|
|
|
|
template <class Archive>
|
|
|
|
void serialize(Archive& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, key, used);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ResolutionSplitRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 167535;
|
2017-05-26 04:48:44 +08:00
|
|
|
KeyRange range;
|
|
|
|
int64_t offset;
|
|
|
|
bool front;
|
|
|
|
ReplyPromise<ResolutionSplitReply> reply;
|
|
|
|
|
|
|
|
template <class Archive>
|
|
|
|
void serialize(Archive& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, range, offset, front, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|