Skip to content

Commit 397ba04

Browse files
author
Mathieu Lecarme
committed
Simple Carbon (from graphite project) driver.
1 parent 7a5decc commit 397ba04

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

examples/carbon.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{mode, max}.
2+
3+
{duration, 5}.
4+
5+
{concurrent, 100}.
6+
7+
{driver, basho_bench_driver_carbon}.
8+
9+
{operations, [{set, 1}]}.
10+
11+
{key_generator, {pareto_int, 100}}.
12+

src/basho_bench_driver_carbon.erl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-module(basho_bench_driver_carbon).
2+
3+
-export([new/1, run/4]).
4+
5+
-include("basho_bench.hrl").
6+
7+
-record(state, {
8+
host,
9+
port,
10+
keys
11+
}).
12+
13+
new(_Id) ->
14+
Host = basho_bench_config:get(carbon_server, "127.0.0.1"),
15+
Port = basho_bench_config:get(carbon_port, 2003),
16+
Keys = basho_bench_config:get(carbon_keys, 10),
17+
{ok, #state{host=Host, port=Port, keys=Keys}}.
18+
19+
run(set, KeyGen, _ValueGen, State) ->
20+
% io:format("SENDING: ~s\n", [Msg]),
21+
case gen_tcp:connect(State#state.host,
22+
State#state.port,
23+
[list, {packet, 0}]) of
24+
{ok, Sock} ->
25+
{Mega, Sec, _Micro} = now(),
26+
Msg = io_lib:format("pim.pam.poum.~p ~p ~p~n", [KeyGen(), (Mega * 1000 + Sec), random:uniform(1000)]),
27+
gen_tcp:send(Sock, Msg),
28+
gen_tcp:close(Sock),
29+
ok;
30+
E ->
31+
%error_logger:error_msg("Failed to connect to graphite: ~p", [E]),
32+
E
33+
end,
34+
{ok, State}.
35+

0 commit comments

Comments
 (0)