Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Rework createReconnectingClient()
We seem to have competing interests going on, where we want some information from the first connection attempt propagated outwards. JIRA: NETCONF-784 Change-Id: I232d523b60c36de85fea909c6405b1d7cac39c57 Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
- Loading branch information
Showing
11 changed files
with
138 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...provider/src/main/java/org/opendaylight/netconf/callhome/mount/SingleReconnectFuture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v1.0 which accompanies this distribution, | ||
| * and is available at http://www.eclipse.org/legal/epl-v10.html | ||
| */ | ||
| package org.opendaylight.netconf.callhome.mount; | ||
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| import io.netty.util.concurrent.DefaultPromise; | ||
| import io.netty.util.concurrent.EventExecutor; | ||
| import io.netty.util.concurrent.Future; | ||
| import org.opendaylight.netconf.client.NetconfClientSession; | ||
| import org.opendaylight.netconf.nettyutil.ReconnectFuture; | ||
| import org.opendaylight.yangtools.yang.common.Empty; | ||
|
|
||
| final class SingleReconnectFuture extends DefaultPromise<Empty> implements ReconnectFuture { | ||
| private final Future<NetconfClientSession> sessionFuture; | ||
|
|
||
| SingleReconnectFuture(final EventExecutor eventExecutor, final Future<NetconfClientSession> sessionFuture) { | ||
| super(eventExecutor); | ||
| this.sessionFuture = requireNonNull(sessionFuture); | ||
| sessionFuture.addListener(future -> { | ||
| if (!isDone()) { | ||
| if (future.isCancelled()) { | ||
| cancel(false); | ||
| } else if (future.isSuccess()) { | ||
| setSuccess(Empty.getInstance()); | ||
| } else { | ||
| setFailure(future.cause()); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean cancel(final boolean mayInterruptIfRunning) { | ||
| if (super.cancel(mayInterruptIfRunning)) { | ||
| if (!sessionFuture.isDone()) { | ||
| sessionFuture.cancel(mayInterruptIfRunning); | ||
| } | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public Future<?> firstSessionFuture() { | ||
| return sessionFuture; | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
.../netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/ReconnectFuture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v1.0 which accompanies this distribution, | ||
| * and is available at http://www.eclipse.org/legal/epl-v10.html | ||
| */ | ||
| package org.opendaylight.netconf.nettyutil; | ||
|
|
||
| import com.google.common.annotations.Beta; | ||
| import io.netty.util.concurrent.Future; | ||
| import org.eclipse.jdt.annotation.NonNull; | ||
| import org.opendaylight.yangtools.yang.common.Empty; | ||
|
|
||
| /** | ||
| * A future representing the task of reconnecting of a certain channel. This future never completes successfully, it | ||
| * either fails when the underlying strategy gives up, or when it is cancelled. It additionally exposes an additional | ||
| * future, which completes when the session is established for the first time. | ||
| */ | ||
| @Beta | ||
| public interface ReconnectFuture extends Future<Empty> { | ||
| /** | ||
| * Return a Future which completes when the first session is established. | ||
| * | ||
| * @return First session establishment future | ||
| */ | ||
| @NonNull Future<?> firstSessionFuture(); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters