Skip to content

Instantly share code, notes, and snippets.

View jbrisbin's full-sized avatar

Jon Brisbin jbrisbin

View GitHub Profile
@jbrisbin
jbrisbin / TestGraphSpec.java
Created January 15, 2014 15:28
Proposed Graph API psuedo-code
class GraphSpec<T> {}
class NodeSpec<T> {}
class State<T> {}
GraphSpec<T> graph = Graphs.compose()
.env(env)
.dispatcher(dispatcher)
.create("bad arg handler", new Consumer<State<Throwable>>(){})
.create("global err handler", new Consumer<State<Throwable>>(){});
@jbrisbin
jbrisbin / ArrayVsListThroughputTests.java
Created February 20, 2014 13:51
Array vs List iteration throughput test
public class ArrayVsListThroughputTests {
static long TIMEOUT = 5000;
@Test
public void testArrayVsListIteration() {
int items = 10;
String[] strArray = new String[items];
List<String> strList = new ArrayList<String>();
for(int i = 0; i < items; i++) {
@jbrisbin
jbrisbin / binary_search_results
Created February 24, 2014 22:38
JMH Benchmark Test Results
> mvn package && java -jar target/microbenchmarks.jar ".*MapBenchmarks.*BinarySearch.*" -f 1 -i 10 -wi 10 -r 3 -tu s
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building reactor-benchmark 1.0.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ reactor-benchmark ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
package org.sample;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.logic.BlackHole;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 5)
+-( spring-xd (master) ):> ./gradlew cleanIdea idea
:cleanIdeaModule
:cleanIdeaProject
:cleanIdea
:modules:cleanIdeaModule
:modules:cleanIdea
:modules.job.filejdbc:cleanIdeaModule
:modules.job.filejdbc:cleanLibs
:modules.job.filejdbc:cleanIdea
:modules.job.ftphdfs:cleanIdeaModule
@jbrisbin
jbrisbin / ForkJoinPoolTests.java
Created May 16, 2014 14:01
Example of using Reactor ForkJoinPool
package reactor.core.fork;
import com.gs.collections.api.list.ImmutableList;
import com.gs.collections.impl.list.mutable.FastList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import reactor.core.Environment;
import reactor.core.composable.Promise;
import reactor.function.Function;
@jbrisbin
jbrisbin / logfile.txt
Created May 21, 2014 16:18
Tomcat leak detector logging
21-May-2014 11:17:31.821 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks The web application [/spring-websocket-portfolio] created a ThreadLocal with key of type [io.netty.channel.ChannelHandlerAdapter$1] (value [io.netty.channel.ChannelHandlerAdapter$1@afed80a]) and a value of type [java.util.WeakHashMap] (value [{class reactor.net.netty.tcp.NettyTcpClient$1=true}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
21-May-2014 11:17:31.821 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoader.checkThreadLocalMapForLeaks The web application [/spring-websocket-portfolio] created a ThreadLocal with key of type [io.netty.util.internal.ThreadLocalRandom$3] (value [io.netty.util.internal.ThreadLocalRandom$3@37ff8726]) and a value of type [io.netty.util.internal.ThreadLocalRandom] (value [io.netty.util.internal.ThreadLocalRandom@1ce5a4ff]) but f
@jbrisbin
jbrisbin / rest-shell-output.txt
Created June 18, 2014 22:27
rest-shell 2.0 sample output
_ _ _____ _____ ___ ___ _____ _ ____
| || |_ _|_ _| _ \ \ \ / / __(_) / / /
| __ | | | | | | _/ |\ \/\/ /\__ \_ / / /
|_||_| |_| |_| |_| | | \_/\_/ |___(_)_/_/
=====================|_|=====================
HTTP and WebSocket interactive shell - version 1.0
(http://localhost:8080/):> get --headers "X-Custom: custom header value"
> GET http://localhost:8080/ HTTP/1.1
>
@jbrisbin
jbrisbin / sample.groovy
Last active August 29, 2015 14:03
Sample Reactive Resource Framework Code
routing {
include SpringConfig
http {
route("/path/to/{resourceId}") to CustomResource
}
}
interface Context extends AbstractMutableMap<String, Object> {
@Test
public void workerOrchestrator() throws InterruptedException {
Environment env = new Environment();
Reactor reactor = Reactors.reactor(env, Environment.THREAD_POOL);
CountDownLatch latch = new CountDownLatch(2);
reactor.on(Selectors.$("worker"), new Consumer() {
@Override