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
@binarytemple
binarytemple / Garbage.erl
Created October 17, 2017 10:22 — forked from angrycub/Garbage.erl
Helper Shell Funs for Riak CS Cleanup
%% Shell functions that can be run in `riak-cs attach`
%% Peek({S3Bucket, Key}) will fetch an object and display the sibling count and
%% the number of manifests in the object.
Peek = fun({Bucket, Key}) ->
io:format("Peeking at ~p/~p.~n", [Bucket, Key]),
{ok, RcPid} = riak_cs_riak_client:checkout(),
ManifestBucket = riak_cs_utils:to_bucket_name(objects, Bucket),
ok = riak_cs_riak_client:set_bucket_name(RcPid, Bucket),
@binarytemple
binarytemple / force_remove_s3_bucket.erl
Created October 17, 2017 10:22 — forked from angrycub/force_remove_s3_bucket.erl
Snippet to forcibly remove a CS Bucket from a Riak CS User
Force_remove_s3_bucket = fun(UserID, Bucket) ->
Update_user_buckets = fun(User, Bucket) ->
Buckets = User#rcs_user_v2.buckets,
%% At this point any siblings from the read of the
%% user record have been resolved so the user bucket
%% list should have 0 or 1 buckets that share a name
%% with `Bucket'.
case [B || B <- Buckets, B#moss_bucket_v1.name =:= Bucket#moss_bucket_v1.name] of
[] ->
{ok, User#rcs_user_v2{buckets=[Bucket | Buckets]}};
@binarytemple
binarytemple / convert_binary_ring.sh
Created October 17, 2017 10:22 — forked from angrycub/convert_binary_ring.sh
Convert Binary Ring to Text
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname convert_binary_ring -mnesia debug verbose
main([RingFile, OutFile]) ->
try
{ok, Binary} = file:read_file(RingFile),
Ring = binary_to_term(Binary),
try
file:write_file(OutFile, io_lib:format("~p.~n", [Ring])),
@binarytemple
binarytemple / example_errors.md
Created October 17, 2017 10:21 — forked from angrycub/example_errors.md
Examples of Riak Error Log Messages

eacces

Note: It is not eaccess

An example created when the ring folder is not owned by the user riak is running as:

2015-06-23 14:57:43.073 [error] <0.154.0>@riak_core_ring_manager:do_write_ringfile:236 Unable to write ring to "./data/ring/riak_core_ring.default.20150623185743" - {badmatch,{error,eacces}}

emfile

@binarytemple
binarytemple / README.md
Created October 17, 2017 10:21 — forked from angrycub/README.md
Erlang Supervisor Ghost Child Monitor

Erlang Supervisor Ghost Montior

Applies to:

  • Riak EE clusters with MDC:
    • 1.4.x - all versions
    • 2.0.x - all versions prior to Riak 2.0.7
    • 2.1.x - all version; fixed in 2.2.0

About

This workaround is a mitigation for basho/riak_kv#1178

@binarytemple
binarytemple / all_atoms.erl
Created October 17, 2017 10:21 — forked from angrycub/all_atoms.erl
Interesting Atom Module
-module(all_atoms).
-export([all_atoms/0, node_atoms/0, node_atoms/1]).
atom_by_number(Index) ->
binary_to_term(<<131,75,Index:24>>).
all_atoms() ->
atoms_starting_at(0).
@binarytemple
binarytemple / Streaming2iReader.java
Created October 17, 2017 10:21 — forked from angrycub/Streaming2iReader.java
Sample code to read through nasty multipart/mixed response to get to individual json chunks,
package com.basho;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import org.apache.wink.common.internal.providers.multipart.MultiPartParser;
@binarytemple
binarytemple / pinger.erl
Created October 17, 2017 10:21 — forked from angrycub/pinger.erl
Ping Riak nodes
-module(pinger).
-export([ping/1,
ping/3,
pinglist/4,
pingall/0,
pingall/1,
pingall/2
]).
@binarytemple
binarytemple / Build a ring using riak_core_claim_sim
Created October 17, 2017 10:21 — forked from angrycub/Build a ring using riak_core_claim_sim
This will enable a ring to be created using riak_core_claim_sim. These rings could then be used to bootstrap a cluster without having to do the join steps.
RingSize = 32,
FirstNodeName = 'riak@127.0.0.1',
NewRing = riak_core_claim_sim:run([
{ring, riak_core_ring:fresh(RingSize, FirstNodeName)},
{target_n_val,4},
{wants,{riak_core_claim,wants_claim_v3}},
{choose,{riak_core_claim,choose_claim_v3}},
{cmds, [[
{join, 'riak@127.0.0.2'},
{join, 'riak@127.0.0.3'},
%% -------------------------------------------------------------------------
%%
%% leveldb_stat_collector: collect statistics from leveldb internal counters
%% to file
%%
%% Copyright (c) 2016 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you 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