Unverified Commit 99ae9700 authored by 张亮's avatar 张亮 Committed by GitHub
Browse files

Merge pull request #944 from saaavsaaa/dev

sync retry needless reset connection should not throw exception
parents a8a222dc dd6ca88f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public final class PathTree {
            return;
        }
        try {
            if (status == status.RELEASE) {
            if (status == PathStatus.RELEASE) {
                LOGGER.debug("loading status:{}", status);
                this.setStatus(PathStatus.CHANGING);
        
@@ -339,7 +339,7 @@ public final class PathTree {
            LOGGER.debug("cache put:{},value:{}", path, value);
            PathUtils.validatePath(path);
            LOGGER.debug("put status:{}", status);
            if (status == status.RELEASE) {
            if (status == PathStatus.RELEASE) {
                if (path.equals(rootNode.get().getKey())) {
                    rootNode.set(new PathNode(rootNode.get().getKey(), value.getBytes(Constants.UTF_8)));
                    return;
+2 −5
Original line number Diff line number Diff line
@@ -15,11 +15,10 @@
 * </p>
 */

package io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section;
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.retry;

import io.shardingsphere.jdbc.orchestration.reg.newzk.client.action.IProvider;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.retry.DelayPolicyExecutor;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.retry.DelayRetryPolicy;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.Connection;
import lombok.Setter;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
@@ -81,8 +80,6 @@ public abstract class Callable<T> {
            delayPolicyExecutor.next();
            if (Connection.needReset(e)) {
                provider.resetConnection();
            } else {
                throw e;
            }
            execDelay();
        } catch (InterruptedException e) {
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public class UsualClient extends BaseClient {
    private final boolean watched = true;
    
    @Getter
    private io.shardingsphere.jdbc.orchestration.reg.newzk.client.action.IExecStrategy strategy;
    private IExecStrategy strategy;
    
    UsualClient(final BaseContext context) {
        super(context);
+1 −3
Original line number Diff line number Diff line
@@ -80,10 +80,8 @@ public abstract class BaseOperation implements Delayed {
        } catch (KeeperException e) {
            if (Connection.needReset(e)) {
                provider.resetConnection();
                result = false;
            } else {
                throw e;
            }
            result = false;
        }
        if (!result && delayPolicyExecutor.hasNext()) {
            delayPolicyExecutor.next();
+11 −0
Original line number Diff line number Diff line
@@ -36,6 +36,17 @@ public class Connection {
        EXCEPTION_RESETS.put(KeeperException.Code.OPERATIONTIMEOUT.intValue(), false);
    }
    
    /**
     * need retry.
     *
     * @param e e
     * @return need retry
     * @throws KeeperException Zookeeper Exception
     */
    public static boolean needRetry(final KeeperException e) throws KeeperException {
        return EXCEPTION_RESETS.containsKey(e.code().intValue());
    }
    
    /**
     * need reset.
     *
Loading