Skip to content
Snippets Groups Projects
Commit 13e70b66 authored by Marco De Marco's avatar Marco De Marco
Browse files

Before ignore timeout property removed

parent d8f8fb3c
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#: Title : fits.sh
#: Date : 2014/03/03
#: Author : "Marco De Marco" <demarco@oats.inaf.it>
#: Version : 0.1
#: Description : Fits verification and preproccessing script
#: Usage :
#: Response :
if [ "$1" == "CHECK" ]; then
#: Section : CHECK
#: Parameter : none
#: Response : CHECK OK
#: : CHECK FATAL
VERIFY_TOOL="/usr/local/bin/fitsverify"
CHECK_STRING="conform to the FITS format"
res=$($VERIFY_TOOL 2>&1)
check=$(echo $res | grep "$CHECK_STRING" | wc | awk '{print $1}')
if [ "$check" -ge "1" ]; then
echo "CHECK OK"
else
echo "CHECK FATAL"
fi
exit 0
elif [ "$1" == "VERIFY" ]; then
#: Section : VERIFY
#: Parameter : file path
#: Response : VERIFY OK
#: : VERIFY WAIT
#: : VERIFY FATAL
VERIFY_TOOL="/usr/local/bin/fitsverify"
FATAL_ERROR="Fatal"
EOF_ERROR="End-of-file"
file=$2
file_name=${file##*/}
#Check regular expression -> fatal
if [[ ! "${file_name,,}" =~ ^[^\.].*\.(fits|fit|fts).*$ ]]; then
echo "VERIFY FATAL : error on regular expression"
exit 0
fi
#if fits verify tools exists -> fatal
if [ ! -x $VERIFY_TOOL ]; then
echo "VERIFY FATAL : verify tools not exists"
exit 0
fi
#if fits file not exists -> fatal
if [ ! -f $file ]; then
echo "VERIFY FATAL : file not exists"
exit 0
fi
#Check with fits verify
res=$($VERIFY_TOOL $file 2>&1)
#if fitsverify return fatal error -> wait
fatal=$(echo $res | grep "$FATAL_ERROR" | wc | awk '{print $1}')
if [ "$fatal" -ge "1" ]; then
echo "VERIFY WAIT"
exit 0
fi
#if fitsverify return end of file -> wait
eof=$(echo $res | grep "$EOF_ERROR" | wc | awk '{print $1}')
if [ "$eof" -ge "1" ]; then
echo "VERIFY WAIT"
exit 0
fi
#else -> ok
echo "VERIFY OK"
exit 0
elif [ "$1" == "PROCESS" ]; then
#: Section : PROCESS
#: Parameter : file path
#: Response : PROCESS OK
#: : PROCESS FATAL
echo "PROCESS OK"
exit 0
else
#: Section : DEFAULT
#: Parameter : none
#: Response : UNKNOWN
echo "UNKNOWN"
exit 0
fi
#!/bin/bash
#: Title : checkfits.sh
#: Date : 2014/10/28
#: Author : "Marco De Marco" <demarco@oats.inaf.it>
#: Version : 1.0
#: Description : Fits verification and preproccessing script
if [ "$1" == "CHECK" ]; then
#: Section : CHECK
#: Parameter : none
#: Response : CHECK OK
#: : CHECK FATAL
#: Description : Check availability of script tools
echo "CHECK OK"
exit 0
elif [ "$1" == "VALID" ]; then
#: Section : VALID
#: Parameter : file path
#: Response : VALID OK
#: : VALID IGNORE
#: Description : Check file name compliance
echo "VALID OK"
exit 0
elif [ "$1" == "VERIFY" ]; then
#: Section : VERIFY
#: Parameter : file path
#: Response : VERIFY OK
#: : VERIFY WAIT
#: : VERIFY FATAL
#: Description : Check file compliance to fits format
file=$2
echo "VERIFY OK"
exit 0
elif [ "$1" == "PREPROCESS" ]; then
#: Section : PREPROCESS
#: Parameter : file path
#: : ingestion result [OK, WAIT, FATAL]
#: Response : PREPROCESS OK
#: : PREPROCESS FATAL
#: Description : Apply preprocessing before ingestion
file=$2
verified=$3
#Check verified parameter value
if [ "$verified" != "OK" -a "$verified" != "WAIT" -a "$verified" != "FATAL" ]; then
echo "PREPROCESS FATAL"
exit 0
fi
echo "PREPROCESS OK"
exit 0
elif [ "$1" == "POSTPROCESS" ]; then
#: Section : POSTPROCESS
#: Parameter : file path
#: : ingestion result [OK, WAIT, FATAL]
#: Response : POSTPROCESS OK
#: : POSTPROCESS FATAL
#: Description : Apply postprocessing after ingestion
file=$2
verified=$3
#Check verified parameter value
if [ "$verified" != "OK" -a "$verified" != "WAIT" -a "$verified" != "FATAL" ]; then
echo "POSTPROCESS FATAL"
exit 0
fi
#Post process verified WAIT files
#if [ "$verified" == "WAIT" ]; then
#fi
#Post process verified FATAL files
#if [ "$verified" == "FATAL" ]; then
#fi
echo "POSTPROCESS OK"
exit 0
else
#: Section : DEFAULT
#: Parameter : none
#: Response : UNKNOWN
echo "UNKNOWN"
exit 0
fi
...@@ -21,12 +21,14 @@ private: ...@@ -21,12 +21,14 @@ private:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// [Private] Constructor destructor deleter // [Private] Constructor destructor deleter
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Configuration(std::string watchPath, std::string destPath, Configuration(std::string watchPath, std::string regularPath,
std::string scriptPath, int workerNumber, int sleepTime, int waitTime, std::string warningPath, std::string errorPath, std::string scriptPath,
uint32_t iNotifyMask) : m_watchPath(watchPath), m_destPath(destPath), int workerNumber, int sleepTime, int waitTime, uint32_t iNotifyMask,
bool ignoreTimeout) : m_watchPath(watchPath), m_regularPath(regularPath),
m_warningPath(warningPath), m_errorPath(errorPath),
m_scriptPath(scriptPath), m_workerNumber(workerNumber), m_scriptPath(scriptPath), m_workerNumber(workerNumber),
m_sleepTime(sleepTime), m_waitTime(waitTime), m_sleepTime(sleepTime), m_waitTime(waitTime),
m_iNotifyMask(iNotifyMask) { } m_iNotifyMask(iNotifyMask), m_ignoreTimeout(ignoreTimeout) { }
virtual ~Configuration() {} virtual ~Configuration() {}
...@@ -42,24 +44,28 @@ public: ...@@ -42,24 +44,28 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// [Public] User methods // [Public] User methods
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
static Configuration::SP create(std::string watchPath, std::string destPath, static Configuration::SP create(std::string watchPath,
std::string regularPath, std::string warningPath, std::string errorPath,
std::string scriptPath, int workerNumber, int sleepTime, int waitTime, std::string scriptPath, int workerNumber, int sleepTime, int waitTime,
uint32_t iNotifyMask) uint32_t iNotifyMask, bool ignoreTimeout)
{ {
Configuration::SP c_sp(new Configuration(watchPath, destPath, scriptPath, Configuration::SP c_sp(new Configuration(watchPath, regularPath,
workerNumber, sleepTime, waitTime, iNotifyMask), warningPath, errorPath, scriptPath, workerNumber, sleepTime,
Configuration::Deleter()); waitTime, iNotifyMask, ignoreTimeout), Configuration::Deleter());
return c_sp; return c_sp;
} }
std::string getWatchPath() const { return m_watchPath; } std::string getWatchPath() const { return m_watchPath; }
std::string getDestPath() const { return m_destPath; } std::string getRegularPath() const { return m_regularPath; }
std::string getWarningPath() const { return m_warningPath; }
std::string getErrorPath() const { return m_errorPath; }
std::string getScriptPath() const { return m_scriptPath; } std::string getScriptPath() const { return m_scriptPath; }
unsigned int getWorkerNumber() const { return m_workerNumber; } unsigned int getWorkerNumber() const { return m_workerNumber; }
unsigned int getSleepTime() const { return m_sleepTime; } unsigned int getSleepTime() const { return m_sleepTime; }
unsigned int getWaitTime() const { return m_waitTime; } unsigned int getWaitTime() const { return m_waitTime; }
uint32_t getINotifyMask() const { return m_iNotifyMask; } uint32_t getINotifyMask() const { return m_iNotifyMask; }
bool getIgnoreTimeout() const { return m_ignoreTimeout; }
private: private:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -68,8 +74,14 @@ private: ...@@ -68,8 +74,14 @@ private:
//INotify watch path //INotify watch path
const std::string m_watchPath; const std::string m_watchPath;
//File destination path //Regular file destination path
const std::string m_destPath; const std::string m_regularPath;
//Warning file destination path
const std::string m_warningPath;
//Error file destination path
const std::string m_errorPath;
//Script path file //Script path file
const std::string m_scriptPath; const std::string m_scriptPath;
...@@ -85,6 +97,9 @@ private: ...@@ -85,6 +97,9 @@ private:
//INotify mask //INotify mask
const uint32_t m_iNotifyMask; const uint32_t m_iNotifyMask;
//Ignore timeout
const bool m_ignoreTimeout;
}; };
} //End of namespace } //End of namespace
......
...@@ -173,20 +173,6 @@ void EventThread::initEventBuffer() throw(std::runtime_error) ...@@ -173,20 +173,6 @@ void EventThread::initEventBuffer() throw(std::runtime_error)
if(!boost::filesystem::is_directory(path)) if(!boost::filesystem::is_directory(path))
throw std::runtime_error("Watch path \"" + throw std::runtime_error("Watch path \"" +
watchPath + "\" is not a valid directory"); watchPath + "\" is not a valid directory");
/*
//All files in watch path are inserted into event buffer
boost::filesystem::directory_iterator startIt(path);
boost::filesystem::directory_iterator endIt;
while(startIt != endIt)
{
if(boost::filesystem::is_regular_file(startIt->status()))
m_eventBuffer_sp->insertNew(startIt->path());
startIt++;
}
*/
} }
//============================================================================== //==============================================================================
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
//================================================================ //================================================================
// Attributes managed are: // Attributes managed are:
//================================================================ //================================================================
// IgnoredFileCounter | Tango::DevULong Scalar
// RegularFileCounter | Tango::DevULong Scalar // RegularFileCounter | Tango::DevULong Scalar
// WarningFileCounter | Tango::DevULong Scalar // WarningFileCounter | Tango::DevULong Scalar
// ErrorFileCounter | Tango::DevULong Scalar // ErrorFileCounter | Tango::DevULong Scalar
...@@ -126,6 +127,7 @@ void PreProcessor::delete_device() ...@@ -126,6 +127,7 @@ void PreProcessor::delete_device()
// Delete device allocated objects // Delete device allocated objects
/*----- PROTECTED REGION END -----*/ // PreProcessor::delete_device /*----- PROTECTED REGION END -----*/ // PreProcessor::delete_device
delete[] attr_IgnoredFileCounter_read;
delete[] attr_RegularFileCounter_read; delete[] attr_RegularFileCounter_read;
delete[] attr_WarningFileCounter_read; delete[] attr_WarningFileCounter_read;
delete[] attr_ErrorFileCounter_read; delete[] attr_ErrorFileCounter_read;
...@@ -151,12 +153,16 @@ void PreProcessor::init_device() ...@@ -151,12 +153,16 @@ void PreProcessor::init_device()
// Get the device properties from database // Get the device properties from database
get_device_property(); get_device_property();
attr_IgnoredFileCounter_read = new Tango::DevULong[1];
attr_RegularFileCounter_read = new Tango::DevULong[1]; attr_RegularFileCounter_read = new Tango::DevULong[1];
attr_WarningFileCounter_read = new Tango::DevULong[1]; attr_WarningFileCounter_read = new Tango::DevULong[1];
attr_ErrorFileCounter_read = new Tango::DevULong[1]; attr_ErrorFileCounter_read = new Tango::DevULong[1];
/*----- PROTECTED REGION ID(PreProcessor::init_device) ENABLED START -----*/ /*----- PROTECTED REGION ID(PreProcessor::init_device) ENABLED START -----*/
//Initialize ignored file counters to zero
*attr_IgnoredFileCounter_read = 0;
//Initialize regular file counters to zero //Initialize regular file counters to zero
*attr_RegularFileCounter_read = 0; *attr_RegularFileCounter_read = 0;
...@@ -215,14 +221,18 @@ void PreProcessor::get_device_property() ...@@ -215,14 +221,18 @@ void PreProcessor::get_device_property()
// Read device properties from database. // Read device properties from database.
Tango::DbData dev_prop; Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("WatchPath")); dev_prop.push_back(Tango::DbDatum("WatchPath"));
dev_prop.push_back(Tango::DbDatum("DestPath")); dev_prop.push_back(Tango::DbDatum("RegularPath"));
dev_prop.push_back(Tango::DbDatum("WarningPath"));
dev_prop.push_back(Tango::DbDatum("ErrorPath"));
dev_prop.push_back(Tango::DbDatum("ScriptPath")); dev_prop.push_back(Tango::DbDatum("ScriptPath"));
dev_prop.push_back(Tango::DbDatum("EventList")); dev_prop.push_back(Tango::DbDatum("EventList"));
dev_prop.push_back(Tango::DbDatum("SleepTime")); dev_prop.push_back(Tango::DbDatum("SleepTime"));
dev_prop.push_back(Tango::DbDatum("WaitTime")); dev_prop.push_back(Tango::DbDatum("WaitTime"));
dev_prop.push_back(Tango::DbDatum("WorkerNumber")); dev_prop.push_back(Tango::DbDatum("WorkerNumber"));
dev_prop.push_back(Tango::DbDatum("IgnoreTimeout"));
dev_prop.push_back(Tango::DbDatum("AutoStart")); dev_prop.push_back(Tango::DbDatum("AutoStart"));
// is there at least one property to be read ? // is there at least one property to be read ?
if (dev_prop.size()>0) if (dev_prop.size()>0)
{ {
...@@ -247,16 +257,38 @@ void PreProcessor::get_device_property() ...@@ -247,16 +257,38 @@ void PreProcessor::get_device_property()
// And try to extract WatchPath value from database // And try to extract WatchPath value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> watchPath; if (dev_prop[i].is_empty()==false) dev_prop[i] >> watchPath;
// Try to initialize DestPath from class property // Try to initialize RegularPath from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> regularPath;
else {
// Try to initialize RegularPath from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> regularPath;
}
// And try to extract RegularPath value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> regularPath;
// Try to initialize WarningPath from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> warningPath;
else {
// Try to initialize WarningPath from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> warningPath;
}
// And try to extract WarningPath value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> warningPath;
// Try to initialize ErrorPath from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name); cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> destPath; if (cl_prop.is_empty()==false) cl_prop >> errorPath;
else { else {
// Try to initialize DestPath from default device value // Try to initialize ErrorPath from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name); def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> destPath; if (def_prop.is_empty()==false) def_prop >> errorPath;
} }
// And try to extract DestPath value from database // And try to extract ErrorPath value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> destPath; if (dev_prop[i].is_empty()==false) dev_prop[i] >> errorPath;
// Try to initialize ScriptPath from class property // Try to initialize ScriptPath from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name); cl_prop = ds_class->get_class_property(dev_prop[++i].name);
...@@ -313,6 +345,17 @@ void PreProcessor::get_device_property() ...@@ -313,6 +345,17 @@ void PreProcessor::get_device_property()
// And try to extract WorkerNumber value from database // And try to extract WorkerNumber value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> workerNumber; if (dev_prop[i].is_empty()==false) dev_prop[i] >> workerNumber;
// Try to initialize IgnoreTimeout from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> ignoreTimeout;
else {
// Try to initialize IgnoreTimeout from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> ignoreTimeout;
}
// And try to extract IgnoreTimeout value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> ignoreTimeout;
// Try to initialize AutoStart from class property // Try to initialize AutoStart from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name); cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> autoStart; if (cl_prop.is_empty()==false) cl_prop >> autoStart;
...@@ -335,10 +378,16 @@ void PreProcessor::get_device_property() ...@@ -335,10 +378,16 @@ void PreProcessor::get_device_property()
checkIfDirectoryExists(watchPath); checkIfDirectoryExists(watchPath);
if(destPath.empty()) if(regularPath.empty())
throw(invalid_argument("DestPath property is empty or not defined")); throw(invalid_argument("Regular property is empty or not defined"));
checkIfDirectoryExists(regularPath);
checkIfDirectoryExists(destPath); if(!warningPath.empty())
checkIfDirectoryExists(warningPath);
if(!errorPath.empty())
checkIfDirectoryExists(errorPath);
if(scriptPath.empty()) if(scriptPath.empty())
throw(invalid_argument("ScriptPath property is empty or not defined")); throw(invalid_argument("ScriptPath property is empty or not defined"));
...@@ -368,8 +417,8 @@ void PreProcessor::get_device_property() ...@@ -368,8 +417,8 @@ void PreProcessor::get_device_property()
if(workerNumber<1 || workerNumber>MAX_WORKER_NUMBER) if(workerNumber<1 || workerNumber>MAX_WORKER_NUMBER)
throw(invalid_argument("WorkerNumber property out of range or not defined")); throw(invalid_argument("WorkerNumber property out of range or not defined"));
m_configuration_sp = Configuration::create(watchPath, destPath, scriptPath, m_configuration_sp = Configuration::create(watchPath, regularPath, warningPath,
workerNumber, sleepTime, waitTime, inotifyMask); errorPath, scriptPath, workerNumber, sleepTime, waitTime, inotifyMask, ignoreTimeout);
} }
catch(invalid_argument& ex) catch(invalid_argument& ex)
{ {
...@@ -390,7 +439,7 @@ void PreProcessor::get_device_property() ...@@ -390,7 +439,7 @@ void PreProcessor::get_device_property()
//-------------------------------------------------------- //--------------------------------------------------------
void PreProcessor::always_executed_hook() void PreProcessor::always_executed_hook()
{ {
DEBUG_STREAM << "PreProcessor::always_executed_hook() " << device_name << endl; INFO_STREAM << "PreProcessor::always_executed_hook() " << device_name << endl;
/*----- PROTECTED REGION ID(PreProcessor::always_executed_hook) ENABLED START -----*/ /*----- PROTECTED REGION ID(PreProcessor::always_executed_hook) ENABLED START -----*/
if(get_state() != Tango::FAULT) if(get_state() != Tango::FAULT)
...@@ -422,6 +471,26 @@ void PreProcessor::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) ...@@ -422,6 +471,26 @@ void PreProcessor::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
/*----- PROTECTED REGION END -----*/ // PreProcessor::read_attr_hardware /*----- PROTECTED REGION END -----*/ // PreProcessor::read_attr_hardware
} }
//--------------------------------------------------------
/**
* Read attribute IgnoredFileCounter related method
* Description:
*
* Data type: Tango::DevULong
* Attr type: Scalar
*/
//--------------------------------------------------------
void PreProcessor::read_IgnoredFileCounter(Tango::Attribute &attr)
{
DEBUG_STREAM << "PreProcessor::read_IgnoredFileCounter(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PreProcessor::read_IgnoredFileCounter) ENABLED START -----*/
boost::mutex::scoped_lock ignoredCounterLock(m_ignoredCounterMutex);
attr.set_value(attr_IgnoredFileCounter_read);
/*----- PROTECTED REGION END -----*/ // PreProcessor::read_IgnoredFileCounter
}
//-------------------------------------------------------- //--------------------------------------------------------
/** /**
* Read attribute RegularFileCounter related method * Read attribute RegularFileCounter related method
...@@ -578,6 +647,11 @@ void PreProcessor::reset_counter() ...@@ -578,6 +647,11 @@ void PreProcessor::reset_counter()
DEBUG_STREAM << "PreProcessor::ResetCounter() - " << device_name << endl; DEBUG_STREAM << "PreProcessor::ResetCounter() - " << device_name << endl;
/*----- PROTECTED REGION ID(PreProcessor::reset_counter) ENABLED START -----*/ /*----- PROTECTED REGION ID(PreProcessor::reset_counter) ENABLED START -----*/
//Reset ignored file counter
boost::mutex::scoped_lock ignoredCounterLock(m_ignoredCounterMutex);
*attr_IgnoredFileCounter_read = 0;
//Reset regular file counter //Reset regular file counter
boost::mutex::scoped_lock regularCounterLock(m_regularCounterMutex); boost::mutex::scoped_lock regularCounterLock(m_regularCounterMutex);
...@@ -596,6 +670,20 @@ void PreProcessor::reset_counter() ...@@ -596,6 +670,20 @@ void PreProcessor::reset_counter()
/*----- PROTECTED REGION END -----*/ // PreProcessor::reset_counter /*----- PROTECTED REGION END -----*/ // PreProcessor::reset_counter
} }
/*----- PROTECTED REGION ID(PreProcessor::namespace_ending) ENABLED START -----*/
//==============================================================================
// PreProcessor::incrementRegularCounter()
//==============================================================================
void PreProcessor::incrementIgnoredCounter()
{
DEBUG_STREAM << "PreProcessor::incrementIgnoredCounter() - " << device_name << endl;
boost::mutex::scoped_lock ignoredCounterLock(m_ignoredCounterMutex);
++*attr_IgnoredFileCounter_read;
}
//============================================================================== //==============================================================================
// PreProcessor::incrementRegularCounter() // PreProcessor::incrementRegularCounter()
//============================================================================== //==============================================================================
...@@ -632,8 +720,6 @@ void PreProcessor::incrementErrorCounter() ...@@ -632,8 +720,6 @@ void PreProcessor::incrementErrorCounter()
++*attr_ErrorFileCounter_read; ++*attr_ErrorFileCounter_read;
} }
/*----- PROTECTED REGION ID(PreProcessor::namespace_ending) ENABLED START -----*/
//============================================================================== //==============================================================================
// PreProcessor::create_inotify_mask() // PreProcessor::create_inotify_mask()
//============================================================================== //==============================================================================
......
...@@ -74,6 +74,9 @@ class PreProcessor : public TANGO_BASE_CLASS ...@@ -74,6 +74,9 @@ class PreProcessor : public TANGO_BASE_CLASS
//Thread shared pointer //Thread shared pointer
EventThread::SP m_eventThread_sp; EventThread::SP m_eventThread_sp;
//Ignored file counter synchronization
boost::mutex m_ignoredCounterMutex;
//Regular file counter synchronization //Regular file counter synchronization
boost::mutex m_regularCounterMutex; boost::mutex m_regularCounterMutex;
...@@ -101,8 +104,12 @@ class PreProcessor : public TANGO_BASE_CLASS ...@@ -101,8 +104,12 @@ class PreProcessor : public TANGO_BASE_CLASS
public: public:
// WatchPath: // WatchPath:
string watchPath; string watchPath;
// DestPath: // RegularPath: Regulars files destination path
string destPath; string regularPath;
// WarningPath: Warnings files destination path
string warningPath;
// ErrorPath: Error files destination path
string errorPath;
// ScriptPath: // ScriptPath:
string scriptPath; string scriptPath;
// EventList: // EventList:
...@@ -113,11 +120,16 @@ public: ...@@ -113,11 +120,16 @@ public:
Tango::DevUShort waitTime; Tango::DevUShort waitTime;
// WorkerNumber: // WorkerNumber:
Tango::DevUShort workerNumber; Tango::DevUShort workerNumber;
// IgnoreTimeout: Behaviour for missing end of file after timeout case:
// true = process those files like regulars files
// false = process those files like erroneous files
Tango::DevBoolean ignoreTimeout;
// AutoStart: Exec On command after init if state is not fault // AutoStart: Exec On command after init if state is not fault
Tango::DevBoolean autoStart; Tango::DevBoolean autoStart;
// Attribute data members // Attribute data members
public: public:
Tango::DevULong *attr_IgnoredFileCounter_read;
Tango::DevULong *attr_RegularFileCounter_read; Tango::DevULong *attr_RegularFileCounter_read;
Tango::DevULong *attr_WarningFileCounter_read; Tango::DevULong *attr_WarningFileCounter_read;
Tango::DevULong *attr_ErrorFileCounter_read; Tango::DevULong *attr_ErrorFileCounter_read;
...@@ -182,6 +194,15 @@ public: ...@@ -182,6 +194,15 @@ public:
//-------------------------------------------------------- //--------------------------------------------------------
virtual void read_attr_hardware(vector<long> &attr_list); virtual void read_attr_hardware(vector<long> &attr_list);
/**
* Attribute IgnoredFileCounter related methods
* Description:
*
* Data type: Tango::DevULong
* Attr type: Scalar
*/
virtual void read_IgnoredFileCounter(Tango::Attribute &attr);
virtual bool is_IgnoredFileCounter_allowed(Tango::AttReqType type);
/** /**
* Attribute RegularFileCounter related methods * Attribute RegularFileCounter related methods
* Description: * Description:
...@@ -251,6 +272,8 @@ public: ...@@ -251,6 +272,8 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// [Public] Users methods // [Public] Users methods
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
virtual void incrementIgnoredCounter();
virtual void incrementRegularCounter(); virtual void incrementRegularCounter();
virtual void incrementWarningCounter(); virtual void incrementWarningCounter();
......
<?xml version="1.0" encoding="ASCII"?> <?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="PreProcessor" pogoRevision="8.1"> <classes name="PreProcessor" pogoRevision="8.1">
<description description="Pre proccesing generic server" title="PreProcessor" sourcePath="/home/mdm/workspace/nadir/pre_precessor/src" language="Cpp" filestogenerate="XMI file,Code files" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <description description="Pre proccesing generic server" title="PreProcessor" sourcePath="/home/marco/workspace/nadir/pre_precessor/src" language="Cpp" filestogenerate="XMI file,Code files" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at oats.inaf.it - demarco" author="demarco" emailDomain="oats.inaf.it" classFamily="Acquisition" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference=""/> <identification contact="at oats.inaf.it - demarco" author="demarco" emailDomain="oats.inaf.it" classFamily="Acquisition" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference=""/>
</description> </description>
...@@ -9,7 +9,15 @@ ...@@ -9,7 +9,15 @@
<type xsi:type="pogoDsl:StringType"/> <type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties> </deviceProperties>
<deviceProperties name="DestPath" description=""> <deviceProperties name="RegularPath" description="Regulars files destination path">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="WarningPath" description="Warnings files destination path">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="ErrorPath" description="Error files destination path">
<type xsi:type="pogoDsl:StringType"/> <type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties> </deviceProperties>
...@@ -33,6 +41,11 @@ ...@@ -33,6 +41,11 @@
<type xsi:type="pogoDsl:UShortType"/> <type xsi:type="pogoDsl:UShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties> </deviceProperties>
<deviceProperties name="IgnoreTimeout" description="Behaviour for missing end of file after timeout case: &#xA;true = process those files like regulars files&#xA;false = process those files like erroneous files">
<type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>false</DefaultPropValue>
</deviceProperties>
<deviceProperties name="AutoStart" description="Exec On command after init if state is not fault"> <deviceProperties name="AutoStart" description="Exec On command after init if state is not fault">
<type xsi:type="pogoDsl:BooleanType"/> <type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
...@@ -89,6 +102,14 @@ ...@@ -89,6 +102,14 @@
</argout> </argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands> </commands>
<attributes name="IgnoredFileCounter" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:UIntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="RegularFileCounter" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <attributes name="RegularFileCounter" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:UIntType"/> <dataType xsi:type="pogoDsl:UIntType"/>
<changeEvent fire="false" libCheckCriteria="false"/> <changeEvent fire="false" libCheckCriteria="false"/>
......
...@@ -293,8 +293,34 @@ void PreProcessorClass::set_default_property() ...@@ -293,8 +293,34 @@ void PreProcessorClass::set_default_property()
} }
else else
add_wiz_dev_prop(prop_name, prop_desc); add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "DestPath"; prop_name = "RegularPath";
prop_desc = ""; prop_desc = "Regulars files destination path";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "WarningPath";
prop_desc = "Warnings files destination path";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "ErrorPath";
prop_desc = "Error files destination path";
prop_def = ""; prop_def = "";
vect_data.clear(); vect_data.clear();
if (prop_def.length()>0) if (prop_def.length()>0)
...@@ -369,6 +395,20 @@ void PreProcessorClass::set_default_property() ...@@ -369,6 +395,20 @@ void PreProcessorClass::set_default_property()
dev_def_prop.push_back(data); dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def); add_wiz_dev_prop(prop_name, prop_desc, prop_def);
} }
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "IgnoreTimeout";
prop_desc = "Behaviour for missing end of file after timeout case: \ntrue = process those files like regulars files\nfalse = process those files like erroneous files";
prop_def = "false";
vect_data.clear();
vect_data.push_back("false");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else else
add_wiz_dev_prop(prop_name, prop_desc); add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "AutoStart"; prop_name = "AutoStart";
...@@ -589,6 +629,30 @@ void PreProcessorClass::attribute_factory(vector<Tango::Attr *> &att_list) ...@@ -589,6 +629,30 @@ void PreProcessorClass::attribute_factory(vector<Tango::Attr *> &att_list)
// Add your own code // Add your own code
/*----- PROTECTED REGION END -----*/ // PreProcessorClass::attribute_factory_before /*----- PROTECTED REGION END -----*/ // PreProcessorClass::attribute_factory_before
// Attribute : IgnoredFileCounter
IgnoredFileCounterAttrib *ignoredfilecounter = new IgnoredFileCounterAttrib();
Tango::UserDefaultAttrProp ignoredfilecounter_prop;
// description not set for IgnoredFileCounter
// label not set for IgnoredFileCounter
// unit not set for IgnoredFileCounter
// standard_unit not set for IgnoredFileCounter
// display_unit not set for IgnoredFileCounter
// format not set for IgnoredFileCounter
// max_value not set for IgnoredFileCounter
// min_value not set for IgnoredFileCounter
// max_alarm not set for IgnoredFileCounter
// min_alarm not set for IgnoredFileCounter
// max_warning not set for IgnoredFileCounter
// min_warning not set for IgnoredFileCounter
// delta_t not set for IgnoredFileCounter
// delta_val not set for IgnoredFileCounter
ignoredfilecounter->set_default_properties(ignoredfilecounter_prop);
// Not Polled
ignoredfilecounter->set_disp_level(Tango::OPERATOR);
// Not Memorized
att_list.push_back(ignoredfilecounter);
// Attribute : RegularFileCounter // Attribute : RegularFileCounter
RegularFileCounterAttrib *regularfilecounter = new RegularFileCounterAttrib(); RegularFileCounterAttrib *regularfilecounter = new RegularFileCounterAttrib();
Tango::UserDefaultAttrProp regularfilecounter_prop; Tango::UserDefaultAttrProp regularfilecounter_prop;
......
...@@ -59,6 +59,19 @@ namespace PreProcessor_ns ...@@ -59,6 +59,19 @@ namespace PreProcessor_ns
//========================================= //=========================================
// Define classes for attributes // Define classes for attributes
//========================================= //=========================================
// Attribute IgnoredFileCounter class definition
class IgnoredFileCounterAttrib: public Tango::Attr
{
public:
IgnoredFileCounterAttrib():Attr("IgnoredFileCounter",
Tango::DEV_ULONG, Tango::READ) {};
~IgnoredFileCounterAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<PreProcessor *>(dev))->read_IgnoredFileCounter(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<PreProcessor *>(dev))->is_IgnoredFileCounter_allowed(ty);}
};
// Attribute RegularFileCounter class definition // Attribute RegularFileCounter class definition
class RegularFileCounterAttrib: public Tango::Attr class RegularFileCounterAttrib: public Tango::Attr
{ {
......
...@@ -53,6 +53,22 @@ namespace PreProcessor_ns ...@@ -53,6 +53,22 @@ namespace PreProcessor_ns
// Attributes Allowed Methods // Attributes Allowed Methods
//================================================= //=================================================
//--------------------------------------------------------
/**
* Method : PreProcessor::is_IgnoredFileCounter_allowed()
* Description : Execution allowed for IgnoredFileCounter attribute
*/
//--------------------------------------------------------
bool PreProcessor::is_IgnoredFileCounter_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for IgnoredFileCounter attribute in read access.
/*----- PROTECTED REGION ID(PreProcessor::IgnoredFileCounterStateAllowed_READ) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PreProcessor::IgnoredFileCounterStateAllowed_READ
return true;
}
//-------------------------------------------------------- //--------------------------------------------------------
/** /**
* Method : PreProcessor::is_RegularFileCounter_allowed() * Method : PreProcessor::is_RegularFileCounter_allowed()
......
#include <ScriptManager.h> #include <ScriptManager.h>
#include <cstdio>
namespace PreProcessor_ns namespace PreProcessor_ns
{ {
...@@ -34,7 +36,7 @@ ScriptManager::SP ScriptManager::create(Tango::DeviceImpl* deviceImpl_p, ...@@ -34,7 +36,7 @@ ScriptManager::SP ScriptManager::create(Tango::DeviceImpl* deviceImpl_p,
} }
//============================================================================== //==============================================================================
// ScriptManager::isReadyToArchive() // ScriptManager::checkScriptCompliance()
//============================================================================== //==============================================================================
void ScriptManager::checkScriptCompliance() void ScriptManager::checkScriptCompliance()
throw(std::runtime_error) throw(std::runtime_error)
...@@ -59,10 +61,40 @@ void ScriptManager::checkScriptCompliance() ...@@ -59,10 +61,40 @@ void ScriptManager::checkScriptCompliance()
} }
//============================================================================== //==============================================================================
// ScriptManager::isFileVerified() // ScriptManager::isFileNameValid()
//============================================================================== //==============================================================================
bool ScriptManager::isFileVerified(boost::filesystem::path& filePath) bool ScriptManager::isFileNameValid(boost::filesystem::path& filePath)
throw(std::runtime_error) throw(std::runtime_error)
{
DEBUG_STREAM << "ScriptManager::isFileNameValid()" << endl;
std::stringstream command;
command << m_configuration_sp->getScriptPath()
<< " VALID " << filePath.string();
std::string result = exec(command.str());
if(result.find("VALID OK") != std::string::npos)
{
return true;
}
else if(result.find("VALID FATAL") != std::string::npos)
{
return false;
}
else
{
std::stringstream errorStream;
errorStream << "Unknown validation error: " << result;
throw std::runtime_error(errorStream.str());
}
}
//==============================================================================
// ScriptManager::isFileVerified()
//==============================================================================
ScriptManager::Verified ScriptManager::isFileVerified(
boost::filesystem::path& filePath) throw(std::runtime_error)
{ {
DEBUG_STREAM << "ScriptManager::isFileVerified()" << endl; DEBUG_STREAM << "ScriptManager::isFileVerified()" << endl;
...@@ -74,17 +106,15 @@ bool ScriptManager::isFileVerified(boost::filesystem::path& filePath) ...@@ -74,17 +106,15 @@ bool ScriptManager::isFileVerified(boost::filesystem::path& filePath)
if(result.find("VERIFY OK") != std::string::npos) if(result.find("VERIFY OK") != std::string::npos)
{ {
return true; return OK;
} }
else if(result.find("VERIFY WAIT") != std::string::npos) else if(result.find("VERIFY WAIT") != std::string::npos)
{ {
return false; return WAIT;
} }
else if(result.find("VERIFY FATAL") != std::string::npos) else if(result.find("VERIFY FATAL") != std::string::npos)
{ {
std::stringstream errorStream; return FATAL;
errorStream << "Verification error: " << result;
throw std::runtime_error(errorStream.str());
} }
else else
{ {
...@@ -97,20 +127,27 @@ bool ScriptManager::isFileVerified(boost::filesystem::path& filePath) ...@@ -97,20 +127,27 @@ bool ScriptManager::isFileVerified(boost::filesystem::path& filePath)
//============================================================================== //==============================================================================
// ScriptManager::preProcessFile() // ScriptManager::preProcessFile()
//============================================================================== //==============================================================================
void ScriptManager::preProcessFile(boost::filesystem::path& filePath) void ScriptManager::preProcessFile(boost::filesystem::path& filePath,
throw(std::runtime_error) ScriptManager::Verified verified) throw(std::runtime_error)
{ {
DEBUG_STREAM << "ScriptManager::preProcessFile()" << endl; DEBUG_STREAM << "ScriptManager::preProcessFile()" << endl;
std::stringstream command; std::stringstream command;
command << m_configuration_sp->getScriptPath() command << m_configuration_sp->getScriptPath()
<< " PROCESS " << filePath.string(); << " PREPROCESS " << filePath.string();
if(verified == OK)
command << " OK";
else if(verified == WAIT)
command << " WAIT";
else if(verified == FATAL)
command << " FATAL";
std::string result = exec(command.str()); std::string result = exec(command.str());
if(result.find("PROCESS OK") == std::string::npos) if(result.find("PREPROCESS OK") == std::string::npos)
{ {
if(result.find("PROCESS FATAL") != std::string::npos) if(result.find("PREPROCESS FATAL") != std::string::npos)
{ {
std::stringstream errorStream; std::stringstream errorStream;
errorStream << "Pre process error: " << result; errorStream << "Pre process error: " << result;
...@@ -125,6 +162,44 @@ void ScriptManager::preProcessFile(boost::filesystem::path& filePath) ...@@ -125,6 +162,44 @@ void ScriptManager::preProcessFile(boost::filesystem::path& filePath)
} }
} }
//==============================================================================
// ScriptManager::postProcessFile()
//==============================================================================
void ScriptManager::postProcessFile(boost::filesystem::path& filePath,
ScriptManager::Verified verified) throw(std::runtime_error)
{
DEBUG_STREAM << "ScriptManager::postProcessFile()" << endl;
std::stringstream command;
command << m_configuration_sp->getScriptPath()
<< " POSTPROCESS " << filePath.string();
if(verified == OK)
command << " OK";
else if(verified == WAIT)
command << " WAIT";
else if(verified == FATAL)
command << " FATAL";
std::string result = exec(command.str());
if(result.find("POSTPROCESS OK") == std::string::npos)
{
if(result.find("POSTPROCESS FATAL") != std::string::npos)
{
std::stringstream errorStream;
errorStream << "Post process error: " << result;
throw std::runtime_error(errorStream.str());
}
else
{
std::stringstream errorStream;
errorStream << "Unknown post process error: " << result;
throw std::runtime_error(errorStream.str());
}
}
}
//============================================================================== //==============================================================================
// ScriptManager::exec() // ScriptManager::exec()
//============================================================================== //==============================================================================
......
...@@ -44,16 +44,27 @@ public: ...@@ -44,16 +44,27 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
static ScriptManager::SP create(Tango::DeviceImpl*, Configuration::SP); static ScriptManager::SP create(Tango::DeviceImpl*, Configuration::SP);
//------------------------------------------------------------------------------
// [Public] Verification results
//------------------------------------------------------------------------------
enum Verified {OK, WAIT, FATAL};
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// [Public] Script methods // [Public] Script methods
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
virtual void checkScriptCompliance() virtual void checkScriptCompliance()
throw(std::runtime_error); throw(std::runtime_error);
virtual bool isFileVerified(boost::filesystem::path&) virtual bool isFileNameValid(boost::filesystem::path&)
throw(std::runtime_error);
virtual Verified isFileVerified(boost::filesystem::path&)
throw(std::runtime_error);
virtual void preProcessFile(boost::filesystem::path&, Verified)
throw(std::runtime_error); throw(std::runtime_error);
virtual void preProcessFile(boost::filesystem::path&) virtual void postProcessFile(boost::filesystem::path&, Verified)
throw(std::runtime_error); throw(std::runtime_error);
protected: protected:
......
...@@ -42,6 +42,9 @@ void WorkerThread::workerLoop() ...@@ -42,6 +42,9 @@ void WorkerThread::workerLoop()
boost::chrono::steady_clock::duration waitTime = boost::chrono::steady_clock::duration waitTime =
boost::chrono::seconds(m_configuration_sp->getWaitTime()); boost::chrono::seconds(m_configuration_sp->getWaitTime());
//Process end of file after timeout like regualr files
bool ignoreTimeout = m_configuration_sp->getIgnoreTimeout();
while(true) while(true)
{ {
try try
...@@ -59,45 +62,67 @@ void WorkerThread::workerLoop() ...@@ -59,45 +62,67 @@ void WorkerThread::workerLoop()
<< fileName << "\"" << endl; << fileName << "\"" << endl;
try try
{ {
bool verified = false; //Process only file that match valid regex
if(m_fileManager_sp->isFileNameValid(origPath))
{
ScriptManager::Verified verified;
do do
{ {
if(m_fileManager_sp->isFileVerified(origPath)) verified = m_fileManager_sp->isFileVerified(origPath);
{
verified = true; if(verified == ScriptManager::OK ||
verified == ScriptManager::FATAL)
break; break;
}
else
{
boost::this_thread::sleep_for(sleepTime); boost::this_thread::sleep_for(sleepTime);
} }
}
while(boost::chrono::steady_clock::now()-start <= waitTime); while(boost::chrono::steady_clock::now()-start <= waitTime);
m_fileManager_sp->preProcessFile(origPath); m_fileManager_sp->preProcessFile(origPath, verified);
copyToDestination(origPath); copyToDestination(origPath, verified);
if(verified) m_fileManager_sp->postProcessFile(origPath, verified);
if(verified == ScriptManager::Verified::OK)
{ {
INFO_STREAM << "WorkerThread::workerLoop() \"" << fileName INFO_STREAM << "WorkerThread::workerLoop() \"" << fileName
<< "\" ingested regularly" << endl; << "\" ingested regularly" << endl;
m_preProcessor_p->incrementRegularCounter(); m_preProcessor_p->incrementRegularCounter();
} }
else else if(verified == ScriptManager::Verified::WAIT)
{ {
WARN_STREAM << "WorkerThread::workerLoop() \"" << fileName WARN_STREAM << "WorkerThread::workerLoop() \"" << fileName
<< "\" archived after timeout" << endl; << "\" archived after timeout" << endl;
m_preProcessor_p->incrementWarningCounter(); m_preProcessor_p->incrementWarningCounter();
} }
else if(verified == ScriptManager::Verified::FATAL)
{
WARN_STREAM << "WorkerThread::workerLoop() \"" << fileName
<< "\" not archived due to fits fatal error" << endl;
m_preProcessor_p->incrementErrorCounter();
}
} }
catch(std::runtime_error& ex) else
{
INFO_STREAM << "WorkerThread::workerLoop() \"" << fileName
<< "\" ignored" << endl;
m_preProcessor_p->incrementIgnoredCounter();
}
}
catch(std::exception& ex)
{ {
ERROR_STREAM << "WorkerThread::workerLoop() \"" << fileName ERROR_STREAM << "WorkerThread::workerLoop() \"" << fileName
<< "\" not archived due to " << ex.what() << endl; << "\" not archived due to " << ex.what() << endl;
m_preProcessor_p->incrementErrorCounter(); m_preProcessor_p->incrementErrorCounter();
} }
catch(...)
{
ERROR_STREAM << "WorkerThread::workerLoop() \"" << fileName
<< "\" not archived due to unknown exception" << endl;
m_preProcessor_p->incrementErrorCounter();
}
m_eventBuffer_sp->markAsProcessed(origPath); m_eventBuffer_sp->markAsProcessed(origPath);
} }
...@@ -106,31 +131,44 @@ void WorkerThread::workerLoop() ...@@ -106,31 +131,44 @@ void WorkerThread::workerLoop()
DEBUG_STREAM << "WorkerThread::workerLoop() interrupt" << endl; DEBUG_STREAM << "WorkerThread::workerLoop() interrupt" << endl;
break; break;
} }
catch(std::exception& ex)
{
ERROR_STREAM << "WorkerThread::workerLoop() " << ex.what() << endl;
}
catch(...)
{
ERROR_STREAM << "WorkerThread::workerLoop() unknown exception" << endl;
}
} //thread loop } //thread loop
} }
//============================================================================== //==============================================================================
// WorkerThread::moveFile()() // WorkerThread::moveFile()()
//============================================================================== //==============================================================================
void WorkerThread::copyToDestination(boost::filesystem::path& origPath) void WorkerThread::copyToDestination(boost::filesystem::path& origPath,
throw (std::runtime_error) ScriptManager::Verified verified) throw (std::runtime_error)
{ {
DEBUG_STREAM << "WorkerThread::moveFile()" << endl; DEBUG_STREAM << "WorkerThread::moveFile()" << endl;
//Process end of file after timeout like regualr files
bool ignoreTimeout = m_configuration_sp->getIgnoreTimeout();
boost::filesystem::path destPath;
if(verified == ScriptManager::OK)
{
destPath /= m_configuration_sp->getRegularPath();
}
else if(verified == ScriptManager::WAIT)
{
if(ignoreTimeout)
destPath /= m_configuration_sp->getRegularPath();
else
destPath /= m_configuration_sp->getWarningPath();
}
else
{
destPath /= m_configuration_sp->getErrorPath();
}
//TODO: come fare per le destinazioni vuote?
if(!boost::filesystem::is_regular_file(origPath)) if(!boost::filesystem::is_regular_file(origPath))
throw std::runtime_error( "Origin path \"" + throw std::runtime_error( "Origin path \"" +
origPath.string() + "\" is not a regular file"); origPath.string() + "\" is not a regular file");
boost::filesystem::path destPath(m_configuration_sp->getDestPath());
if(!boost::filesystem::exists(destPath)) if(!boost::filesystem::exists(destPath))
throw std::runtime_error( "Destination path \"" + throw std::runtime_error( "Destination path \"" +
destPath.string() + "\" not exists"); destPath.string() + "\" not exists");
......
...@@ -35,8 +35,8 @@ protected: ...@@ -35,8 +35,8 @@ protected:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// [Protected] Utilities methods // [Protected] Utilities methods
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
virtual void copyToDestination(boost::filesystem::path&) virtual void copyToDestination(boost::filesystem::path&,
throw (std::runtime_error); ScriptManager::Verified) throw (std::runtime_error);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// [Protected] Class variables // [Protected] Class variables
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment