Commit ad1a5222 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

User opt-in for the readonly kludge. Refactor for next step.

parent f5a161dc
......@@ -189,6 +189,7 @@ public:
std::shared_ptr<SDGenericDatasetWrapper> datasetwrapper() const {return _dataset;}
bool _mylogger(int priority, const std::string& message) const;
bool _sslogger(int priority, const std::ios& ss) const;
void _set_backoff(seismicdrive::SDGenericDataset* sdgd);
private:
/**
* This class is used by _split_by_segment to describe a request as seen by
......@@ -1023,40 +1024,6 @@ 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 (this->logger_(2, "")) {
std::stringstream ss;
ss << "Backoff " << (policy.enabled ? "enabled" : "disabled")
<< " retries " << policy.maxRetry
<< " start " << (float)policy.initialWaitingTimeMicroSec*1.0e-6
<< " max " << (float)policy.maxWaitingTimeMicroSec*1.0e-6;
this->logger_(2, ss.str());
}
}
}
};
/**
......@@ -1156,7 +1123,7 @@ SeismicStoreFile::SeismicStoreFile(const std::string& filename, OpenMode mode, c
try {
if (mode != OpenMode::Closed)
datasetwrapper->setBackoff();
_set_backoff(dataset.get());
switch (mode) {
case OpenMode::Closed:
break;
......@@ -1252,6 +1219,41 @@ SeismicStoreFile::_sslogger(int priority, const std::ios& ss) const
return _logger(priority, sstream ? sstream->str() : std::string());
}
/**
* 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
SeismicStoreFile::_set_backoff(seismicdrive::SDGenericDataset* sdgd)
{
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;
}
sdgd->setExponentialRetryBackoffPolicy(&policy);
if (_logger(2, "")) {
std::stringstream ss;
ss << "Backoff " << (policy.enabled ? "enabled" : "disabled")
<< " retries " << policy.maxRetry
<< " start " << (float)policy.initialWaitingTimeMicroSec*1.0e-6
<< " max " << (float)policy.maxWaitingTimeMicroSec*1.0e-6;
_logger(2, ss.str());
}
}
}
std::shared_ptr<FileADT>
SeismicStoreFile::xx_make_instance(const std::string& filename, OpenMode mode, const IOContext *iocontext)
{
......
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