Skip to content

Instantly share code, notes, and snippets.

@mlex
mlex / BurstyBackPressureTest.java
Created June 15, 2016 08:06
Test to demonstrate backpressure handling of reactor WorkQueueProcessor with bursty producers
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAccumulator;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxEmitter;
import reactor.core.publisher.WorkQueueProcessor;
@mlex
mlex / spotify-instana-notification.scpt
Created March 8, 2017 10:25
spotify-instana-notification.scpt
-- Post event with information about the currently playing track to instana
set oldPlayingTrack to getCurrentlyPlayingTrack()
repeat while true
set currentlyPlayingTrack to getCurrentlyPlayingTrack()
if currentlyPlayingTrack is not oldPlayingTrack then
set curl_data to "{\\\"title\\\":\\\"Listening to Track\\\",\\\"text\\\":\\\"Currently playing " & currentlyPlayingTrack & "\\\",\\\"duration\\\":60,\\\"severity\\\":-1}"
set curl_command to "curl -XPOST -d \"" & curl_data & "\" http://127.0.0.1:42699/com.instana.plugin.generic.event"
-- display notification curl_command
do shell script curl_command
package com.instana;
import static org.junit.Assert.assertTrue;
import java.time.Duration;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@mlex
mlex / JcToolsMpscCompoundQueueRelaxedOfferInfiniteLoop.java
Last active August 30, 2017 12:19
Testcase to reproduce a bug in JCTools MpscCompoundQueue.relaxedOffer that leads to infinite loop.
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;
import org.jctools.queues.MessagePassingQueue;
import org.jctools.queues.MpscCompoundQueue;
public class JcToolsMpscCompoundQueueRelaxedOfferInfiniteLoop {
public static final int PARALLELISM = 8;
public static final int DRAIN_SLEEP_NANOS = 100000;
@mlex
mlex / ReactorThreadStealingTest.java
Last active June 15, 2020 08:08
Reproduce reactor 3 thread stealing when flatMapIterable is followed by publishOn
import java.time.Duration;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;