X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnect%2Fnetconf%2Flistener%2FNetconfDeviceCommunicator.java;h=8045f8cb4a9556160b44fb46d4d3bbc12374435a;hp=4da727f5c24e56e37c4e11acd6150d9afded1cd8;hb=8546c990b067c288f913d75b92dcdb652fb4dc86;hpb=0601a12e4717510c404ca9a4432727c42745c1ab diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java index 4da727f5c2..8045f8cb4a 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfDeviceCommunicator.java @@ -8,7 +8,6 @@ package org.opendaylight.controller.sal.connect.netconf.listener; import java.util.ArrayDeque; -import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Queue; @@ -22,19 +21,18 @@ import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; import org.opendaylight.controller.netconf.client.NetconfClientSession; import org.opendaylight.controller.netconf.client.NetconfClientSessionListener; +import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlUtil; -import org.opendaylight.controller.sal.common.util.RpcErrors; -import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.controller.sal.connect.api.RemoteDevice; import org.opendaylight.controller.sal.connect.api.RemoteDeviceCommunicator; import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil; -import org.opendaylight.controller.sal.connect.util.FailedRpcResult; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -82,8 +80,12 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, } public void initializeRemoteConnection(final NetconfClientDispatcher dispatch, - final NetconfReconnectingClientConfiguration config) { - dispatch.createReconnectingClient(config); + final NetconfClientConfiguration config) { + if(config instanceof NetconfReconnectingClientConfiguration) { + dispatch.createReconnectingClient((NetconfReconnectingClientConfiguration) config); + } else { + dispatch.createClient(config); + } } private void tearDown( String reason ) { @@ -135,9 +137,10 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, private RpcResult createErrorRpcResult( RpcError.ErrorType errorType, String message ) { - return new FailedRpcResult( RpcErrors.getRpcError( null, - NetconfDocumentedException.ErrorTag.operation_failed.getTagValue(), - null, RpcError.ErrorSeverity.ERROR, message, errorType, null ) ); + return RpcResultBuilder.failed() + .withError( errorType, NetconfDocumentedException.ErrorTag.operation_failed.getTagValue(), + message ) + .build(); } @Override @@ -203,8 +206,8 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, logger.warn( "{}: Invalid request-reply match, reply message contains different message-id, request: {}, response: {}", id, msgToS( request.request ), msgToS( message ), e ); - request.future.set( new FailedRpcResult( - NetconfMessageTransformUtil.toRpcError( e ) ) ); + request.future.set( RpcResultBuilder.failed() + .withRpcError( NetconfMessageTransformUtil.toRpcError( e ) ).build() ); return; } @@ -215,12 +218,12 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, logger.warn( "{}: Error reply from remote device, request: {}, response: {}", id, msgToS( request.request ), msgToS( message ), e ); - request.future.set( new FailedRpcResult( - NetconfMessageTransformUtil.toRpcError( e ) ) ); + request.future.set( RpcResultBuilder.failed() + .withRpcError( NetconfMessageTransformUtil.toRpcError( e ) ).build() ); return; } - request.future.set(Rpcs.getRpcResult( true, message, Collections.emptySet() ) ); + request.future.set( RpcResultBuilder.success( message ).build() ); } }