-
-
Save abohomol/16433e39ba0b9452ea51cf3360bd5b36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import org.kaaproject.kaa.client.AndroidKaaPlatformContext | |
import org.kaaproject.kaa.client.BaseKaaClient | |
import org.kaaproject.kaa.client.logging.memory.MemLogStorage | |
import org.kaaproject.kaa.client.logging.strategies.RecordCountLogUploadStrategy | |
/* | |
* Implementation of In-Memory log storage with enlarged allocated space. | |
*/ | |
class LargeMemLogStorage : MemLogStorage(MAX_STORAGE_SIZE_BYTES, MAX_BUCKET_SIZE_BYTES, MAX_BUCKET_RECORD_COUNT) { | |
companion object { | |
private const val MAX_STORAGE_SIZE_BYTES: Long = 100 * 1024 * 1024 | |
private const val MAX_BUCKET_SIZE_BYTES: Long = 16 * 1024 | |
private const val MAX_BUCKET_RECORD_COUNT = 256 | |
} | |
} | |
/* | |
* | |
*/ | |
class ConfiguredKaaClient(context: Context) : BaseKaaClient(AndroidKaaPlatformContext(context), null) { | |
companion object { | |
private const val LOG_UPLOAD_THRESHOLD = 1 | |
private const val BATCH_SIZE_BYTES = 100 * 1024 | |
private const val MAX_PARALLEL_LOG_UPLOADS = 1 | |
private const val LOG_DELIVERY_TIMEOUT_SEC = 10 | |
} | |
init { | |
setLogStorage(LargeMemLogStorage()) | |
val uploadStrategy = RecordCountLogUploadStrategy(LOG_UPLOAD_THRESHOLD) | |
uploadStrategy.timeout = LOG_DELIVERY_TIMEOUT_SEC | |
uploadStrategy.setBatch(BATCH_SIZE_BYTES) | |
uploadStrategy.maxParallelUploads = MAX_PARALLEL_LOG_UPLOADS | |
setLogUploadStrategy(uploadStrategy) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment