Skip to content

Instantly share code, notes, and snippets.

View binarytemple's full-sized avatar

Bryan Hunt binarytemple

  • The mountains of mourne
View GitHub Profile
#!/usr/bin/env python
import httplib
import json
from datetime import datetime, date, time
from time import sleep
import os.path
from multiprocessing import Process
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
echo "Data load start time: $(date +%s)"
for i in {1..100}
do
curl -XPOST http://localhost:10018/riak/some_bucket -d "$RANDOM" -H "X-Riak-Index-Timestamp_int: $(date +%s)" -H "Content-Type: text/plain"
sleep 0.5
done
echo "Data load end time: $(date +%s)"
echo "Running MapReduce"
curl -XPOST http://localhost:10018/mapred -H "Content-Type: application/json" -d '
@binarytemple
binarytemple / scr27.md
Last active August 29, 2015 14:06 — forked from slfritchie/scr27.md

Riak Source Code Reading #27: Riak KV backend API and storage

The Riak KV backend store API

behaviour_info(callbacks) ->
    [
     {api_version,0},

10 Erlang one liners to impress your friends

  1. Multiple Each Item in a List by 2:

[X * 2 || X <- lists:seq(1, 11)].

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two

sample

  • timeout(sec) : 5
  • message count: 2
(riak1@127.0.0.1)14> redbug:start(5000, 2, {riak_kv_keys_fsm,'_'}).
ok

16:23:32 <{riak_core_coverage_fsm,init,1}> {riak_kv_keys_fsm,init,
%% Get the state for the local node
%% The get_my_ring function really returns the ring
%% plus other state information about the cluster.
{ok, State} = riak_core_ring_manager:get_my_ring().
%% Get number of partitions
riak_core_ring:num_partitions(State).
%% Get the names of custom buckets
riak_core_ring:get_buckets(State).
%% Get the state for the local node
%% The get_my_ring function really returns the ring
%% plus other state information about the cluster.
{ok, State} = riak_core_ring_manager:get_my_ring().
%% Get number of partitions
riak_core_ring:num_partitions(State).
%% Get the names of custom buckets
riak_core_ring:get_buckets(State).