Skip to content
Snippets Groups Projects
Commit 8704e7ab authored by Ruud Overeem's avatar Ruud Overeem
Browse files

Task #3877: All changes made on the MAC-OnlineCTC-3947 branch (23321:23357)...

Task #3877: All changes made on the MAC-OnlineCTC-3947 branch (23321:23357) are merged into the 1.9 release.
Warning: This does NOT include the new version of filling the PVSS variables for CEP-Navigator!

parent caa2d872
No related branches found
No related tags found
No related merge requests found
......@@ -2421,6 +2421,8 @@ MAC/APL/CEPCU/src/CEPlogProcessor/CEPDatapoints.dpl -text
MAC/APL/CEPCU/src/CEPlogProcessor/CEPDatapointtypes.dpl -text
MAC/APL/CEPCU/src/CEPlogProcessor/CircularBuffer.h -text
MAC/APL/CEPCU/src/CEPlogProcessor/rtlogsender.py -text
MAC/APL/CEPCU/src/OnlineControl/forkexec.cc -text
MAC/APL/CEPCU/src/OnlineControl/forkexec.h -text
MAC/APL/CEPCU/src/OnlineControl/tPVSSMapping.cc -text
MAC/APL/CEPCU/src/PythonControl/PythonControl.conf -text
MAC/APL/CEPCU/src/PythonControl/tMDparser.cc -text
......
# Preset rs002 specific options
option(USE_BACKTRACE "Use backtrace" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
# Path to Postgres C API
set(PQ_ROOT_DIR /usr/local/pgsql)
......
# $Id$
# Do not split the following line, otherwise makeversion will fail!
lofar_package(CEPCU 1.0 DEPENDS Common ALC PLC ApplCommon MACIO GCFTM GCFRTDB APLCommon RTDBCommon OTDB)
lofar_package(CEPCU 1.0 DEPENDS Common ApplCommon MACIO GCFTM GCFRTDB APLCommon RTDBCommon OTDB)
include(LofarFindPackage)
lofar_find_package(Boost REQUIRED COMPONENTS date_time)
......
//# CEPApplMgr.cc: Implementation of the Virtual CEPApplMgr task
//#
//# Copyright (C) 2002-2004
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id$
#include <lofar_config.h>
#include <Common/StringUtil.h>
#include <APL/APLCommon/Controller_Protocol.ph>
#include <GCF/TM/GCF_Scheduler.h>
#include "CEPApplMgr.h"
namespace LOFAR {
using namespace GCF::TM;
using namespace ACC::ALC;
using namespace APLCommon;
namespace CEPCU {
//
// CEPApplMgr(interface, appl)
//
CEPApplMgr::CEPApplMgr(CEPApplMgrInterface& interface,
const string& appName,
uint32 expRuntime,
const string& acdHost,
const string& paramFile) :
itsProcName (appName),
itsParamFile (paramFile),
itsCAMInterface(interface),
// (nrProcs, expectedlifetime,activityLevel,architecture);
itsACclient (this, appName, 10, expRuntime, 1, 0, acdHost),
itsReqState (CTState::NOSTATE),
itsCurState (CTState::NOSTATE),
itsContinuePoll(true)
{
use(); // to avoid that this object will be deleted in GCFTask::stop;
}
//
// ~CEPApplMgr()
//
CEPApplMgr::~CEPApplMgr()
{
GCFScheduler::instance()->deregisterHandler(*this);
}
//
// workProc()
//
void CEPApplMgr::workProc()
{
if (itsContinuePoll) {
itsACclient.processACmsgFromServer();
}
}
//
// handleAckMsg(cmd, result, info)
//
// Translate ACC ack into MAC state.
//
void CEPApplMgr::handleAckMsg(ACCmd cmd,
uint16 ACCresult,
const string& info)
{
LOG_INFO(formatString("command: %d, result: %d, info: %s", cmd, ACCresult, info.c_str()));
uint16 MACresult = (ACCresult & AcCmdMaskOk) ?
CT_RESULT_NO_ERROR : CT_RESULT_UNSPECIFIED;
switch (cmd) {
case ACCmdBoot:
if (ACCresult == AcCmdMaskOk) {
itsCurState = CTState::CONNECTED;
}
itsCAMInterface.appSetStateResult(itsProcName, CTState::CONNECT, MACresult);
break;
case ACCmdDefine:
if (ACCresult == AcCmdMaskOk) {
itsCurState = CTState::CLAIMED;
}
itsCAMInterface.appSetStateResult(itsProcName, CTState::CLAIM, MACresult);
break;
case ACCmdInit:
if (ACCresult == AcCmdMaskOk) {
itsCurState = CTState::PREPARED;
}
itsCAMInterface.appSetStateResult(itsProcName, CTState::PREPARE, MACresult);
break;
case ACCmdRun:
if (ACCresult == AcCmdMaskOk) {
itsCurState = CTState::RESUMED;
}
itsCAMInterface.appSetStateResult(itsProcName, CTState::RESUME, MACresult);
break;
case ACCmdPause:
if (ACCresult == AcCmdMaskOk) {
itsCurState = CTState::SUSPENDED;
}
itsCAMInterface.appSetStateResult(itsProcName, CTState::SUSPEND, MACresult);
break;
case ACCmdRelease:
if (ACCresult == AcCmdMaskOk) {
itsCurState = CTState::RELEASED;
}
itsCAMInterface.appSetStateResult(itsProcName, CTState::RELEASE, MACresult);
break;
case ACCmdQuit:
if (ACCresult == AcCmdMaskOk) {
// itsContinuePoll = false;
itsCurState = CTState::QUITED;
}
itsCAMInterface.appSetStateResult(itsProcName, CTState::QUIT, MACresult);
break;
default:
LOG_WARN_STR("Received command = " << cmd << ", result = " << ACCresult
<< ", info = " << info << " not handled!");
break;
}
}
//
// sendCommand (newState, options)
//
// Translate MAC commands into ACC commands.
//
void CEPApplMgr::sendCommand (CTState::CTstateNr newState, const string& options)
{
switch (newState) {
case CTState::CONNECT:
itsACclient.boot(0, itsParamFile);
break;
case CTState::CLAIM:
itsACclient.define(0);
break;
case CTState::PREPARE:
itsACclient.init(0);
break;
case CTState::RESUME:
itsACclient.run(0);
break;
case CTState::SUSPEND:
itsACclient.pause(0, 0, options);
break;
case CTState::RELEASE:
itsACclient.release(0);
break;
case CTState::QUIT:
itsACclient.quit(0);
break;
default:
break;
}
}
//
// handleAnswerMsg(answer)
//
void CEPApplMgr::handleAnswerMsg (const string& answer)
{
itsCAMInterface.appSupplyInfoAnswer(itsProcName, answer);
}
//
// supplyInfoFunc(keyList)
//
string CEPApplMgr::supplyInfoFunc (const string& keyList)
{
return (itsCAMInterface.appSupplyInfo(itsProcName, keyList));
}
} // namespace CEPCU
} // namespace LOFAR
//# CEPApplMgr.h: factory class for Virtual Backends.
//#
//# Copyright (C) 2002-2005
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id$
#ifndef CEPAPPLMGR_H
#define CEPAPPLMGR_H
//# Includes
#include <GCF/TM/GCF_Handler.h>
#include <ALC/ACAsyncClient.h>
#include <APL/APLCommon/CTState.h>
//# local includes
//# Common Includes
// forward declaration
namespace LOFAR {
using APLCommon::CTState;
namespace CEPCU {
// The CEPApplMgrInterface is an abstract baseclass to define the interface
// the CEPApplMgr will call for passing the results of ACC back to the controller.
class CEPApplMgrInterface
{
public:
virtual ~CEPApplMgrInterface() {}
virtual void appSetStateResult (const string& procName,
CTState::CTstateNr newState,
uint16 result) = 0;
virtual string appSupplyInfo (const string& procName,
const string& keyList) = 0;
virtual void appSupplyInfoAnswer(const string& procName,
const string& answer) = 0;
protected:
CEPApplMgrInterface() {}
private:
// protected copy constructor
CEPApplMgrInterface(const CEPApplMgrInterface&);
// protected assignment operator
CEPApplMgrInterface& operator=(const CEPApplMgrInterface&);
};
// The CEPApplMgr class acts as an ACClient for the OnlineController but it
// also an active component because is is also inherited from GCFHandler.
// The GCFHandler-workproc will poll the ACC connection for incomming msgs.
class CEPApplMgr : public ACC::ALC::ACClientFunctions,
GCF::TM::GCFHandler
{
public:
CEPApplMgr(CEPApplMgrInterface& interface,
const string& appName,
uint32 expectedRuntime,
const string& acdHost,
const string& paramFile);
virtual ~CEPApplMgr();
// method used by the OnlineController to initiate a new command
void sendCommand (CTState::CTstateNr newState, const string& options);
// methods may be called from specialized CEPApplMgrInterface
bool boot (const time_t scheduleTime,
const string& configID);
bool define (const time_t scheduleTime) const;
bool init (const time_t scheduleTime) const;
bool run (const time_t scheduleTime) const;
bool pause (const time_t scheduleTime,
const time_t maxWaitTime,
const string& condition) const;
bool release (const time_t scheduleTime) const;
bool quit (const time_t scheduleTime) const;
bool shutdown (const time_t scheduleTime) const;
bool snapshot (const time_t scheduleTime,
const string& destination) const;
bool recover (const time_t scheduleTime,
const string& source) const;
bool reinit (const time_t scheduleTime,
const string& configID) const;
string askInfo (const string& keylist) const;
bool cancelCmdQueue () const;
const string& getName() const;
protected:
// protected copy constructor
CEPApplMgr(const CEPApplMgr&);
// protected assignment operator
CEPApplMgr& operator=(const CEPApplMgr&);
private:
// implemenation of abstract GCFHandler methods
friend class GCF::TM::GCFHandler;
void workProc();
void stop();
// implemenation of abstract ACClientFunctions methods
friend class ACC::ALC::ACClientFunctions;
void handleAckMsg (ACC::ALC::ACCmd cmd,
uint16 result,
const string& info);
void handleAnswerMsg (const string& answer);
string supplyInfoFunc (const string& keyList);
// --- datamembers ---
string itsProcName; // my name
string itsParamFile; // name of paramfile
CEPApplMgrInterface& itsCAMInterface; // link to OnlineController
ACC::ALC::ACAsyncClient itsACclient; // link to ACC controller
uint16 itsReqState; // requested state
uint16 itsCurState; // reached state
bool itsContinuePoll; // for workProc
// ACC::ALC::ACCmd itsLastOkCmd;
};
inline const string& CEPApplMgr::getName() const
{
return (itsProcName);
}
inline bool CEPApplMgr::boot(const time_t scheduleTime,
const string& configID)
{
itsContinuePoll = true;
return (itsACclient.boot(scheduleTime, configID));
}
inline bool CEPApplMgr::define(const time_t scheduleTime) const
{
return (itsACclient.define(scheduleTime));
}
inline bool CEPApplMgr::init(const time_t scheduleTime) const
{
return (itsACclient.init(scheduleTime));
}
inline bool CEPApplMgr::run(const time_t scheduleTime) const
{
return (itsACclient.run(scheduleTime));
}
inline bool CEPApplMgr::pause (const time_t scheduleTime,
const time_t maxWaitTime,
const string& condition) const
{
return (itsACclient.pause(scheduleTime, maxWaitTime, condition));
}
inline bool CEPApplMgr::release (const time_t scheduleTime) const
{
return (itsACclient.release(scheduleTime));
}
inline bool CEPApplMgr::quit (const time_t scheduleTime) const
{
return (itsACclient.quit(scheduleTime));
}
inline bool CEPApplMgr::shutdown (const time_t scheduleTime) const
{
return (itsACclient.shutdown(scheduleTime));
}
inline bool CEPApplMgr::snapshot (const time_t scheduleTime,
const string& destination) const
{
return (itsACclient.snapshot(scheduleTime, destination));
}
inline bool CEPApplMgr::recover (const time_t scheduleTime,
const string& source) const
{
return (itsACclient.recover(scheduleTime, source));
}
inline bool CEPApplMgr::reinit (const time_t scheduleTime,
const string& configID) const
{
return (itsACclient.reinit(scheduleTime, configID));
}
inline bool CEPApplMgr::cancelCmdQueue () const
{
return itsACclient.cancelCmdQueue();
}
inline void CEPApplMgr::stop()
{ }
} // namespace CEPCU
} // namespace LOFAR
#endif
......@@ -8,6 +8,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
lofar_add_bin_program(OnlineControl
OnlineControlMain.cc
OnlineControl.cc
CEPApplMgr.cc)
forkexec.cc)
lofar_add_executable(tPVSSMapping tPVSSMapping.cc)
This diff is collapsed.
......@@ -41,8 +41,6 @@
#include <APL/APLCommon/ParentControl.h>
#include <APL/APLCommon/CTState.h>
#include <CEPApplMgr.h>
// forward declaration
namespace LOFAR {
......@@ -57,9 +55,7 @@ using GCF::TM::GCFTask;
using GCF::RTDB::RTDBPropertySet;
using APLCommon::ParentControl;
class OnlineControl : public GCFTask,
public CEPApplMgrInterface
class OnlineControl : public GCFTask
{
public:
explicit OnlineControl(const string& cntlrName);
......@@ -78,25 +74,14 @@ public:
static void signalHandler (int signum);
void finish();
protected: // implemenation of abstract CEPApplMgrInterface methods
string appSupplyInfo (const string& procName, const string& keyList);
void appSupplyInfoAnswer (const string& procName, const string& answer);
// A result of one of the applications was received, update the administration
// off the controller and send the result to the parentcontroller if appropriate.
void appSetStateResult (const string& procName,
CTState::CTstateNr newState,
uint16 result);
private:
// avoid defaultconstruction and copying
OnlineControl();
OnlineControl(const OnlineControl&);
OnlineControl& operator=(const OnlineControl&);
uint32 _doBoot();
void _setupBGPmappingTables();
void _doBoot();
void _doQuit();
void _finishController (uint16_t result);
void _connectedHandler (GCFPortInterface& port);
void _disconnectedHandler (GCFPortInterface& port);
......@@ -104,22 +89,6 @@ private:
void _databaseEventHandler(GCFEvent& event);
void _passMetadatToOTDB ();
// Send a command to all (or the first) applications.
void startNewState (CTState::CTstateNr newState,
const string& options);
// typedefs for the internal adminsitration of all the Applications we control
typedef boost::shared_ptr<CEPApplMgr> CEPApplMgrPtr;
typedef map<string, CEPApplMgrPtr> CAMmap;
typedef map<string, CEPApplMgrPtr>::iterator CAMiter;
// Internal bookkeeping-finctions for the dependancy-order of the applications.
void setApplOrder (vector<string>& anApplOrder);
CAMiter firstApplication(CTState::CTstateNr aState);
CAMiter nextApplication();
bool hasNextApplication();
void noApplication();
// ----- datamembers -----
RTDBPropertySet* itsPropertySet;
RTDBPropertySet* itsBGPApplPropSet;
......@@ -133,20 +102,8 @@ private:
GCFTCPPort* itsLogControlPort;
CAMmap itsCEPapplications;
ParameterSet itsResultParams;
CTState::CTstateNr itsState;
bool itsUseApplOrder; // Applications depend?
vector<string> itsApplOrder; // startOrder of the applications.
string itsCurrentAppl; // current application we are handling.
CTState::CTstateNr itsApplState; // state currently handled by apps.
string itsOptions; // Current active option
uint16 itsOverallResult;
int16 itsNrOfAcks2Recv;
// ParameterSet variables
string itsTreePrefix;
uint32 itsInstanceNr;
......
//# forkexec.cc: Custom fork/exec implementation for more control
//#
//# Copyright (C) 2002-2004
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# Always #include <lofar_config.h> first!
#include <lofar_config.h>
//# Includes
#include "forkexec.h"
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
namespace LOFAR {
namespace CEPCU {
int32 forkexec( const char *command )
{
int status;
pid_t pid;
pid = fork();
switch (pid) {
case -1:
// error
return -1;
case 0:
// child process
// close all filedescriptors
for (int f = dup(2); f > 2; --f) {
while ( close(f) == EINTR )
;
}
execl("/bin/sh", "/bin/sh", "-c", command, static_cast<char*>(0));
// only reached if exec fails
_exit(1);
default:
// parent process
if (waitpid(pid, &status, 0) == -1) {
// error
return errno;
}
return WEXITSTATUS(status);
}
}
} // namespace CEPCU
} // namespace LOFAR
//# PR_BGL.h: Custom fork/exec implementation for more control
//#
//# Copyright (C) 2002-2004
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# Note: This source is read best with tabstop 4.
//#
//# $Id: PR_BGL.h 10517 2007-09-17 07:54:57Z overeem $
#ifndef LOFAR_CEPCUBIN_FORKEXEC_H
#define LOFAR_CEPCUBIN_FORKEXEC_H
//# Never #include <config.h> or #include <lofar_config.h> in a header file!
//# Includes
#include <Common/LofarTypes.h>
namespace LOFAR {
namespace CEPCU {
// a custom implementation of system( command )
int32 forkexec( const char *command );
} // namespace CEPCU
} // namespace LOFAR
#endif
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