Skip to content
Snippets Groups Projects
Commit d01aa204 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-156: implemented updateActiveList and updateFinishedList for TMSS. Use TMSS-status-strings

parent fdec19a8
No related branches found
No related tags found
1 merge request!116TMSS-156: Resolve TMSS-156
......@@ -629,7 +629,7 @@ GCFEvent::TResult MACScheduler::active_state(GCFEvent& event, GCFPortInterface&
}
else
#endif
itsTMSSconnection->setSubtaskState(theObs->second, "active");
itsTMSSconnection->setSubtaskState(theObs->second, "started");
break;
}
......@@ -648,7 +648,7 @@ GCFEvent::TResult MACScheduler::active_state(GCFEvent& event, GCFPortInterface&
tm.setTreeState(theObs->second, tsc.get("completing"));
} else
#endif
itsTMSSconnection->setSubtaskState(theObs->second, "completing");
itsTMSSconnection->setSubtaskState(theObs->second, "finishing");
break;
}
......@@ -925,9 +925,6 @@ void MACScheduler::_updatePlannedList()
boost::split(tmp, url, [](char c){return c == '/';});
int subtask_id = stoi(tmp[tmp.size()-2]);
// std::cout << "Wrote parset to " << filename << std::endl;
// _setParsetOnMsgBus(filename);
// construct name and timings info for observation
string obsName(observationName(subtask_id));
ptime start_time = time_from_string(subtask["start_time"].asString().replace(10, 1, " "));
......@@ -1039,19 +1036,17 @@ void MACScheduler::_updateActiveList()
{
LOG_DEBUG("_updateActiveList()");
GCFPValueArray activeArr;
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
// get new list (list is ordered on starttime)
vector<OTDBtree> activeDBlist = itsOTDBconnection->getTreeGroup(2, 0, itsExclPLcluster);
if (activeDBlist.empty()) {
LOG_DEBUG ("No active Observations");
LOG_DEBUG ("No active OTDB Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
}
#endif
// walk through the list, prepare PVSS for the new obs, update own admin lists.
GCFPValueArray activeArr;
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
int32 idx = activeDBlist.size() - 1;
for ( ; idx >= 0; idx--) {
if (activeDBlist[idx].processType=="RESERVATION" || activeDBlist[idx].processType=="MAINTENANCE") {
......@@ -1070,8 +1065,45 @@ void MACScheduler::_updateActiveList()
} // for
#endif
// Finally we can pass the list with active observations to PVSS.
// get new list (list is/should_be ordered on starttime)
Json::Value activeSubTasks = itsTMSSconnection->getActiveSubTasks();
if (activeSubTasks.empty()) {
LOG_DEBUG ("No active TMSS Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
}
// walk through the list, prepare PVSS for the new obs, update own admin lists.
int32 idx = activeSubTasks.size() - 1;
for ( ; idx >= 0; idx--) {
Json::Value subtask = activeSubTasks[idx];
// if (subtask.processType=="RESERVATION" || subtask.processType=="MAINTENANCE") {
// continue;
// }
// get subtask_id from url. I know, ugly, needs to be in json itself.
vector<string> tmp;
string url(subtask["url"].asString());
boost::split(tmp, url, [](char c){return c == '/';});
int subtask_id = stoi(tmp[tmp.size()-2]);
// construct name and timings info for observation
string obsName(observationName(subtask_id));
ptime start_time = time_from_string(subtask["start_time"].asString().replace(10, 1, " "));
ptime modTime = time_from_string(subtask["updated_at"].asString().replace(10, 1, " "));
activeArr.push_back(new GCFPVString(obsName));
// remove obs from planned-list if its still in there.
OLiter prepIter = itsPreparedObs.find(subtask_id);
if (prepIter != itsPreparedObs.end()) {
itsPreparedObs.erase(prepIter);
}
} // for
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
// Finally we can pass the list with active observations to PVSS.
itsPropertySet->setValue(PN_MS_ACTIVE_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, activeArr));
#endif
......@@ -1090,21 +1122,19 @@ void MACScheduler::_updateFinishedList()
{
LOG_DEBUG("_updateFinishedList()");
GCFPValueArray finishedArr;
int32 freeSpace = MAX_CONCURRENT_OBSERVATIONS - itsNrPlanned - itsNrActive;
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
// get new list (list is ordered on starttime)
vector<OTDBtree> finishedDBlist = itsOTDBconnection->getTreeGroup(3, itsFinishedPeriod, itsExclPLcluster);
if (finishedDBlist.empty()) {
LOG_DEBUG ("No finished Observations");
LOG_DEBUG ("No finishing OTDB Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
}
#endif
// walk through the list, prepare PVSS for the new obs, update own admin lists.
// We must show the last part of the (optional) limited list.
GCFPValueArray finishedArr;
int32 freeSpace = MAX_CONCURRENT_OBSERVATIONS - itsNrPlanned - itsNrActive;
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
int32 idx = finishedDBlist.size() - 1;
int32 limit = idx - (MIN2(MIN2(finishedDBlist.size(), itsMaxFinished), (uint32)freeSpace) - 1);
for ( ; idx >= limit ; idx--) {
......@@ -1116,8 +1146,49 @@ void MACScheduler::_updateFinishedList()
string obsName(observationName(finishedDBlist[idx].treeID()));
finishedArr.push_back(new GCFPVString(obsName));
} // for
// Finally we can pass the list with finished observations to PVSS.
itsPropertySet->setValue(PN_MS_FINISHED_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, finishedArr));
// free used memory
for (int i = finishedArr.size()-1; i>=0; --i) {
delete finishedArr[i];
}
#endif
//reset for TMSS
finishedArr = GCFPValueArray();
freeSpace = MAX_CONCURRENT_OBSERVATIONS - itsNrPlanned - itsNrActive;
// get new list (list is/should_be ordered on starttime)
Json::Value finishingSubTasks = itsTMSSconnection->getFinishingSubTasks();
if (finishingSubTasks.empty()) {
LOG_DEBUG ("No finishing TMSS Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
}
// walk through the list, prepare PVSS for the new obs, update own admin lists.
// We must show the last part of the (optional) limited list.
int32 idx = finishingSubTasks.size() - 1;
int32 limit = idx - (MIN2(MIN2(finishingSubTasks.size(), itsMaxFinished), (uint32)freeSpace) - 1);
for ( ; idx >= limit ; idx--) {
Json::Value subtask = finishingSubTasks[idx];
// if (subtask.processType=="RESERVATION" || subtask.processType=="MAINTENANCE") {
// continue;
// }
// get subtask_id from url. I know, ugly, needs to be in json itself.
vector<string> tmp;
string url(subtask["url"].asString());
boost::split(tmp, url, [](char c){return c == '/';});
int subtask_id = stoi(tmp[tmp.size()-2]);
// construct name info for observation
string obsName(observationName(subtask_id));
finishedArr.push_back(new GCFPVString(obsName));
} // for
// Finally we can pass the list with finished observations to PVSS.
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
itsPropertySet->setValue(PN_MS_FINISHED_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, finishedArr));
......
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