Search in sources :

Example 6 with SchemaResourcesDTO

use of org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO in project netconf by opendaylight.

the class AbstractNetconfTopology method createDeviceCommunicator.

protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node, final NetconfNodeAugmentedOptional nodeOptional) {
    final Host host = node.getHost();
    final IpAddress ipAddress = host.getIpAddress();
    final InetSocketAddress address;
    if (ipAddress != null) {
        address = new InetSocketAddress(IetfInetUtil.INSTANCE.inetAddressFor(ipAddress), node.getPort().getValue().toJava());
    } else {
        address = new InetSocketAddress(host.getDomainName().getValue(), node.getPort().getValue().toJava());
    }
    final RemoteDeviceId remoteDeviceId = new RemoteDeviceId(nodeId.getValue(), address);
    final long keepaliveDelay = node.requireKeepaliveDelay().toJava();
    RemoteDeviceHandler<NetconfSessionPreferences> salFacade = createSalFacade(remoteDeviceId);
    if (keepaliveDelay > 0) {
        LOG.info("Adding keepalive facade, for device {}", nodeId);
        salFacade = new KeepaliveSalFacade(remoteDeviceId, salFacade, this.keepaliveExecutor.getExecutor(), keepaliveDelay, node.requireDefaultRequestTimeoutMillis().toJava());
    }
    final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device;
    final List<SchemaSourceRegistration<?>> yanglibRegistrations;
    if (node.requireSchemaless()) {
        device = new SchemalessNetconfDevice(baseSchemas, remoteDeviceId, salFacade);
        yanglibRegistrations = List.of();
    } else {
        final boolean reconnectOnChangedSchema = node.requireReconnectOnChangedSchema();
        final SchemaResourcesDTO resources = schemaManager.getSchemaResources(node, nodeId.getValue());
        device = new NetconfDeviceBuilder().setReconnectOnSchemasChange(reconnectOnChangedSchema).setSchemaResourcesDTO(resources).setGlobalProcessingExecutor(this.processingExecutor).setId(remoteDeviceId).setSalFacade(salFacade).setNode(node).setEventExecutor(eventExecutor).setNodeOptional(nodeOptional).setDeviceActionFactory(deviceActionFactory).setBaseSchemas(baseSchemas).build();
        yanglibRegistrations = registerDeviceSchemaSources(remoteDeviceId, node, resources);
    }
    final Optional<UserPreferences> userCapabilities = getUserCapabilities(node);
    final int rpcMessageLimit = node.requireConcurrentRpcLimit().toJava();
    if (rpcMessageLimit < 1) {
        LOG.info("Concurrent rpc limit is smaller than 1, no limit will be enforced for device {}", remoteDeviceId);
    }
    final NetconfDeviceCommunicator netconfDeviceCommunicator = userCapabilities.isPresent() ? new NetconfDeviceCommunicator(remoteDeviceId, device, userCapabilities.get(), rpcMessageLimit) : new NetconfDeviceCommunicator(remoteDeviceId, device, rpcMessageLimit);
    if (salFacade instanceof KeepaliveSalFacade) {
        ((KeepaliveSalFacade) salFacade).setListener(netconfDeviceCommunicator);
    }
    return new NetconfConnectorDTO(netconfDeviceCommunicator, salFacade, yanglibRegistrations);
}
Also used : UserPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.UserPreferences) NetconfDeviceCommunicator(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator) InetSocketAddress(java.net.InetSocketAddress) KeepaliveSalFacade(org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfDeviceBuilder(org.opendaylight.netconf.sal.connect.netconf.NetconfDeviceBuilder) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SchemaSourceRegistration(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SchemalessNetconfDevice(org.opendaylight.netconf.sal.connect.netconf.SchemalessNetconfDevice)

Example 7 with SchemaResourcesDTO

use of org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO in project netconf by opendaylight.

the class DefaultSchemaResourceManager method getSchemaResources.

@NonNull
private synchronized SchemaResourcesDTO getSchemaResources(final String subdir) {
    // Fast path for unusual devices
    final SchemaResourcesDTO existing = resources.get(subdir);
    if (existing != null) {
        return existing;
    }
    final SchemaResourcesDTO created = createResources(subdir);
    resources.put(subdir, created);
    return created;
}
Also used : SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) Objects.requireNonNull(java.util.Objects.requireNonNull) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

SchemaResourcesDTO (org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO)7 ActorRef (akka.actor.ActorRef)3 TestActorRef (akka.testkit.TestActorRef)3 Test (org.junit.Test)3 NetconfTopologySetup (org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup)3 File (java.io.File)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 NetconfSessionPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)2 Host (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 RevisionSourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier)2 ActorSystem (akka.actor.ActorSystem)1 Props (akka.actor.Props)1 AskTimeoutException (akka.pattern.AskTimeoutException)1 TestKit (akka.testkit.javadsl.TestKit)1 Timeout (akka.util.Timeout)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1