@@ -64,6 +64,7 @@ TFederatedReadSessionImpl::TFederatedReadSessionImpl(const TFederatedReadSession
64
64
, Observer(std::move(observer))
65
65
, AsyncInit(Observer->WaitForFirstState ())
66
66
, FederationState(nullptr )
67
+ , Log(Connections->GetLog ())
67
68
, SessionId(CreateGuidAsString())
68
69
{
69
70
}
@@ -101,15 +102,17 @@ void TFederatedReadSessionImpl::OnFederatedStateUpdateImpl() {
101
102
CloseImpl ();
102
103
return ;
103
104
}
104
- if (Settings.ReadMirroredEnabled ) {
105
- Y_ABORT_UNLESS (Settings.Databases .size () == 1 );
106
- // add -mirrored-from- topics to Settings
105
+ if (Settings.IsReadMirroredEnabled () ) {
106
+ Y_ABORT_UNLESS (Settings.GetDatabasesToReadFrom () .size () == 1 );
107
+ auto dbToReadFrom = * Settings. GetDatabasesToReadFrom (). begin ();
107
108
108
- // how to get mirrors in general case???
109
- std::vector<TString> dcNames = {" sas" , " vla" , " klg" , " vlx" };
109
+ std::vector<TString> dcNames = GetAllFederationLocations ();
110
110
auto topics = Settings.Topics_ ;
111
111
for (const auto & topic : topics) {
112
112
for (const auto & dc : dcNames) {
113
+ if (AsciiEqualsIgnoreCase (dc, dbToReadFrom)) {
114
+ continue ;
115
+ }
113
116
auto mirroredTopic = topic;
114
117
mirroredTopic.PartitionIds_ .clear ();
115
118
mirroredTopic.Path (topic.Path_ + " -mirrored-from-" + dc);
@@ -134,17 +137,25 @@ void TFederatedReadSessionImpl::OnFederatedStateUpdateImpl() {
134
137
OpenSubSessionsImpl (databases);
135
138
}
136
139
140
+ std::vector<TString> TFederatedReadSessionImpl::GetAllFederationLocations () {
141
+ std::vector<TString> result;
142
+ for (const auto & db : FederationState->DbInfos ) {
143
+ result.push_back (db->location ());
144
+ }
145
+ return result;
146
+ }
147
+
137
148
bool TFederatedReadSessionImpl::IsDatabaseEligibleForRead (const std::shared_ptr<TDbInfo>& db) {
138
149
if (db->status () != TDbInfo::Status::DatabaseInfo_Status_AVAILABLE &&
139
150
db->status () != TDbInfo::Status::DatabaseInfo_Status_READ_ONLY) {
140
151
return false ;
141
152
}
142
153
143
- if (Settings.Databases .empty ()) {
154
+ if (Settings.GetDatabasesToReadFrom () .empty ()) {
144
155
return true ;
145
156
}
146
157
147
- for (const auto & dbFromSettings : Settings.Databases ) {
158
+ for (const auto & dbFromSettings : Settings.GetDatabasesToReadFrom () ) {
148
159
if (AsciiEqualsIgnoreCase (db->name (), dbFromSettings) ||
149
160
AsciiEqualsIgnoreCase (db->id (), dbFromSettings)) {
150
161
return true ;
0 commit comments