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
-module(cs_manifest_siblings).
-compile(export_all).
start() ->
start(1).
%% @doc Trace to determine the number of siblings of Riak CS manifest
%% objects. The `Threshold' parameter is used to limit the output to
%% manifest objects whose sibling count is >= to `Threshold'.
start(Threshold) ->
#!/usr/bin/env escript
%% -*- coding: utf-8 -*-
%%! -pa /usr/lib64/riak-cs/lib/riakc-1.4.1/ebin /usr/lib64/riak-cs/lib/riak_pb-1.4.4.0/ebin /usr/lib64/riak-cs/lib/protobuffs-0.8.1/ebin /usr/lib64/riak-cs/lib/riak_cs-1.4.5/ebin /usr/lib/riak-cs/lib/riakc-1.4.1/ebin /usr/lib/riak-cs/lib/riak_pb-1.4.4.0/ebin /usr/lib/riak-cs/lib/protobuffs-0.8.1/ebin /usr/lib/riak-cs/lib/riak_cs-1.4.5/ebin
%%! -pa /usr/lib64/riak-cs/lib/riakc-1.3.1.1/ebin /usr/lib64/riak-cs/lib/riak_pb-1.3.0/ebin /usr/lib64/riak-cs/lib/protobuffs-0.8.0/ebin /usr/lib/riak-cs/lib/riakc-1.3.1.1/ebin /usr/lib/riak-cs/lib/riak_pb-1.3.0/ebin /usr/lib/riak-cs/lib/protobuffs-0.8.0/ebin /usr/lib/riak-cs/ebin
%%! -pa /Users/kelly/basho/repos/riak_cs/deps/riakc/ebin /Users/kelly/basho/repos/riak_cs/deps/riak_pb/ebin /Users/kelly/basho/repos/riak_cs/deps/protobuffs/ebin /Users/kelly/basho/repos/riak_cs/deps/riakc/ebin /Users/kelly/basho/repos/riak_cs/deps/riak_pb/ebin /Users/kelly/basho/repos/riak_cs/deps/protobuffs/ebin /Users/kelly/basho/repos/riak_cs/dep
@binarytemple
binarytemple / 2i.markdown
Last active August 29, 2015 14:03 — forked from kellymclaughlin/gist:4043845
riakc secondary index put

Indexes = [{<<"index1_bin">>, <<"val">>}, {<<"index2_int">>, 1}], Meta = dict:store(<<"index">>, Indexes, dict:new()), Obj = riakc_obj:new(<<"mybucket">>, <<"mykey">>, <<"myval">>), Obj1 = riakc_obj:update_metadata(Obj, Meta), riakc_pb_socket:put(RiakPid, Obj1).

%% Get current number of online schedulers
Schedulers = erlang:system_info(schedulers_online).
%% Reduce number online to 1
erlang:system_flag(schedulers_online, 1).
%% Restore to original number of online schedulers
erlang:system_flag(schedulers_online, Schedulers).

Trying to create...

A function which takes a function as it's argument, spawning it in new process, waiting for it's result, then returning the result.

I can't get the syntax right.

2> FooAsync =  fun(Infun) -> Parent = self(), spawn( fun() -> X = Infun(), Parent ! X  end ) , ok   end .
#Fun
ulimit -n 4096
for i in ./dev*/bin/riak ; do $i stop ; done
for i in ./dev*/bin/riak ; do $i start; done


./dev2/bin/riak-admin cluster join [email protected]
./dev3/bin/riak-admin cluster join [email protected]
./dev1/bin/riak-admin cluster plan
krab$ ../ej
** Erjang R15B03 ** [root:/usr/local/lib/erlang] [erts:5.9.3.1] [unicode]
Eshell V5.9.3.1 (abort with ^G)
1> erlang:load_nif("/Users/krab/Projects/riak/deps/bitcask/priv/bitcask.so", any).
ok
2> {ok,KeyDir} = bitcask_nifs:keydir_new().
{ok,<<>>}
3> bitcask_nifs:keydir_put_int(KeyDir, <<"key">>, 2, 100, <<123:64>>, 2222, 3333, 3, <<123:64>>).
already_exists
4> bitcask_nifs:keydir_put_int(KeyDir, <<"key">>, 2, 100, <<123:64>>, 2222, 3333, 0, <<123:64>>).
#!/usr/lib/riak/erts-5.7.5/bin/escript
%% -*- erlang -*-
%%! -pa /usr/lib/riak/lib/bitcask-1.1.6/ebin
%% Note: this script is designed for Riak 0.14.2 on Debian/Ubuntu
main([Root]) ->
case file:list_dir(filename:absname(Root)) of
{ok, VnodeDirs} ->
[ check_bitcask(filename:absname(Dir, Root)) || Dir <- VnodeDirs];
{error, Reason} ->
ListCask = fun(Vnode,OutFile) ->
Fold_data = fun(Handle) ->
FoldFun = fun(Key, _Ts, _PosInfo, {ok,Acc}) -> io:format(OutFile, "~p~n",[binary_to_term(Key)]),{ok,Acc + 1} end,
try bitcask_fileops:fold_keys(Handle, FoldFun, {ok,0}, datafile) of
{ok,A} -> A;
{error,E} -> {error, E}
catch
_Error ->
{error, io_lib:format("~s~s~n",["Corrupted datafile: ",bitcask_fileops:datafile_name(Handle)])}
-module(extract_bitcask).
main([Dir, Output]) ->
{ok, Fh} = file:open(Output,[write]),
io:format("Dumping bucket/keys for partition: ~p to output file: ~p\n", [Dir,Output]),
F = fun(Entry, _Acc) ->
case Entry of
{bitcask_entry, Key, _S, _T, _F, _U} ->
{B, K} = binary_to_term(Key),
erlang:put(extraction_counter, erlang:get(extraction_counter) + 1) ,