Commit 6ba0639c authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Allow configuring seismic store back-off via an environment variable.

parent 87f10dde
......@@ -47,11 +47,13 @@
#include <SDGenericDataset.h>
#include <SDUtils.h>
#include <Constants.h>
#include <HttpContext.h>
#else
#include <SDAPI/SDManager.h>
#include <SDAPI/SDGenericDataset.h>
#include <SDAPI/SDUtils.h>
#include <SDAPI/Constants.h>
#include <SDAPI/HttpContext.h>
#endif
/** \cond SSTORE */
......@@ -932,6 +934,38 @@ public:
}
}
}
/**
* Configure the exponential backoff used by Seismic Store.
* Only expected to be used for debugging.
*
* * -1 => use defaults.
* * 0 => Turn off exponential backoff completely.
* * >0 =? Set maximum repeat count.
*/
void setBackoff()
{
int retries = Environment::getNumericEnv("OPENZGY_SD_BACKOFF", -1);
if (retries >= 0) {
seismicdrive::ExponentialRetryBackoffPolicy policy;
if (retries == 0) {
policy.enabled = false;
}
else {
policy.enabled = true;
policy.maxRetry = retries;
policy.initialWaitingTimeMicroSec = 500 * 1000;
policy.maxWaitingTimeMicroSec = 32 * 1000 * 1000;
}
dataset_->setExponentialRetryBackoffPolicy(&policy);
if (SeismicStoreFile::_logger(2, ""))
SeismicStoreFile::_logger(2, std::stringstream() << std::boolalpha
<< "Backoff enabled " << policy.enabled
<< " retries " << policy.maxRetry
<< " start " << (float)policy.initialWaitingTimeMicroSec*1.0e-6
<< " max " << (float)policy.maxWaitingTimeMicroSec*1.0e-6);
}
}
};
SDGenericDatasetWrapper::~SDGenericDatasetWrapper()
......@@ -1040,6 +1074,8 @@ SeismicStoreFile::SeismicStoreFile(const std::string& filename, OpenMode mode, c
dataset->open(seismicdrive::SDDatasetDisposition::OVERWRITE, extra);
break;
}
if (mode != OpenMode::Closed)
datasetwrapper->setBackoff();
}
catch (const std::exception& ex) {
SeismicStoreFile::_logger(1, std::stringstream()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment