Interface DiscardUnsyncedChangesStrategy
-
- All Superinterfaces:
AutomaticClientResetStrategy,SyncClientResetStrategy
public interface DiscardUnsyncedChangesStrategy extends AutomaticClientResetStrategy
Strategy that automatically resolves a Client Reset by discarding any unsynced data. UnlikeManuallyRecoverUnsyncedChangesStrategythere is no need to close Realm instances before performing the client reset. Once completed changes will be reported through the normal collection and object notifications.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 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 callbackonAfterReset(Realm, Realm)would be invoked if the changes have been discarded successfully.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 Deprecated Methods Modifier and Type Method Description voidonAfterReset(Realm before, Realm after)Callback invoked before the Client Reset discards any unsynced changes.voidonBeforeReset(Realm realm)Callback that indicates a Client Reset is about to happen.voidonError(SyncSession session, ClientResetRequiredError error)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 before the Client Reset discards any unsynced changes. 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 any unsynced changes from being discarded.
-
onError
@Deprecated void onError(SyncSession session, ClientResetRequiredError error)
Deprecated.Callback that indicates the Client reset failed to complete. It should be handled asManuallyRecoverUnsyncedChangesStrategy.onClientReset(SyncSession, ClientResetRequiredError).- Parameters:
session-SyncSessionthis error happened on.error-ClientResetRequiredErrorthe specific Client Reset error.
-
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.
-
-