diff --git a/MAC/APL/APLCommon/src/ChildControl.cc b/MAC/APL/APLCommon/src/ChildControl.cc index 2cc16e96555183ce095cd41bf888d0010fb7e1c0..2cf26291b1d8d77183d5a657ca3a3d4da13a1955 100644 --- a/MAC/APL/APLCommon/src/ChildControl.cc +++ b/MAC/APL/APLCommon/src/ChildControl.cc @@ -94,6 +94,7 @@ ChildControl::ChildControl() : } itsCntlrList = &(ControllerAdmin::instance()->itsList); + } // @@ -151,8 +152,9 @@ void ChildControl::openService(const string& aServiceName, bool ChildControl::startChild (uint16 aCntlrType, OTDBtreeIDType anObsID, uint32 instanceNr, - const string& hostname) + const string& aHostname) { + string hostname(realHostname(aHostname)); LOG_DEBUG_STR("startChild(" << aCntlrType <<","<< anObsID <<","<< instanceNr <<","<< hostname << ")"); @@ -270,7 +272,8 @@ void ChildControl::startChildControllers() uint32 treeID = globalParameterSet()->getUint32("_treeID"); uint16 instanceNr = 0; // TODO string childCntlrName = - controllerName(childCntlrType, instanceNr, treeID, hostnames[i]); + controllerName(childCntlrType, instanceNr, + treeID, realHostname(hostnames[i])); // child already running??? CTState::CTstateNr requestedState = getRequestedState(childCntlrName); @@ -887,7 +890,7 @@ void ChildControl::_setEstablishedState(const string& aName, // void ChildControl::_doGarbageCollection() { - LOG_DEBUG ("Garbage collection"); + LOG_DEBUG_STR ("Garbage collection(" << itsGarbageInterval << ")"); CIiter iter = itsCntlrList->begin(); const_CIiter end = itsCntlrList->end(); @@ -1042,6 +1045,16 @@ GCFEvent::TResult ChildControl::operational(GCFEvent& event, _setEstablishedState(controller->cntlrName, CTState::ANYSTATE, time(0), CT_RESULT_LOST_CONNECTION); controller->port = 0; + +#if 0 // Try to restart the controller over 5 seconds + // Add it to the action list. + controller->retryTime = time(0) + 300 ; + itsListener->cancelTimer(itsActionTimer); + itsActionTimer = itsListener->setTimer(1.0); + itsActionList.push_back(*controller); + + // And schedule cleanup when everthing fails +#endif if (itsGarbageTimer) { itsTimerPort.cancelTimer(itsGarbageTimer); } @@ -1052,8 +1065,7 @@ GCFEvent::TResult ChildControl::operational(GCFEvent& event, } break; - case F_TIMER: - { + case F_TIMER: { GCFTimerEvent& timerEvent = static_cast<GCFTimerEvent&>(event); LOG_DEBUG_STR("TIMERID=" << timerEvent.id); if (timerEvent.id == itsGarbageTimer) { @@ -1066,18 +1078,16 @@ GCFEvent::TResult ChildControl::operational(GCFEvent& event, } break; - case STARTDAEMON_CREATED: // startDaemon reports startup of program - { - STARTDAEMONCreatedEvent result(event); - LOG_DEBUG_STR("Startup of " << result.cntlrName << " ready, result=" - << result.result); - _setEstablishedState(result.cntlrName, CTState::CREATED, time(0), - result.result); + case STARTDAEMON_CREATED: { // startDaemon reports startup of program + STARTDAEMONCreatedEvent result(event); + LOG_DEBUG_STR("Startup of " << result.cntlrName << " ready, result=" + << result.result); + _setEstablishedState(result.cntlrName, CTState::CREATED, time(0), + result.result); } break; - case CONTROL_CONNECT: // received from just started controller - { + case CONTROL_CONNECT: { // received from just started controller CONTROLConnectEvent msg(event); CONTROLConnectedEvent answer; diff --git a/MAC/APL/APLCommon/src/ParentControl.cc b/MAC/APL/APLCommon/src/ParentControl.cc index efb003ba836ab68cde44392344ef9c319270454d..d403a4a837a246031227468accbacd1b315c4a37 100644 --- a/MAC/APL/APLCommon/src/ParentControl.cc +++ b/MAC/APL/APLCommon/src/ParentControl.cc @@ -905,7 +905,7 @@ GCFEvent::TResult ParentControl::operational(GCFEvent& event, PIiter parent = findParent(msg.cntlrName); if (isParent(parent)) { // note do not register this state, it is not a real state - LOG_DEBUG_STR("Passing SCHEDULED event to parent ocntroller"); + LOG_DEBUG_STR("Passing SCHEDULED event to parent controller"); parent->port->send(msg); } } diff --git a/MAC/APL/APLCommon/src/StationInfo.cc b/MAC/APL/APLCommon/src/StationInfo.cc index 39ceea79e90f72907e06d52a835ce89776d406e3..c5acf80df3c75cbce35dbecf686754b3da230787 100644 --- a/MAC/APL/APLCommon/src/StationInfo.cc +++ b/MAC/APL/APLCommon/src/StationInfo.cc @@ -48,6 +48,9 @@ static char* stationTypeTable[] = { "CS", "RS", "ES" }; // uint16 stationRingNr() { + if (!isdigit(myHostname(false).substr(2,1)[0])) { + return(0); + } return (lexical_cast<uint16>(myHostname(false).substr(3,2))); } @@ -61,6 +64,9 @@ uint16 stationRingNr() // uint16 stationArmNr() { + if (!isdigit(myHostname(false).substr(2,1)[0])) { + return(0); + } return (lexical_cast<uint16>(myHostname(false).substr(2,1))); } @@ -120,6 +126,31 @@ string PVSSDatabaseName() return (hostname); } +// +// realHostname +// +// In SAS the stationnames are used as hostnames so the last 'C' is missing. +// This routine tries to find out if it has to add the C to the given hostname. +// +string realHostname(const string& someName) +{ + // first figure out in which letter our machinename ends. + string hostname(myHostname(false)); + char lastChar(*(--toUpper(hostname).end())); + if (lastChar != 'C' && lastChar != 'T') { + lastChar = '\0'; + } + + // if name ends in same char assume the name is correct. + string::const_iterator riter = someName.end(); + if (*(--riter) == lastChar) { + return (someName); + } + + return (string(someName+lastChar)); +} + + } // namespace Deployment } // namespace LOFAR