@Override
    public void commitMigration(PartitionMigrationEvent event) {
        try {
            migrationAwareService.commitMigration(event);
        } finally {
            if (isPrimaryReplicaMigrationEvent(event)) {
                int completed = ownerMigrationsCompleted.incrementAndGet();
                assert completed <= ownerMigrationsStarted.get();
            }
        }
    }
@Test
    public void commitMigration() {
        // when: before - commit migration methods have been executed
        try {
            countingMigrationAwareService.commitMigration(event);
        } catch (RuntimeException e) {
            // we do not care whether the wrapped service throws an exception
        }

        int currentMigrationStamp = countingMigrationAwareService.getMigrationStamp();
        // then: if event involves primary replica, stamp should change.
        if (isPrimaryReplicaMigrationEvent(event)) {
            assertNotEquals(initialMigrationStamp, currentMigrationStamp);
        } else {
            assertEquals(initialMigrationStamp, currentMigrationStamp);
        }
        assertTrue(countingMigrationAwareService.validateMigrationStamp(currentMigrationStamp));
    }