Commits

Scott Fritchie committed 6efde18

Add support to Hibari driver for Thrift encoding for UBF protocols

  • Participants
  • Parent commits 34d5c21

Comments (0)

Files changed (2)

File examples/hibari.config

+%% -*- mode: erlang -*-
+
 {mode, max}.
 %% Remember: actual rate = mode rate (below) * concurrent (below)
 %%
 %% generators?
 %{mode, {rate, 8}}.
 
-{duration, 15}.                                  % 1 minute is very short
+{duration, 15}.                                   % 1 minute is very short
 
 {concurrent, 100}.                                % 5 is low for Hibari
 
               "/Users/fritchie/src/hibari/src/erl-apps/gdss-ubf-proto__HEAD/ebin",
               "/Users/fritchie/src/hibari/src/erl-third-party/mochiweb__HEAD/ebin",
               "/Users/fritchie/src/hibari/src/erl-tools/ubf-jsonrpc__HEAD/ebin",
+              "/Users/fritchie/src/hibari/src/erl-tools/ubf-thrift__HEAD/ebin",
               "/Users/fritchie/src/hibari/src/erl-tools/ubf__HEAD/ebin"
              ]}.
 
-%{key_generator, {uniform_int_bin, 35000}}.
 {key_generator, {int_to_bin, {uniform_int, 99000}}}.
 
 {value_generator, {fixed_bin, 1000}}.
 %{value_generator, {fixed_bin, 10000}}.
 
-%% Default is [{get,4}, {put,4}, {delete, 1}] which means that out
-%% of every 9 operations, 'get' will be called four times, 'put' will
+%% Default is [{get,4}, {put,4}, {delete, 1}] which means that out of
+%% every 9 operations, 'get' will be called four times, 'put' will
 %% called four times, and 'delete' will be called once, on average.
 
 {operations, [{get,4}, {put,4}, {delete, 1}]}.
 
 %% hibari_client_type
 %%
-%% Type of Hibari client: native, ubf, ebf, jsf, json_rpc
+%% Type of Hibari client: native, ubf, ebf, jsf, tbf, json_rpc
 %% Uncomment only one of the pairs below.
 %%
 %% hibari_server_tcp_port
 %%    EBF        7580
 %%    UBF        7581
 %%    JSF        7582
+%%    TBF        7583
+%%
+%% hibari_server_service: undefined, gdss, gdss_stub
+%%
+%% For use with all Hibari clients other than the native Erlang client.
+%% (This attribute is ignored by the native Erlang client.)
+%%
+%% UBF service for the target server.  The service "gdss" is the
+%% default service.  The service "gdss_stub" can be used to measure
+%% the latency (and throughput) of the UBF rpc transport.
+%%
 
-%% TODO: Native type is broken due to gmt app can't start because of
-%%       reliance on init:get_argument(), and bash_bench isn't starting
-%%       with the extra cmd line args necessary.  Sending patch to Joe.
 %{hibari_client_type, native}.
 %{hibari_server_tcp_port, -1}.           % Value is unused but must be present
+%{hibari_server_service, undefined}.     % Value is unused but must be present
 
 {hibari_client_type, ebf}.
 {hibari_server_tcp_port, 7580}.
+{hibari_server_service, gdss}.
+%{hibari_server_service, gdss_stub}.
 
 %{hibari_client_type, ubf}.
 %{hibari_server_tcp_port, 7581}.
+%{hibari_server_service, gdss}.
+%{hibari_server_service, gdss_stub}.
 
 %% TODO: Hibari's JSF support is broken right now, but I'm not sure?
 %{hibari_client_type, jsf}.
 %{hibari_server_tcp_port, 7582}.
+%{hibari_server_service, gdss}.
+%{hibari_server_service, gdss_stub}.
+
+%{hibari_client_type, tbf}.
+%{hibari_server_tcp_port, 7583}.
+%{hibari_server_service, gdss}.
+%{hibari_server_service, gdss_stub}.
 
 %% TODO: SLF: Untested!  Try testing against bb2e?
 %{hibari_client_type, json_rpc}.
 %{hibari_server_tcp_port, 22982377582}.
+%{hibari_server_service, gdss}.
+%{hibari_server_service, gdss_stub}.
 
 %% hibari_servers
-%% 
-%% For use with all Hibari clients other than the native Erlang client.
-%% (This attribute is ignored by the native Erlang client.)
+%%
+%% For use with all Hibari clients other than the native Erlang
+%% client.  (This attribute is ignored by the native Erlang client.)
 %%
 %% Each concurrent load generator will use one server from this list.
-%% The assignment is made at plugin initialization time and will not change
-%% for the life of the load generator process.
+%% The assignment is made at plugin initialization time and will not
+%% change for the life of the load generator process.
 %%
 %% This list should include all Hibari servers in the cluster.  The
 %% list may contain valid DNS hostnames and/or IP addresses, both as
 %% don't put a comma after the last item in the list.)
 
 {hibari_servers, [
-                  %%"localhost"
-                  "bb2e"
+                  "localhost"
                  ]}.
 
 %% hibari_native_1node
 %% node in the Hibari cluster.  After we connect to that node, we'll
 %% automatically become aware of all other nodes in the cluster.
 
-{hibari_native_1node, 'gdss_dev2@sbb'}.
+{hibari_native_1node, 'gdss1@localhost'}.
 
 %% hibari_native_my_sname
 %%
 %% For the Erlang native client, this is the name of the basho_bench
-%% node.
+%% node.  Before running the test, it is recommended to register this
+%% native Erlang client's nodename for monitoring by the Hibari admin
+%% server.  Please click on the "Add/Delete a client node monitor."
+%% link of the Hibari admin server's webpage for further information.
 
 {hibari_native_my_sname, 'basho_bench'}.
 
 %% be sure to use single quotes.
 
 {hibari_native_cookie, 'SKHZSZEOIVIYDXBZQHOB'}.
-

File src/basho_bench_driver_hibari.erl

           id,
           hibari_servers,
           hibari_port,
+          hibari_service,
           clnt,
-          table
+          table,
+          value_generator
          }).
 
 %% ====================================================================
                 "/path/to/your-hibari-distro/src/erl-apps/cluster-info__HEAD/ebin"},
                {jsf,
                 "/path/to/your-hibari-distro/src/erl-tools/ubf-jsonrpc__HEAD/ebin"},
+               {tbf,
+                "/path/to/your-hibari-distro/src/erl-tools/ubf-thrift__HEAD/ebin"},
                {mochijson2,
                 "/path/to/your-hibari-distro/src/erl-third-party/mochiweb__HEAD/ebin"},
                {ubf_client,
     HibariServers = basho_bench_config:get(hibari_servers),
     HibariType = basho_bench_config:get(hibari_client_type),
     HibariTcpPort = basho_bench_config:get(hibari_server_tcp_port),
+    HibariService = basho_bench_config:get(hibari_server_service),
     Native1Node = basho_bench_config:get(hibari_native_1node),
     NativeSname = basho_bench_config:get(hibari_native_my_sname),
     NativeTickTime = basho_bench_config:get(hibari_native_ticktime),
     NativeCookie = basho_bench_config:get(hibari_native_cookie),
+    ValueGenerator = basho_bench_config:get(value_generator),
 
     Clnt = make_clnt(HibariType, Id, NativeSname, NativeTickTime, NativeCookie,
-                     Native1Node, HibariServers, HibariTcpPort, false),
+                     Native1Node, HibariServers, HibariTcpPort, HibariService, ValueGenerator, false),
 
     {ok, #state{hibari_type = HibariType,
                 id = Id,
                 hibari_servers = HibariServers,
                 hibari_port = HibariTcpPort,
+                hibari_service = HibariService,
                 clnt = Clnt,
-                table = Table
+                table = Table,
+                value_generator = ValueGenerator
                }}.
 
 run(get, KeyGen, _ValueGen, #state{hibari_type = ClientType, clnt = Clnt,
         [{ok, _TS, _Val}] ->
             {ok, S};
         [key_not_exist] ->
-            %%io:format("g!"),
             {ok, S};
         timeout ->
             {error, timeout, close_and_reopen(S)};
         [ok] ->
             {ok, S};
         [key_not_exist] ->
-            %%io:format("d!"),
             {ok, S};
         timeout ->
             {error, timeout, close_and_reopen(S)};
         {error, {_X, _Y}}
     end;
 do(Type, Clnt, Table, OpList)
-  when Type == ubf; Type == ebf; Type == jsf ->
+  when Type == ubf; Type == ebf; Type == jsf; Type == tbf ->
     try begin
             DoOp = {do, Table, OpList, [], ?BASIC_TIMEOUT+100},
             {reply, Res, none} = ubf_client:rpc(Clnt, DoOp, ?BASIC_TIMEOUT),
     end.
 
 make_clnt(HibariType, Id, NativeSname, NativeTickTime, NativeCookie,
-          Native1Node, HibariServers, HibariTcpPort, RetryP) ->
+          Native1Node, HibariServers, HibariTcpPort, HibariService, ValueGenerator, RetryP) ->
     case HibariType of
         native when Id == 1 ->
             ?INFO("Try to start net_kernel with name ~p\n", [NativeSname]),
         native ->
             %% All the work was done above in Id == 1 clause
             undefined;
-        X when X == ebf; X == ubf; X == jsf ->
+        X when X == ebf; X == ubf; X == jsf; X == tbf ->
             %% Choose the node using our ID as a modulus
             Server = lists:nth((Id rem length(HibariServers)+1),
                                HibariServers),
             case ubf_client:connect(Server, HibariTcpPort,
                                     [{proto, HibariType}], 60*1000) of
                 {ok, Pid, _} ->
+                    Args =
+                        case HibariService of
+                            gdss_stub ->
+                                case ValueGenerator of
+                                    %% extract and set value size to be used for gdss stub's get responses
+                                    {value_generator, {fixed_bin, ValueSize}} when is_integer(ValueSize) ->
+                                        [{get_value_size, ValueSize}];
+                                    _ ->
+                                        []
+                                end;
+                            _ ->
+                                []
+                        end,
                     {reply, {ok, ok}, none} =
-                        ubf_client:rpc(Pid, {startSession, ?S("gdss"), []},
+                        ubf_client:rpc(Pid, {startSession, ?S(atom_to_list(HibariService)), Args},
                                        60*1000),
                     Pid;
                 Error ->
             end
     end.
 
-%% UBF/EBF/JSF timeouts cause problems for basho_bench.  If we report
-%% an error, we'll timeout.  But if we don't report an error, then
-%% basho_bench will assume that we can continue using the same #state
-%% and therefore the same UBF/EBF/JSF client ... but that client is
-%% now in an undefined state and cannot be used again.
+%% UBF/EBF/JSF/TBF timeouts cause problems for basho_bench.  If we
+%% report an error, we'll timeout.  But if we don't report an error,
+%% then basho_bench will assume that we can continue using the same
+%% #state and therefore the same UBF/EBF/JSF/TBF client ... but that
+%% client is now in an undefined state and cannot be used again.
 %%
 %% So, we use this function to forcibly close the current client and
 %% open a new one.  For the native client, this ends up doing almost
                         id = OldId,
                         hibari_type = HibariType,
                         hibari_servers = HibariServers,
-                        hibari_port = HibariTcpPort} = S) ->
+                        hibari_port = HibariTcpPort,
+                        hibari_service = HibariService,
+                        value_generator = ValueGenerator} = S) ->
     %%?INFO("close_and_reopen #~p\n", [OldId]),
     catch ubf_client:close(OldClnt),
 
             true                 -> OldId
          end,
     NewClnt = make_clnt(HibariType, Id, foo, foo, foo,
-                        foo, HibariServers, HibariTcpPort, true),
+                        foo, HibariServers, HibariTcpPort, HibariService, ValueGenerator, true),
     S#state{clnt = NewClnt}.
-