Search in sources :

Example 1 with AbstractDatabasePersistenceAsyncCallback

use of com.microsoft.azure.mobile.persistence.DatabasePersistenceAsync.AbstractDatabasePersistenceAsyncCallback in project mobile-center-sdk-android by Microsoft.

the class DefaultChannel method deleteLogsOnSuspended.

private void deleteLogsOnSuspended(final GroupState groupState) {
    final List<Log> logs = new ArrayList<>();
    final int stateSnapshot = mCurrentState;
    mPersistence.getLogs(groupState.mName, CLEAR_BATCH_SIZE, logs, new AbstractDatabasePersistenceAsyncCallback() {

        @Override
        public void onSuccess(Object result) {
            deleteLogsOnSuspended(groupState, stateSnapshot, logs);
        }
    });
}
Also used : AbstractDatabasePersistenceAsyncCallback(com.microsoft.azure.mobile.persistence.DatabasePersistenceAsync.AbstractDatabasePersistenceAsyncCallback) MobileCenterLog(com.microsoft.azure.mobile.utils.MobileCenterLog) Log(com.microsoft.azure.mobile.ingestion.models.Log) ArrayList(java.util.ArrayList)

Example 2 with AbstractDatabasePersistenceAsyncCallback

use of com.microsoft.azure.mobile.persistence.DatabasePersistenceAsync.AbstractDatabasePersistenceAsyncCallback in project mobile-center-sdk-android by Microsoft.

the class DefaultChannel method triggerIngestion.

/**
     * This will, if we're not using the limit for pending batches, trigger sending of a new request.
     * It will also reset the counters for sending out items for both the number of items enqueued and
     * the handlers. It will do this even if we don't have reached the limit
     * of pending batches or the time interval.
     *
     * @param groupName the group name
     */
private synchronized void triggerIngestion(@NonNull final String groupName) {
    if (!mEnabled) {
        return;
    }
    final GroupState groupState = mGroupStates.get(groupName);
    MobileCenterLog.debug(LOG_TAG, "triggerIngestion(" + groupName + ") pendingLogCount=" + groupState.mPendingLogCount);
    cancelTimer(groupState);
    /* Check if we have reached the maximum number of pending batches, log to LogCat and don't trigger another sending. */
    if (groupState.mSendingBatches.size() == groupState.mMaxParallelBatches) {
        MobileCenterLog.debug(LOG_TAG, "Already sending " + groupState.mMaxParallelBatches + " batches of analytics data to the server.");
        return;
    }
    /* Get a batch from Persistence. */
    final List<Log> batch = new ArrayList<>(groupState.mMaxLogsPerBatch);
    final int stateSnapshot = mCurrentState;
    mPersistence.getLogs(groupName, groupState.mMaxLogsPerBatch, batch, new AbstractDatabasePersistenceAsyncCallback() {

        @Override
        public void onSuccess(Object result) {
            triggerIngestion((String) result, groupState, stateSnapshot, batch);
        }
    });
}
Also used : AbstractDatabasePersistenceAsyncCallback(com.microsoft.azure.mobile.persistence.DatabasePersistenceAsync.AbstractDatabasePersistenceAsyncCallback) MobileCenterLog(com.microsoft.azure.mobile.utils.MobileCenterLog) Log(com.microsoft.azure.mobile.ingestion.models.Log) ArrayList(java.util.ArrayList)

Example 3 with AbstractDatabasePersistenceAsyncCallback

use of com.microsoft.azure.mobile.persistence.DatabasePersistenceAsync.AbstractDatabasePersistenceAsyncCallback in project mobile-center-sdk-android by Microsoft.

the class DefaultChannel method addGroup.

@Override
public synchronized void addGroup(final String groupName, int maxLogsPerBatch, long batchTimeInterval, int maxParallelBatches, GroupListener groupListener) {
    /* Init group. */
    MobileCenterLog.debug(LOG_TAG, "addGroup(" + groupName + ")");
    final GroupState groupState = new GroupState(groupName, maxLogsPerBatch, batchTimeInterval, maxParallelBatches, groupListener);
    mGroupStates.put(groupName, groupState);
    /* Count pending logs. */
    final int stateSnapshot = mCurrentState;
    mPersistence.countLogs(groupName, new AbstractDatabasePersistenceAsyncCallback() {

        @Override
        public void onSuccess(Object result) {
            checkPendingLogsAfterCounting(groupState, stateSnapshot, (Integer) result);
        }
    });
}
Also used : AbstractDatabasePersistenceAsyncCallback(com.microsoft.azure.mobile.persistence.DatabasePersistenceAsync.AbstractDatabasePersistenceAsyncCallback)

Aggregations

AbstractDatabasePersistenceAsyncCallback (com.microsoft.azure.mobile.persistence.DatabasePersistenceAsync.AbstractDatabasePersistenceAsyncCallback)3 Log (com.microsoft.azure.mobile.ingestion.models.Log)2 MobileCenterLog (com.microsoft.azure.mobile.utils.MobileCenterLog)2 ArrayList (java.util.ArrayList)2