curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Flier Lu (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CURATOR-212) checkState will set a new connection to old connected state
Date Thu, 30 Apr 2015 08:06:05 GMT

     [ https://issues.apache.org/jira/browse/CURATOR-212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Flier Lu updated CURATOR-212:
-----------------------------
    Description: 
consider the situation, after the EnsembleProvider changed the connection string, ConnectionState.process
received a session event, which will invoke checkState to check whether the client is connected.
{code}
    @Override
    public void process(WatchedEvent event)
    {
        //...
        boolean wasConnected = isConnected.get();
        boolean newIsConnected = wasConnected;
        if ( event.getType() == Watcher.Event.EventType.None )
        {
            newIsConnected = checkState(event.getState(), wasConnected);
        }

        if ( newIsConnected != wasConnected )
        {
            isConnected.set(newIsConnected);
            connectionStartMs = System.currentTimeMillis();
        }
    }
{code}
if the old connection state is SyncConnected or ConnectedReadOnly, isConnected will be set
true, even the handleNewConnectionString() was invoked, and the state was reset to create
a new connection.

After checkState return, process will set the new connection to the old connected state.
{code}
        if ( checkNewConnectionString && zooKeeper.hasNewConnectionString() )
        {
            isConnected = false; // force to set it
            handleNewConnectionString();
        }
{code}
We could force the state to disconnected when we found a new connection will be create.

  was:
consider the situation, after the EnsembleProvider changed the connection string, ConnectionState.process
received a session event, which will invoke checkState to check whether the client is connected.
<code>
    @Override
    public void process(WatchedEvent event)
    {
        //...
        boolean wasConnected = isConnected.get();
        boolean newIsConnected = wasConnected;
        if ( event.getType() == Watcher.Event.EventType.None )
        {
            newIsConnected = checkState(event.getState(), wasConnected);
        }

        if ( newIsConnected != wasConnected )
        {
            isConnected.set(newIsConnected);
            connectionStartMs = System.currentTimeMillis();
        }
    }
<code>
if the old connection state is SyncConnected or ConnectedReadOnly, isConnected will be set
true, even the handleNewConnectionString() was invoked, and the state was reset to create
a new connection.

After checkState return, process will set the new connection to the old connected state.
<code>
        if ( checkNewConnectionString && zooKeeper.hasNewConnectionString() )
        {
            isConnected = false; // force to set it
            handleNewConnectionString();
        }
<code>
We could force the state to disconnected when we found a new connection will be create.


> checkState will set a new connection to old connected state
> -----------------------------------------------------------
>
>                 Key: CURATOR-212
>                 URL: https://issues.apache.org/jira/browse/CURATOR-212
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Client
>    Affects Versions: TBD
>            Reporter: Flier Lu
>            Priority: Minor
>
> consider the situation, after the EnsembleProvider changed the connection string, ConnectionState.process
received a session event, which will invoke checkState to check whether the client is connected.
> {code}
>     @Override
>     public void process(WatchedEvent event)
>     {
>         //...
>         boolean wasConnected = isConnected.get();
>         boolean newIsConnected = wasConnected;
>         if ( event.getType() == Watcher.Event.EventType.None )
>         {
>             newIsConnected = checkState(event.getState(), wasConnected);
>         }
>         if ( newIsConnected != wasConnected )
>         {
>             isConnected.set(newIsConnected);
>             connectionStartMs = System.currentTimeMillis();
>         }
>     }
> {code}
> if the old connection state is SyncConnected or ConnectedReadOnly, isConnected will be
set true, even the handleNewConnectionString() was invoked, and the state was reset to create
a new connection.
> After checkState return, process will set the new connection to the old connected state.
> {code}
>         if ( checkNewConnectionString && zooKeeper.hasNewConnectionString() )
>         {
>             isConnected = false; // force to set it
>             handleNewConnectionString();
>         }
> {code}
> We could force the state to disconnected when we found a new connection will be create.



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

Mime
View raw message