- Starting: https://github.com/basho/riak_kv/blob/1.4.2/src/riak_kv_wm_object.erl#L619
- We create a new
riak_objectand populate the various fields with the headers, metadata supplied by the client. - Big suprise, we eventually call
riak_client:put: https://github.com/basho/riak_kv/blob/1.4.2/src/riak_client.erl#L143 - If/when the client returns any errors these are handled in
handle_common_errorsand it is nice to return human readable errors to client :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib | |
| import httplib | |
| import json | |
| import sys | |
| def get_stats(ip, port=80): | |
| url = 'http://%s:%s/stats' % (ip, port) | |
| sock = urllib.urlopen(url) | |
| jsons = sock.read() | |
| obj = json.loads(jsons) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {ok, C} = riak:local_client(). | |
| {ok, Buckets} = C:list_buckets(). | |
| [ lk:fsm(B) || B <- Buckets ]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {ok, C} = riak:local_client(). | |
| {ok, Obj} = C:get(<<"bucket">>, <<"key">>). | |
| iolist_size(term_to_binary(Obj)). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(localstream). | |
| -export([load/1, keys/0, bucket/0, map/3]). | |
| -define(QUERY, [{map, {modfun, localstream, map}, none, true}]). | |
| load(HowMany) -> | |
| {ok, Client} = riak:local_client(), | |
| lists:foreach(fun(Index) -> | |
| BIndex = list_to_binary(integer_to_list(Index)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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 | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %%% Run with 'escript app_deps.erl' | |
| %%% Change the path in filelib:wildcard/1 as required to capture all | |
| %%% your dependencies. | |
| %%% | |
| %%% Rectangular nodes will represent library apps (no processes involved) | |
| %%% and the circular nodes will represent regular apps. An arrow going from | |
| %%% 'A -> B' means 'A depends on B'. | |
| %%% | |
| %%% This script depends on graphviz being present on the system. | |
| -module(app_deps). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %%% Run with 'escript app_deps.erl' | |
| %%% Change the path in filelib:wildcard/1 as required to capture all | |
| %%% your dependencies. | |
| %%% | |
| %%% Rectangular nodes will represent library apps (no processes involved) | |
| %%% and the circular nodes will represent regular apps. An arrow going from | |
| %%% 'A -> B' means 'A depends on B'. | |
| %%% | |
| %%% This script depends on graphviz being present on the system. | |
| -module(app_deps). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ``` | |
| Calc = fun(Bucket,Key) -> | |
| BKey = {Bucket,Key}, | |
| {ok, Ring} = riak_core_ring_manager:get_my_ring(), | |
| DocIdx = riak_core_util:chash_key(BKey), | |
| NValue = 1, | |
| UpNodes = riak_core_node_watcher:nodes(tanodb), | |
| Preflist2 = riak_core_apl:get_apl_ann(DocIdx, NValue, Ring, UpNodes), | |
| [Res] = [Part || {{Part,Node}, Type} <- Preflist2], | |
| Res |
Wrapper shell script:
$ cat ./riak_cs_inspector.sh
#!/bin/bash
ERL_LIBS=dev/dev1/lib dev/dev1/erts-5.9.3.1/bin/escript \
dev/dev1/lib/riak_cs/priv/tools/internal/riak_cs_inspector.erl $*
Usage: