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=9fa68eeea6f87c7f1a4cb4634b0759a61cc2f83e;hb=refs%2Fchanges%2F64%2F8964%2F4;hpb=b3d0ded2590e6a5a61055010f7b24e9a943c8d31 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 9fa68eeea6..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; @@ -26,16 +25,14 @@ import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguratio 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; @@ -86,9 +83,9 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener, final NetconfClientConfiguration config) { if(config instanceof NetconfReconnectingClientConfiguration) { dispatch.createReconnectingClient((NetconfReconnectingClientConfiguration) config); + } else { + dispatch.createClient(config); } - - dispatch.createClient(config); } private void tearDown( String reason ) { @@ -140,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 @@ -208,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; } @@ -220,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() ); } }