public final class RecoveryConfig extends Object
This class defines thresholds and policies for when and how automatic recovery should be triggered. Recovery involves clearing the database directory and re-downloading fresh database files.
Recovery can be triggered by various error conditions:
When recovery is triggered, the configured action determines behavior:
RecoveryConfig.RecoveryAction.AUTOMATIC - Immediately attempt recoveryRecoveryConfig.RecoveryAction.NOTIFY_ONLY - Fire event but don't auto-recoverRecoveryConfig.RecoveryAction.DISABLE_SERVICE - Disable service until manual intervention
RecoveryConfig config = RecoveryConfig.builder()
.recoveryAction(RecoveryAction.AUTOMATIC)
.initFailureThreshold(3)
.lookupErrorThreshold(20)
.recoverOnDownloadFailure(true)
.recoverOnCorruption(true)
.maxAutoRecoveryAttempts(3)
.autoRecoveryCooldownMinutes(60)
.build();
IP2LocationManager.getInstance().setRecoveryConfig(config);
The default configuration uses RecoveryConfig.RecoveryAction.NOTIFY_ONLY with
conservative thresholds. To enable automatic recovery, explicitly set
the recovery action to RecoveryConfig.RecoveryAction.AUTOMATIC.
IP2LocationManager.setRecoveryConfig(RecoveryConfig),
IServiceStatusListener.onRecoveryRecommended(String, boolean)| Modifier and Type | Class and Description |
|---|---|
static class |
RecoveryConfig.Builder
Builder for creating
RecoveryConfig instances. |
static class |
RecoveryConfig.RecoveryAction
Actions to take when recovery conditions are met.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_AUTO_RECOVERY_COOLDOWN_MINUTES
Default cooldown between automatic recovery attempts (minutes).
|
static int |
DEFAULT_INIT_FAILURE_THRESHOLD
Default threshold for consecutive initialization failures.
|
static int |
DEFAULT_LOOKUP_ERROR_THRESHOLD
Default threshold for consecutive lookup errors.
|
static int |
DEFAULT_MAX_AUTO_RECOVERY_ATTEMPTS
Default maximum automatic recovery attempts.
|
| Modifier and Type | Method and Description |
|---|---|
static RecoveryConfig |
automatic()
Returns a configuration for fully automatic recovery.
|
static RecoveryConfig.Builder |
builder()
Creates a new builder for RecoveryConfig.
|
static RecoveryConfig |
defaults()
Returns the default configuration (notify only, no auto-recovery).
|
int |
getAutoRecoveryCooldownMinutes()
Returns the cooldown period between recovery attempts.
|
int |
getInitFailureThreshold()
Returns the threshold for consecutive initialization failures.
|
int |
getLookupErrorThreshold()
Returns the threshold for consecutive lookup errors.
|
int |
getMaxAutoRecoveryAttempts()
Returns the maximum number of automatic recovery attempts.
|
RecoveryConfig.RecoveryAction |
getRecoveryAction()
Returns the action to take when recovery is triggered.
|
boolean |
isAutoRecoveryEnabled()
Returns whether automatic recovery is enabled.
|
boolean |
isNotifyOnTransientErrors()
Returns whether to notify listeners on transient errors.
|
boolean |
isRecoverOnCorruption()
Returns whether to trigger recovery on database corruption.
|
boolean |
isRecoverOnDownloadFailure()
Returns whether to trigger recovery after download failures.
|
static RecoveryConfig |
strict()
Returns a strict configuration that disables service on errors.
|
String |
toString() |
public static final int DEFAULT_INIT_FAILURE_THRESHOLD
public static final int DEFAULT_LOOKUP_ERROR_THRESHOLD
public static final int DEFAULT_MAX_AUTO_RECOVERY_ATTEMPTS
public static final int DEFAULT_AUTO_RECOVERY_COOLDOWN_MINUTES
public static RecoveryConfig.Builder builder()
public static RecoveryConfig defaults()
public static RecoveryConfig automatic()
This preset enables automatic recovery with sensible defaults for production servers.
public static RecoveryConfig strict()
This preset is for environments where geolocation failures should prevent dependent operations from continuing.
public RecoveryConfig.RecoveryAction getRecoveryAction()
public int getInitFailureThreshold()
Recovery is triggered after this many consecutive failures to initialize the service.
public int getLookupErrorThreshold()
Recovery is triggered after this many consecutive lookups
return GeoLocation.Status.DB_ERROR.
public boolean isRecoverOnDownloadFailure()
When enabled, recovery is triggered if database download fails after all retry attempts are exhausted.
true if recovery on download failure is enabledpublic boolean isRecoverOnCorruption()
When enabled, recovery is triggered immediately when database corruption is detected (invalid format, failed integrity check, etc.).
true if recovery on corruption is enabledpublic int getMaxAutoRecoveryAttempts()
After this many failed recovery attempts, the service will stop trying and require manual intervention.
public int getAutoRecoveryCooldownMinutes()
After a failed recovery attempt, the service will wait this many minutes before trying again.
public boolean isNotifyOnTransientErrors()
Transient errors (network issues, temporary server errors) may resolve on retry. When disabled, these errors are logged but don't trigger listener notifications.
true if transient error notifications are enabledpublic boolean isAutoRecoveryEnabled()
true if recovery action is AUTOMATICPhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© 2026 Mindus SARL. All rights reserved.