Search in sources :

Example 1 with CreateInitialMasterActorData

use of org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData in project netconf by opendaylight.

the class MasterSalFacade method sendInitialDataToActor.

private Future<Object> sendInitialDataToActor() {
    final List<SourceIdentifier> sourceIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(currentMountContext.getEffectiveModelContext()).stream().map(mi -> RevisionSourceIdentifier.create(mi.getName(), mi.getRevision())).collect(Collectors.toList());
    LOG.debug("{}: Sending CreateInitialMasterActorData with sourceIdentifiers {} to {}", id, sourceIdentifiers, masterActorRef);
    // send initial data to master actor
    return Patterns.ask(masterActorRef, new CreateInitialMasterActorData(deviceDataBroker, netconfService, sourceIdentifiers, deviceRpc, deviceAction), actorResponseWaitTime);
}
Also used : AbstractNetconfDataTreeService(org.opendaylight.netconf.sal.connect.netconf.sal.AbstractNetconfDataTreeService) NetconfDataTreeService(org.opendaylight.netconf.dom.api.NetconfDataTreeService) LoggerFactory(org.slf4j.LoggerFactory) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) NetconfDeviceDataBroker(org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceDataBroker) Timeout(akka.util.Timeout) ActorRef(akka.actor.ActorRef) Cluster(akka.cluster.Cluster) Objects.requireNonNull(java.util.Objects.requireNonNull) Patterns(akka.pattern.Patterns) OnComplete(akka.dispatch.OnComplete) RemoteDeviceHandler(org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler) DOMActionService(org.opendaylight.mdsal.dom.api.DOMActionService) Logger(org.slf4j.Logger) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) Future(scala.concurrent.Future) RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) SchemaContextUtil(org.opendaylight.yangtools.yang.model.util.SchemaContextUtil) Collectors(java.util.stream.Collectors) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) List(java.util.List) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier) ActorSystem(akka.actor.ActorSystem) NetconfDeviceSalProvider(org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalProvider) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) NetconfDeviceNotificationService(org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceNotificationService) CreateInitialMasterActorData(org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData) NetconfDeviceCapabilities(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) CreateInitialMasterActorData(org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier)

Example 2 with CreateInitialMasterActorData

use of org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData in project netconf by opendaylight.

the class NetconfNodeActorTest method initializeMaster.

private void initializeMaster(final List<SourceIdentifier> sourceIdentifiers) {
    masterRef.tell(new CreateInitialMasterActorData(mockDOMDataBroker, netconfService, sourceIdentifiers, mockDOMRpcService, mockDOMActionService), testKit.getRef());
    testKit.expectMsgClass(MasterActorDataInitialized.class);
}
Also used : CreateInitialMasterActorData(org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData)

Example 3 with CreateInitialMasterActorData

use of org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData in project netconf by opendaylight.

the class NetconfNodeManagerTest method initializeMaster.

private void initializeMaster() {
    TestKit kit = new TestKit(masterSystem);
    testMasterActorRef.tell(new CreateInitialMasterActorData(mockDeviceDataBroker, netconfService, SOURCE_IDENTIFIERS, mockRpcService, mockActionService), kit.getRef());
    kit.expectMsgClass(MasterActorDataInitialized.class);
}
Also used : CreateInitialMasterActorData(org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData) TestKit(akka.testkit.javadsl.TestKit)

Example 4 with CreateInitialMasterActorData

use of org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData in project netconf by opendaylight.

the class NetconfNodeActor method handleReceive.

@SuppressWarnings("checkstyle:IllegalCatch")
@Override
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();
        this.netconfService = masterActorData.getNetconfDataTreeService();
        final DOMDataTreeReadTransaction tx = deviceDataBroker.newReadOnlyTransaction();
        readTxActor = context().actorOf(ReadTransactionActor.props(tx));
        this.deviceRpc = masterActorData.getDeviceRpc();
        this.deviceAction = masterActorData.getDeviceAction();
        sender().tell(new MasterActorDataInitialized(), self());
        LOG.debug("{}: Master is ready.", id);
    } else if (message instanceof RefreshSetupMasterActorData) {
        setup = ((RefreshSetupMasterActorData) message).getNetconfTopologyDeviceSetup();
        id = ((RefreshSetupMasterActorData) message).getRemoteDeviceId();
        sender().tell(new MasterActorDataInitialized(), self());
    } else if (message instanceof AskForMasterMountPoint) {
        // master
        AskForMasterMountPoint askForMasterMountPoint = (AskForMasterMountPoint) message;
        // only master contains reference to deviceDataBroker
        if (deviceDataBroker != null) {
            LOG.debug("{}: Sending RegisterMountPoint reply to {}", id, askForMasterMountPoint.getSlaveActorRef());
            askForMasterMountPoint.getSlaveActorRef().tell(new RegisterMountPoint(sourceIdentifiers, self()), sender());
        } else {
            LOG.warn("{}: Received {} but we don't appear to be the master", id, askForMasterMountPoint);
            sender().tell(new Failure(new NotMasterException(self())), self());
        }
    } else if (message instanceof YangTextSchemaSourceRequest) {
        // master
        final YangTextSchemaSourceRequest yangTextSchemaSourceRequest = (YangTextSchemaSourceRequest) message;
        sendYangTextSchemaSourceProxy(yangTextSchemaSourceRequest.getSourceIdentifier(), sender());
    } else if (message instanceof NewReadTransactionRequest) {
        // master
        sender().tell(new Success(readTxActor), self());
    } else if (message instanceof NewWriteTransactionRequest) {
        // master
        try {
            final DOMDataTreeWriteTransaction tx = deviceDataBroker.newWriteOnlyTransaction();
            final ActorRef txActor = context().actorOf(WriteTransactionActor.props(tx, writeTxIdleTimeout));
            sender().tell(new Success(txActor), self());
        } catch (final Exception t) {
            sender().tell(new Failure(t), self());
        }
    } else if (message instanceof NewReadWriteTransactionRequest) {
        try {
            final DOMDataTreeReadWriteTransaction tx = deviceDataBroker.newReadWriteTransaction();
            final ActorRef txActor = context().actorOf(ReadWriteTransactionActor.props(tx, writeTxIdleTimeout));
            sender().tell(new Success(txActor), self());
        } catch (final Exception t) {
            sender().tell(new Failure(t), self());
        }
    } else if (message instanceof InvokeRpcMessage) {
        // master
        final InvokeRpcMessage invokeRpcMessage = (InvokeRpcMessage) message;
        invokeSlaveRpc(invokeRpcMessage.getSchemaPath().lastNodeIdentifier(), invokeRpcMessage.getNormalizedNodeMessage(), sender());
    } else if (message instanceof InvokeActionMessage) {
        // master
        final InvokeActionMessage invokeActionMessage = (InvokeActionMessage) message;
        LOG.info("InvokeActionMessage Details : {}", invokeActionMessage.toString());
        invokeSlaveAction(invokeActionMessage.getSchemaPath(), invokeActionMessage.getContainerNodeMessage(), invokeActionMessage.getDOMDataTreeIdentifier(), sender());
    } else if (message instanceof RegisterMountPoint) {
        // slaves
        RegisterMountPoint registerMountPoint = (RegisterMountPoint) message;
        sourceIdentifiers = registerMountPoint.getSourceIndentifiers();
        registerSlaveMountPoint(registerMountPoint.getMasterActorRef());
        sender().tell(new Success(null), self());
    } else if (message instanceof UnregisterSlaveMountPoint) {
        // slaves
        unregisterSlaveMountPoint();
    } else if (message instanceof RefreshSlaveActor) {
        // slave
        actorResponseWaitTime = ((RefreshSlaveActor) message).getActorResponseWaitTime();
        id = ((RefreshSlaveActor) message).getId();
        schemaRegistry = ((RefreshSlaveActor) message).getSchemaRegistry();
        setup = ((RefreshSlaveActor) message).getSetup();
        schemaRepository = ((RefreshSlaveActor) message).getSchemaRepository();
    } else if (message instanceof NetconfDataTreeServiceRequest) {
        ActorRef netconfActor = context().actorOf(NetconfDataTreeServiceActor.props(netconfService, writeTxIdleTimeout));
        sender().tell(new Success(netconfActor), self());
    }
}
Also used : NewWriteTransactionRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionRequest) NewReadWriteTransactionRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadWriteTransactionRequest) CreateInitialMasterActorData(org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData) ActorRef(akka.actor.ActorRef) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) UnregisterSlaveMountPoint(org.opendaylight.netconf.topology.singleton.messages.UnregisterSlaveMountPoint) NetconfDataTreeServiceRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.NetconfDataTreeServiceRequest) RefreshSetupMasterActorData(org.opendaylight.netconf.topology.singleton.messages.RefreshSetupMasterActorData) AskForMasterMountPoint(org.opendaylight.netconf.topology.singleton.messages.AskForMasterMountPoint) Success(akka.actor.Status.Success) NotMasterException(org.opendaylight.netconf.topology.singleton.messages.NotMasterException) AskTimeoutException(akka.pattern.AskTimeoutException) IOException(java.io.IOException) InvokeRpcMessage(org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessage) RefreshSlaveActor(org.opendaylight.netconf.topology.singleton.messages.RefreshSlaveActor) DOMDataTreeReadWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction) YangTextSchemaSourceRequest(org.opendaylight.netconf.topology.singleton.messages.YangTextSchemaSourceRequest) MasterActorDataInitialized(org.opendaylight.netconf.topology.singleton.messages.MasterActorDataInitialized) NewReadTransactionRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadTransactionRequest) InvokeActionMessage(org.opendaylight.netconf.topology.singleton.messages.action.InvokeActionMessage) RegisterMountPoint(org.opendaylight.netconf.topology.singleton.messages.RegisterMountPoint) NotMasterException(org.opendaylight.netconf.topology.singleton.messages.NotMasterException) DOMDataTreeReadTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction) Failure(akka.actor.Status.Failure)

Aggregations

CreateInitialMasterActorData (org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData)4 ActorRef (akka.actor.ActorRef)2 ActorSystem (akka.actor.ActorSystem)1 Failure (akka.actor.Status.Failure)1 Success (akka.actor.Status.Success)1 Cluster (akka.cluster.Cluster)1 OnComplete (akka.dispatch.OnComplete)1 AskTimeoutException (akka.pattern.AskTimeoutException)1 Patterns (akka.pattern.Patterns)1 TestKit (akka.testkit.javadsl.TestKit)1 Timeout (akka.util.Timeout)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IOException (java.io.IOException)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Collectors (java.util.stream.Collectors)1 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)1 DOMActionService (org.opendaylight.mdsal.dom.api.DOMActionService)1 DOMDataBroker (org.opendaylight.mdsal.dom.api.DOMDataBroker)1 DOMDataTreeReadTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction)1