2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.callhome.mount;
10 import static java.util.Objects.requireNonNull;
12 import io.netty.util.concurrent.DefaultPromise;
13 import io.netty.util.concurrent.EventExecutor;
14 import io.netty.util.concurrent.Future;
15 import org.opendaylight.netconf.client.NetconfClientSession;
16 import org.opendaylight.netconf.nettyutil.ReconnectFuture;
17 import org.opendaylight.yangtools.yang.common.Empty;
19 final class SingleReconnectFuture extends DefaultPromise<Empty> implements ReconnectFuture {
20 private final Future<NetconfClientSession> sessionFuture;
22 SingleReconnectFuture(final EventExecutor eventExecutor, final Future<NetconfClientSession> sessionFuture) {
24 this.sessionFuture = requireNonNull(sessionFuture);
25 sessionFuture.addListener(future -> {
27 if (future.isCancelled()) {
29 } else if (future.isSuccess()) {
30 setSuccess(Empty.value());
32 setFailure(future.cause());
39 public boolean cancel(final boolean mayInterruptIfRunning) {
40 if (super.cancel(mayInterruptIfRunning)) {
41 if (!sessionFuture.isDone()) {
42 sessionFuture.cancel(mayInterruptIfRunning);
50 public Future<?> firstSessionFuture() {