- DistributedDataStore follower2DistributedDataStore = follower2TestKit.setupDistributedDataStore(testName,
- MODULE_SHARDS_CARS_PEOPLE_1_2_3, false);
-
- // 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());
- DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
-
- IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars", new ShardStatsVerifier() {
- @Override
- public void verify(ShardStats stats) {
- assertEquals("getTxCohortCacheSize", 1, stats.getTxCohortCacheSize());
- }
- });
-
- writeTx = followerDistributedDataStore.newWriteOnlyTransaction();
- MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
- writeTx.write(CarsModel.newCarPath("optima"), car);
- DOMStoreThreePhaseCommitCohort cohort2 = writeTx.ready();
-
- IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars", new ShardStatsVerifier() {
- @Override
- public void verify(ShardStats stats) {
- assertEquals("getTxCohortCacheSize", 2, stats.getTxCohortCacheSize());
- }
- });
-
- // Gracefully stop the leader via a Shutdown message.
-
- sendDatastoreContextUpdate(leaderDistributedDataStore, leaderDatastoreContextBuilder.
+ try (DistributedDataStore follower2DistributedDataStore = follower2TestKit.setupDistributedDataStore(testName,
+ MODULE_SHARDS_CARS_PEOPLE_1_2_3, false)) {
+
+ // 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());
+ DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
+
+ IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars", new ShardStatsVerifier() {
+ @Override
+ public void verify(ShardStats stats) {
+ assertEquals("getTxCohortCacheSize", 1, stats.getTxCohortCacheSize());
+ }
+ });
+
+ writeTx = followerDistributedDataStore.newWriteOnlyTransaction();
+ MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
+ writeTx.write(CarsModel.newCarPath("optima"), car);
+ DOMStoreThreePhaseCommitCohort cohort2 = writeTx.ready();
+
+ IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars", new ShardStatsVerifier() {
+ @Override
+ public void verify(ShardStats stats) {
+ assertEquals("getTxCohortCacheSize", 2, stats.getTxCohortCacheSize());
+ }
+ });
+
+ // Gracefully stop the leader via a Shutdown message.
+
+ sendDatastoreContextUpdate(leaderDistributedDataStore, leaderDatastoreContextBuilder.