I hereby claim:
- I am jpe42 on github.
- I am jamespedwards42 (https://keybase.io/jamespedwards42) on keybase.
- I have a public key whose fingerprint is 6898 5D15 3F6F 6890 ADA1 F473 30CE 9FFF 6EDE 7CAF
To claim this, I am signing this object:
| final Map<Node, Node> nodeMappings = new HashMap<>(3); | |
| nodeMappings.put(Node.create("internal1", 7001), Node.create("public1", 7001)); | |
| nodeMappings.put(Node.create("internal1", 7002), Node.create("public2", 7002)); | |
| nodeMappings.put(Node.create("internal1", 7003), Node.create("public3", 7003)); | |
| final Collection<Node> discoveryNodes = Collections.singleton(Node.create("public1", 7001)); | |
| // Static mapper, could easily be something dynamic as well. | |
| final NodeMapper nodeMapper = |
| // BITFIELD command taken from http://redis.io/commands/BITFIELD | |
| // BITFIELD mykey INCRBY i5 100 1 GET u4 0 | |
| final CmdByteArray<long[]> bitfieldCmd = CmdByteArray.startBuilding(Cmds.BITFIELD, 9) | |
| .addSlotKey("mykey") | |
| .addSubCmd(Cmds.BITFIELD_INCRBY, "i5", "100", "1") | |
| .addSubCmd(Cmds.BITFIELD_GET, "u4", "0").create(); | |
| try (final RedisClient client = | |
| RedisClientFactory.startBuilding().create(Node.create("localhost", 6379))) { |
I hereby claim:
To claim this, I am signing this object:
| private static int runWithJedipus(final IntStream keys) { | |
| int count = 0; | |
| try (final RedisClient client = | |
| RedisClientFactory.startBuilding().create(Node.create("127.0.0.1", 6379))) { | |
| client.sendCmd(Cmds.FLUSHALL); | |
| final long start = System.currentTimeMillis(); |
| final Node node = Node.create("127.0.0.1", 6379); | |
| final String channel = "jedipus"; | |
| final RedisClientFactory.Builder clientFactory = RedisClientFactory.startBuilding(); | |
| final ElementRetryDelay<Node> nodeRetryDelay = | |
| ElementRetryDelay.startBuilding().withMaxDelay(Duration.ofSeconds(30)).create(); | |
| final RedisClientExecutor clientExecutor = RedisClientExecutor.startBuilding() | |
| .withClientFactory(clientFactory) |
| import java.util.PrimitiveIterator; | |
| import static java.lang.Character.digit; | |
| public final class Hex { | |
| private Hex() {} | |
| private static final char[] HEX_CHARS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', | |
| '9', 'a', 'b', 'c', 'd', 'e', 'f'}; |
| package systems.comodal.collision.cache; | |
| import java.lang.invoke.MethodHandles; | |
| import java.lang.invoke.VarHandle; | |
| import java.util.concurrent.ThreadLocalRandom; | |
| /** | |
| * Provides atomic operations for 8-bit logarithmic counters backed by a byte array. | |
| * | |
| * @author James P. Edwards |
| import javax.servlet.http.HttpServletRequest; | |
| public class RequestUtil { | |
| public static String getRequestIp(final HttpServletRequest request) { | |
| String ip = request.getHeader("X-Forwarded-For"); | |
| if (ip == null) { | |
| return request.getRemoteAddr(); | |
| } | |
| ip = ip.trim(); |
| #!/bin/bash | |
| #./createMasters.sh 7001 5 redis-cluster-m- comodal/alpine-redis | |
| readonly STARTING_PORT=${1:-0} | |
| readonly NUM_MASTERS=${2:-0} | |
| readonly NAME_PREFIX=${3:-"redis-cluster-m-"} | |
| readonly IMAGE=${4:-"comodal/alpine-redis"} | |
| for ((port = STARTING_PORT, endPort = port + NUM_MASTERS; port < endPort; port++)) do | |
| name="$NAME_PREFIX$port" | |
| docker service create\ | |
| --name "$name"\ |
| #!/bin/bash | |
| #./meetNodes.sh 7001 5 redis-cluster-m- | |
| readonly STARTING_PORT=${1:-0} | |
| readonly NUM_MASTERS=${2:-0} | |
| readonly NAME_PREFIX=${3:-"redis-cluster-m-"} | |
| readonly LOCAL_CONTAINER_ID=$(docker ps -f name="$NAME_PREFIX" -q | head -n 1) | |
| readonly LOCAL_PORT=$(docker inspect --format='{{index .Config.Labels "com.docker.swarm.service.name"}}' "$LOCAL_CONTAINER_ID" | sed 's|.*-||') | |
| # From local service task, meet all other nodes | |
| for ((port = STARTING_PORT, endPort = STARTING_PORT + NUM_MASTERS; port < endPort; port++)) do | |
| if [ "$LOCAL_PORT" == $port ]; then |