import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
import org.opendaylight.controller.cluster.schema.provider.impl.RemoteSchemaProvider;
import org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.impl.ProxyDOMRpcService;
import org.opendaylight.netconf.topology.singleton.impl.ProxyYangTextSourceProvider;
import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadWriteTransactionRequest;
import org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionRequest;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
+import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
import scala.concurrent.duration.Duration;
public class NetconfNodeActor extends AbstractUntypedActor {
-
private final Duration writeTxIdleTimeout;
private final DOMMountPointService mountPointService;
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;
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
- public void handleReceive(final Object message) throws Exception {
+ public void handleReceive(final Object message) {
LOG.debug("{}: received message {}", id, message);
if (message instanceof CreateInitialMasterActorData) { // master
final CreateInitialMasterActorData masterActorData = (CreateInitialMasterActorData) message;
sourceIdentifiers = masterActorData.getSourceIndentifiers();
this.deviceDataBroker = masterActorData.getDeviceDataBroker();
- final DOMDataReadOnlyTransaction tx = deviceDataBroker.newReadOnlyTransaction();
+ final DOMDataTreeReadTransaction tx = deviceDataBroker.newReadOnlyTransaction();
readTxActor = context().actorOf(ReadTransactionActor.props(tx));
this.deviceRpc = masterActorData.getDeviceRpc();
sender().tell(new Success(readTxActor), self());
} else if (message instanceof NewWriteTransactionRequest) { // master
try {
- final DOMDataWriteTransaction tx = deviceDataBroker.newWriteOnlyTransaction();
+ final DOMDataTreeWriteTransaction tx = deviceDataBroker.newWriteOnlyTransaction();
final ActorRef txActor = context().actorOf(WriteTransactionActor.props(tx, writeTxIdleTimeout));
sender().tell(new Success(txActor), self());
} catch (final Exception t) {
} else if (message instanceof NewReadWriteTransactionRequest) {
try {
- final DOMDataReadWriteTransaction tx = deviceDataBroker.newReadWriteTransaction();
+ final DOMDataTreeReadWriteTransaction tx = deviceDataBroker.newReadWriteTransaction();
final ActorRef txActor = context().actorOf(ReadWriteTransactionActor.props(tx, writeTxIdleTimeout));
sender().tell(new Success(txActor), self());
} catch (final Exception t) {
}
private void sendYangTextSchemaSourceProxy(final SourceIdentifier sourceIdentifier, final ActorRef sender) {
- final ListenableFuture<@NonNull YangTextSchemaSource> schemaSourceFuture =
+ final ListenableFuture<YangTextSchemaSource> schemaSourceFuture =
schemaRepository.getSchemaSource(sourceIdentifier, YangTextSchemaSource.class);
Futures.addCallback(schemaSourceFuture, new FutureCallback<YangTextSchemaSource>() {
}
@Override
- public void onFailure(@Nonnull final Throwable throwable) {
+ public void onFailure(final Throwable throwable) {
LOG.debug("{}: getSchemaSource for {} failed", id, sourceIdentifier, throwable);
sender.tell(new Failure(throwable), getSelf());
}
Futures.addCallback(rpcResult, new FutureCallback<DOMRpcResult>() {
@Override
- public void onSuccess(@Nullable final DOMRpcResult domRpcResult) {
+ public void onSuccess(final DOMRpcResult domRpcResult) {
LOG.debug("{}: invokeSlaveRpc for {}, domRpcResult: {}", id, schemaPath, domRpcResult);
if (domRpcResult == null) {
}
@Override
- public void onFailure(@Nonnull final Throwable throwable) {
+ public void onFailure(final Throwable throwable) {
recipient.tell(new Failure(throwable), getSelf());
}
}, MoreExecutors.directExecutor());
return new ProxyDOMRpcService(setup.getActorSystem(), masterReference, id, actorResponseWaitTime);
}
- private SchemaContextFactory createSchemaContextFactory(final ActorRef masterReference) {
+ private EffectiveModelContextFactory createSchemaContextFactory(final ActorRef masterReference) {
final RemoteYangTextSourceProvider remoteYangTextSourceProvider =
new ProxyYangTextSourceProvider(masterReference, getContext().dispatcher(), actorResponseWaitTime);
final RemoteSchemaProvider remoteProvider = new RemoteSchemaProvider(remoteYangTextSourceProvider,
YangTextSchemaSource.class, PotentialSchemaSource.Costs.REMOTE_IO.getValue())))
.collect(Collectors.toList());
- return schemaRepository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
+ return schemaRepository.createEffectiveModelContextFactory();
}
- private void resolveSchemaContext(final SchemaContextFactory schemaContextFactory,
- final SlaveSalFacade localSlaveSalManager, final ActorRef masterReference, int tries) {
- final ListenableFuture<SchemaContext> schemaContextFuture =
- schemaContextFactory.createSchemaContext(sourceIdentifiers);
+ private void resolveSchemaContext(final EffectiveModelContextFactory schemaContextFactory,
+ final SlaveSalFacade localSlaveSalManager, final ActorRef masterReference, final int tries) {
+ final ListenableFuture<EffectiveModelContext> schemaContextFuture =
+ schemaContextFactory.createEffectiveModelContext(sourceIdentifiers);
Futures.addCallback(schemaContextFuture, new FutureCallback<SchemaContext>() {
@Override
- public void onSuccess(@Nonnull final SchemaContext result) {
+ public void onSuccess(final SchemaContext result) {
executeInSelf(() -> {
// Make sure the slaveSalManager instance hasn't changed since we initiated the schema context
// resolution.
}
@Override
- public void onFailure(@Nonnull final Throwable throwable) {
+ public void onFailure(final Throwable throwable) {
executeInSelf(() -> {
if (slaveSalManager == localSlaveSalManager) {
final Throwable cause = Throwables.getRootCause(throwable);
registeredSchemas = null;
}
}
-
}