You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gossip.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/02/26 12:59:46 UTC
[jira] [Commented] (GOSSIP-49) Refactor Failure detector Lambda
into named class
[ https://issues.apache.org/jira/browse/GOSSIP-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15884738#comment-15884738 ]
ASF GitHub Bot commented on GOSSIP-49:
--------------------------------------
GitHub user makrusak opened a pull request:
https://github.com/apache/incubator-gossip/pull/37
GOSSIP-49 Refactor Failure detector Lambda into named class
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/makrusak/incubator-gossip GOSSIP-49
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-gossip/pull/37.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #37
----
commit c6c62290f73f9da7665f11c4c6ce8a3e7b95309f
Author: Maxim Rusak <ma...@yandex.ru>
Date: 2017-02-26T12:55:21Z
GOSSIP-49 Refactor Failure detector Lambda into named class
----
> Refactor Failure detector Lambda into named class
> -------------------------------------------------
>
> Key: GOSSIP-49
> URL: https://issues.apache.org/jira/browse/GOSSIP-49
> Project: Gossip
> Issue Type: Improvement
> Reporter: Edward Capriolo
> Assignee: Maxim Rusak
> Fix For: 0.1.2
>
>
> When receiving a message the PassiveGossipThread updates heartbeats. Currently a lambda in the GossipManager, which periodically moves through the list and marks hosts as down and fires the event notification listner:
> {noformat}
> scheduledServiced.scheduleAtFixedRate(() -> {
> try {
> for (Entry<LocalGossipMember, GossipState> entry : members.entrySet()) {
> Double result = null;
> try {
> result = entry.getKey().detect(clock.nanoTime());
> //System.out.println(entry.getKey() +" "+ result);
> if (result != null) {
> if (result > settings.getConvictThreshold() && entry.getValue() == GossipState.UP) {
> members.put(entry.getKey(), GossipState.DOWN);
> listener.gossipEvent(entry.getKey(), GossipState.DOWN);
> }
> if (result <= settings.getConvictThreshold() && entry.getValue() == GossipState.DOWN) {
> members.put(entry.getKey(), GossipState.UP);
> listener.gossipEvent(entry.getKey(), GossipState.UP);
> }
> }
> } catch (IllegalArgumentException ex) {
> //0.0 returns throws exception computing the mean.
> long now = clock.nanoTime();
> long nowInMillis = TimeUnit.MILLISECONDS.convert(now,TimeUnit.NANOSECONDS);
> if (nowInMillis - settings.getCleanupInterval() > entry.getKey().getHeartbeat() && entry.getValue() == GossipState.UP){
> LOGGER.warn("Marking down");
> members.put(entry.getKey(), GossipState.DOWN);
> listener.gossipEvent(entry.getKey(), GossipState.DOWN);
> }
> } //end catch
> } // end for
> } catch (RuntimeException ex) {
> LOGGER.warn("scheduled state had exception", ex);
> }
> {noformat}
> This should be moved to a named class that is injected with the data members it needs. This would make the logic easier to unit/mock test. We need to run it periodically in the rare case that no messages are coming to us, but we could also run this after receiving a message rather than waiting for the scheduled executor to trigger it. In many cases that would alert faster.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)