private void processChangeTrackerStopped(ChangeTracker tracker) { Log.d(Log.TAG_SYNC, "changeTrackerStopped. lifecycle: %s", lifecycle); switch (lifecycle) { case ONESHOT: // TODO: This is too early to fire STOP_GRACEFUL, Need to change. Log.d(Log.TAG_SYNC, "fire STOP_GRACEFUL"); if (tracker.getLastError() != null) { setError(tracker.getLastError()); } stateMachine.fire(ReplicationTrigger.STOP_GRACEFUL); break; case CONTINUOUS: if (stateMachine.isInState(ReplicationState.OFFLINE)) { // in this case, we don't want to do anything here, since // we told the change tracker to go offline .. Log.d(Log.TAG_SYNC, "Change tracker stopped because we are going offline"); } else if (stateMachine.isInState(ReplicationState.STOPPING) || stateMachine.isInState(ReplicationState.STOPPED)) { Log.d(Log.TAG_SYNC, "Change tracker stopped because replicator is stopping or stopped."); } else { // otherwise, try to restart the change tracker, since it should // always be running in continuous replications String msg = String.format("Change tracker stopped during continuous replication"); Log.e(Log.TAG_SYNC, msg); parentReplication.setLastError(new Exception(msg)); fireTrigger(ReplicationTrigger.WAITING_FOR_CHANGES); Log.d( Log.TAG_SYNC, "Scheduling change tracker restart in %d ms", CHANGE_TRACKER_RESTART_DELAY_MS); workExecutor.schedule( new Runnable() { @Override public void run() { // the replication may have been stopped by the time this scheduled fires // so we need to check the state here. if (stateMachine.isInState(ReplicationState.RUNNING)) { Log.d(Log.TAG_SYNC, "%s still running, restarting change tracker", this); startChangeTracker(); } else { Log.d( Log.TAG_SYNC, "%s still no longer running, not restarting change tracker", this); } } }, CHANGE_TRACKER_RESTART_DELAY_MS, TimeUnit.MILLISECONDS); } break; default: Log.e(Log.TAG_SYNC, "Unknown lifecycle: %s", lifecycle); } }