Search in sources :

Example 1 with CursorAwareDataTreeModification

use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.

the class LocalProxyTransactionTest method testForwardToRemoteCommit.

@Override
@Test
public void testForwardToRemoteCommit() throws Exception {
    final TestProbe probe = createProbe();
    final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
    final CommitLocalTransactionRequest request = new CommitLocalTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), modification, null, true);
    doAnswer(LocalProxyTransactionTest::applyToCursorAnswer).when(modification).applyToCursor(any());
    final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
    verify(modification).applyToCursor(any());
    Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.THREE_PHASE, modifyRequest.getPersistenceProtocol().get());
    checkModifications(modifyRequest);
}
Also used : TestProbe(akka.testkit.TestProbe) CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) Test(org.junit.Test)

Example 2 with CursorAwareDataTreeModification

use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.

the class LocalReadWriteProxyTransaction method sealModification.

private void sealModification() {
    Preconditions.checkState(sealedModification == null, "Transaction %s is already sealed", this);
    final CursorAwareDataTreeModification mod = getModification();
    mod.ready();
    sealedModification = mod;
}
Also used : CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)

Example 3 with CursorAwareDataTreeModification

use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.

the class AbstractDataStoreClientBehaviorTest method testGetConnection.

@Test
public void testGetConnection() throws Exception {
    // set up data tree mock
    final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
    when(modification.readNode(YangInstanceIdentifier.EMPTY)).thenReturn(Optional.empty());
    final DataTreeSnapshot snapshot = mock(DataTreeSnapshot.class);
    when(snapshot.newModification()).thenReturn(modification);
    final DataTree dataTree = mock(DataTree.class);
    when(dataTree.takeSnapshot()).thenReturn(snapshot);
    final TestProbe backendProbe = new TestProbe(system, "backend");
    final long shard = 0L;
    behavior.createTransaction().read(YangInstanceIdentifier.EMPTY);
    final AbstractClientConnection<ShardBackendInfo> connection = behavior.getConnection(shard);
    // check cached connection for same shard
    Assert.assertSame(connection, behavior.getConnection(shard));
    final ConnectClientRequest connectClientRequest = actorContextProbe.expectMsgClass(ConnectClientRequest.class);
    Assert.assertEquals(CLIENT_ID, connectClientRequest.getTarget());
    final long sequence = 0L;
    Assert.assertEquals(sequence, connectClientRequest.getSequence());
    actorContextProbe.reply(new ConnectClientSuccess(CLIENT_ID, sequence, backendProbe.ref(), Collections.emptyList(), dataTree, 3));
    Assert.assertEquals(clientActorProbe.ref(), connection.localActor());
    // capture and execute command passed to client context
    final InternalCommand<ShardBackendInfo> command = clientActorProbe.expectMsgClass(InternalCommand.class);
    command.execute(behavior);
    // check, whether command was reaplayed
    verify(modification).readNode(YangInstanceIdentifier.EMPTY);
}
Also used : ConnectClientSuccess(org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess) ConnectClientRequest(org.opendaylight.controller.cluster.access.commands.ConnectClientRequest) DataTree(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree) TestProbe(akka.testkit.TestProbe) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot) CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification) Test(org.junit.Test)

Example 4 with CursorAwareDataTreeModification

use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.

the class LocalReadWriteProxyTransaction method commitRequest.

@Override
CommitLocalTransactionRequest commitRequest(final boolean coordinated) {
    final CursorAwareDataTreeModification mod = getModification();
    final CommitLocalTransactionRequest ret = new CommitLocalTransactionRequest(getIdentifier(), nextSequence(), localActor(), mod, recordedFailure, coordinated);
    closedException = this::submittedException;
    return ret;
}
Also used : CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)

Aggregations

CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)4 TestProbe (akka.testkit.TestProbe)2 Test (org.junit.Test)2 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)2 ConnectClientRequest (org.opendaylight.controller.cluster.access.commands.ConnectClientRequest)1 ConnectClientSuccess (org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess)1 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)1 DataTree (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree)1 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)1