Interface RecoverUnsyncedChangesStrategy
-
- All Superinterfaces:
AutomaticClientResetStrategy,SyncClientResetStrategy
public interface RecoverUnsyncedChangesStrategy extends AutomaticClientResetStrategy
Strategy that attempts to automatically recover any unsynced changes during a Client Reset.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 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 callbackonAfterReset(Realm, Realm)would be invoked if the changes have been recovered successfully.In the event that the client reset could not automatically recover 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 voidonAfterReset(Realm before, Realm after)Callback invoked after a 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.
-
onAfterReset
void onAfterReset(Realm before, Realm after)
Callback invoked after a 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.- Parameters:
before- the frozen realm from before the reset.after-RealmRealm after 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.
-
-