foundationdb/fdbserver/DataDistributorInterface.h

73 lines
2.1 KiB
C++

/*
* DataDistributorInterface.h
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
*
* 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.
*/
#ifndef FOUNDATIONDB_DATADISTRIBUTORINTERFACE_H
#define FOUNDATIONDB_DATADISTRIBUTORINTERFACE_H
#include "fdbrpc/fdbrpc.h"
struct DataDistributorInterface {
UID id;
RequestStream<ReplyPromise<Void>> waitFailure;
RequestStream< struct GetRateInfoRequest > getRateInfo;
DataDistributorInterface() {}
NetworkAddress address() const { return getRateInfo.getEndpoint().address; }
bool operator== (const DataDistributorInterface& r) const {
return id == r.id;
}
bool operator!= (const DataDistributorInterface& r) const {
return !(*this == r);
}
bool isValid() const { return id != UID(); }
template <class Archive>
void serialize(Archive& ar) {
serializer(ar, id, waitFailure, getRateInfo);
}
};
struct GetRateInfoRequest {
UID requesterID;
int64_t totalReleasedTransactions;
ReplyPromise<struct GetRateInfoReply> reply;
GetRateInfoRequest() {}
GetRateInfoRequest( UID const& requesterID, int64_t totalReleasedTransactions ) : requesterID(requesterID), totalReleasedTransactions(totalReleasedTransactions) {}
template <class Ar>
void serialize(Ar& ar) {
serializer(ar, requesterID, totalReleasedTransactions, reply);
}
};
struct GetRateInfoReply {
double transactionRate;
double leaseDuration;
template <class Ar>
void serialize(Ar& ar) {
serializer(ar, transactionRate, leaseDuration);
}
};
#endif //FOUNDATIONDB_DATADISTRIBUTORINTERFACE_H