<commit_before>% Copyright (c) 2010, NorthScale, Inc.
% All rights reserved.

-module(ns_config_default).

-export([default/0, mergable/1,
         default_data_directory/0,
         find_root/1, is_root/1]).

default() ->
    [{directory, default_data_directory()},
     {rest, [{port, 8080} % Port number of the REST admin API and UI.
            ]},
     {rest_creds, [{creds, []}]},
     {port_servers, [{memcached, "./memcached",
                      [% "-E", "engines/default_engine.so",
                       "-p", "11212"
                      ],
                      [{env, [{"MEMCACHED_CHECK_STDIN", "thread"}]}]
                     }
                    ]},
     {alerts, []},
     {pools, [{"default",
               [{port, 11211},
                {buckets, [{"default",
                            [{auth_plain, undefined},
                             {size_per_node, 64} % In MB.
                            ]}
                          ]}
               ]}
             ]},
     {nodes_wanted, []}
    ].

default_data_directory() ->
    % When installed, we live in something that looks like...
    %
    %   C:/Program Files/NorthScale/Server/
    %     bin/
    %       ns_server/ebin/ns_config_default.beam
    %     priv/
    %       config
    %     data
    %
    % If we find a directory that h
    %
    P1 = filename:absname(code:which(ns_config_default)), % Our beam path.
    P2 = filename:dirname(P1), % ".../ebin"
    P3 = filename:dirname(P2), % ".../ns_server"
    P4 = filename:dirname(P3), % might be sibling to /priv
    RootPath = case find_root(P4) of
                   false -> P3;
                   X     -> X
               end,
    DataPath = filename:join(RootPath, "data"),
    filelib:ensure_dir(DataPath),
    DataPath.

find_root("") -> false;
find_root(".") -> false;
find_root("/") -> false;
find_root(DirPath) ->
    case is_root(DirPath) of
        true  -> DirPath;
        false -> DirNext = filename:dirname(DirPath),
                 % Case when "c:/" =:= "c:/" on windows.
                 case DirNext =/= DirPath of
                     true  -> find_root(DirNext);
                     false -> false
                 end
    end.

is_root(DirPath) ->
    filelib:is_dir(filename:join(DirPath, "bin")) =:= true andalso
    filelib:is_dir(filename:join(DirPath, "priv")) =:= true.

mergable(_CurrList) ->
    [otp,
     rest,
     rest_creds,
     port_servers,
     alerts,
     pools,
     nodes_wanted].
<commit_msg>added test keys to ns_config_default<commit_after>% Copyright (c) 2010, NorthScale, Inc.
% All rights reserved.

-module(ns_config_default).

-export([default/0, mergable/1,
         default_data_directory/0,
         find_root/1, is_root/1]).

default() ->
    [{directory, default_data_directory()},
     {rest, [{port, 8080} % Port number of the REST admin API and UI.
            ]},
     {rest_creds, [{creds, []}]},
     {port_servers, [{memcached, "./memcached",
                      [% "-E", "engines/default_engine.so",
                       "-p", "11212"
                      ],
                      [{env, [{"MEMCACHED_CHECK_STDIN", "thread"}]}]
                     }
                    ]},
     {alerts, []},
     {pools, [{"default",
               [{port, 11211},
                {buckets, [{"default",
                            [{auth_plain, undefined},
                             {size_per_node, 64} % In MB.
                            ]}
                          ]}
               ]}
             ]},
     {nodes_wanted, []}
    ].

default_data_directory() ->
    % When installed, we live in something that looks like...
    %
    %   C:/Program Files/NorthScale/Server/
    %     bin/
    %       ns_server/ebin/ns_config_default.beam
    %     priv/
    %       config
    %     data
    %
    % If we find a directory that h
    %
    P1 = filename:absname(code:which(ns_config_default)), % Our beam path.
    P2 = filename:dirname(P1), % ".../ebin"
    P3 = filename:dirname(P2), % ".../ns_server"
    P4 = filename:dirname(P3), % might be sibling to /priv
    RootPath = case find_root(P4) of
                   false -> P3;
                   X     -> X
               end,
    DataPath = filename:join(RootPath, "data"),
    filelib:ensure_dir(DataPath),
    DataPath.

find_root("") -> false;
find_root(".") -> false;
find_root("/") -> false;
find_root(DirPath) ->
    case is_root(DirPath) of
        true  -> DirPath;
        false -> DirNext = filename:dirname(DirPath),
                 % Case when "c:/" =:= "c:/" on windows.
                 case DirNext =/= DirPath of
                     true  -> find_root(DirNext);
                     false -> false
                 end
    end.

is_root(DirPath) ->
    filelib:is_dir(filename:join(DirPath, "bin")) =:= true andalso
    filelib:is_dir(filename:join(DirPath, "priv")) =:= true.

mergable(_CurrList) ->
    [otp,
     rest,
     rest_creds,
     port_servers,
     alerts,
     pools,
     nodes_wanted,
     test0, test1, test2].

{'fraction_non_alphanumeric': 0.14336989032901296, 'fraction_numerical': 0.01415752741774676, 'mean_word_length': 1.5500762582613117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '782650', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1555, 'n_words': 325}