From b9ce3175f1e97ba50a01d307f2cf53cdea5e29da Mon Sep 17 00:00:00 2001 From: Fabian Peller <fabian.peller-konrad@kit.edu> Date: Tue, 2 May 2023 18:26:24 +0200 Subject: [PATCH] comment out mongodb stuff --- .../armem/server/ltm/CoreSegment.cpp | 54 +++++++++---------- .../libraries/armem/server/ltm/Entity.cpp | 29 +++++----- .../armem/server/ltm/EntityInstance.cpp | 28 +++++----- .../armem/server/ltm/EntitySnapshot.cpp | 38 +++++++------ .../libraries/armem/server/ltm/Memory.cpp | 29 +++++----- .../armem/server/ltm/ProviderSegment.cpp | 54 +++++++++---------- .../aron/converter/stdstl/CMakeLists.txt | 4 ++ 7 files changed, 112 insertions(+), 124 deletions(-) diff --git a/source/RobotAPI/libraries/armem/server/ltm/CoreSegment.cpp b/source/RobotAPI/libraries/armem/server/ltm/CoreSegment.cpp index 13a6fbe8b..5e0f1908b 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/CoreSegment.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/CoreSegment.cpp @@ -17,7 +17,7 @@ namespace armarx::armem::server::ltm DiskMemoryItemMixin(p, exportName, id), MongoDBStorageMixin(s, exportName, id) { - start(); + //start(); } bool @@ -25,7 +25,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { for (const auto& doc : getAllDocuments()) { @@ -35,10 +35,10 @@ namespace armarx::armem::server::ltm getMemoryBasePath(), getSettings(), getExportName(), segment_id, processors); func(c); } - } + } else */ // legacy - /*else if (fullPathExists()) + if (fullPathExists()) { for (const auto& subdirName : getAllDirectories()) { @@ -50,7 +50,7 @@ namespace armarx::armem::server::ltm processors); func(c); } - }*/ + } return true; } @@ -59,7 +59,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { auto c = ProviderSegment(getMemoryBasePath(), getSettings(), @@ -68,9 +68,9 @@ namespace armarx::armem::server::ltm processors); return (bool)c.collectionExists(); - } + }*/ - /*if (fullPathExists()) + if (fullPathExists()) { auto c = ProviderSegment(getMemoryBasePath(), getSettings(), @@ -79,7 +79,7 @@ namespace armarx::armem::server::ltm processors); return c.fullPathExists(); - }*/ + } return false; } @@ -115,17 +115,17 @@ namespace armarx::armem::server::ltm e.aronType() = aron::type::Object::DynamicCastAndCheck(typeAron); }; - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { // TODO: - } + } else */ - /*else if (std::string filename = TYPE_FILENAME + conv.suffix; - fullPathExists() && fileExists(filename)) + if (std::string filename = TYPE_FILENAME + conv.suffix; + fullPathExists() && fileExists(filename)) { auto typeFileContent = readDataFromFile(filename); setType(typeFileContent); - }*/ + } forEachProviderSegment( [&e](auto& x) @@ -141,7 +141,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if ((connected() && collectionExists()) /* || fullPathExists()*/) + if (/*(connected() && collectionExists()) ||*/ fullPathExists()) { c.forEachProviderSegment( [&](auto& e) @@ -170,11 +170,11 @@ namespace armarx::armem::server::ltm id().coreSegmentName = c.id().coreSegmentName; }; - if (!connected()) + /*if (!connected()) { ARMARX_WARNING << "LTM CORE SEGMENT NOT CONNECTED ALTHOUGH ENABLED " << id().str(); return; - } + }*/ // add foreign key to memory collection if (c.hasAronType()) @@ -184,24 +184,20 @@ namespace armarx::armem::server::ltm auto [vec, modeSuffix] = conv.convert(c.aronType()); ARMARX_CHECK_EMPTY(modeSuffix); - std::string dataStr{vec.begin(), vec.end()}; - auto dataJson = nlohmann::json::parse(dataStr); + //std::string dataStr{vec.begin(), vec.end()}; + /*auto dataJson = nlohmann::json::parse(dataStr); + + writeForeignKeyToPreviousDocument(dataJson);*/ - writeForeignKeyToPreviousDocument(dataJson); + ensureFullPathExists(true); + std::string filename = (TYPE_FILENAME + conv.suffix); + writeDataToFile(filename, vec); } else { - writeForeignKeyToPreviousDocument(); + /*writeForeignKeyToPreviousDocument();*/ } - // legacy: also ensure filesystem exists - //ensureFullPathExists(true); - /*else - { - std::string filename = (TYPE_FILENAME + conv.suffix); - writeDataToFile(filename, vec); - }*/ - c.forEachProviderSegment( [&](const auto& prov) { diff --git a/source/RobotAPI/libraries/armem/server/ltm/Entity.cpp b/source/RobotAPI/libraries/armem/server/ltm/Entity.cpp index 116c4d91b..b34d9d516 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/Entity.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/Entity.cpp @@ -31,7 +31,7 @@ namespace armarx::armem::server::ltm DiskMemoryItemMixin(p, exportName, id), MongoDBStorageMixin(s, exportName, id) { - start(); + //start(); } bool @@ -39,7 +39,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { for (const auto& doc : getAllDocuments()) { @@ -52,8 +52,8 @@ namespace armarx::armem::server::ltm getMemoryBasePath(), getSettings(), getExportName(), segment_id, processors); func(c); } - } - /*else if (fullPathExists()) + } else */ + if (fullPathExists()) { for (const auto& d : getAllDirectories()) // days @@ -110,7 +110,7 @@ namespace armarx::armem::server::ltm } } } - */ + return true; } @@ -201,7 +201,7 @@ namespace armarx::armem::server::ltm Entity::hasSnapshot(const Time& n) const { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { auto c = EntitySnapshot(getMemoryBasePath(), getSettings(), @@ -209,9 +209,9 @@ namespace armarx::armem::server::ltm id().withTimestamp(n), processors); return (bool)c.documentExists(); - } + }*/ - /*if (fullPathExists()) + if (fullPathExists()) { auto c = EntitySnapshot(getMemoryBasePath(), getSettings(), @@ -219,7 +219,7 @@ namespace armarx::armem::server::ltm id().withTimestamp(n), processors); return c.fullPathExists(); - }*/ + } return false; } @@ -400,7 +400,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if ((connected() && collectionExists()) /* || fullPathExists()*/) + if (/*(connected() && collectionExists()) ||*/ fullPathExists()) { p.forEachSnapshot( @@ -429,16 +429,13 @@ namespace armarx::armem::server::ltm id().entityName = c.id().entityName; } - if (!connected()) + /*if (!connected()) { ARMARX_WARNING << "LTM ENTITY NOT CONNECTED ALTHOUGH ENABLED " << id().str(); return; - } - - writeForeignKeyToPreviousDocument(); + }*/ - // legacy: also ensure filesystem exists - //ensureFullPathExists(true); + //writeForeignKeyToPreviousDocument(); c.forEachSnapshot( [&](const auto& snap) diff --git a/source/RobotAPI/libraries/armem/server/ltm/EntityInstance.cpp b/source/RobotAPI/libraries/armem/server/ltm/EntityInstance.cpp index 9afb3c269..b5800ec11 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/EntityInstance.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/EntityInstance.cpp @@ -23,7 +23,7 @@ namespace armarx::armem::server::ltm DiskMemoryItemMixin(p, exportName, id), MongoDBStorageMixin(s, exportName, id) { - start(); + //start(); } void @@ -46,7 +46,7 @@ namespace armarx::armem::server::ltm aron::data::DictPtr datadict = nullptr; aron::data::DictPtr metadatadict = nullptr; - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { if (auto d = documentExists(); d) { @@ -87,9 +87,9 @@ namespace armarx::armem::server::ltm ARMARX_ERROR << "Could not find the metadata key. Continuing without metadata."; } } - } + } else */ - /*else if (fullPathExists()) + if (fullPathExists()) { std::string dataFilename = (DATA_FILENAME + dictConverter.suffix); @@ -122,7 +122,7 @@ namespace armarx::armem::server::ltm ARMARX_ERROR << "Could not find the metadata file '" << metadataPath.string() << "'. Continuing without metadata."; } - }*/ + } // check for special members TODO: only allowed for direct children? auto allFilesInIndexFolder = getAllFiles(); @@ -170,14 +170,13 @@ namespace armarx::armem::server::ltm auto& dictConverter = processors->defaultObjectConverter; - if (!connected()) + /*if (!connected()) { ARMARX_WARNING << "LTM ENTITY INSTANCE NOT CONNECTED ALTHOUGH ENABLED " << id().str(); return {}; - } + }*/ - // legacy: also ensure filesystem exists - // ensureFullPathExists(true); + ensureFullPathExists(true); // data auto dataAron = std::make_shared<aron::data::Dict>(); @@ -213,9 +212,8 @@ namespace armarx::armem::server::ltm ARMARX_CHECK_EMPTY(dataVecModeSuffix); ARMARX_CHECK_EMPTY(metadataVecModeSuffix); - return nlohmann::json::parse(std::string(dataVec.begin(), dataVec.end())); + auto dataToReturn = nlohmann::json::parse(std::string(dataVec.begin(), dataVec.end())); - /*else { std::string dataFilename = (DATA_FILENAME + dictConverter.suffix); std::string metadataFilename = (METADATA_FILENAME + dictConverter.suffix); @@ -224,9 +222,11 @@ namespace armarx::armem::server::ltm writeDataToFile(dataFilename, dataVec); writeDataToFile(metadataFilename, metadataVec); - }*/ + } + + statistics.recordedData++; + statistics.recordedMetaData++; - //statistics.recordedData++; - //statistics.recordedMetaData++; + return dataToReturn; } } // namespace armarx::armem::server::ltm diff --git a/source/RobotAPI/libraries/armem/server/ltm/EntitySnapshot.cpp b/source/RobotAPI/libraries/armem/server/ltm/EntitySnapshot.cpp index fd030f54b..693f015a2 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/EntitySnapshot.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/EntitySnapshot.cpp @@ -23,7 +23,7 @@ namespace armarx::armem::server::ltm DiskMemoryItemMixin(p, exportName, id), MongoDBStorageMixin(s, exportName, id) { - start(); + //start(); } bool @@ -31,7 +31,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { if (auto d = documentExists(); d) { @@ -47,9 +47,9 @@ namespace armarx::armem::server::ltm func(c); } } - } + } else */ - /*else if (fullPathExists()) + if (fullPathExists()) { for (const auto& i : getAllDirectories()) { @@ -68,7 +68,7 @@ namespace armarx::armem::server::ltm processors); func(c); } - }*/ + } return true; } @@ -77,7 +77,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { if (auto d = documentExists(); d) { @@ -85,9 +85,9 @@ namespace armarx::armem::server::ltm std::vector<nlohmann::json> instances = doc[DATA]; return (size_t)index < instances.size(); } - } + }*/ - /*if (fullPathExists()) + if (fullPathExists()) { auto c = EntityInstance(getMemoryBasePath(), getSettings(), @@ -95,7 +95,7 @@ namespace armarx::armem::server::ltm id().withInstanceIndex(index), processors); return c.fullPathExists(); - }*/ + } return false; } @@ -130,7 +130,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if ((connected() && collectionExists() && documentExists()) /* || fullPathExists()*/) + if (/*(connected() && collectionExists() && documentExists()) ||*/ fullPathExists()) { p.forEachInstance( [&](auto& e) @@ -140,7 +140,7 @@ namespace armarx::armem::server::ltm getExportName(), id().withInstanceIndex(e.id().instanceIndex), processors); - //c.resolve(e); + c.resolve(e); }); } } @@ -159,17 +159,14 @@ namespace armarx::armem::server::ltm id().timestamp = p.id().timestamp; } - if (!connected()) + /*if (!connected()) { ARMARX_WARNING << "LTM ENTITY SNAPSHOT NOT CONNECTED ALTHOUGH ENABLED " << id().str(); return; - } - - // legacy: also ensure filesystem exists - //ensureFullPathExists(true); + }*/ - nlohmann::json data; - data[DATA] = std::vector<nlohmann::json>(); + //nlohmann::json data; + //data[DATA] = std::vector<nlohmann::json>(); p.forEachInstance( [&](const auto& e) @@ -179,11 +176,12 @@ namespace armarx::armem::server::ltm getExportName(), id().withInstanceIndex(e.id().instanceIndex), processors); + c.store(e); - data[DATA].push_back(c.store(e)); + //data[DATA].push_back(c.store(e)); statistics.recordedInstances++; }); - writeDataToDocument(data); + //writeDataToDocument(data); } } // namespace armarx::armem::server::ltm diff --git a/source/RobotAPI/libraries/armem/server/ltm/Memory.cpp b/source/RobotAPI/libraries/armem/server/ltm/Memory.cpp index fe87a47ba..06f81e22c 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/Memory.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/Memory.cpp @@ -54,7 +54,7 @@ namespace armarx::armem::server::ltm Memory::_enable() { BufferedBase::start(); - MongoDBStorageMixin::start(); + //MongoDBStorageMixin::start(); } void @@ -81,7 +81,7 @@ namespace armarx::armem::server::ltm std::lock_guard l(ltm_mutex); // for each - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { for (const auto& doc : getAllDocuments()) { @@ -93,10 +93,10 @@ namespace armarx::armem::server::ltm processors); func(c); } - } + } else */ - /*// legacy: check fs - else if (fullPathExists()) + // legacy: check fs + if (fullPathExists()) { for (const auto& subdirName : getAllDirectories()) { @@ -108,7 +108,7 @@ namespace armarx::armem::server::ltm processors); func(c); } - }*/ + } return true; } @@ -124,7 +124,7 @@ namespace armarx::armem::server::ltm } // check if collection exists - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { auto c = CoreSegment(getMemoryBasePath(), getSettings(), @@ -133,9 +133,9 @@ namespace armarx::armem::server::ltm processors); return (bool)c.collectionExists(); - } + }*/ - /*// legacy: check if segment is stored on hard drive without db + // legacy: check if segment is stored on hard drive without db if (fullPathExists()) { auto c = CoreSegment(getMemoryBasePath(), @@ -145,7 +145,7 @@ namespace armarx::armem::server::ltm processors); return c.fullPathExists(); - }*/ + } return false; } @@ -188,7 +188,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); // we cannot load a memory multiple times simultaneously - if ((connected() && collectionExists()) /* || fullPathExists()*/) + if (/*(connected() && collectionExists()) ||*/ fullPathExists()) { m.forEachCoreSegment( [&](auto& e) @@ -223,14 +223,11 @@ namespace armarx::armem::server::ltm setMemoryID(memory.id()); } - if (!connected()) + /*if (!connected()) { ARMARX_WARNING << "LTM NOT CONNECTED ALTHOUGH ENABLED " << id().str(); return; - } - - // legacy: also ensure filesystem exists - // ensureFullPathExists(true); + }*/ memory.forEachCoreSegment( [&](const auto& core) diff --git a/source/RobotAPI/libraries/armem/server/ltm/ProviderSegment.cpp b/source/RobotAPI/libraries/armem/server/ltm/ProviderSegment.cpp index fb64b87c3..0cb941e1f 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/ProviderSegment.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/ProviderSegment.cpp @@ -19,7 +19,7 @@ namespace armarx::armem::server::ltm DiskMemoryItemMixin(p, exportName, id), MongoDBStorageMixin(s, exportName, id) { - start(); + //start(); } bool @@ -27,7 +27,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { for (const auto& doc : getAllDocuments()) { @@ -37,9 +37,9 @@ namespace armarx::armem::server::ltm getMemoryBasePath(), getSettings(), getExportName(), segment_id, processors); func(c); } - } + } else */ - /*else if (fullPathExists()) + if (fullPathExists()) { for (const auto& subdirName : getAllDirectories()) @@ -52,7 +52,7 @@ namespace armarx::armem::server::ltm processors); func(c); } - }*/ + } return true; } @@ -61,7 +61,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { auto c = Entity(getMemoryBasePath(), getSettings(), @@ -69,9 +69,9 @@ namespace armarx::armem::server::ltm id().withEntityName(name), processors); return (bool)c.collectionExists(); - } + }*/ - /*if (fullPathExists()) + if (fullPathExists()) { auto c = Entity(getMemoryBasePath(), getSettings(), @@ -79,7 +79,7 @@ namespace armarx::armem::server::ltm id().withEntityName(name), processors); return c.fullPathExists(); - }*/ + } return false; } @@ -114,17 +114,17 @@ namespace armarx::armem::server::ltm e.aronType() = aron::type::Object::DynamicCastAndCheck(typeAron); }; - if (connected() && collectionExists()) + /*if (connected() && collectionExists()) { // TODO: - } + } else */ - /*else if (std::string filename = TYPE_FILENAME + conv.suffix; - fullPathExists() && fileExists(filename)) + if (std::string filename = TYPE_FILENAME + conv.suffix; + fullPathExists() && fileExists(filename)) { auto typeFileContent = readDataFromFile(filename); setType(typeFileContent); - }*/ + } forEachEntity( [&e](auto& x) @@ -140,7 +140,7 @@ namespace armarx::armem::server::ltm { std::lock_guard l(ltm_mutex); - if ((connected() && collectionExists()) /* || fullPathExists()*/) + if (/*(connected() && collectionExists()) ||*/ fullPathExists()) { p.forEachEntity( [&](auto& e) @@ -169,11 +169,11 @@ namespace armarx::armem::server::ltm id().providerSegmentName = p.id().providerSegmentName; } - if (!connected()) + /*if (!connected()) { ARMARX_WARNING << "LTM PROVIDER SEGMENT NOT CONNECTED ALTHOUGH ENABLED " << id().str(); return; - } + }*/ // add foreign key to memory collection if (p.hasAronType()) @@ -183,24 +183,20 @@ namespace armarx::armem::server::ltm auto [vec, modeSuffix] = conv.convert(p.aronType()); ARMARX_CHECK_EMPTY(modeSuffix); - std::string dataStr{vec.begin(), vec.end()}; - auto dataJson = nlohmann::json::parse(dataStr); + //std::string dataStr{vec.begin(), vec.end()}; + //auto dataJson = nlohmann::json::parse(dataStr); + + //writeForeignKeyToPreviousDocument(dataJson); - writeForeignKeyToPreviousDocument(dataJson); + ensureFullPathExists(true); + std::string filename = (TYPE_FILENAME + conv.suffix); + writeDataToFile(filename, vec); } else { - writeForeignKeyToPreviousDocument(); + //writeForeignKeyToPreviousDocument(); } - // legacy: also ensure filesystem exists - //ensureFullPathExists(true); - /*else - { - std::string filename = (TYPE_FILENAME + conv.suffix); - writeDataToFile(filename, vec); - }*/ - p.forEachEntity( [&](const auto& e) { diff --git a/source/RobotAPI/libraries/aron/converter/stdstl/CMakeLists.txt b/source/RobotAPI/libraries/aron/converter/stdstl/CMakeLists.txt index f9b36927a..707f8eeee 100644 --- a/source/RobotAPI/libraries/aron/converter/stdstl/CMakeLists.txt +++ b/source/RobotAPI/libraries/aron/converter/stdstl/CMakeLists.txt @@ -22,5 +22,9 @@ set(LIB_HEADERS armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") +# legacy alias +add_library(aronvectorconverter ALIAS aronstdstlconverter) +# namespace alias add_library(RobotAPI::aron::converter::stdstl ALIAS aronstdstlconverter) + -- GitLab