import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
private final Timeout actorResponseWaitTime;
private final DOMMountPointService mountPointService;
- private final SchemaSourceRegistry schemaRegistry;
- private final SchemaRepository schemaRepository;
private volatile NetconfTopologySetup setup;
private volatile ListenerRegistration<NetconfNodeManager> dataChangeListenerRegistration;
final DOMMountPointService mountPointService) {
this.setup = setup;
this.id = id;
- this.schemaRegistry = setup.getSchemaResourcesDTO().getSchemaRegistry();
- this.schemaRepository = setup.getSchemaResourcesDTO().getSchemaRepository();
this.actorResponseWaitTime = actorResponseWaitTime;
this.mountPointService = mountPointService;
}
@GuardedBy("this")
private void createOrUpdateActorRef() {
if (slaveActorRef == null) {
- slaveActorRef = setup.getActorSystem().actorOf(NetconfNodeActor.props(setup, id, schemaRegistry,
- schemaRepository, actorResponseWaitTime, mountPointService));
+ slaveActorRef = setup.getActorSystem().actorOf(NetconfNodeActor.props(setup, id, actorResponseWaitTime,
+ mountPointService));
LOG.debug("{}: Slave actor created with name {}", id, slaveActorRef);
} else {
slaveActorRef
- .tell(new RefreshSlaveActor(setup, id, schemaRegistry, schemaRepository, actorResponseWaitTime),
- ActorRef.noSender());
+ .tell(new RefreshSlaveActor(setup, id, actorResponseWaitTime), ActorRef.noSender());
}
}
package org.opendaylight.netconf.topology.singleton.impl;
-import static org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils.DEFAULT_SCHEMA_REPOSITORY;
-
import akka.actor.ActorRef;
import akka.cluster.Cluster;
import akka.dispatch.OnComplete;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
final String masterAddress =
Cluster.get(netconfTopologyDeviceSetup.getActorSystem()).selfAddress().toString();
masterActorRef = netconfTopologyDeviceSetup.getActorSystem().actorOf(NetconfNodeActor.props(
- netconfTopologyDeviceSetup, remoteDeviceId, DEFAULT_SCHEMA_REPOSITORY, DEFAULT_SCHEMA_REPOSITORY,
- actorResponseWaitTime, mountService),
+ netconfTopologyDeviceSetup, remoteDeviceId, actorResponseWaitTime, mountService),
NetconfTopologyUtils.createMasterActorName(remoteDeviceId.getName(), masterAddress));
remoteDeviceConnector.startRemoteDeviceConnection(newMasterSalFacade());
* Refresh, if configuration data was changed.
* @param setup new setup
*/
- void refresh(@Nonnull final NetconfTopologySetup setup) {
+ void refresh(final NetconfTopologySetup setup) {
netconfTopologyDeviceSetup = Preconditions.checkNotNull(setup);
remoteDeviceId = NetconfTopologyUtils.createRemoteDeviceId(netconfTopologyDeviceSetup.getNode().getNodeId(),
netconfTopologyDeviceSetup.getNode().augmentation(NetconfNode.class));
private ActorRef readTxActor;
private List<SchemaSourceRegistration<YangTextSchemaSource>> registeredSchemas;
- public static Props props(final NetconfTopologySetup setup,
- final RemoteDeviceId id, final SchemaSourceRegistry schemaRegistry,
- final SchemaRepository schemaRepository, final Timeout actorResponseWaitTime,
- final DOMMountPointService mountPointService) {
+ public static Props props(final NetconfTopologySetup setup, final RemoteDeviceId id,
+ final Timeout actorResponseWaitTime, final DOMMountPointService mountPointService) {
return Props.create(NetconfNodeActor.class, () ->
- new NetconfNodeActor(setup, id, schemaRegistry, schemaRepository, actorResponseWaitTime,
- mountPointService));
+ new NetconfNodeActor(setup, id, actorResponseWaitTime, mountPointService));
}
protected NetconfNodeActor(final NetconfTopologySetup setup,
- final RemoteDeviceId id, final SchemaSourceRegistry schemaRegistry,
- final SchemaRepository schemaRepository, final Timeout actorResponseWaitTime,
+ final RemoteDeviceId id, final Timeout actorResponseWaitTime,
final DOMMountPointService mountPointService) {
this.setup = setup;
this.id = id;
- this.schemaRegistry = schemaRegistry;
- this.schemaRepository = schemaRepository;
+ this.schemaRegistry = setup.getSchemaResourcesDTO().getSchemaRegistry();
+ this.schemaRepository = setup.getSchemaResourcesDTO().getSchemaRepository();
this.actorResponseWaitTime = actorResponseWaitTime;
this.writeTxIdleTimeout = setup.getIdleTimeout();
this.mountPointService = mountPointService;
private final Timeout actorResponseWaitTime;
public RefreshSlaveActor(final NetconfTopologySetup setup, final RemoteDeviceId id,
- final SchemaSourceRegistry schemaRegistry, final SchemaRepository schemaRepository,
final Timeout actorResponseWaitTime) {
this.setup = setup;
this.id = id;
- this.schemaRegistry = schemaRegistry;
- this.schemaRepository = schemaRepository;
+ this.schemaRegistry = setup.getSchemaResourcesDTO().getSchemaRegistry();
+ this.schemaRepository = setup.getSchemaResourcesDTO().getSchemaRepository();
this.actorResponseWaitTime = actorResponseWaitTime;
}
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.MockitoAnnotations.initMocks;
+import static org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils.DEFAULT_SCHEMA_REPOSITORY;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
+import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.impl.actors.NetconfNodeActor;
import org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException;
@Mock
private SchemaContext mockSchemaContext;
+ @Mock
+ private SchemaResourcesDTO schemaResourceDTO;
+
@Before
public void setup() {
initMocks(this);
masterSchemaRepository.registerSchemaSourceListener(
TextToASTTransformer.create(masterSchemaRepository, masterSchemaRepository));
+ doReturn(masterSchemaRepository).when(schemaResourceDTO).getSchemaRepository();
+ doReturn(mockRegistry).when(schemaResourceDTO).getSchemaRegistry();
final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setActorSystem(system)
- .setIdleTimeout(Duration.apply(1, TimeUnit.SECONDS)).build();
+ .setIdleTimeout(Duration.apply(1, TimeUnit.SECONDS)).setSchemaResourceDTO(schemaResourceDTO).build();
- final Props props = NetconfNodeActor.props(setup, remoteDeviceId, masterSchemaRepository,
- masterSchemaRepository, TIMEOUT, mockMountPointService);
+ final Props props = NetconfNodeActor.props(setup, remoteDeviceId, TIMEOUT, mockMountPointService);
masterRef = TestActorRef.create(system, props, "master_messages");
final RemoteDeviceId newRemoteDeviceId = new RemoteDeviceId("netconf-topology2",
new InetSocketAddress(InetAddresses.forString("127.0.0.2"), 9999));
- final NetconfTopologySetup newSetup = NetconfTopologySetupBuilder.create().setActorSystem(system).build();
+ final NetconfTopologySetup newSetup = NetconfTopologySetupBuilder.create()
+ .setSchemaResourceDTO(schemaResourceDTO).setActorSystem(system).build();
masterRef.tell(new RefreshSetupMasterActorData(newSetup, newRemoteDeviceId), testKit.getRef());
@SuppressWarnings("unchecked")
@Test
public void testRegisterMountPointWithSchemaFailures() throws Exception {
- final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setActorSystem(system).build();
+ SchemaResourcesDTO schemaResourceDTO2 = mock(SchemaResourcesDTO.class);
+ doReturn(mockRegistry).when(schemaResourceDTO2).getSchemaRegistry();
+ doReturn(mockSchemaRepository).when(schemaResourceDTO2).getSchemaRepository();
+ final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setSchemaResourceDTO(schemaResourceDTO2)
+ .setActorSystem(system).build();
- final ActorRef slaveRef = system.actorOf(NetconfNodeActor.props(setup, remoteDeviceId, mockRegistry,
- mockSchemaRepository, TIMEOUT, mockMountPointService));
+ final ActorRef slaveRef = system.actorOf(NetconfNodeActor.props(setup, remoteDeviceId, TIMEOUT,
+ mockMountPointService));
// Test unrecoverable failure.
verify(mockSchemaRepository, times(2)).createSchemaContextFactory(any(SchemaSourceFilter.class));
}
+ @Test(expected = MissingSchemaSourceException.class)
+ public void testMissingSchemaSourceOnMissingProvider() throws Exception {
+ SchemaResourcesDTO schemaResourceDTO2 = mock(SchemaResourcesDTO.class);
+ doReturn(DEFAULT_SCHEMA_REPOSITORY).when(schemaResourceDTO2).getSchemaRegistry();
+ doReturn(DEFAULT_SCHEMA_REPOSITORY).when(schemaResourceDTO2).getSchemaRepository();
+ final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setActorSystem(system)
+ .setSchemaResourceDTO(schemaResourceDTO2).setIdleTimeout(Duration.apply(1, TimeUnit.SECONDS)).build();
+ final Props props = NetconfNodeActor.props(setup, remoteDeviceId, TIMEOUT, mockMountPointService);
+ ActorRef actor = TestActorRef.create(system, props, "master_messages_2");
+
+ final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("testID");
+
+ final ProxyYangTextSourceProvider proxyYangProvider =
+ new ProxyYangTextSourceProvider(actor, system.dispatcher(), TIMEOUT);
+
+ final Future<YangTextSchemaSourceSerializationProxy> resolvedSchemaFuture =
+ proxyYangProvider.getYangTextSchemaSource(sourceIdentifier);
+ Await.result(resolvedSchemaFuture, TIMEOUT.duration());
+ }
+
@Test
public void testYangTextSchemaSourceRequest() throws Exception {
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("testID");
}
private ActorRef registerSlaveMountPoint() {
+ SchemaResourcesDTO schemaResourceDTO2 = mock(SchemaResourcesDTO.class);
+ doReturn(mockRegistry).when(schemaResourceDTO2).getSchemaRegistry();
+ doReturn(mockSchemaRepository).when(schemaResourceDTO2).getSchemaRepository();
final ActorRef slaveRef = system.actorOf(NetconfNodeActor.props(
- NetconfTopologySetupBuilder.create().setActorSystem(system).build(), remoteDeviceId, mockRegistry,
- mockSchemaRepository, TIMEOUT, mockMountPointService));
+ NetconfTopologySetupBuilder.create().setSchemaResourceDTO(schemaResourceDTO2).setActorSystem(system)
+ .build(), remoteDeviceId, TIMEOUT, mockMountPointService));
doReturn(Futures.immediateFuture(mockSchemaContext))
.when(mockSchemaContextFactory).createSchemaContext(any());
TestMasterActor(NetconfTopologySetup setup, RemoteDeviceId deviceId, Timeout actorResponseWaitTime,
DOMMountPointService mountPointService) {
- super(setup, deviceId, setup.getSchemaResourcesDTO().getSchemaRegistry(),
- setup.getSchemaResourcesDTO().getSchemaRepository(), actorResponseWaitTime, mountPointService);
+ super(setup, deviceId, actorResponseWaitTime, mountPointService);
}
@SuppressWarnings({ "rawtypes", "unchecked" })