当前位置: 首页>>代码示例>>Java>>正文


Java PeopleModel类代码示例

本文整理汇总了Java中org.opendaylight.controller.md.cluster.datastore.model.PeopleModel的典型用法代码示例。如果您正苦于以下问题:Java PeopleModel类的具体用法?Java PeopleModel怎么用?Java PeopleModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PeopleModel类属于org.opendaylight.controller.md.cluster.datastore.model包,在下文中一共展示了PeopleModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSnapshot

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
private static ShardSnapshotState createSnapshot() {
    final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
    dataTree.setSchemaContext(SchemaContextHelper.select(SchemaContextHelper.CARS_YANG,
            SchemaContextHelper.PEOPLE_YANG));

    DataTreeSnapshot snapshot = dataTree.takeSnapshot();

    DataTreeModification modification = snapshot.newModification();

    modification.merge(CarsModel.BASE_PATH, CarsModel.create());
    modification.merge(PeopleModel.BASE_PATH, PeopleModel.create());
    modification.ready();
    dataTree.commit(dataTree.prepare(modification));

    return new ShardSnapshotState(new MetadataShardDataTreeSnapshot(dataTree.takeSnapshot().readNode(
            YangInstanceIdentifier.EMPTY).get()));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:ShardRecoveryCoordinatorTest.java

示例2: testWriteTransactionWithMultipleShards

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testWriteTransactionWithMultipleShards() throws Exception {
    initDatastoresWithCarsAndPeople("testWriteTransactionWithMultipleShards");

    final DOMStoreWriteTransaction writeTx = followerDistributedDataStore.newWriteOnlyTransaction();
    assertNotNull("newWriteOnlyTransaction returned null", writeTx);

    final YangInstanceIdentifier carsPath = CarsModel.BASE_PATH;
    final NormalizedNode<?, ?> carsNode = CarsModel.emptyContainer();
    writeTx.write(carsPath, carsNode);

    final YangInstanceIdentifier peoplePath = PeopleModel.BASE_PATH;
    final NormalizedNode<?, ?> peopleNode = PeopleModel.emptyContainer();
    writeTx.write(peoplePath, peopleNode);

    followerTestKit.doCommit(writeTx.ready());

    final DOMStoreReadTransaction readTx = followerDistributedDataStore.newReadOnlyTransaction();

    verifyNode(readTx, carsPath, carsNode);
    verifyNode(readTx, peoplePath, peopleNode);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DistributedDataStoreRemotingIntegrationTest.java

示例3: testReadWriteTransactionWithMultipleShards

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testReadWriteTransactionWithMultipleShards() throws Exception {
    initDatastoresWithCarsAndPeople("testReadWriteTransactionWithMultipleShards");

    final DOMStoreReadWriteTransaction rwTx = followerDistributedDataStore.newReadWriteTransaction();
    assertNotNull("newReadWriteTransaction returned null", rwTx);

    final YangInstanceIdentifier carsPath = CarsModel.BASE_PATH;
    final NormalizedNode<?, ?> carsNode = CarsModel.emptyContainer();
    rwTx.write(carsPath, carsNode);

    final YangInstanceIdentifier peoplePath = PeopleModel.BASE_PATH;
    final NormalizedNode<?, ?> peopleNode = PeopleModel.emptyContainer();
    rwTx.write(peoplePath, peopleNode);

    followerTestKit.doCommit(rwTx.ready());

    final DOMStoreReadTransaction readTx = followerDistributedDataStore.newReadOnlyTransaction();

    verifyNode(readTx, carsPath, carsNode);
    verifyNode(readTx, peoplePath, peopleNode);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DistributedDataStoreRemotingIntegrationTest.java

示例4: readPeople

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
private Optional<NormalizedNode<?,?>> readPeople(final ShardDataTree shardDataTree) {
    final TipProducingDataTree dataTree = shardDataTree.getDataTree();
    // FIXME: this should not be called here
    dataTree.setSchemaContext(peopleSchemaContext);

    return shardDataTree.readNode(PeopleModel.BASE_PATH);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:ShardRecoveryCoordinatorTest.java

示例5: test

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void test() throws Exception {
    assertTrue("Failed to mkdir " + restoreDirectoryPath, restoreDirectoryFile.mkdirs());

    final DatastoreSnapshot configSnapshot = new DatastoreSnapshot("config",
            newShardManagerSnapshot("config-one", "config-two"),
            Arrays.asList(new DatastoreSnapshot.ShardSnapshot("config-one", newSnapshot(CarsModel.BASE_PATH,
                    CarsModel.newCarsNode(CarsModel.newCarsMapNode(CarsModel.newCarEntry("optima",
                        BigInteger.valueOf(20000L)),CarsModel.newCarEntry("sportage",
                            BigInteger.valueOf(30000L)))))),
                    new DatastoreSnapshot.ShardSnapshot("config-two", newSnapshot(PeopleModel.BASE_PATH,
                        PeopleModel.emptyContainer()))));

    DatastoreSnapshot operSnapshot = new DatastoreSnapshot("oper",
            null, Arrays.asList(new DatastoreSnapshot.ShardSnapshot("oper-one", newSnapshot(TestModel.TEST_PATH,
                    ImmutableNodes.containerNode(TestModel.TEST_QNAME)))));

    DatastoreSnapshotList snapshotList = new DatastoreSnapshotList(Arrays.asList(configSnapshot, operSnapshot));

    try (FileOutputStream fos = new FileOutputStream(backupFile)) {
        SerializationUtils.serialize(snapshotList, fos);
    }

    DatastoreSnapshotRestore instance = DatastoreSnapshotRestore.instance(restoreDirectoryPath);

    assertDatastoreSnapshotEquals(configSnapshot, instance.getAndRemove("config"));
    assertDatastoreSnapshotEquals(operSnapshot, instance.getAndRemove("oper"));

    assertNull("DatastoreSnapshot was not removed", instance.getAndRemove("config"));

    assertFalse(backupFile + " was not deleted", backupFile.exists());

    instance = DatastoreSnapshotRestore.instance(restoreDirectoryPath);
    assertNull("Expected null DatastoreSnapshot", instance.getAndRemove("config"));
    assertNull("Expected null DatastoreSnapshot", instance.getAndRemove("oper"));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:37,代码来源:DatastoreSnapshotRestoreTest.java

示例6: testMergeWithInvalidNamespace

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testMergeWithInvalidNamespace() throws DataValidationFailedException {
    NormalizedNode<?, ?> normalizedNode = PeopleModel.emptyContainer();
    YangInstanceIdentifier path = PeopleModel.BASE_PATH;

    pruningDataTreeModification.merge(path, normalizedNode);

    verify(mockModification, times(1)).merge(path, normalizedNode);

    DataTreeCandidateTip candidate = getCandidate();
    assertEquals("getModificationType", ModificationType.UNMODIFIED, candidate.getRootNode().getModificationType());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:PruningDataTreeModificationTest.java

示例7: testWriteWithInvalidNamespace

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testWriteWithInvalidNamespace() throws DataValidationFailedException {
    NormalizedNode<?, ?> normalizedNode = PeopleModel.emptyContainer();
    YangInstanceIdentifier path = PeopleModel.BASE_PATH;

    pruningDataTreeModification.write(path, normalizedNode);

    verify(mockModification, times(1)).write(path, normalizedNode);

    DataTreeCandidateTip candidate = getCandidate();
    assertEquals("getModificationType", ModificationType.UNMODIFIED, candidate.getRootNode().getModificationType());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:PruningDataTreeModificationTest.java

示例8: testChainedTransactionFailureWithMultipleShards

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testChainedTransactionFailureWithMultipleShards() throws Exception {
    initDatastoresWithCarsAndPeople("testChainedTransactionFailureWithMultipleShards");

    final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
            ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(
                    LogicalDatastoreType.CONFIGURATION, followerDistributedDataStore).build(),
                    MoreExecutors.directExecutor());

    final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
    final DOMTransactionChain txChain = broker.createTransactionChain(listener);

    final DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();

    writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer());

    final ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
                .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();

    // Note that merge will validate the data and fail but put succeeds b/c deep validation is not
    // done for put for performance reasons.
    writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);

    try {
        writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
        fail("Expected TransactionCommitFailedException");
    } catch (final TransactionCommitFailedException e) {
        // Expected
    }

    verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx), any(Throwable.class));

    txChain.close();
    broker.close();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:37,代码来源:DistributedDataStoreRemotingIntegrationTest.java

示例9: testWriteTransactionWithMultipleShards

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testWriteTransactionWithMultipleShards() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testWriteTransactionWithMultipleShards", "cars-1", "people-1")) {

                DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
                assertNotNull("newWriteOnlyTransaction returned null", writeTx);

                writeTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
                writeTx.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());

                doCommit(writeTx.ready());

                writeTx = dataStore.newWriteOnlyTransaction();

                writeTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
                writeTx.write(PeopleModel.PERSON_LIST_PATH, PeopleModel.newPersonMapNode());

                doCommit(writeTx.ready());

                writeTx = dataStore.newWriteOnlyTransaction();

                final MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
                final YangInstanceIdentifier carPath = CarsModel.newCarPath("optima");
                writeTx.write(carPath, car);

                final MapEntryNode person = PeopleModel.newPersonEntry("jack");
                final YangInstanceIdentifier personPath = PeopleModel.newPersonPath("jack");
                writeTx.write(personPath, person);

                doCommit(writeTx.ready());

                // Verify the data in the store
                final DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();

                Optional<NormalizedNode<?, ?>> optional = readTx.read(carPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", car, optional.get());

                optional = readTx.read(personPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", person, optional.get());
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:49,代码来源:DistributedDataStoreIntegrationTest.java

示例10: testReadWriteTransactionWithMultipleShards

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testReadWriteTransactionWithMultipleShards() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testReadWriteTransactionWithMultipleShards", "cars-1", "people-1")) {

                DOMStoreReadWriteTransaction readWriteTx = dataStore.newReadWriteTransaction();
                assertNotNull("newReadWriteTransaction returned null", readWriteTx);

                readWriteTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
                readWriteTx.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());

                doCommit(readWriteTx.ready());

                readWriteTx = dataStore.newReadWriteTransaction();

                readWriteTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
                readWriteTx.write(PeopleModel.PERSON_LIST_PATH, PeopleModel.newPersonMapNode());

                doCommit(readWriteTx.ready());

                readWriteTx = dataStore.newReadWriteTransaction();

                final MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
                final YangInstanceIdentifier carPath = CarsModel.newCarPath("optima");
                readWriteTx.write(carPath, car);

                final MapEntryNode person = PeopleModel.newPersonEntry("jack");
                final YangInstanceIdentifier personPath = PeopleModel.newPersonPath("jack");
                readWriteTx.write(personPath, person);

                final Boolean exists = readWriteTx.exists(carPath).checkedGet(5, TimeUnit.SECONDS);
                assertEquals("exists", true, exists);

                Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(carPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", car, optional.get());

                doCommit(readWriteTx.ready());

                // Verify the data in the store
                DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();

                optional = readTx.read(carPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", car, optional.get());

                optional = readTx.read(personPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", person, optional.get());

            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:57,代码来源:DistributedDataStoreIntegrationTest.java

示例11: testTransactionChainWithMultipleShards

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testTransactionChainWithMultipleShards() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testTransactionChainWithMultipleShards", "cars-1", "people-1")) {

                final DOMStoreTransactionChain txChain = dataStore.createTransactionChain();

                DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
                assertNotNull("newWriteOnlyTransaction returned null", writeTx);

                writeTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
                writeTx.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());

                writeTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
                writeTx.write(PeopleModel.PERSON_LIST_PATH, PeopleModel.newPersonMapNode());

                final DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();

                final DOMStoreReadWriteTransaction readWriteTx = txChain.newReadWriteTransaction();

                final MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
                final YangInstanceIdentifier carPath = CarsModel.newCarPath("optima");
                readWriteTx.write(carPath, car);

                final MapEntryNode person = PeopleModel.newPersonEntry("jack");
                final YangInstanceIdentifier personPath = PeopleModel.newPersonPath("jack");
                readWriteTx.merge(personPath, person);

                Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(carPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", car, optional.get());

                optional = readWriteTx.read(personPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", person, optional.get());

                final DOMStoreThreePhaseCommitCohort cohort2 = readWriteTx.ready();

                writeTx = txChain.newWriteOnlyTransaction();

                writeTx.delete(carPath);

                final DOMStoreThreePhaseCommitCohort cohort3 = writeTx.ready();

                final ListenableFuture<Boolean> canCommit1 = cohort1.canCommit();
                final ListenableFuture<Boolean> canCommit2 = cohort2.canCommit();

                doCommit(canCommit1, cohort1);
                doCommit(canCommit2, cohort2);
                doCommit(cohort3);

                txChain.close();

                final DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();

                optional = readTx.read(carPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", false, optional.isPresent());

                optional = readTx.read(personPath).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", person, optional.get());
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:68,代码来源:DistributedDataStoreIntegrationTest.java

示例12: testChainedTransactionFailureWithSingleShard

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testChainedTransactionFailureWithSingleShard() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testChainedTransactionFailureWithSingleShard", "cars-1")) {

                final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
                        ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
                                .put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
                        MoreExecutors.directExecutor());

                final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
                final DOMTransactionChain txChain = broker.createTransactionChain(listener);

                final DOMDataReadWriteTransaction writeTx = txChain.newReadWriteTransaction();

                writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH,
                        PeopleModel.emptyContainer());

                final ContainerNode invalidData = ImmutableContainerNodeBuilder.create()
                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
                        .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();

                writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);

                try {
                    writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
                    fail("Expected TransactionCommitFailedException");
                } catch (final TransactionCommitFailedException e) {
                    // Expected
                }

                verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx),
                        any(Throwable.class));

                txChain.close();
                broker.close();
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:43,代码来源:DistributedDataStoreIntegrationTest.java

示例13: testChainedTransactionFailureWithMultipleShards

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testChainedTransactionFailureWithMultipleShards() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testChainedTransactionFailureWithMultipleShards", "cars-1", "people-1")) {

                final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
                        ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
                                .put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
                        MoreExecutors.directExecutor());

                final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
                final DOMTransactionChain txChain = broker.createTransactionChain(listener);

                final DOMDataReadWriteTransaction writeTx = txChain.newReadWriteTransaction();

                writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH,
                        PeopleModel.emptyContainer());

                final ContainerNode invalidData = ImmutableContainerNodeBuilder.create()
                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
                        .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();

                writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);

                // Note that merge will validate the data and fail but put
                // succeeds b/c deep validation is not
                // done for put for performance reasons.
                try {
                    writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
                    fail("Expected TransactionCommitFailedException");
                } catch (final TransactionCommitFailedException e) {
                    // Expected
                }

                verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx),
                        any(Throwable.class));

                txChain.close();
                broker.close();
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:46,代码来源:DistributedDataStoreIntegrationTest.java

示例14: testRestoreFromDatastoreSnapshot

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testRestoreFromDatastoreSnapshot() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            final String name = "transactionIntegrationTest";

            final ContainerNode carsNode = CarsModel.newCarsNode(
                    CarsModel.newCarsMapNode(CarsModel.newCarEntry("optima", BigInteger.valueOf(20000L)),
                            CarsModel.newCarEntry("sportage", BigInteger.valueOf(30000L))));

            DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
            dataTree.setSchemaContext(SchemaContextHelper.full());
            AbstractShardTest.writeToStore(dataTree, CarsModel.BASE_PATH, carsNode);
            NormalizedNode<?, ?> root = AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.EMPTY);

            final Snapshot carsSnapshot = Snapshot.create(
                    new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)),
                    Collections.emptyList(), 2, 1, 2, 1, 1, "member-1", null);

            dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
            dataTree.setSchemaContext(SchemaContextHelper.full());

            final NormalizedNode<?, ?> peopleNode = PeopleModel.create();
            AbstractShardTest.writeToStore(dataTree, PeopleModel.BASE_PATH, peopleNode);

            root = AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.EMPTY);

            final Snapshot peopleSnapshot = Snapshot.create(
                    new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)),
                    Collections.emptyList(), 2, 1, 2, 1, 1, "member-1", null);

            restoreFromSnapshot = new DatastoreSnapshot(name, null, Arrays.asList(
                    new DatastoreSnapshot.ShardSnapshot("cars", carsSnapshot),
                    new DatastoreSnapshot.ShardSnapshot("people", peopleSnapshot)));

            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, name, "module-shards-member1.conf", true, "cars", "people")) {

                final DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();

                // two reads
                Optional<NormalizedNode<?, ?>> optional = readTx.read(CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", carsNode, optional.get());

                optional = readTx.read(PeopleModel.BASE_PATH).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("Data node", peopleNode, optional.get());
            }
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:53,代码来源:DistributedDataStoreIntegrationTest.java

示例15: testLeadershipTransferOnShutdown

import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; //导入依赖的package包/类
@Test
public void testLeadershipTransferOnShutdown() throws Exception {
    //TODO remove when test passes also for ClientBackedDataStore
    Assume.assumeTrue(testParameter.equals(DistributedDataStore.class));
    leaderDatastoreContextBuilder.shardBatchedModificationCount(1);
    followerDatastoreContextBuilder.shardElectionTimeoutFactor(10).customRaftPolicyImplementation(null);
    final String testName = "testLeadershipTransferOnShutdown";
    initDatastores(testName, MODULE_SHARDS_CARS_PEOPLE_1_2_3, CARS_AND_PEOPLE);

    final IntegrationTestKit follower2TestKit = new IntegrationTestKit(follower2System,
            DatastoreContext.newBuilderFrom(followerDatastoreContextBuilder.build()).operationTimeoutInMillis(100),
            commitTimeout);
    try (AbstractDataStore follower2DistributedDataStore = follower2TestKit.setupAbstractDataStore(
            testParameter, testName, MODULE_SHARDS_CARS_PEOPLE_1_2_3, false)) {

        followerTestKit.waitForMembersUp("member-3");
        follower2TestKit.waitForMembersUp("member-1", "member-2");

        // Create and submit a couple tx's so they're pending.

        DOMStoreWriteTransaction writeTx = followerDistributedDataStore.newWriteOnlyTransaction();
        writeTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
        writeTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
        writeTx.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
        final DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();

        IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars",
            stats -> assertEquals("getTxCohortCacheSize", 1, stats.getTxCohortCacheSize()));

        writeTx = followerDistributedDataStore.newWriteOnlyTransaction();
        final MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
        writeTx.write(CarsModel.newCarPath("optima"), car);
        final DOMStoreThreePhaseCommitCohort cohort2 = writeTx.ready();

        IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars",
            stats -> assertEquals("getTxCohortCacheSize", 2, stats.getTxCohortCacheSize()));

        // Gracefully stop the leader via a Shutdown message.

        sendDatastoreContextUpdate(leaderDistributedDataStore, leaderDatastoreContextBuilder
            .shardElectionTimeoutFactor(100));

        final FiniteDuration duration = FiniteDuration.create(5, TimeUnit.SECONDS);
        final Future<ActorRef> future = leaderDistributedDataStore.getActorContext().findLocalShardAsync("cars");
        final ActorRef leaderActor = Await.result(future, duration);

        final Future<Boolean> stopFuture = Patterns.gracefulStop(leaderActor, duration, Shutdown.INSTANCE);

        // Commit the 2 transactions. They should finish and succeed.

        followerTestKit.doCommit(cohort1);
        followerTestKit.doCommit(cohort2);

        // Wait for the leader actor stopped.

        final Boolean stopped = Await.result(stopFuture, duration);
        assertEquals("Stopped", Boolean.TRUE, stopped);

        // Verify leadership was transferred by reading the committed data from the other nodes.

        verifyCars(followerDistributedDataStore.newReadOnlyTransaction(), car);
        verifyCars(follower2DistributedDataStore.newReadOnlyTransaction(), car);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:65,代码来源:DistributedDataStoreRemotingIntegrationTest.java


注:本文中的org.opendaylight.controller.md.cluster.datastore.model.PeopleModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。