*/
package org.opendaylight.netconf.sal.connect.netconf.sal;
-import com.google.common.base.Function;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
listener.sendRequest(netconfMessage, type.getLastComponent());
final ListenableFuture<DOMRpcResult> transformed =
- Futures.transform(rpcResultListenableFuture, (Function<RpcResult<NetconfMessage>, DOMRpcResult>) input1 -> {
+ Futures.transform(rpcResultListenableFuture, input1 -> {
if (input1.isSuccessful()) {
return transformer.toRpcResult(input1.getResult(), type);
- } else {
- return new DefaultDOMRpcResult(input1.getErrors());
}
+
+ return new DefaultDOMRpcResult(input1.getErrors());
}, MoreExecutors.directExecutor());
- return Futures.makeChecked(transformed,
- e -> new DOMRpcImplementationNotAvailableException(e,
+ return Futures.makeChecked(transformed, e -> new DOMRpcImplementationNotAvailableException(e,
"Unable to invoke rpc %s on device %s", type, deviceId));
}
public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@Nonnull final T lsnr) {
throw new UnsupportedOperationException("Not available for netconf 1.0");
}
-
}
package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
-import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
@Override
public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
- final ListenableFuture<Void> commitFutureAsVoid = Futures.transform(commitConfiguration(),
- (Function<RpcResult<Void>, Void>) input -> {
- Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
- "Submit failed with errors: %s", input.getErrors());
- return null;
- }, MoreExecutors.directExecutor());
+ final ListenableFuture<Void> commitFutureAsVoid = Futures.transform(commitConfiguration(), input -> {
+ Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
+ "Submit failed with errors: %s", input.getErrors());
+ return null;
+ }, MoreExecutors.directExecutor());
return Futures.makeChecked(commitFutureAsVoid, input -> new TransactionCommitFailedException(
"Submit of transaction " + getIdentifier() + " failed", input));
*/
package org.opendaylight.protocol.framework;
+import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.concurrent.Promise;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
/**
* Abstract base class for session negotiators. It implements the basic
* substrate to implement SessionNegotiator API specification, with subclasses
* @param <S> Protocol session type, has to extend {@code ProtocolSession<M>}
*/
@Deprecated
-public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>> extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
+public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>>
+ extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
private final Logger LOG = LoggerFactory.getLogger(AbstractSessionNegotiator.class);
private final Promise<S> promise;
protected final Channel channel;
* @param msg Message which should be sent.
*/
protected final void sendMessage(final M msg) {
- this.channel.writeAndFlush(msg).addListener(
- (ChannelFutureListener) f -> {
- if (!f.isSuccess()) {
- LOG.info("Failed to send message {}", msg, f.cause());
- negotiationFailed(f.cause());
- } else {
- LOG.trace("Message {} sent to socket", msg);
- }
- });
+ this.channel.writeAndFlush(msg).addListener(f -> {
+ if (!f.isSuccess()) {
+ LOG.info("Failed to send message {}", msg, f.cause());
+ negotiationFailed(f.cause());
+ } else {
+ LOG.trace("Message {} sent to socket", msg);
+ }
+ });
}
@Override
import io.netty.util.concurrent.DefaultPromise;
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
import java.net.InetSocketAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
channel.pipeline().addLast(new ClosedChannelHandler(ReconnectPromise.this));
});
- pending.addListener((GenericFutureListener<Future<Object>>) future -> {
+ pending.addListener(future -> {
if (!future.isSuccess() && !ReconnectPromise.this.isDone()) {
ReconnectPromise.this.setFailure(future.cause());
}