<commit_before>%  @copyright 2008-2011 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.

%% @author <NAME> <<EMAIL>>
%% @doc Cyclon overlay network.
%% 
%%      This can be used in order to get random nodes, e.g. by vivaldi and
%%      gossip.
%% @end
%% @reference <NAME>, <NAME>, <NAME>. CYCLON:
%% Inexpensive Membership Management for Unstructured P2P Overlays.
%% Journal of Network and Systems Management, Vol. 13, No. 2, June 2005.
%% @version $Id$
-module(cyclon).
-author('<EMAIL>').
-vsn('$Id$').

-behaviour(gen_component).

-include("scalaris.hrl").

-export([start_link/1]).

% functions gen_component and the config module use
-export([init/1, on_inactive/2, on_active/2,
         activate/0, deactivate/0,
         rm_send_changes/4,
         check_config/0]).

% helpers for creating getter messages:
-export([get_subset_rand/1,
         get_subset_rand_next_interval/1, get_subset_rand_next_interval/2]).

%% -export([get_ages/0, get_ages/1]).

%% State of the cyclon process:
%% {Cache, Node, Cycles, TriggerState}
%% Node: the scalaris node of this cyclon-task
%% Cycles: the amount of shuffle-cycles
-type(state_active() :: {RandomNodes::cyclon_cache:cache(),
                         MyNode::node:node_type() | null,
                         Cycles::integer(), TriggerState::trigger:state()}).
-type(state_inactive() :: {inactive, QueuedMessages::msg_queue:msg_queue(),
                           TriggerState::trigger:state()}).
%% -type(state() :: state_active() | state_inactive()).

% accepted messages of an active cyclon process
-type(message() ::
    {cy_shuffle} |
    {rm_changed, NewNode::node:node_type()} |
    {cy_subset, SourcePid::comm:mypid(), PSubset::cyclon_cache:cache()} |
    {cy_subset_response, QSubset::cyclon_cache:cache(), PSubset::cyclon_cache:cache()} |
    {get_node_details_response, node_details:node_details()} |
    {get_dht_nodes_response, Nodes::[comm:mypid()]} | 
    {get_ages, SourcePid::comm:erl_local_pid()} |
    {get_subset_rand, N::pos_integer(), SourcePid::comm:erl_local_pid()} |
    {web_debug_info, Requestor::comm:erl_local_pid()}).

-define(SEND_OPTIONS, [{channel, prio}]).
% prevent warnings in the log
% (the entry for a failed node will age and will be removed when it is old enough)
-define(SEND_TO_GROUP_MEMBER(Pid, Process, Msg), comm:send(Pid, Msg, [{group_member, Process}, {?quiet}, {channel, prio}])).<commit_msg>cyclon: use no_keep_alive for gossip messages<commit_after>%  @copyright 2008-2011 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.

%% @author <NAME> <<EMAIL>>
%% @doc Cyclon overlay network.
%% 
%%      This can be used in order to get random nodes, e.g. by vivaldi and
%%      gossip.
%% @end
%% @reference <NAME>, <NAME>, <NAME>. CYCLON:
%% Inexpensive Membership Management for Unstructured P2P Overlays.
%% Journal of Network and Systems Management, Vol. 13, No. 2, June 2005.
%% @version $Id$
-module(cyclon).
-author('<EMAIL>').
-vsn('$Id$').

-behaviour(gen_component).

-include("scalaris.hrl").

-export([start_link/1]).

% functions gen_component and the config module use
-export([init/1, on_inactive/2, on_active/2,
         activate/0, deactivate/0,
         rm_send_changes/4,
         check_config/0]).

% helpers for creating getter messages:
-export([get_subset_rand/1,
         get_subset_rand_next_interval/1, get_subset_rand_next_interval/2]).

%% -export([get_ages/0, get_ages/1]).

%% State of the cyclon process:
%% {Cache, Node, Cycles, TriggerState}
%% Node: the scalaris node of this cyclon-task
%% Cycles: the amount of shuffle-cycles
-type(state_active() :: {RandomNodes::cyclon_cache:cache(),
                         MyNode::node:node_type() | null,
                         Cycles::integer(), TriggerState::trigger:state()}).
-type(state_inactive() :: {inactive, QueuedMessages::msg_queue:msg_queue(),
                           TriggerState::trigger:state()}).
%% -type(state() :: state_active() | state_inactive()).

% accepted messages of an active cyclon process
-type(message() ::
    {cy_shuffle} |
    {rm_changed, NewNode::node:node_type()} |
    {cy_subset, SourcePid::comm:mypid(), PSubset::cyclon_cache:cache()} |
    {cy_subset_response, QSubset::cyclon_cache:cache(), PSubset::cyclon_cache:cache()} |
    {get_node_details_response, node_details:node_details()} |
    {get_dht_nodes_response, Nodes::[comm:mypid()]} | 
    {get_ages, SourcePid::comm:erl_local_pid()} |
    {get_subset_rand, N::pos_integer(), SourcePid::comm:erl_local_pid()} |
    {web_debug_info, Requestor::comm:erl_local_pid()}).

-define(SEND_OPTIONS, [{channel, prio}, {no_keep_alive}]).
% prevent warnings in the log
% (the entry for a failed node will age and will be removed when it is old enough)
-define(SEND_TO_GROUP_MEMBER(Pid, Process, Msg), comm:send(Pid, Msg, [{group_member, Process},
                                                                      {?quiet}, {channel, prio}, {no_keep_alive}])).
{'fraction_non_alphanumeric': 0.1369246164109406, 'fraction_numerical': 0.011007338225483656, 'mean_word_length': 3.9398682042833606, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1301780', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1901, 'n_words': 526}