Interface RecoverOrDiscardUnsyncedChangesStrategy
-
- All Superinterfaces:
AutomaticClientResetStrategy,SyncClientResetStrategy
public interface RecoverOrDiscardUnsyncedChangesStrategy extends AutomaticClientResetStrategy
Strategy that attempts to automatically recover any unsynced changes during a Client Reset, if the recovery fails the changes would be discarded.A synced Realm may need to be reset because the MongoDB Realm Server encountered an error and had to be restored from a backup or because it has been too long since the client connected to the server so the server has rotated the logs.
The Client Reset thus occurs because the server does not have the full information required to bring the Client fully up to date.
The recover or discard unsynced changes process is as follows: when a client reset is received by the client the
onBeforeReset(Realm)callback is invoked, then the client would be reset. Once the reset has concluded the callbackonAfterRecovery(Realm, Realm)(Realm, Realm)} would be invoked if the changes have been recovered successfully, otherwise the changes would be discarded andonAfterDiscard(Realm, Realm)(Realm, Realm)} (Realm, Realm)} would be invoked.In the event that the client reset could not discard the unsynced data the
onManualResetFallback(SyncSession, ClientResetRequiredError)would be invoked. It allows to manually resolve the reset as it would have been done inManuallyRecoverUnsyncedChangesStrategy.onClientReset(SyncSession, ClientResetRequiredError).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidonAfterDiscard(Realm before, Realm after)Callback invoked before the Client Reset discards any unsynced changes because the recovery failed.voidonAfterRecovery(Realm before, Realm after)Callback invoked once the Client Reset has recovered the unsynced changes successfully.voidonBeforeReset(Realm realm)Callback that indicates a Client Reset is about to happen.voidonManualResetFallback(SyncSession session, ClientResetRequiredError error)Callback that indicates the Client reset failed to complete.
-
-
-
Method Detail
-
onBeforeReset
void onBeforeReset(Realm realm)
Callback that indicates a Client Reset is about to happen. It provides a handle to the local realm before the reset.- Specified by:
onBeforeResetin interfaceAutomaticClientResetStrategy- Parameters:
realm- frozenRealmin its state before the reset.
-
onAfterRecovery
void onAfterRecovery(Realm before, Realm after)
Callback invoked once the Client Reset has recovered the unsynced changes successfully. It provides two Realm instances, a frozen one displaying the state before the reset and a regular Realm with the current state.
-
onAfterDiscard
void onAfterDiscard(Realm before, Realm after)
Callback invoked before the Client Reset discards any unsynced changes because the recovery failed. It provides two Realm instances, a frozen one displaying the state before the reset and a regular Realm displaying the current state that can be used to recover objects from the reset.
-
onManualResetFallback
void onManualResetFallback(SyncSession session, ClientResetRequiredError error)
Callback that indicates the Client reset failed to complete. It should be handled asManuallyRecoverUnsyncedChangesStrategy.onClientReset(SyncSession, ClientResetRequiredError).- Specified by:
onManualResetFallbackin interfaceAutomaticClientResetStrategy- Parameters:
session-SyncSessionthis error happened on.error-ClientResetRequiredErrorthe specific Client Reset error.
-
-