2017-05-26 04:48:44 +08:00
/*
* ServerDBInfo . 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_SERVERDBINFO_H
# define FDBSERVER_SERVERDBINFO_H
# pragma once
2018-10-20 01:30:13 +08:00
# include "fdbserver/ClusterRecruitmentInterface.h"
2019-01-19 03:30:18 +08:00
# include "fdbserver/DataDistributorInterface.h"
2018-10-20 01:30:13 +08:00
# include "fdbserver/MasterInterface.h"
# include "fdbserver/LogSystemConfig.h"
2019-02-15 08:24:46 +08:00
# include "fdbserver/RatekeeperInterface.h"
2018-10-20 01:30:13 +08:00
# include "fdbserver/RecoveryState.h"
2019-01-25 03:43:26 +08:00
# include "fdbserver/LatencyBandConfig.h"
2017-05-26 04:48:44 +08:00
struct ServerDBInfo {
2019-01-31 05:53:23 +08:00
constexpr static FileIdentifier file_identifier = 13838807 ;
2017-05-26 04:48:44 +08:00
// This structure contains transient information which is broadcast to all workers for a database,
// permitting them to communicate with each other. It is not available to the client. This mechanism
// (see GetServerDBInfoRequest) is closely parallel to OpenDatabaseRequest for the client.
UID id ; // Changes each time any other member changes
ClusterControllerFullInterface clusterInterface ;
ClientDBInfo client ; // After a successful recovery, eventually proxies that communicate with it
2019-02-13 07:50:44 +08:00
Optional < DataDistributorInterface > distributor ; // The best guess of current data distributor.
2017-05-26 04:48:44 +08:00
MasterInterface master ; // The best guess as to the most recent master, which might still be recovering
2019-02-15 08:24:46 +08:00
Optional < RatekeeperInterface > ratekeeper ;
2017-05-26 04:48:44 +08:00
vector < ResolverInterface > resolvers ;
DBRecoveryCount recoveryCount ; // A recovery count from DBCoreState. A successful master recovery increments it twice; unsuccessful recoveries may increment it once. Depending on where the current master is in its recovery process, this might not have been written by the current master.
2018-05-09 08:17:17 +08:00
RecoveryState recoveryState ;
2017-05-26 04:48:44 +08:00
LifetimeToken masterLifetime ; // Used by masterserver to detect not being the currently chosen master
LocalityData myLocality ; // (Not serialized) Locality information, if available, for the *local* process
LogSystemConfig logSystemConfig ;
std : : vector < UID > priorCommittedLogServers ; // If !fullyRecovered and logSystemConfig refers to a new log system which may not have been committed to the coordinated state yet, then priorCommittedLogServers are the previous, fully committed generation which need to stay alive in case this recovery fails
2019-01-19 08:18:34 +08:00
Optional < LatencyBandConfig > latencyBandConfig ;
2017-05-26 04:48:44 +08:00
2018-08-17 01:24:12 +08:00
explicit ServerDBInfo ( ) : recoveryCount ( 0 ) , recoveryState ( RecoveryState : : UNINITIALIZED ) { }
2017-05-26 04:48:44 +08:00
bool operator = = ( ServerDBInfo const & r ) const { return id = = r . id ; }
bool operator ! = ( ServerDBInfo const & r ) const { return id ! = r . id ; }
template < class Ar >
void serialize ( Ar & ar ) {
2019-02-20 06:04:45 +08:00
serializer ( ar , id , clusterInterface , client , distributor , master , ratekeeper , resolvers , recoveryCount , recoveryState , masterLifetime , logSystemConfig , priorCommittedLogServers , latencyBandConfig ) ;
2017-05-26 04:48:44 +08:00
}
} ;
2019-04-17 06:00:12 +08:00
struct GetServerDBInfoRequest {
constexpr static FileIdentifier file_identifier = 9467438 ;
UID knownServerInfoID ;
Standalone < VectorRef < StringRef > > issues ;
std : : vector < NetworkAddress > incompatiblePeers ;
2019-09-11 05:27:22 +08:00
ReplyPromise < CachedSerialization < struct ServerDBInfo > > reply ;
2019-04-17 06:00:12 +08:00
template < class Ar >
void serialize ( Ar & ar ) {
serializer ( ar , knownServerInfoID , issues , incompatiblePeers , reply ) ;
}
} ;
2017-05-26 04:48:44 +08:00
# endif