Commit b914a864 authored by Phoebe Buckheister's avatar Phoebe Buckheister 🦎

Merge branch 'v6-backport-messions-filename-change' into 'v6'

V6 backport messions filename change

See merge request !190
parents 32ed625f 86a710e6
...@@ -27,7 +27,10 @@ ...@@ -27,7 +27,10 @@
#define STORAGETK_TARGETID_FILENAME "targetID" /* contains first-run targetID */ #define STORAGETK_TARGETID_FILENAME "targetID" /* contains first-run targetID */
#define STORAGETK_TARGETNUMID_FILENAME "targetNumID" /* contains first-run targetNumID */ #define STORAGETK_TARGETNUMID_FILENAME "targetNumID" /* contains first-run targetNumID */
#define STORAGETK_SESSIONS_BACKUP_FILE_NAME "sessions" /* contains session backup information */ #define STORAGETK_SESSIONS_BACKUP_FILE_NAME "sessions" /* contains session backup information */
#define STORAGETK_MSESSIONS_BACKUP_FILE_NAME "msessions" /* mirror session backup information */ /* mirror session backup information */
#define STORAGETK_MSESSIONS_BACKUP_FILE_NAME "mirroredSessions"
/* old file name for mirror session backup information, for compatibility */
#define STORAGETK_MSESSIONS_OLD_BACKUP_FILE_NAME "msessions"
#define STORAGETK_FILEID_TIMESTAMP_SHIFTBITS 32 /* timestamp is shifted by this number of bits */ #define STORAGETK_FILEID_TIMESTAMP_SHIFTBITS 32 /* timestamp is shifted by this number of bits */
......
...@@ -1620,10 +1620,14 @@ bool App::restoreSessions() ...@@ -1620,10 +1620,14 @@ bool App::restoreSessions()
std::string path = this->metaPathStr + "/" + std::string(STORAGETK_SESSIONS_BACKUP_FILE_NAME); std::string path = this->metaPathStr + "/" + std::string(STORAGETK_SESSIONS_BACKUP_FILE_NAME);
std::string mpath = this->metaPathStr + "/" + std::string(STORAGETK_MSESSIONS_BACKUP_FILE_NAME); std::string mpath = this->metaPathStr + "/" + std::string(STORAGETK_MSESSIONS_BACKUP_FILE_NAME);
std::string oldMpath = this->metaPathStr + "/"
+ std::string(STORAGETK_MSESSIONS_OLD_BACKUP_FILE_NAME);
bool pathRes = StorageTk::pathExists(path); bool pathRes = StorageTk::pathExists(path);
bool mpathRes = StorageTk::pathExists(mpath); bool mpathRes = StorageTk::pathExists(mpath);
if (!pathRes && !mpathRes) bool oldMpathRes = StorageTk::pathExists(oldMpath);
if (!pathRes && !mpathRes && !oldMpathRes)
return false; return false;
if (pathRes) if (pathRes)
...@@ -1631,24 +1635,44 @@ bool App::restoreSessions() ...@@ -1631,24 +1635,44 @@ bool App::restoreSessions()
bool loadRes = this->sessions->loadFromFile(path, *metaStore); bool loadRes = this->sessions->loadFromFile(path, *metaStore);
if (!loadRes) if (!loadRes)
{ {
log->logErr("Could not restore all sessions"); LOG_TOP(GENERAL, CRITICAL, "Could not restore all sessions.");
retVal = false; retVal = false;
} }
} }
if (mpathRes) if(mpathRes && oldMpathRes)
{ {
bool loadRes = this->mirroredSessions->loadFromFile(mpath, *metaStore); // if both the old and the new file exists, log and exit
if (!loadRes) throw ComponentInitException("Found both msessions (old) and "
"mirroredSessions files. One of them needs to be deleted before proceeding. Aborting.");
}
else if(oldMpathRes)
{
LOG_TOP(GENERAL, NOTICE, "Old mirrored sessions file (msessions) found. Renaming.");
if(rename(oldMpath.c_str(),mpath.c_str()) == -1)
{
LOG_TOP(GENERAL, WARNING, "Couldn't rename msessions file.");
}
mpathRes = StorageTk::pathExists(mpath);
}
if(mpathRes)
{
bool loadRes = false;
loadRes = this->mirroredSessions->loadFromFile(mpath, *metaStore);
if(!loadRes)
{ {
log->logErr("Could not restore all mirrored sessions"); log->logErr("Could not restore all mirrored sessions.");
retVal = false; retVal = false;
} }
} }
log->log(Log_NOTICE, "Restored " LOG_TOP(GENERAL, NOTICE, "Restored "
+ StringTk::uintToStr(sessions->getSize()) + " sessions and " + StringTk::uintToStr(sessions->getSize()) + " sessions and "
+ StringTk::uintToStr(mirroredSessions->getSize()) + " mirrored sessions"); + StringTk::uintToStr(mirroredSessions->getSize()) + " mirrored sessions.");
return retVal; return retVal;
} }
......
on main do
cd main.properties["meta0"]["config"]["storeMetaDirectory"] do
shutdown_daemon_soft(main, "meta0")
shell "cat mirroredSessions > /dev/null"
shell "cp mirroredSessions msessions"
startup_daemon(main, "meta", main.properties["meta0"]["config"], "meta0")
sleep 3
raise "meta should not have been started due to both files existing" \
if shell? "ps aux | grep -q [m]eta0"
shell "rm mirroredSessions"
startup_daemon(main, "meta", main.properties["meta0"]["config"], "meta0")
sleep 3
raise "msessions file should be gone" if shell? "cat msessions > /dev/null"
end
end
\ No newline at end of file
hosts:
main:
- mgmtd
- meta
- meta
- storage
- helperd
- client
mirroring:
meta_groups:
- id: 100
primary: 1
secondary: 2
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment