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%2FNetconfRemoteSchemaSourceProvider.java;h=c734e80d9aa06f76d3c4a96c277b8c71a7a48d74;hp=12be689cb94fdd94f9df329d9cf7162ca250625c;hb=9c9d6e69da3aff2d0576d8c15ea0fa0692595b6d;hpb=82c8b8d0a8584735a02146b437f38ebdaebd9194 diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfRemoteSchemaSourceProvider.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfRemoteSchemaSourceProvider.java index 12be689cb9..c734e80d9a 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfRemoteSchemaSourceProvider.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfRemoteSchemaSourceProvider.java @@ -1,8 +1,15 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. 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.controller.sal.connect.netconf; -import java.util.Set; +import java.util.Collection; +import java.util.concurrent.ExecutionException; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; @@ -21,11 +28,10 @@ class NetconfRemoteSchemaSourceProvider implements SchemaSourceProvider public static final QName GET_SCHEMA_QNAME = QName.create(IETF_NETCONF_MONITORING, "get-schema"); public static final QName GET_DATA_QNAME = QName.create(IETF_NETCONF_MONITORING, "data"); - NetconfDevice device; + private final NetconfDevice device; public NetconfRemoteSchemaSourceProvider(NetconfDevice device) { - super(); - this.device = device; + this.device = Preconditions.checkNotNull(device); } @Override @@ -38,16 +44,20 @@ class NetconfRemoteSchemaSourceProvider implements SchemaSourceProvider request.addLeaf("version", revision.get()); } - device.logger.info("Loading YANG schema source for {}:{}", moduleName, revision); - RpcResult schemaReply = device.invokeRpc(GET_SCHEMA_QNAME, request.toInstance()); - if (schemaReply.isSuccessful()) { - String schemaBody = getSchemaFromRpc(schemaReply.getResult()); - if (schemaBody != null) { - device.logger.info("YANG Schema successfully retrieved from remote for {}:{}", moduleName, revision); - return Optional.of(schemaBody); + device.logger.trace("Loading YANG schema source for {}:{}", moduleName, revision); + try { + RpcResult schemaReply = device.invokeRpc(GET_SCHEMA_QNAME, request.toInstance()).get(); + if (schemaReply.isSuccessful()) { + String schemaBody = getSchemaFromRpc(schemaReply.getResult()); + if (schemaBody != null) { + device.logger.trace("YANG Schema successfully retrieved from remote for {}:{}", moduleName, revision); + return Optional.of(schemaBody); + } } + device.logger.warn("YANG shcema was not successfully retrieved."); + } catch (InterruptedException | ExecutionException e) { + device.logger.warn("YANG shcema was not successfully retrieved.", e); } - device.logger.info("YANG shcema was not successfully retrieved."); return Optional.absent(); } @@ -62,8 +72,8 @@ class NetconfRemoteSchemaSourceProvider implements SchemaSourceProvider } return null; } - - public static final boolean isSupportedFor(Set capabilities) { + + public static final boolean isSupportedFor(Collection capabilities) { return capabilities.contains(IETF_NETCONF_MONITORING); } }