1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2001-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20%%% File : bench.hrl 21%%% Author : Hakan Mattsson <hakan@cslab.ericsson.se> 22%%% Purpose : Define various database records 23%%% Created : 21 Jun 2001 by Hakan Mattsson <hakan@cslab.ericsson.se> 24%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 25 26-record(config, 27 { 28 generator_profile = random, 29 generator_warmup = timer:seconds(2), 30 generator_duration = timer:seconds(15), 31 generator_cooldown = timer:seconds(2), 32 generator_nodes = [node() | nodes()], 33 statistics_detail = debug, 34 n_generators_per_node = 1, 35 write_lock_type = sticky_write, 36 table_nodes = [node() | nodes()], 37 storage_type = ram_copies, 38 n_subscribers = 25000, 39 n_groups = 5, 40 n_servers = 1, 41 n_replicas = 1, 42 n_fragments = 100, 43 use_binary_subscriber_key = false, 44 always_try_nearest_node = false, 45 cookie = 'bench' 46 }). 47 48-record(subscriber, 49 { 50 subscriber_number, % string (10 chars) 51 subscriber_name, % string (32 chars) 52 group_id, % integer (uint32) 53 location, % integer (uint32) 54 active_sessions, % array of 32 booleans (32 bits) 55 changed_by, % string (25 chars) 56 changed_time, % string (25 chars) 57 suffix 58 }). 59 60-record(group, 61 { 62 group_id, % integer (uint32) 63 group_name, % string (32 chars) 64 allow_read, % array of 32 booleans (32 bits) 65 allow_insert, % array of 32 booleans (32 bits) 66 allow_delete % array of 32 booleans (32 bits) 67 }). 68 69-record(server, 70 { 71 server_key, % {ServerId, SubscriberNumberSuffix} 72 server_name, % string (32 chars) 73 no_of_read, % integer (uint32) 74 no_of_insert, % integer (uint32) 75 no_of_delete, % integer (uint32) 76 suffix 77 }). 78 79-record(session, 80 { 81 session_key, % {SubscriberNumber, ServerId} 82 session_details, % string (4000 chars) 83 suffix 84 }). 85 86-define(d(Format, Args), 87 io:format("~s" ++ Format, [string:left(lists:flatten(io_lib:format("~p(~p):", [?MODULE, ?LINE])), 30, $ ) | Args])). 88 89-define(e(Format, Args), 90 begin 91 ok = error_logger:format("~p(~p): " ++ Format, [?MODULE, ?LINE | Args]), 92 timer:sleep(1000) 93 end). 94 95-define(ERROR(M, F, A, R), 96 ?e("~w:~w~p\n\t ->~p\n", [M, F, A, R])). 97 98-define(APPLY(M, F, A), 99 fun() -> 100 case catch apply(M, F, A) of 101 ok -> {ok, ok}; 102 {atomic, R} -> {ok, R}; 103 {ok, R} -> {ok, R}; 104 {aborted, R} -> ?ERROR(M, F, A, R); 105 {error, R} -> ?ERROR(M, F, A, R); 106 R -> ?ERROR(M, F, A, R) 107 end 108 end()). 109