camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Wang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-8208) ZooKeeperRoutePolicy is not able to recover after session expiration
Date Wed, 07 Jan 2015 07:46:35 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-8208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14267372#comment-14267372
] 

Leo Wang commented on CAMEL-8208:
---------------------------------

I don't think this patch work for us because the internal ElectoralMonitorRoute is "dead"
once session expired which means that It won't receive any Exchange message afterward. So
you patched code was just not being reached.

Actually, we've done a fix by watching the Zookeeper client if SessionExpired event received,
we reset the ZooKeeperElection so that it create a new ElectoralMonitorRoute and do election
again next time when isMaster() is call.
{code:title=ZooKeeperElection.java}

...
    private ElectoralMonitorRoute electoralMonitorRoute;
...
    private ZooKeeperEndpoint createCandidateNode(CamelContext camelContext) {
        LOG.info("Initializing ZookeeperElection with uri '{}'", uri);
        ZooKeeperEndpoint zep = camelContext.getEndpoint(uri, ZooKeeperEndpoint.class);
        zep.getConfiguration().setCreate(true);
        zep.getConfiguration().setTimeout(SolviansBaseRoute.SESSION_EXPIRED_TIMEOUT);
        String fullpath = createFullPathToCandidate(zep);
        Exchange e = zep.createExchange();
        e.setPattern(ExchangePattern.InOut);
        e.getIn().setHeader(ZooKeeperMessage.ZOOKEEPER_NODE, fullpath);
        e.getIn().setHeader(ZooKeeperMessage.ZOOKEEPER_CREATE_MODE, CreateMode.EPHEMERAL_SEQUENTIAL);
        producerTemplate.send(zep, e);

        if (e.isFailed()) {
            LOG.error("Error setting up election node " + fullpath, e.getException());
        } else {
            LOG.info("Candidate node '{}' has been created", fullpath);
            try {
                electoralMonitorRoute = new ElectoralMonitorRoute(zep);
                camelContext.addRoutes(electoralMonitorRoute);
            } catch (Exception ex) {
                LOG.error("Error configuring ZookeeperElection", ex);
            }
        }
        return zep;

    }
...
    public void reset() throws Exception {
        camelContext.removeEndpoints(uri);
        camelContext.removeComponent("zookeeper");
        camelContext.stopRoute(this.electoralMonitorRoute.getRouteCollection().getId());
        camelContext.removeRoute(this.electoralMonitorRoute.getRouteCollection().getId());
        producerTemplate.stop();
        this.isCandidateCreated = false;
        this.electionComplete = new CountDownLatch(1);
        producerTemplate = camelContext.createProducerTemplate();
    }
...
{code}

> ZooKeeperRoutePolicy is not able to recover after session expiration
> --------------------------------------------------------------------
>
>                 Key: CAMEL-8208
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8208
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-zookeeper
>    Affects Versions: 2.13.2
>            Reporter: Leo Wang
>
> My company is using ZooKeeperRoutePolicy to maintain a Master/Slaver cluster. Sometimes
the cluster got network problem which make the app server disconnect from remote ZooKeeper
server. The disconnection usually don't last long but still long enough to expire the zookeeper
session of ZooKeeperRoutePolicy. By our observation, it seems ZooKeeperRoutePolicy would not
recovery and do re-election after session expiration which lead to multiple master situation.
> Is it possible to do enhancement or bug fixing on this?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message