% @copyright 2007-2016 Zuse Institute Berlin

%    Licensed 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 License for the specific language governing permissions and
%    limitations under the License.

% $Id$

%% @doc how many scalaris nodes per vm
{nodes_per_vm,1}.

%% DeadNode Cache Parameters
%% @doc zombieDetectorInterval
{zombieDetectorInterval, 10000}.
%% @doc how many dead nodes have to be observed
{zombieDetectorSize, 10}.

%% log4erl log parameters (before log4erl is started, error_logger with
%% parameters from preconfig will be used)
{log_path, "../log"}.
%% @doc Loglevel: debug < info < warn < error < fatal < none
{log_level, warn}.
{log_level_file, warn}.
%% @doc Specify name without extension (".txt" will be used).
%%      The two different logger's file names must be unique!
{log_file_name_errorlogger, "scalaris_error_logger"}.
{log_file_name_log4erl, "scalaris_log4erl"}.
{log_file_size, 1048576}. % 1024*1024
{log_file_rotations, 4}. % results in to up to 5 files

%% @doc LogFormat, see Readme for log4erl
{log_format,"[%L] %l%n"}.
{log_format_file,"%j %T [%L] %l%n"}.


%% @doc the initial number of milliseconds between two failure
%% detector checks
{failure_detector_interval, 3000}.

%% @doc number of milliseconds between two re-registrations at the mgmt_server
{reregister_interval, 600000}.

%% @doc the replication degree of the system
{replication_factor, 4}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Overlay/ring maintenance
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% @doc the interval between two stabilization runs
{stabilization_interval_base, 10000}.

%% @doc the length of the successor list
{succ_list_length, 9}.

%% @doc the length of the predecessor list
{pred_list_length, 9}.

%% @doc the interval between two requests for new cyclon nodes to integrate
%%      (in Seconds)
{tman_cyclon_interval, 5}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% routing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% @doc the interval between two finger/pointer stabilization runs
{pointer_base_stabilization_interval, 30000}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% redundancy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% data redundancy strategy (default is replication)
{redundancy_module, replication}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% replication
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% key_creation algorithm
{key_creator, random}.

%{key_creator, random_with_bit_mask}.
% (randomkey band mask2) bor mask1
%{key_creator_bitmask, {16#00000000000000000000000000000000, 16#3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}}.
%{key_creator_bitmask, {16#40000000000000000000000000000000, 16#3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}}.
%{key_creator_bitmask, {16#80000000000000000000000000000000, 16#3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}}.
%{key_creator_bitmask, {16#C0000000000000000000000000000000, 16#3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% chord
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{chord_base, 64}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% (g)frtchord
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% @doc enable active learning lookups
{rt_frt_al, true}.

%% @doc the interval between active learning lookups for rt_frt
{rt_frt_al_interval, 5}. % in s

%% @doc configure the maximum size for routing tables.
{rt_frt_max_entries, 32}.

%% @doc the interval between gossip is queried for a ring size estimate
{rt_frt_gossip_interval, 10}. % in s

%% @doc choose the strategy for rt refinement.
%% - best_rt_reduction_ratio: send message if worse than reduction ratio for a best rt
%% - convergent_rt_reduction_ratio: send message if worse than reduction ratio for a convergent rt
{rt_frt_reduction_ratio_strategy, best_rt_reduction_ratio}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Gossip
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Gossip based load aggregation

{gossip_load_interval, 1000}.
{gossip_load_min_cycles_per_round, 10}.
{gossip_load_max_cycles_per_round, 1000}.
{gossip_load_fanout, 1}.
{gossip_load_convergence_count_best_values, 10}.
{gossip_load_convergence_count_new_round, 20}.
{gossip_load_convergence_epsilon, 5.0}.
{gossip_load_number_of_buckets, 10}.
{gossip_load_additional_modules, [lb_active_gossip_load_metric, lb_active_gossip_request_metric]}.

%% Cyclon (gossip based peer sampling)

{gossip_cyclon_interval, 4900}.
{gossip_cyclon_cache_size, 20}.
{gossip_cyclon_shuffle_length, 8}.


%% Vivaldi (network coordinates)

{gossip_vivaldi_interval, 10000}. % in milliseconds
{gossip_vivaldi_dimensions, 2}.
{gossip_vivaldi_count_measurements, 10}.
{gossip_vivaldi_measurements_delay, 1}. % in seconds
{gossip_vivaldi_latency_timeout, 60}. % in seconds


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Ganglia
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{ganglia_enable, false}.
{ganglia_interval, 30000}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DC clustering
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{dc_clustering_enable, false}.
{dc_clustering_interval, 20000}.
{dc_clustering_reset_interval, 60000}.
{dc_clustering_radius, 10000.0}. % 10 ms radius


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% toke (tokyocabinet)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{db_directory, "../data"}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% transactions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{range_read_timeout, 5000}.
{tx_rtm_update_interval, 60000}.
{tx_timeout, 5000}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% paxos
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{learner_noinit_timeout, 5500}.
{acceptor_noinit_timeout, 5500}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% node move
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{move_use_incremental_slides, true}.
{move_max_transport_entries, 1000}.
{move_wait_for_reply_timeout, 30000}. % logs a warning if no reply is received within this many ms (will be checked every (<value> div 4) ms)
{move_send_msg_retry_delay, 1000}. % after receiving a send_error, wait this many ms before re-trying
{move_send_msg_retries, 2}. % logs a warning if a message could not be delivered after this many retries


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% node join
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{join_request_timeout, 1000}.
{join_request_timeouts, 3}.
{join_lookup_timeout, 3000}.
{join_known_hosts_timeout, 1000}.
{join_timeout, 30000}.
{join_get_number_of_samples_timeout, 1000}.
{join_lb_psv, lb_psv_gossip}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% passive load balancing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{lb_psv_samples, 2}. % rely on lb_psv_gossip to give O(log n) samples
{lb_psv_split_fallback, split_address}. % or: keep_key

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% active load balancing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{lb_active, false}.
%% see lb_active.erl for available modules
%% set to none to disable balancing
{lb_active_module, lb_active_karger}.

%% see lb_stats.erl for available metrics
{lb_active_load_metric, reductions}.
%% set to db_reads, db_writes, or db_all
{lb_active_request_metric, db_all}.
%% set to items or requests
{lb_active_balance, requests}.
%% fall back to items if no requests available
{lb_active_fall_back_to_items, true}.
%% use global information about metrics
{lb_active_use_gossip, true}.
%% threshold to calculate the minimum change in standard deviation to
%% determine whether to initiate a load balancing operation
{lb_active_gossip_stddev_threshold, 1}.
%% between 0 and 1 to set the minimum ratio between the requests
%% received on items and the number of total items at a node
{lb_active_request_confidence, 0.1}.

%% size of the request histogram
%% (when higher more accuracy but slower processing)
{lb_active_histogram_size, 100}.
%% interval size for metric data
{lb_active_monitor_resolution, 5000}.
%% how often to collect metric data
{lb_active_monitor_interval, 3000}.
%% minimum number of old metric values to consider
{lb_active_monitor_history_min, 3}.
%% maximum number of old metric values to consider
{lb_active_monitor_history_max, 12}.

%% maximum of time to wait for pending ops
{lb_active_wait_for_pending_ops, 10000}.

%% Karger and Ruhl module (lb_active_karger)
{lb_active_karger_interval, 10000}.
%% 0 < epsilon < 0.25 or set to self_tuning
{lb_active_karger_epsilon, 0.24}.
%% random nodes to contact each round
{lb_active_karger_rnd_nodes, 2}.
%% make a decision after this timeout
{lb_active_karger_simulation_timeout, 3000}.

%% Directory module (lb_active_directories)
%% how often to publish node information in directories
{lb_active_directories_publish_interval, 10000}.
%% how often to check a directory for load balancing
{lb_active_directories_directory_interval, 10000}.
%% maximum load balancing operations for a directory to initiate at once
{lb_active_directories_max_transfer, 2}.

% in case of jumps:
% supports active load balancing with passive load balancing
% when the node rejoins the ring
{lb_active_and_psv, false}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% monitoring
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for reported monitoring data, keep this many time slots (the slot length depends on the data)
{monitor_timeslots_to_keep, 360}. % 10s time slot -> keep data for 1 hour
{monitor_perf_interval, 30}. % start micro-benchmark every 30s (0 to disable)
{rrd_timing_hist_size, 20}. % for every timing value, create a histogram of size 20

% explicitly start OS monitor without active load balancing
{start_os_mon, false}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% network
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% port(s) for incoming communications, try one in this range
% (overwritten in startup scripts)
{port, {14195, 14198}}.

% http web server port for debug interface, JSON interface
% (overwritten in startup scripts)
{yaws_port, 8000}.

% the maximum size of a post request for the JSON-RPC
% (either a number of bytes, or nolimit)
{yaws_max_post_data, 1048576}. % 1MB

% http web server docroot
{docroot, "../docroot"}.

% Allows to restrict access to the web debug interface (including the JSON-RPC!).
% Expects a list of {"User", "Password"} tuples.
% Note: This will effectively disable the JSON-RPC including the Python and Ruby
%       APIs as they are not prepared to handle authentication yet.
{yaws_auth, []}.
%{yaws_auth, [{"User", "Password"}]}.

%% the following two parameters should both be smaller than failure_detector_interval
{tcp_send_timeout, 1000}.
{tcp_connect_timeout, 1000}.
{tcp_idle_timeout, 30000}.

% default: listen on all interfaces:
{listen_ip, {0,0,0,0}}.

% default assume local testing
{mgmt_server, {{127,0,0,1},14195,mgmt_server}}.
{known_hosts, [{{127,0,0,1},14195, service_per_vm}, {{127,0,0,1},14196, service_per_vm},
               {{127,0,0,1},14197, service_per_vm}, {{127,0,0,1},14198, service_per_vm}]}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% dht_node process modules (used for mockup_dht_node in unittests)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{dht_node, dht_node}.

%% collect lookup statistics?
{dht_node_monitor, true}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% rrepair processes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{rrepair_enabled, true}.
%{rr_recon_method, trivial}.
%{rr_recon_method, shash}.
%{rr_recon_method, bloom}.
{rr_recon_method, merkle_tree}.
%{rr_recon_method, art}.

% defines how many bits to use for encoding the version number in the 'trivial'
% phases of all above algorithms
% possible values: pos_integer() for fixed number of bits or 'variable' for
% using a number of bits based on the collision formulae
{rr_recon_version_bits, 32}.
% minimum number of bits to use for hash signatures other than the version number (> 0)
% note that additionally, this value is limited by the used algorithm's max value
% -> you should not change this!
{rr_recon_min_sig_size, 1}.

% when a non-graceful leave of a pred is found, resolve the missing items
{rrepair_after_crash, true}.

% probability of starting a synchronisation with a random node if trigger
% has fired. ]0,100]
{rr_trigger_probability, 33}.

% integer duration until next triggering (milliseconds)
%{rr_trigger_interval, 0}. % = periodic trigger disabled
{rr_trigger_interval, 600000}. % =10*60*1000 (every 10 minutes)

% garbage collector execution interval (milliseconds)
{rr_gc_interval, 3600000}. % = 1*60*60*1000 (every hour)

% time to live for sessions until they are garbage collected (milliseconds)
{rr_session_ttl, 600000}. % =10*60*1000 (10 minutes)

% probability of at least one false positive - in (0,1]
{rr_recon_p1e, 0.1}.

% specifies how many items to retrieve from the DB at once.
% (tries to reduce the load of a single request in the dht_node process)
{rr_max_items, 100000}. % pos_integer() | all.

% set reconciliation algorithm name, parameters (merkle)
{rr_merkle_branch_factor, 4}. % merkle tree branching factor thus number of childs per node (> 1)
{rr_merkle_bucket_size, 3}. % size of merkle tree leaf buckets (> 0)
% number of merkle trees a sync range is split into to reduce the number of
% message rounds when differences exist (it increases message costs when no
% differences exist though!)
{rr_merkle_num_trees, 32}. % (> 0)

% set reconciliation algorithm name, parameters (art)
% rr_merkle_branch_factor and rr_merkle_bucket_size from above are also used
{rr_art_inner_fpr, 0.001}.
{rr_art_leaf_fpr, 0.01}.
{rr_art_correction_factor, 2}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% leases
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%{leases, true}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% autoscale and cloud modules
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{autoscale, false}.
{autoscale_cloud_module, cloud_local}.
{autoscale_alarms, []}.

{autoscale_server, false}.
{autoscale_server_plot_path, ""}.

{cloud_local_min_vms, 0}.
{cloud_local_max_vms, 10}.

{cloud_ssh_hosts, []}.
{cloud_ssh_path, ""}.
{cloud_ssh_services, []}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% worker pool
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{wpool_maxw, 2}.
{wpool_js, false}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% db backend
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{ensure_recover, false}. % if true this will check on startup whether the current configuration allows recovery

{db_backend, db_ets}. % Can be db_ets, db_mnesia, db_toke, db_hanoidb


{db_prbr_chunker, db_prbr}.