diff --git a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.cc b/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.cc deleted file mode 100644 index 95ee9fa602a77d2b10e3043a799adaa3f1942a1c..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.cc +++ /dev/null @@ -1,244 +0,0 @@ -//# BGPlogProcessor.cc: Captures cout datastreams of CEP programs -//# -//# Copyright (C) 2009 -//# 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$ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -//# Includes -#include <Common/LofarLogger.h> -#include <Common/LofarLocators.h> -#include <Common/ParameterSet.h> -#include <Common/SystemUtil.h> -#include "BGPlogProcessor.h" - -namespace LOFAR { - using namespace GCF::TM; - namespace APL { - -// -// BGPlogProcessor(name) -// -BGPlogProcessor::BGPlogProcessor(const string& progName) : - GCFTask ((State)&BGPlogProcessor::startListener, progName), - itsListener (0) -{ - // prepare TCP port to accept connections on - itsListener = new GCFTCPPort (*this, "BGPlogger:v1_0", GCFPortInterface::MSPP, 0); - ASSERTSTR(itsListener, "Cannot allocate listener port"); - itsListener->setPortNumber(globalParameterSet()->getInt("BGPlogProcessor.portNr")); - - itsBufferSize = globalParameterSet()->getInt("BGPlogProcessor.bufferSize", 1024); -} - -// -// ~BGPlogProcessor() -// -BGPlogProcessor::~BGPlogProcessor() -{ - if (itsListener) { - delete itsListener; - } -} - -// -// startListener(event, port) -// -GCFEvent::TResult BGPlogProcessor::startListener(GCFEvent& event, GCFPortInterface& port) -{ - LOG_DEBUG_STR("startListener:" << eventName(event) << "@" << port.getName()); - - switch (event.signal) { - case F_INIT: - itsListener->autoOpen(0, 10, 2); // report within 10 seconds. - break; - - case F_CONNECTED: - LOG_DEBUG("Listener is started, going to operational mode"); - TRAN (BGPlogProcessor::operational); - break; - - case F_DISCONNECTED: - LOG_FATAL_STR("Cannot open the listener on port " << itsListener->getPortNumber() << ". Quiting!"); - GCFScheduler::instance()->stop(); - break; - } - - return (GCFEvent::HANDLED); -} - -// -// operational(event, port) -// -GCFEvent::TResult BGPlogProcessor::operational(GCFEvent& event, GCFPortInterface& port) -{ - LOG_DEBUG_STR("operational:" << eventName(event) << "@" << port.getName()); - - switch (event.signal) { - case F_ACCEPT_REQ: - _handleConnectionRequest(); - break; - - case F_CONNECTED: - break; - - case F_DISCONNECTED: - port.close(); - case F_DATAIN: - _handleDataStream(&port); - break; - } - - return (GCFEvent::HANDLED); -} - -// -// _handleConnectionRequest() -// -void BGPlogProcessor::_handleConnectionRequest() -{ - GCFTCPPort* pNewClient = new GCFTCPPort(); - ASSERT(pNewClient); - - pNewClient->init(*this, "newClient", GCFPortInterface::SPP, 0, true); - if (!itsListener->accept(*pNewClient)) { - LOG_WARN("Connection with new client went wrong"); - return; - } - - // give stream its own buffer. - streamBuffer_t stream; - stream.socket = pNewClient; - stream.buffer = (char*)malloc(itsBufferSize); - stream.inPtr = 0; - stream.outPtr = 0; - itsLogStreams[pNewClient] = stream; - LOG_INFO_STR("Added new client to my admin"); -} - -// -// _handleDataStream(sid) -// -void BGPlogProcessor::_handleDataStream(GCFPortInterface* port) -{ - // read in the new bytes - streamBuffer_t stream = itsLogStreams[port]; - LOG_DEBUG_STR("handleDataStream:in=" << stream.inPtr << ", out=" << stream.outPtr); - int newBytes = stream.socket->recv(stream.buffer + stream.inPtr, itsBufferSize - stream.inPtr); - LOG_DEBUG_STR("received " << newBytes << " new bytes"); - if (newBytes < 0) { -// LOG_ERROR_STR("read on socket " << sid << " returned " << newBytes << ". Closing connection"); - free (stream.buffer); - stream.socket->close(); - free(stream.socket); - itsLogStreams.erase(port); - return; - } -// LOG_DEBUG_STR("Received " << newBytes << " bytes at sid " << sid); - stream.inPtr += newBytes; - - // process as much data as possible from the buffer. - for (int i = stream.outPtr; i <= stream.inPtr; i++) { - if (stream.buffer[i] != '\n') { - continue; - } - - stream.buffer[i] = '\0'; -// LOG_INFO(formatString("SID %d:>%s<", sid, &(stream.buffer[stream.outPtr]))); - LOG_INFO(formatString("(%d,%d)>%s<", stream.outPtr, i, &(stream.buffer[stream.outPtr]))); - _processLogLine(&(stream.buffer[stream.outPtr])); - stream.outPtr = i+1; - if (stream.outPtr >= stream.inPtr) { // All received bytes handled? - LOG_DEBUG("Reset of read/write pointers"); - stream.inPtr = 0; - stream.outPtr = 0; - itsLogStreams[port] = stream; // copy changes back to admin - return; - } - } - - if (stream.outPtr > (int)(0.5*itsBufferSize)) { - // When buffer becomes full shift leftovers to the left. - LOG_DEBUG_STR("move with: " << stream.inPtr << ", " << stream.outPtr); - memmove (stream.buffer, stream.buffer + stream.outPtr, (stream.inPtr - stream.outPtr + 1)); - stream.inPtr -= stream.outPtr; - stream.outPtr = 0; - } - - itsLogStreams[port] = stream; // copy changes back to admin -} - -// -// _getProcessID(char*) -// -string BGPlogProcessor::_getProcessID(char* cString) -{ - char delimiter[]="|"; - char* result = strtok(cString, delimiter); // get loglevel - if (!result) { // unknown line skip it. - LOG_DEBUG("No loglevel found"); - return (""); - } - - if (!(result = strtok(NULL, delimiter))) { // get processID - LOG_DEBUG("No processID found"); - return (""); - } - - return (result); -} - - -// -// _processLogLine(char*) -// -void BGPlogProcessor::_processLogLine(char* cString) -{ - string processName(_getProcessID(cString)); - LOG_DEBUG_STR("Processname=" << processName); - if (processName.empty()) { - return; - } - - // TODO: switch on processName to right analysis routine - - char* logMsg = strtok(NULL, "|"); - char* result; - - if ((result = strstr(logMsg, " late: "))) { - float late; - sscanf(result, " late: %f ", &late); // TODO check result - LOG_DEBUG_STR("Late: " << late); - } - else if ((result = strstr(logMsg, "ION->CN:"))) { - float ioTime; - sscanf(result, "ION->CN:%f", &ioTime); // TODO check result - LOG_DEBUG_STR("ioTime: " << ioTime); - } - else if ((result = strstr(logMsg, "received ["))) { - int blocks0(0), blocks1(0), blocks2(0), blocks3(0); - sscanf(result, "received [%d,%d,%d,%d]", &blocks0, &blocks1, &blocks2, &blocks3); // TODO check result - LOG_DEBUG(formatString("blocks: %d, %d, %d, %d", blocks0, blocks1, blocks2, blocks3)); - } -} - - } // namespace APL -} // namespace LOFAR diff --git a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.conf b/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.conf deleted file mode 100644 index 49b98e69176624c578c54b4509b8209f4210750a..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.conf +++ /dev/null @@ -1,5 +0,0 @@ -# -# Parameter file for CEPlogProcessor -# -BGPlogProcessor.portNr = 24500 -BGPlogProcessor.bufferSize = 1024 diff --git a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.h b/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.h deleted file mode 100644 index 4de11d41b9561cbd5d4815436c7b30d59ec7a6c6..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessor.h +++ /dev/null @@ -1,92 +0,0 @@ -//# BGPlogProcessor.h: Daemon for catching CEP cout log streams -//# -//# Copyright (C) 2009 -//# 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$ - -#ifndef LOFAR_APL_BGPLOGPROCESSOR_H -#define LOFAR_APL_BGPLOGPROCESSOR_H - -// \file -// Daemon for launching Application Controllers - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -//# Includes -#include <GCF/TM/GCF_Control.h> - -namespace LOFAR { - using GCF::TM::GCFTask; - using GCF::TM::GCFTCPPort; - using GCF::TM::GCFPortInterface; - namespace APL { -// \addtogroup CEPCU -// @{ - - -// The BGPlogProcessor class implements a small daemon that ... -class BGPlogProcessor : public GCFTask -{ -public: - // Creates an BGPlogProcessor object that start listening on the port mentioned - // in the ParameterSet. - explicit BGPlogProcessor(const string& progName); - - // Destructor. - ~BGPlogProcessor(); - - // its processing states - GCFEvent::TResult startListener(GCFEvent& e, GCFPortInterface& p); - GCFEvent::TResult operational (GCFEvent& e, GCFPortInterface& p); - -private: - // Copying is not allowed - BGPlogProcessor(const BGPlogProcessor& that); - BGPlogProcessor& operator=(const BGPlogProcessor& that); - - void _handleConnectionRequest(); - void _handleDataStream(GCFPortInterface* port); - string _getProcessID (char* cString); - void _processLogLine (char* cString); - - //# --- Datamembers --- - // The listener socket to receive the requests on. - GCFTCPPort* itsListener; - - // internal structure for admin for 1 stream - typedef struct { - GCFTCPPort* socket; - char* buffer; - int inPtr; - int outPtr; - } streamBuffer_t; - - // Map containing all the streambuffers. - map<GCFPortInterface*, streamBuffer_t> itsLogStreams; - - // buffersize of the streambuffers. - int itsBufferSize; -}; - -// @} addgroup - } // namespace APL -} // namespace LOFAR - -#endif diff --git a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessorMain.cc b/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessorMain.cc deleted file mode 100644 index ac6c1296485106b27e537a9e41222fe4e89b162d..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/BGPlogProcessor/BGPlogProcessorMain.cc +++ /dev/null @@ -1,59 +0,0 @@ -//# BGPlogProcessorMain.cc: Deamon to dispatch the BG/P logging to PVSS -//# -//# Copyright (C) 2009 -//# 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$ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -//# Includes -#include <Common/LofarLogger.h> -#include <Common/LofarLocators.h> -#include <GCF/TM/GCF_Scheduler.h> -#include "BGPlogProcessor.h" - -using namespace LOFAR; -using namespace GCF::TM; -using namespace LOFAR::APL; - -// -// MAIN (parameterfile) -// -int main (int argc, char* argv[]) -{ - try { - GCFScheduler::instance()->init(argc, argv, "BGPlogProcessor"); - - BGPlogProcessor loggerTask("BGPlogger"); - loggerTask.start(); // make initial transition - - GCFScheduler::instance()->run(); - - LOG_INFO_STR("Shutting down: " << argv[0]); - } - catch (LOFAR::Exception& ex) { - LOG_FATAL_STR("Caught exception: " << ex); - LOG_FATAL ("Terminated by exception!"); - return (1); - } - - LOG_INFO("Terminated normally"); - return (0); -} diff --git a/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.conf b/MAC/APL/CEPCU/src/BGPlogProcessor/CEPlogProcessor.conf similarity index 100% rename from MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.conf rename to MAC/APL/CEPCU/src/BGPlogProcessor/CEPlogProcessor.conf diff --git a/MAC/APL/CEPCU/src/BGPlogProcessor/CMakeLists.txt b/MAC/APL/CEPCU/src/BGPlogProcessor/CMakeLists.txt index 0efebc1369c199c35b330c58bc4222c05257ddf5..0b310b2101bc1ed7d4d98a5d1ea29c2f2561f36b 100644 --- a/MAC/APL/CEPCU/src/BGPlogProcessor/CMakeLists.txt +++ b/MAC/APL/CEPCU/src/BGPlogProcessor/CMakeLists.txt @@ -1,9 +1,9 @@ # $Id$ -lofar_add_bin_program(BGPlogProcessor - BGPlogProcessorMain.cc - BGPlogProcessor.cc) +lofar_add_bin_program(CEPlogProcessor + CEPlogProcessorMain.cc + CEPlogProcessor.cc) install(FILES - BGPlogProcessor.conf + CEPlogProcessor.conf DESTINATION etc) diff --git a/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.cc b/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.cc deleted file mode 100644 index a5f454999d29eccf7080d418ca196c9ef241c004..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.cc +++ /dev/null @@ -1,173 +0,0 @@ -//# CEPlogProcessor.cc: Captures cout datastreams of CEP programs -//# -//# Copyright (C) 2009 -//# 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$ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -//# Includes -#include <Common/LofarLogger.h> -#include <Common/LofarLocators.h> -#include <Common/SystemUtil.h> -#include <ALC/ACRequest.h> -#include "CEPlogProcessor.h" - -namespace LOFAR { - namespace APL { - -CEPlogProcessor::CEPlogProcessor(const string& progName) : - itsListener (0), - itsParamSet (new ParameterSet) -{ - // Read in the parameterfile with network parameters. - ConfigLocator aCL; - string configFile(progName + ".conf"); - LOG_DEBUG_STR("Using parameterfile: "<< configFile <<"-->"<< aCL.locate(configFile)); - itsParamSet->adoptFile(aCL.locate(configFile)); // May throw - - // Open listener for AC requests. - itsListener = new Socket("CEPlogProcessor", - itsParamSet->getString("CEPlogProcessor.portNr"), - Socket::TCP); - - itsBufferSize = itsParamSet->getInt("CEPlogProcessor.bufferSize", 1024); -} - -CEPlogProcessor::~CEPlogProcessor() -{ - if (itsListener) { delete itsListener; } - if (itsParamSet) { delete itsParamSet; } -} - -void CEPlogProcessor::doWork() throw (Exception) -{ - // Prepare a fd_set for select - itsConnSet.add(itsListener->getSid()); - - LOG_INFO ("CEPlogProcessor: entering main loop"); - - while (true) { - // wait for connection request or data - FdSet readSet(itsConnSet); - struct timeval tv; // prepare select-timer - tv.tv_sec = 60; // this must be IN the while loop - tv.tv_usec = 0; // because select will change tv - int32 selResult = select(readSet.highest()+1, readSet.getSet(), 0, 0, &tv); - - // -1 may be an interrupt or a program-error. - if ((selResult == -1) && (errno != EINTR)) { - THROW(Exception, "CEPlogProcessor: 'select' returned serious error: " << - errno << ":" << strerror(errno)); - } - - if (selResult == -1) { // EINTR: ignore - continue; - } - - for (int sid = itsConnSet.lowest(); sid <= itsConnSet.highest(); sid++) { - LOG_TRACE_FLOW_STR("testing sid " << sid); - if (!readSet.isSet(sid)) { - continue; - } - - // Request for new AC? - if (sid == itsListener->getSid()) { - handleConnectionRequest(); - } - else { - handleDataStream(sid); - } - } // for - } // while -} - -// -// handleConnectionRequest() -// -void CEPlogProcessor::handleConnectionRequest() -{ - // Accept the new connection - Socket* dataSocket = itsListener->accept(-1); - ASSERTSTR(dataSocket, - "Serious problems on listener socket, exiting! : " << itsListener->errstr()); - itsConnSet.add(dataSocket->getSid()); - - // give stream its own buffer. - streamBuffer_t stream; - stream.socket = dataSocket; - stream.buffer = (char*)malloc(itsBufferSize); - stream.inPtr = 0; - stream.outPtr = 0; - itsLogStreams[dataSocket->getSid()] = stream; -} - -// -// handleDataStream(sid) -// -void CEPlogProcessor::handleDataStream(int sid) -{ - // read in the new bytes - streamBuffer_t stream = itsLogStreams[sid]; - LOG_DEBUG_STR("handleDataStream[" << sid << "]:in=" << stream.inPtr << ", out=" << stream.outPtr); - int newBytes = stream.socket->read(stream.buffer + stream.inPtr, itsBufferSize - stream.inPtr); - if (newBytes < 0) { - LOG_ERROR_STR("read on socket " << sid << " returned " << newBytes << ". Closing connection"); - free (stream.buffer); - stream.socket->close(); - free(stream.socket); - itsLogStreams.erase(sid); - itsConnSet.remove(sid); - return; - } - LOG_DEBUG_STR("Received " << newBytes << " bytes at sid " << sid); - stream.inPtr += newBytes; - - // process as much data as possible from the buffer. - for (int i = stream.outPtr; i <= stream.inPtr; i++) { - if (stream.buffer[i] != '\n') { - continue; - } - - stream.buffer[i] = '\0'; - LOG_INFO(formatString("SID %d:>%s<", sid, &(stream.buffer[stream.outPtr]))); - stream.outPtr = i+1; - if (stream.outPtr >= stream.inPtr) { // All received bytes handled? - LOG_DEBUG("Reset of read/write pointers"); - stream.inPtr = 0; - stream.outPtr = 0; - itsLogStreams[sid] = stream; // copy changes back to admin - return; - } - } - - if (stream.outPtr > (int)(0.5*itsBufferSize)) { - // When buffer becomes full shift leftovers to the left. - LOG_DEBUG_STR("move with: " << stream.inPtr << ", " << stream.outPtr); - memmove (stream.buffer, stream.buffer + stream.outPtr, (stream.inPtr - stream.outPtr + 1)); - stream.inPtr -= stream.outPtr; - stream.outPtr = 0; - } - - itsLogStreams[sid] = stream; // copy changes back to admin -} - - } // namespace APL -} // namespace LOFAR diff --git a/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.h b/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.h deleted file mode 100644 index 88744b95ccec0f28141ba8f0a8c884174334201e..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessor.h +++ /dev/null @@ -1,96 +0,0 @@ -//# CEPlogProcessor.h: Daemon for catching CEP cout log streams -//# -//# Copyright (C) 2009 -//# 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$ - -#ifndef LOFAR_APL_CEPLOGPROCESSOR_H -#define LOFAR_APL_CEPLOGPROCESSOR_H - -// \file -// Daemon for launching Application Controllers - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -//# Includes -#include <Common/Exception.h> -#include <Common/Net/Socket.h> -#include <Common/Net/FdSet.h> -#include <Common/ParameterSet.h> - - -namespace LOFAR { - namespace APL { -// \addtogroup CEPCU -// @{ - - -// The CEPlogProcessor class implements a small daemon that ... -class CEPlogProcessor -{ -public: - // Creates an CEPlogProcessor object that start listening on the port mentioned - // in the ParameterSet. - explicit CEPlogProcessor(const string& progName); - - // Destructor. - ~CEPlogProcessor(); - - // Its normal (never ending) loop. - void doWork() throw (Exception); - -private: - // Copying is not allowed - CEPlogProcessor(const CEPlogProcessor& that); - CEPlogProcessor& operator=(const CEPlogProcessor& that); - - void handleConnectionRequest(); - void handleDataStream(int sid); - - //# --- Datamembers --- - // The listener socket to receive the requests on. - Socket* itsListener; - - // The parameterSet that was received during start up. - ParameterSet* itsParamSet; - - // File descriptor set of connected sockets - FdSet itsConnSet; - - // internal structure for admin for 1 stream - typedef struct { - Socket* socket; - char* buffer; - int inPtr; - int outPtr; - } streamBuffer_t; - - // Map containing all the streambuffers. - map<int, streamBuffer_t> itsLogStreams; - - // buffersize of the streambuffers. - int itsBufferSize; -}; - -// @} addgroup - } // namespace APL -} // namespace LOFAR - -#endif diff --git a/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessorMain.cc b/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessorMain.cc deleted file mode 100644 index 29d492c575d5babd80fdc71e3bc238167eb64eec..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/CEPlogProcessor/CEPlogProcessorMain.cc +++ /dev/null @@ -1,95 +0,0 @@ -//# CEPlogProcessorMain.cc: daemon for launching application controllers. -//# -//# Copyright (C) 2009 -//# 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$ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -//# Includes -#include <sys/stat.h> // umask -#include <unistd.h> // fork, basename -#include <Common/LofarLogger.h> -#include <Common/LofarLocators.h> -#include "CEPlogProcessor.h" - -using namespace LOFAR; -using namespace LOFAR::APL; - -// -// MAIN (parameterfile) -// -int main (int /*argc*/, char* argv[]) { - - // Always bring up the logger first - ConfigLocator aCL; - string progName = basename(argv[0]); -#ifdef HAVE_LOG4CPLUS - string logPropFile(progName + ".log_prop"); -#else - string logPropFile(progName + ".debug"); -#endif -#ifdef HAVE_LOG4CPLUS - INIT_VAR_LOGGER (aCL.locate(logPropFile).c_str(), progName); -#else - INIT_LOGGER (aCL.locate(logPropFile).c_str()); - -#endif - LOG_DEBUG_STR("Initialized logsystem with: " << aCL.locate(logPropFile)); - - // Tell operator we are trying to start up. - LOG_INFO_STR("Starting up: " << argv[0]); - - try { -#if REAL_DAEMON - pid_t pid = fork(); - switch (pid) { - case -1: // error - LOG_FATAL("Unable to fork daemon process, exiting."); - return (-1); - case 0: // child (the real daemon) - // do nothing; - break; - default: // parent - LOG_INFO_STR("Daemon succesfully started, pid = " << pid); - return (0); - } -#endif - // TODO: active the next two calls. -// setsid(); // disconnect from terminalsession -// chdir("/"); // might be on a mounted file system - umask(0); // no limits - - CEPlogProcessor theDaemon(progName); - - theDaemon.doWork(); - - LOG_INFO_STR("Shutting down: " << argv[0]); - } - catch (LOFAR::Exception& ex) { - LOG_FATAL_STR("Caught exception: " << ex); - LOG_FATAL ("Terminated by exception!"); - return (1); - } - - LOG_INFO("Terminated normally"); - return (0); - -} diff --git a/MAC/APL/CEPCU/src/CEPlogProcessor/CMakeLists.txt b/MAC/APL/CEPCU/src/CEPlogProcessor/CMakeLists.txt deleted file mode 100644 index 0b310b2101bc1ed7d4d98a5d1ea29c2f2561f36b..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/CEPlogProcessor/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# $Id$ - -lofar_add_bin_program(CEPlogProcessor - CEPlogProcessorMain.cc - CEPlogProcessor.cc) - -install(FILES - CEPlogProcessor.conf - DESTINATION etc) diff --git a/MAC/APL/CEPCU/src/CMakeLists.txt b/MAC/APL/CEPCU/src/CMakeLists.txt index 7b30106d28aa1ff6546b4ce4ea4bee8c86f720b8..564d1d038b08f09a10a7226c9648e33d88b455a9 100644 --- a/MAC/APL/CEPCU/src/CMakeLists.txt +++ b/MAC/APL/CEPCU/src/CMakeLists.txt @@ -12,6 +12,5 @@ lofar_add_bin_program(versioncepcu versioncepcu.cc) add_subdirectory(OnlineControl) add_subdirectory(PythonControl) -add_subdirectory(CEPlogProcessor) add_subdirectory(BGPlogProcessor) # add_subdirectory(OfflineControl)