|
@@ -3,34 +3,55 @@
|
|
namespace NKikimr::NBlobDepot {
|
|
namespace NKikimr::NBlobDepot {
|
|
|
|
|
|
void TBlobDepotAgent::HandleStorageProxy(TAutoPtr<IEventHandle> ev) {
|
|
void TBlobDepotAgent::HandleStorageProxy(TAutoPtr<IEventHandle> ev) {
|
|
- if (TabletId == Max<ui64>()) {
|
|
|
|
|
|
+ if (TabletId == Max<ui64>() || !PendingEventQ.empty()) {
|
|
// TODO: memory usage control
|
|
// TODO: memory usage control
|
|
PendingEventQ.emplace_back(ev.Release());
|
|
PendingEventQ.emplace_back(ev.Release());
|
|
} else {
|
|
} else {
|
|
- auto *query = CreateQuery(ev);
|
|
|
|
- STLOG(PRI_DEBUG, BLOB_DEPOT_AGENT, BDA13, "new query", (VirtualGroupId, VirtualGroupId),
|
|
|
|
- (QueryId, query->GetQueryId()), (TabletId, query->GetTabletId()), (Name, query->GetName()));
|
|
|
|
- if (!TabletId) {
|
|
|
|
- query->EndWithError(NKikimrProto::ERROR, "group is in error state");
|
|
|
|
|
|
+ ProcessStorageEvent(std::unique_ptr<IEventHandle>(ev.Release()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void TBlobDepotAgent::HandlePendingEvent() {
|
|
|
|
+ THPTimer timer;
|
|
|
|
+
|
|
|
|
+ do {
|
|
|
|
+ if (!PendingEventQ.empty()) {
|
|
|
|
+ ProcessStorageEvent(std::move(PendingEventQ.front()));
|
|
|
|
+ PendingEventQ.pop_front();
|
|
} else {
|
|
} else {
|
|
- query->Initiate();
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
+ } while (TDuration::Seconds(timer.Passed()) <= TDuration::MicroSeconds(100));
|
|
|
|
+
|
|
|
|
+ if (!PendingEventQ.empty()) {
|
|
|
|
+ TActivationContext::Send(new IEventHandle(TEvPrivate::EvProcessPendingEvent, 0, SelfId(), {}, nullptr, 0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void TBlobDepotAgent::Handle(TEvBlobStorage::TEvBunchOfEvents::TPtr ev) {
|
|
|
|
- ev->Get()->Process(this);
|
|
|
|
- }
|
|
|
|
|
|
+ void TBlobDepotAgent::ProcessStorageEvent(std::unique_ptr<IEventHandle> ev) {
|
|
|
|
+ TQuery *query = nullptr;
|
|
|
|
|
|
- TBlobDepotAgent::TQuery *TBlobDepotAgent::CreateQuery(TAutoPtr<IEventHandle> ev) {
|
|
|
|
switch (ev->GetTypeRewrite()) {
|
|
switch (ev->GetTypeRewrite()) {
|
|
#define XX(TYPE) \
|
|
#define XX(TYPE) \
|
|
- case TEvBlobStorage::TYPE: return CreateQuery<TEvBlobStorage::TYPE>(std::unique_ptr<IEventHandle>(ev.Release()));
|
|
|
|
|
|
+ case TEvBlobStorage::TYPE: query = CreateQuery<TEvBlobStorage::TYPE>(std::move(ev)); break;
|
|
|
|
|
|
ENUMERATE_INCOMING_EVENTS(XX)
|
|
ENUMERATE_INCOMING_EVENTS(XX)
|
|
#undef XX
|
|
#undef XX
|
|
}
|
|
}
|
|
- Y_FAIL();
|
|
|
|
|
|
+
|
|
|
|
+ Y_VERIFY(query);
|
|
|
|
+
|
|
|
|
+ STLOG(PRI_DEBUG, BLOB_DEPOT_AGENT, BDA13, "new query", (VirtualGroupId, VirtualGroupId),
|
|
|
|
+ (QueryId, query->GetQueryId()), (TabletId, query->GetTabletId()), (Name, query->GetName()));
|
|
|
|
+ if (!TabletId) {
|
|
|
|
+ query->EndWithError(NKikimrProto::ERROR, "group is in error state");
|
|
|
|
+ } else {
|
|
|
|
+ query->Initiate();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void TBlobDepotAgent::Handle(TEvBlobStorage::TEvBunchOfEvents::TPtr ev) {
|
|
|
|
+ ev->Get()->Process(this);
|
|
}
|
|
}
|
|
|
|
|
|
void TBlobDepotAgent::HandleQueryWatchdog() {
|
|
void TBlobDepotAgent::HandleQueryWatchdog() {
|