Commit 6debe0e9 authored by Bernd Lietzow's avatar Bernd Lietzow 🐨 Committed by Christian Mohrbacher

mgmtd: save target states also on shutdown

* when beegfs-mgmtd is started and stopped agan very quickly, it was
  possible that the target state files had not been written, but the
  format.conf file had. This prevented the next startup, because a
  missing state file means something is very wrong.
* Factored out saving the target and node states so that we don't have to
  do the whole Program::getApp... dance in the run() method of the
  InternodeSyncer.

(cherry picked from commit 9fd021b3a9e7f2946b3bd05dc371a8e1fd45a2e8)
parent 1adb6f17
......@@ -42,6 +42,7 @@ void InternodeSyncer::run()
}
saveTargetMappings();
saveStates();
}
void InternodeSyncer::syncLoop()
......@@ -127,8 +128,7 @@ void InternodeSyncer::syncLoop()
if (statesModified)
app->getHeartbeatMgr()->notifyAsyncRefreshTargetStates();
mgmtdTargetStateStore->saveStatesToFile();
mgmtdMetaStateStore->saveStatesToFile();
saveStates();
lastStatesUpdateT.setToNow();
}
......@@ -681,6 +681,16 @@ void InternodeSyncer::updateTargetBuddyCapacityPools()
}
void InternodeSyncer::saveStates()
{
App* app = Program::getApp();
auto* targetStateStore = app->getTargetStateStore();
auto* metaStateStore = app->getMetaStateStore();
targetStateStore->saveStatesToFile();
metaStateStore->saveStatesToFile();
}
/**
* Saves targetStrID->numID mappings (from targetNumIDMapper) and target->node mappings (from
* targetMapper).
......
......@@ -62,6 +62,7 @@ class InternodeSyncer : public PThread
void logDemotionFlags(const DemotionFlags& demotionFlags, NodeType nodeType);
void saveTargetMappings();
void saveStates();
void dropIdleConns();
unsigned dropIdleConnsByStore(NodeStoreServersEx* nodes);
......
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