private void ApplyRavenConfig(bool fromTimer = false)
{
if (Interlocked.Exchange(ref updatingRavenConfig, 1) == 0)
{
try
{
if (fromTimer &&
DateTimeOffset.UtcNow < this.lastUpdatedRavenConfig.Add(updateInterval))
{
logger.Debug("Raven config timer doing nothing, since config was updated recently.");
return;
}
logger.Debug("Loading Raven config...");
LoadRavenConfig();
lock (this.allStoreWrappers)
{
foreach (var wrapper in allStoreWrappers)
{
wrapper.UpdateInnerStore(wrapper);
}
}
this.lastUpdatedRavenConfig = DateTimeOffset.UtcNow;
// When the Url of the readOnlyOpsStore changes, we may receive
// change notifications from both old and new inner stores.
// A small delay should cause one to be ignored.
Thread.Sleep(1000);
}
catch (Exception exception)
{
logger.ErrorException("Error updating Raven config", exception);
if (exception.IsFatal())
{
throw;
}
}
finally
{
Interlocked.Exchange(ref updatingRavenConfig, 0);
}
}
}