Update to version 2

This commit is contained in:
2022-11-18 13:42:30 +01:00
parent 284fef3ec2
commit 8934eeac6b
23 changed files with 5109 additions and 5695 deletions

View File

@@ -91,13 +91,9 @@ PluginApplication::PluginApplication(int argc, char **argv, const string &desc)
_sendTimeout = 60;
_logStatus = false;
_statusFlushInterval = 10;
_host = "localhost";
_port = DEFAULT_PORT;
_strAddr = "localhost:" + sc::toString(DEFAULT_PORT);
SC_FS_DECLARE_PATH(path, "@ROOTDIR@/var/run/" + SCCoreApp->name() + "/journal");
SC_FS_DECLARE_PATH(path, "@ROOTDIR@/var/run/" + SCCoreApp->name() + "/journal")
_journalFile = path.string();
_mseedEnabled = false;
@@ -105,6 +101,7 @@ PluginApplication::PluginApplication(int argc, char **argv, const string &desc)
_mseedRecordLength = 9;
_strMseedEncoding = "Steim2";
_maxFutureEndTime = 120;
_dumpPackets = false;
// By default we disable the acquisition autostart because not all plugins
// require this feature. It must be enabled explicitly if required.
@@ -114,8 +111,16 @@ PluginApplication::PluginApplication(int argc, char **argv, const string &desc)
void PluginApplication::createCommandLineDescription() {
Seiscomp::Client::StreamApplication::createCommandLineDescription();
commandline().addGroup("Output");
commandline().addOption("Output", "addr,a", "Data output address, format is [HOST:PORT]", &_strAddr);
commandline().addOption("Output", "buffer-size,b", "Size (bytes) of the packet buffer", &_bufferSize);
commandline().addOption("Output", "addr,a",
"Data output address\n"
"[[caps|capss]://][user:pass@]host[:port]", &_strAddr);
commandline().addOption("Output", "agent",
"Sets the agent string. Allows "
"the server to identify the "
"application that sends data.",
&_agent);
commandline().addOption("Output", "buffer-size,b",
"Size (bytes) of the packet buffer", &_bufferSize);
commandline().addOption("Output", "backfilling",
"Enable backfilling for out-of-order records. The backfilling buffer size is "
"in seconds", &_backfillingBufferSize);
@@ -132,6 +137,7 @@ void PluginApplication::createCommandLineDescription() {
"the packet end time is greater than the current time plus this "
"value the packet will be discarded. By default this value is set to 120 seconds.",
&_maxFutureEndTime);
commandline().addOption("Output", "dump-packets", "Dump packets to stdout");
commandline().addGroup("Journal");
commandline().addOption("Journal", "journal,j",
"File to store stream states. Use an empty string to disable this feature.", &_journalFile);
@@ -192,12 +198,12 @@ bool PluginApplication::init() {
Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_INFO, LogInfo);
Gempa::CAPS::SetLogHandler(Gempa::CAPS::LL_DEBUG, LogDebug);
_plugin.setHost(_host);
_plugin.setPort(_port);
_plugin.setBufferSize(_bufferSize);
_plugin.setFlushInterval(_flushInterval);
_plugin.setTimeouts(_ackTimeout, _lastAckTimeout, _sendTimeout);
_plugin.setMaxFutureEndTime(_maxFutureEndTime);
_plugin.dumpPackets(_dumpPackets);
_plugin.setAgent(_agent);
if ( _mseedEnabled ) {
MSEEDEncoderFactory *factory = nullptr;
@@ -211,7 +217,7 @@ bool PluginApplication::init() {
factory = new Steim1EncoderFactory();
_plugin.setEncoderFactory(factory);
}
if ( _mseedEncoding == Steim2 ) {
else if ( _mseedEncoding == Steim2 ) {
SEISCOMP_INFO("Output stream encoding set to MiniSEED/Steim2");
factory = new Steim2EncoderFactory();
_plugin.setEncoderFactory(factory);
@@ -260,20 +266,23 @@ bool PluginApplication::init() {
bool PluginApplication::initConfiguration() {
if ( !Seiscomp::Client::StreamApplication::initConfiguration() ) return false;
try { _host = configGetString("output.host"); }
catch ( ... ) { }
try {
_plugin.setHost(configGetString("output.host"));
}
catch ( ... ) {
}
try { _port = configGetInt("output.port"); }
try {
_plugin.setPort(configGetInt("output.port"));
}
catch ( ... ) { }
try { _sendTimeout = configGetInt("output.timeout"); }
catch ( ... ) { }
try {
string addr = configGetString("output.addr");
if ( !splitAddress(_host, _port, addr, DEFAULT_PORT) ) {
SEISCOMP_ERROR("%s: Invalid CAPS address, format is [HOST:PORT]",
addr.c_str());
string addr = configGetString("output.address");
if ( !_plugin.setAddress(addr) ) {
return false;
}
}
@@ -307,6 +316,19 @@ bool PluginApplication::initConfiguration() {
try { _backfillingBufferSize = configGetInt("output.backfillingBufferSize"); }
catch ( ... ) { }
try { _maxFutureEndTime = configGetInt("output.maxFutureEndTime"); }
catch ( ... ) { }
try { _agent = configGetString("output.agent"); }
catch ( ... ) {
if ( version() ) {
_agent = name() + string(" ") + version();
}
else {
_agent = name();
}
}
try { _journalFile = configGetString("journal.file"); }
catch ( ... ) {}
@@ -325,9 +347,6 @@ bool PluginApplication::initConfiguration() {
try { _statusFlushInterval = configGetInt("statusLog.flush"); }
catch ( ... ) {}
try { _maxFutureEndTime= configGetInt("output.maxFutureEndTime"); }
catch ( ... ) { }
return true;
}
@@ -342,6 +361,10 @@ bool PluginApplication::validateParameters() {
_logStatus = true;
}
if ( commandline().hasOption("dump-packets") ) {
_dumpPackets = true;
}
if ( commandline().hasOption("encoding") ) {
if ( !fromString(_mseedEncoding, _strMseedEncoding)) return false;
}
@@ -353,9 +376,7 @@ bool PluginApplication::validateParameters() {
}
if ( commandline().hasOption("addr") ) {
if ( !splitAddress(_host, _port, _strAddr, DEFAULT_PORT) ) {
SEISCOMP_ERROR("%s: Invalid CAPS address, format is [HOST:PORT]",
_strAddr.c_str());
if ( !_plugin.setAddress(_strAddr, DEFAULT_PORT) ) {
return false;
}
}