1 /*
2  * DataDistributorInterface.h
3  *
4  * This source file is part of the FoundationDB open source project
5  *
6  * Copyright 2013-2019 Apple Inc. and the FoundationDB project authors
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef FDBSERVER_DATADISTRIBUTORINTERFACE_H
22 #define FDBSERVER_DATADISTRIBUTORINTERFACE_H
23 
24 #include "fdbrpc/fdbrpc.h"
25 #include "fdbrpc/Locality.h"
26 
27 struct DataDistributorInterface {
28 	RequestStream<ReplyPromise<Void>> waitFailure;
29 	RequestStream<struct HaltDataDistributorRequest> haltDataDistributor;
30 	struct LocalityData locality;
31 
DataDistributorInterfaceDataDistributorInterface32 	DataDistributorInterface() {}
DataDistributorInterfaceDataDistributorInterface33 	explicit DataDistributorInterface(const struct LocalityData& l) : locality(l) {}
34 
initEndpointsDataDistributorInterface35 	void initEndpoints() {}
idDataDistributorInterface36 	UID id() const { return waitFailure.getEndpoint().token; }
addressDataDistributorInterface37 	NetworkAddress address() const { return waitFailure.getEndpoint().getPrimaryAddress(); }
38 	bool operator== (const DataDistributorInterface& r) const {
39 		return id() == r.id();
40 	}
41 	bool operator!= (const DataDistributorInterface& r) const {
42 		return !(*this == r);
43 	}
44 
45 	template <class Archive>
serializeDataDistributorInterface46 	void serialize(Archive& ar) {
47 		serializer(ar, waitFailure, haltDataDistributor, locality);
48 	}
49 };
50 
51 struct HaltDataDistributorRequest {
52 	UID requesterID;
53 	ReplyPromise<Void> reply;
54 
HaltDataDistributorRequestHaltDataDistributorRequest55 	HaltDataDistributorRequest() {}
HaltDataDistributorRequestHaltDataDistributorRequest56 	explicit HaltDataDistributorRequest(UID uid) : requesterID(uid) {}
57 
58 	template<class Ar>
serializeHaltDataDistributorRequest59 	void serialize(Ar& ar) {
60 		serializer(ar, requesterID, reply);
61 	}
62 };
63 
64 #endif //FDBSERVER_DATADISTRIBUTORINTERFACE_H
65