#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace DB { NamesAndTypesList ZooKeeperLogElement::getNamesAndTypes() { auto type_enum = std::make_shared( DataTypeEnum8::Values { {"Request", static_cast(REQUEST)}, {"Response", static_cast(RESPONSE)}, {"Finalize", static_cast(FINALIZE)}, }); auto op_num_enum = std::make_shared( DataTypeEnum16::Values { {"Watch", 0}, {"Close", static_cast(Coordination::OpNum::Close)}, {"Error", static_cast(Coordination::OpNum::Error)}, {"Create", static_cast(Coordination::OpNum::Create)}, {"Remove", static_cast(Coordination::OpNum::Remove)}, {"Exists", static_cast(Coordination::OpNum::Exists)}, {"Get", static_cast(Coordination::OpNum::Get)}, {"Set", static_cast(Coordination::OpNum::Set)}, {"GetACL", static_cast(Coordination::OpNum::GetACL)}, {"SetACL", static_cast(Coordination::OpNum::SetACL)}, {"SimpleList", static_cast(Coordination::OpNum::SimpleList)}, {"Sync", static_cast(Coordination::OpNum::Sync)}, {"Heartbeat", static_cast(Coordination::OpNum::Heartbeat)}, {"List", static_cast(Coordination::OpNum::List)}, {"Check", static_cast(Coordination::OpNum::Check)}, {"Multi", static_cast(Coordination::OpNum::Multi)}, {"Auth", static_cast(Coordination::OpNum::Auth)}, {"SessionID", static_cast(Coordination::OpNum::SessionID)}, }); auto error_enum = std::make_shared( DataTypeEnum8::Values { {"ZOK", static_cast(Coordination::Error::ZOK)}, {"ZSYSTEMERROR", static_cast(Coordination::Error::ZSYSTEMERROR)}, {"ZRUNTIMEINCONSISTENCY", static_cast(Coordination::Error::ZRUNTIMEINCONSISTENCY)}, {"ZDATAINCONSISTENCY", static_cast(Coordination::Error::ZDATAINCONSISTENCY)}, {"ZCONNECTIONLOSS", static_cast(Coordination::Error::ZCONNECTIONLOSS)}, {"ZMARSHALLINGERROR", static_cast(Coordination::Error::ZMARSHALLINGERROR)}, {"ZUNIMPLEMENTED", static_cast(Coordination::Error::ZUNIMPLEMENTED)}, {"ZOPERATIONTIMEOUT", static_cast(Coordination::Error::ZOPERATIONTIMEOUT)}, {"ZBADARGUMENTS", static_cast(Coordination::Error::ZBADARGUMENTS)}, {"ZINVALIDSTATE", static_cast(Coordination::Error::ZINVALIDSTATE)}, {"ZAPIERROR", static_cast(Coordination::Error::ZAPIERROR)}, {"ZNONODE", static_cast(Coordination::Error::ZNONODE)}, {"ZNOAUTH", static_cast(Coordination::Error::ZNOAUTH)}, {"ZBADVERSION", static_cast(Coordination::Error::ZBADVERSION)}, {"ZNOCHILDRENFOREPHEMERALS", static_cast(Coordination::Error::ZNOCHILDRENFOREPHEMERALS)}, {"ZNODEEXISTS", static_cast(Coordination::Error::ZNODEEXISTS)}, {"ZNOTEMPTY", static_cast(Coordination::Error::ZNOTEMPTY)}, {"ZSESSIONEXPIRED", static_cast(Coordination::Error::ZSESSIONEXPIRED)}, {"ZINVALIDCALLBACK", static_cast(Coordination::Error::ZINVALIDCALLBACK)}, {"ZINVALIDACL", static_cast(Coordination::Error::ZINVALIDACL)}, {"ZAUTHFAILED", static_cast(Coordination::Error::ZAUTHFAILED)}, {"ZCLOSING", static_cast(Coordination::Error::ZCLOSING)}, {"ZNOTHING", static_cast(Coordination::Error::ZNOTHING)}, {"ZSESSIONMOVED", static_cast(Coordination::Error::ZSESSIONMOVED)}, }); auto watch_type_enum = std::make_shared( DataTypeEnum8::Values { {"CREATED", static_cast(Coordination::Event::CREATED)}, {"DELETED", static_cast(Coordination::Event::DELETED)}, {"CHANGED", static_cast(Coordination::Event::CHANGED)}, {"CHILD", static_cast(Coordination::Event::CHILD)}, {"SESSION", static_cast(Coordination::Event::SESSION)}, {"NOTWATCHING", static_cast(Coordination::Event::NOTWATCHING)}, }); auto watch_state_enum = std::make_shared( DataTypeEnum16::Values { {"EXPIRED_SESSION", static_cast(Coordination::State::EXPIRED_SESSION)}, {"AUTH_FAILED", static_cast(Coordination::State::AUTH_FAILED)}, {"CONNECTING", static_cast(Coordination::State::CONNECTING)}, {"ASSOCIATING", static_cast(Coordination::State::ASSOCIATING)}, {"CONNECTED", static_cast(Coordination::State::CONNECTED)}, {"NOTCONNECTED", static_cast(Coordination::State::NOTCONNECTED)}, }); return { {"type", std::move(type_enum)}, {"event_date", std::make_shared()}, {"event_time", std::make_shared(6)}, {"address", DataTypeFactory::instance().get("IPv6")}, {"port", std::make_shared()}, {"session_id", std::make_shared()}, {"xid", std::make_shared()}, {"has_watch", std::make_shared()}, {"op_num", op_num_enum}, {"path", std::make_shared()}, {"data", std::make_shared()}, {"is_ephemeral", std::make_shared()}, {"is_sequential", std::make_shared()}, {"version", std::make_shared(std::make_shared())}, {"requests_size", std::make_shared()}, {"request_idx", std::make_shared()}, {"zxid", std::make_shared()}, {"error", std::make_shared(error_enum)}, {"watch_type", std::make_shared(watch_type_enum)}, {"watch_state", std::make_shared(watch_state_enum)}, {"path_created", std::make_shared()}, {"stat_czxid", std::make_shared()}, {"stat_mzxid", std::make_shared()}, {"stat_pzxid", std::make_shared()}, {"stat_version", std::make_shared()}, {"stat_cversion", std::make_shared()}, {"stat_dataLength", std::make_shared()}, {"stat_numChildren", std::make_shared()}, {"children", std::make_shared(std::make_shared())}, }; } void ZooKeeperLogElement::appendToBlock(MutableColumns & columns) const { assert(type != UNKNOWN); size_t i = 0; columns[i++]->insert(type); auto event_time_seconds = event_time / 1000000; columns[i++]->insert(DateLUT::instance().toDayNum(event_time_seconds).toUnderType()); columns[i++]->insert(event_time); columns[i++]->insert(IPv6ToBinary(address.host()).data()); columns[i++]->insert(address.port()); columns[i++]->insert(session_id); columns[i++]->insert(xid); columns[i++]->insert(has_watch); columns[i++]->insert(op_num); columns[i++]->insert(path); columns[i++]->insert(data); columns[i++]->insert(is_ephemeral); columns[i++]->insert(is_sequential); columns[i++]->insert(version ? Field(*version) : Field()); columns[i++]->insert(requests_size); columns[i++]->insert(request_idx); columns[i++]->insert(zxid); columns[i++]->insert(error ? Field(*error) : Field()); columns[i++]->insert(watch_type ? Field(*watch_type) : Field()); columns[i++]->insert(watch_state ? Field(*watch_state) : Field()); columns[i++]->insert(path_created); columns[i++]->insert(stat.czxid); columns[i++]->insert(stat.mzxid); columns[i++]->insert(stat.pzxid); columns[i++]->insert(stat.version); columns[i++]->insert(stat.cversion); columns[i++]->insert(stat.dataLength); columns[i++]->insert(stat.numChildren); Array children_array; for (const auto & c : children) children_array.emplace_back(c); columns[i++]->insert(children_array); } };