Skip to content
Snippets Groups Projects
Commit b22f9d25 authored by Joana Plewnia's avatar Joana Plewnia
Browse files

removed old comments, added try-catch for setting export name, added...

removed old comments, added try-catch for setting export name, added ARMARX_INFO output for export name information
parent 3ccdae49
No related branches found
No related tags found
1 merge request!322Feature/forgetting in wm and em
Pipeline #15992 passed
......@@ -18,27 +18,9 @@ namespace armarx::armem::server::ltm
MongoDBStorageMixin::configureMixin(json);
}
Memory::Memory() : Memory(std::filesystem::path("/tmp/ARMARX/LTM_Exports"), {}, "MemoryExport", "Test")
Memory::Memory() :
Memory(std::filesystem::path("/tmp/ARMARX/LTM_Exports"), {}, "MemoryExport", "Test")
{
//set path to include date of creation as prefix:
this->current_date = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm* localTime = std::localtime(&this->current_date);
// convert current time into string:
std::stringstream ss;
ss << std::put_time(localTime, "%Y_%m_%d");
std::string dateString = ss.str();
// change memory base path to include current date (date of memory creation)
std::filesystem::path current_base_path = this->getMemoryBasePath();
this->setMemoryBasePath(current_base_path.append(dateString));
//inform user about change:
ARMARX_DEBUG << "Changed memory base path to include current date of "
<< dateString
<< " to "
<< this->getMemoryBasePath()
;
}
Memory::Memory(const detail::mixin::Path& p,
......@@ -60,6 +42,26 @@ namespace armarx::armem::server::ltm
DiskMemoryItemMixin(p, exportName, MemoryID(memoryName, "")),
MongoDBStorageMixin(s, exportName, MemoryID(memoryName, ""))
{
//set path to include date of creation as prefix:
this->current_date = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm* localTime = std::localtime(&this->current_date);
// convert current time into string:
std::stringstream ss;
ss << std::put_time(localTime, "%Y_%m_%d");
std::string dateString = ss.str();
// change memory base path to include current date (date of memory creation)
std::filesystem::path current_base_path = this->getMemoryBasePath();
this->setMemoryBasePath(current_base_path.append(dateString));
//inform user about change:
ARMARX_DEBUG << "Changed memory base path to include current date of "
<< dateString
<< " to "
<< this->getMemoryBasePath()
;
ARMARX_INFO << "Creating a new memory at " << p.string() << " and " << exportName;
}
......@@ -101,23 +103,6 @@ namespace armarx::armem::server::ltm
{
std::lock_guard l(ltm_mutex);
// for each
/*if (connected() && collectionExists())
{
for (const auto& doc : getAllDocuments())
{
std::string segmentName = doc[FOREIGN_KEY];
CoreSegment c(getMemoryBasePath(),
getSettings(),
getExportName(),
id().withCoreSegmentName(segmentName),
processors);
func(c);
}
} else */
//ARMARX_INFO << "LTM: forEach CoreSegment";
//ARMARX_INFO << "";
// legacy: check fs
if (fullPathExists())
{
......
......@@ -71,6 +71,13 @@ namespace armarx::armem::server::ltm::detail
{
this->startRecording();
}
try{
ARMARX_INFO << "Export name: " << p.export_name;
this->_setExportName(p.export_name);
} catch(...){
ARMARX_WARNING << "Could not read and/or set export name";
}
}
/// enable this LTM
......@@ -79,6 +86,7 @@ namespace armarx::armem::server::ltm::detail
{
auto now = armarx::core::time::DateTime::Now();
ARMARX_INFO << "Enabling LTM " << id().str() << " at " << now.toDateTimeString();
ARMARX_INFO << "Storing information at " << this->getExportName();
enabled = true;
if(statistics.firstStart){
statistics.firstStarted = armarx::core::time::DateTime::Now();
......@@ -192,9 +200,6 @@ namespace armarx::armem::server::ltm::detail
defs->optional(p.configuration_on_startup, prefix + "configuration");
defs->optional(p.export_name, prefix + "exportName");
defs->optional(p.export_path, prefix + "exportPath");
ARMARX_INFO << "Setting property definitions";
_setExportName(p.export_name);
}
/// enable/disable
......
......@@ -34,8 +34,9 @@ namespace armarx::armem::server::ltm::detail::mixin
void
DiskMemoryItemMixin::setMixinExportName(const std::string& n)
{
//ARMARX_INFO << "Currently setting export name to: " << n;
ARMARX_INFO << "Currently setting export name to: " << n;
exportName = n;
ARMARX_INFO << "Currently export name in mixin is set to " << this->exportName;
}
void
......@@ -51,7 +52,7 @@ namespace armarx::armem::server::ltm::detail::mixin
{
if (json.find("DiskMemory.memoryParentPath") != json.end())
{
memoryBasePath = Path(json.at("DiskMemory.memoryParentPath"));
//memoryBasePath = Path(json.at("DiskMemory.memoryParentPath"));
}
}
......
......@@ -196,7 +196,7 @@ namespace armarx::armem::server::plugins
iceAdapter.setMemoryListener(memoryTopic);
connected = true;
ARMARX_INFO << "Export Name: " << longtermMemory.getExportName(); //TODO: remove after testing
//ARMARX_INFO << "Export Name: " << longtermMemory.getExportName(); //TODO: remove after testing
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment