Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@abelyansky
abelyansky / KBC
Last active August 20, 2019 19:03
public void processRecord(PutRecordsRequestEntry entry) {
try {
int recordSize = (int) this.kinesisClientManager.estimateSize(entry);
// enforce size and rate limits by blocking until new tokens are generated
entriesRatePerShard.acquire();
bytesRatePerShard.acquire(recordSize);
if (bufferQueue.size() + 1 >= MAX_ENTRIES_IN_REQUEST) {
if (logger.isDebugEnabled()) logger.debug("buffer queue is at size limit. flushing");
@abelyansky
abelyansky / threads_in_spark
Created June 3, 2019 18:56
simulating thread behavior in spark
import scala.concurrent.{Future,Await, blocking}
import scala.util.{Failure, Success}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
val WORKERS_WAIT_ON_THREADS = true
val (javaThreadCounter, scalaThreadCounter) = (sc.longAccumulator, sc.longAccumulator)
val df = sc.parallelize(1 to 10).toDF()
@abelyansky
abelyansky / payload.lua
Created August 19, 2016 17:58
small wrk2 plugin to generate load using a file of sampled, base64 encoded cookies
mime = require('mime')
wrk.method = "POST"
wrk.headers["Content-type"] = "application/x-protobuf"
requests = {}
init = function(args)
io.input('/home/centos/cookies_small')
for line in io.lines() do
actor = mime.unb64(line)