Skip to content

Instantly share code, notes, and snippets.

View mgodave's full-sized avatar
🤟

Dave Rusek mgodave

🤟
  • ex-Twitter
  • Denver, CO
  • 14:35 (UTC -06:00)
View GitHub Profile
package org.robotninjas.util.netty;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
@mgodave
mgodave / gist:8495373
Last active January 3, 2016 17:19
Talk abstract

Using "A Note on Distributed Computing" and "Seven Fallacies of Distributed Computing" as a guide I would like to explore the topic of distributed programming in Java. Starting with a gentle introduction to the challenges of programming in a distributed environment I will then look at some historical approaches used on the JVM and address their shortcomings. I will then explore some more modern approaches which address many of the concerns laid out in Waldo's seminal paper and discuss some of what must be considered when programming distibuted systems in Java. I will close out the talk by discussing some frameworks and libraries which make this task easier, including other languages built on top of the JVM.

Q: Is this talk: "Just Open a Socket"? - Talk to Sean.

I think what I'm trying to communicate is that everyone is telling us how bad RPC and Distributed Objects are, so what am I supposed to do?! Why are they bad and what am I supposed to do instead, what are good best practices? What does distributed pr

package org.robotninjas.util.concurrent;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.util.concurrent.*;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;
public class Test implements StateMachine {
@Override
public void applyOperation(@Nonnull ByteBuffer entry) {
System.out.println(entry.getLong());
}
public static void main(String... args) throws Exception {
ClusterConfig config = ClusterConfig.from(
@mgodave
mgodave / gist:7646319
Last active April 3, 2019 08:41
Create a single value Observable from a Guava ListenableFuture.
public static <T> Observable<T> create(ListenableFuture<T> future, Executor executor) {
AsyncSubject<T> subject = AsyncSubject.create();
future.addListener(() -> {
try {
T value = future.get();
subject.onNext(value);
subject.onCompleted();
} catch (Exception e) {
subject.onError(e);
}
@mgodave
mgodave / actor.kt
Last active October 15, 2018 09:29
Kotlin actor
package actors
import com.google.common.util.concurrent.ListenableFuture
import com.google.common.util.concurrent.SettableFuture
import com.google.common.util.concurrent.MoreExecutors
import java.util.concurrent.Executors
import java.util.ArrayList
import java.util.concurrent.LinkedBlockingQueue
import com.google.common.util.concurrent.ListeningExecutorService
import java.util.concurrent.ThreadFactory
@mgodave
mgodave / futures.kt
Created November 14, 2013 04:35
Akka Futures API in Kotlin (for fun)
import com.google.common.util.concurrent.ListeningExecutorService
import com.google.common.util.concurrent.MoreExecutors
import java.util.concurrent.Executors
import com.google.common.util.concurrent.ListenableFuture
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.FutureCallback
import com.google.common.util.concurrent.SettableFuture
import java.util.ArrayList
object KFutures {
@mgodave
mgodave / CounterMutationBuilder.java
Created October 16, 2013 20:08
CRDT user API PoC
/*
* Copyright 2013 Basho Technologies Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2013 Basho Technologies Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
public class ChainingExample {
private final Executor mainPool;
private final Executor ioPool;
public ChainingExample(Executor mainPool, Executor ioPool) {
this.mainPool = mainPool;
this.ioPool = ioPool;
}