use of com.microsoft.appcenter.ingestion.Ingestion in project mobile-center-sdk-android by Microsoft.
the class DefaultChannel method suspend.
/**
* Stop sending logs until app is restarted or the channel is enabled again.
*
* @param deleteLogs in addition to suspending, if this is true, delete all logs from Persistence.
* @param exception the exception that caused suspension.
*/
private void suspend(boolean deleteLogs, Exception exception) {
mDiscardLogs = deleteLogs;
mCurrentState++;
for (GroupState groupState : mGroupStates.values()) {
cancelTimer(groupState);
/* Delete all other batches and call callback method that are currently in progress. */
for (Iterator<Map.Entry<String, List<Log>>> iterator = groupState.mSendingBatches.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<String, List<Log>> entry = iterator.next();
iterator.remove();
if (deleteLogs) {
GroupListener groupListener = groupState.mListener;
if (groupListener != null) {
for (Log log : entry.getValue()) {
groupListener.onFailure(log, exception);
}
}
}
}
}
for (Ingestion ingestion : mIngestions) {
try {
ingestion.close();
} catch (IOException e) {
AppCenterLog.error(LOG_TAG, "Failed to close ingestion: " + ingestion, e);
}
}
if (deleteLogs) {
for (GroupState groupState : mGroupStates.values()) {
deleteLogsOnSuspended(groupState);
}
} else {
mPersistence.clearPendingLogState();
}
}
Aggregations