Skip to content

Instantly share code, notes, and snippets.

View angrycub's full-sized avatar

Charlie Voiselle angrycub

View GitHub Profile
@angrycub
angrycub / gist:3934789
Created October 22, 2012 21:56
Examples of Conditional PUTS using the riak-java-client.
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.IRiakObject;
import com.basho.riak.client.RiakFactory;
import com.basho.riak.client.bucket.Bucket;
import com.basho.riak.client.builders.RiakObjectBuilder;
public class RiakSandbox {
public static final String BUCKET_NAME = "conditionalPutTest";
@angrycub
angrycub / process.md
Created November 8, 2012 22:06
Replacing a Node to End with a Node of the Same Name

##Replacing a node with a machine of the same name ###Objective The goal is to replace a Riak instance with a new Riak instance of the same name so that the application environment does not need to have instance-name related changes.

###Scenario

Riak is running in a cluster of five nodes.

  • riak@node1.localdomain on node1.localdomain (192.168.17.11)
  • riak@node2.localdomain on node2.localdomain (192.168.17.12)
@angrycub
angrycub / LegacyRiakReplInstallation.md
Created November 14, 2012 19:12
Beginning of Replication Setup Documentation

Riak MDC Quick Start

The Riak MDC Quick Start will walk through the process of configuring Riak MDC replication to perform bidirectional replication between two exemplar Riak clusters in separate networks. Bidirectional replication is accomplished by setting up unidirectional replication in both directions between the clusters.

###Scenario Configure Riak MDC to perform bidirectional replication, given the following two (2) three-node Riak EE Clusters:

####Cluster 1

node1172.16.1.11riak@172.16.1.11
nameipnodename
@angrycub
angrycub / GameLeaderboard.java
Created November 29, 2012 22:36
Resolver Informing Transient Object Variable
package basho;
import com.basho.riak.client.convert.RiakKey;
import java.util.ArrayList;
import java.util.Collection;
import java.util.TreeSet;
import org.codehaus.jackson.annotate.JsonIgnore;
public final class GameLeaderboard
{
@angrycub
angrycub / gist:4447147
Created January 3, 2013 20:53
Unstick Schedulers
Scheds = erlang:system_flag(schedulers_online, 1),
timer:sleep(250),
_ = erlang:system_flag(schedulers_online, Scheds),
erlang:system_info(schedulers_online).
@angrycub
angrycub / process.md
Last active October 17, 2017 10:03
Using Force Remove to Change a nodes IP address.

##Using Force Replace to Change a nodes IP address. ###Objective Previous to Riak 1.2, a cluster node's IP address could be changed by running riak-admin reip on each cluster node. As of Riak 1.2, this method has been replaced with riak-admin cluster force-replace which is safer and does not require any downtime.

###Scenario

Riak is running in a cluster of five nodes.

  • riak@64.214.83.25 on node1.localdomain (192.168.17.11)(64.214.83.25)
  • riak@64.214.83.26 on node2.localdomain (192.168.17.12)(64.214.83.26)
@angrycub
angrycub / readme.md
Last active December 12, 2015 07:18
Simple Riak Replication Hook Sample

To install the sample hook,

  • Compile riak_repl_hook_sample.erl

    Note on the Erlang Compiler: You must use the Erlang compiler (erlc) associated with the Riak installation or the version of Erlang used when compiling Riak from source. For packaged Riak installations, you can consult Table 1 below for the default location of Riak’s erlc for each supported platform. If you compiled from source, use the erlc from the Erlang version you used to compile Riak.

    Distribution Path
    CentOS & RHEL Linux /usr/lib64/riak/erts-5.9.1/bin/erlc
    Debian & Ubuntu Linux /usr/lib/riak/erts-5.9.1/bin/erlc
@angrycub
angrycub / delete_mode.md
Created February 8, 2013 18:49
Mailing List Post from Jon Meredith about Delete Mode.

Summary/tl;dr - Riak 1.0.0 has introduced more control over deletion with the delete_mode setting.

If you plan to delete and recreate objects under the same key rapidly, and there is enough disk available to store tombstones, it is safest to set delete_mode to keep.

The default three second delay for removing tombstones balances keeping the tombstone around long enough for any rapid delete/recreates, but unlike the keep mode it does remove the data.

Riak keeps your objects available during failures by storing multiple copies of the data. This redundancy makes deletion more complex than a single node database. For example, Riak needs to ensure deletes issued while nodes are down get applied when the nodes recover, or resolve what happens if the network is partitioned and an object is deleted on one side but updated on the other side.

Deletes in Riak are a two step process, first it writes a tombstone objects to the N replicas and only once all replicas have stored the tombstone are they remove

@angrycub
angrycub / scratchpad.md
Last active December 14, 2015 12:18
All the phone things....

Using ADB to forward VNC

  • Plug in phone to USB

  • In command prompt run:

    adb forward tcp:5801 tcp:5801
    adb forward tcp:5901 tcp:5901
    
  • Make sure Droid VNC Server is started on the phone

% Purpose: I use this pre-commit hook to mark objects in a bucket as "dirty" with secondary indexing.
% I then use a script to scrape out all dirty objects, do some processing, then save them with
% "dirty_bin = false" as an index and the pre-commit hook erases the "dirty_bin" index.
% So in essence it works as: `if dirty_bin = false; del dirty_bin; else dirty_bin = true; end`
%
% To install this pre-commit hook (just like any Riak pre-commit hook in Erlang), you need to create an Erlang file and
% put it in your "basho-patches" directory. For me, on Ubuntu, this was "/usr/lib/riak/lib/basho-patches".
% Once there, you need to compile it to a .beam file. This was helped by using the Riak provided erlc compiler,
% which, on my Ubuntu system, was at "/usr/lib/riak/erts-5.8.5/bin/erlc"
%