Search in sources :

Example 1 with GetConfigRequest

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

the class NetconfDataTreeServiceActor method onReceive.

@Override
public void onReceive(final Object message) {
    if (message instanceof GetWithFieldsRequest) {
        final GetWithFieldsRequest getRequest = (GetWithFieldsRequest) message;
        final YangInstanceIdentifier path = getRequest.getPath();
        final ListenableFuture<Optional<NormalizedNode>> future = netconfService.get(getRequest.getPath(), getRequest.getFields());
        context().stop(self());
        sendResult(future, path, sender(), self());
    } else if (message instanceof GetRequest) {
        final GetRequest getRequest = (GetRequest) message;
        final YangInstanceIdentifier path = getRequest.getPath();
        final ListenableFuture<Optional<NormalizedNode>> future = netconfService.get(path);
        context().stop(self());
        sendResult(future, path, sender(), self());
    } else if (message instanceof GetConfigWithFieldsRequest) {
        final GetConfigWithFieldsRequest getConfigRequest = (GetConfigWithFieldsRequest) message;
        final YangInstanceIdentifier path = getConfigRequest.getPath();
        final ListenableFuture<Optional<NormalizedNode>> future = netconfService.getConfig(path, getConfigRequest.getFields());
        context().stop(self());
        sendResult(future, path, sender(), self());
    } else if (message instanceof GetConfigRequest) {
        final GetConfigRequest getConfigRequest = (GetConfigRequest) message;
        final YangInstanceIdentifier path = getConfigRequest.getPath();
        final ListenableFuture<Optional<NormalizedNode>> future = netconfService.getConfig(path);
        context().stop(self());
        sendResult(future, path, sender(), self());
    } else if (message instanceof LockRequest) {
        invokeRpcCall(netconfService::lock, sender(), self());
    } else if (message instanceof MergeEditConfigRequest) {
        final MergeEditConfigRequest request = (MergeEditConfigRequest) message;
        netconfService.merge(request.getStore(), request.getNormalizedNodeMessage().getIdentifier(), request.getNormalizedNodeMessage().getNode(), Optional.ofNullable(request.getDefaultOperation()));
    } else if (message instanceof ReplaceEditConfigRequest) {
        final ReplaceEditConfigRequest request = (ReplaceEditConfigRequest) message;
        netconfService.replace(request.getStore(), request.getNormalizedNodeMessage().getIdentifier(), request.getNormalizedNodeMessage().getNode(), Optional.ofNullable(request.getDefaultOperation()));
    } else if (message instanceof CreateEditConfigRequest) {
        final CreateEditConfigRequest request = (CreateEditConfigRequest) message;
        netconfService.create(request.getStore(), request.getNormalizedNodeMessage().getIdentifier(), request.getNormalizedNodeMessage().getNode(), Optional.ofNullable(request.getDefaultOperation()));
    } else if (message instanceof DeleteEditConfigRequest) {
        final DeleteEditConfigRequest request = (DeleteEditConfigRequest) message;
        netconfService.delete(request.getStore(), request.getPath());
    } else if (message instanceof RemoveEditConfigRequest) {
        final RemoveEditConfigRequest request = (RemoveEditConfigRequest) message;
        netconfService.remove(request.getStore(), request.getPath());
    } else if (message instanceof CommitRequest) {
        submit(sender(), self());
    } else if (message instanceof DiscardChangesRequest) {
        invokeRpcCall(netconfService::discardChanges, sender(), self());
    } else if (message instanceof UnlockRequest) {
        context().stop(self());
        invokeRpcCall(netconfService::unlock, sender(), self());
    } else if (message instanceof ReceiveTimeout) {
        LOG.warn("Haven't received any message for {} seconds, cancelling transaction and stopping actor", idleTimeout);
        invokeRpcCall(netconfService::discardChanges, sender(), self());
        invokeRpcCall(netconfService::unlock, sender(), self());
        context().stop(self());
    } else {
        unhandled(message);
    }
}
Also used : GetWithFieldsRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetWithFieldsRequest) MergeEditConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.MergeEditConfigRequest) CommitRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.CommitRequest) Optional(java.util.Optional) ReplaceEditConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.ReplaceEditConfigRequest) CreateEditConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.CreateEditConfigRequest) GetConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigRequest) DeleteEditConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.DeleteEditConfigRequest) RemoveEditConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.RemoveEditConfigRequest) ReceiveTimeout(akka.actor.ReceiveTimeout) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) UnlockRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.UnlockRequest) GetConfigWithFieldsRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigWithFieldsRequest) GetRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetRequest) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DiscardChangesRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.DiscardChangesRequest) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) LockRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.LockRequest)

Example 2 with GetConfigRequest

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

the class NetconfDataTreeServiceActorTest method testGetConfigFailure.

@Test
public void testGetConfigFailure() {
    final ReadFailedException cause = new ReadFailedException("fail");
    doReturn(immediateFailedFluentFuture(cause)).when(netconfService).getConfig(PATH);
    actorRef.tell(new GetConfigRequest(PATH), probe.ref());
    verify(netconfService).getConfig(PATH);
    final Status.Failure response = probe.expectMsgClass(Status.Failure.class);
    assertEquals(cause, response.cause());
}
Also used : Status(akka.actor.Status) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) GetConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigRequest) Test(org.junit.Test)

Example 3 with GetConfigRequest

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

the class NetconfDataTreeServiceActorTest method testGetConfig.

@Test
public void testGetConfig() {
    doReturn(immediateFluentFuture(Optional.of(NODE))).when(netconfService).getConfig(PATH);
    actorRef.tell(new GetConfigRequest(PATH), probe.ref());
    verify(netconfService).getConfig(PATH);
    final NormalizedNodeMessage response = probe.expectMsgClass(NormalizedNodeMessage.class);
    assertEquals(NODE, response.getNode());
}
Also used : NormalizedNodeMessage(org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage) GetConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigRequest) Test(org.junit.Test)

Example 4 with GetConfigRequest

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

the class ActorProxyNetconfServiceFacade method getConfig.

@Override
public ListenableFuture<Optional<NormalizedNode>> getConfig(final YangInstanceIdentifier path) {
    LOG.debug("{}: GetConfig {} {} via actor {}", id, CONFIGURATION, path, masterActor);
    final Future<Object> future = Patterns.ask(masterActor, new GetConfigRequest(path), askTimeout);
    return read(future, CONFIGURATION, path);
}
Also used : GetConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigRequest)

Example 5 with GetConfigRequest

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

the class ProxyNetconfServiceTest method testGetConfig.

@Test
public void testGetConfig() throws Exception {
    ProxyNetconfService netconf = newSuccessfulProxyNetconfService();
    final ListenableFuture<Optional<NormalizedNode>> getConfig = netconf.getConfig(PATH);
    final GetConfigRequest getRequest = masterActor.expectMsgClass(GetConfigRequest.class);
    assertEquals(PATH, getRequest.getPath());
    masterActor.reply(new NormalizedNodeMessage(PATH, node));
    final Optional<NormalizedNode> result = getConfig.get(5, TimeUnit.SECONDS);
    assertTrue(result.isPresent());
    assertEquals(node, result.get());
}
Also used : NormalizedNodeMessage(org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage) Optional(java.util.Optional) GetConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigRequest) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Aggregations

GetConfigRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigRequest)6 Test (org.junit.Test)4 Optional (java.util.Optional)2 NormalizedNodeMessage (org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage)2 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)2 ReceiveTimeout (akka.actor.ReceiveTimeout)1 Status (akka.actor.Status)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)1 CommitRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.CommitRequest)1 CreateEditConfigRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.CreateEditConfigRequest)1 DeleteEditConfigRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.DeleteEditConfigRequest)1 DiscardChangesRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.DiscardChangesRequest)1 GetConfigWithFieldsRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.GetConfigWithFieldsRequest)1 GetRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.GetRequest)1 GetWithFieldsRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.GetWithFieldsRequest)1 LockRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.LockRequest)1 MergeEditConfigRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.MergeEditConfigRequest)1 RemoveEditConfigRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.RemoveEditConfigRequest)1 ReplaceEditConfigRequest (org.opendaylight.netconf.topology.singleton.messages.netconf.ReplaceEditConfigRequest)1