iron-core/src/main/java/io/axway/iron/core/spi/file/IronMigration.java
private static void completeStoreSnapshotWithMissingInstanceSnapshots(Path targetStoresPath) {
        String transactionIdRegexAlone = "\"transactionId\"\\s*:\\s*\\d+\\s*,";
        String transactionIdRegexReplace = "(.*\"transactionId\"\\s*:\\s*)\\d+(\\s*,.*)";
        Pattern transactionIdPattern = compile(transactionIdRegexAlone);
        Set<File> previousSnapshots = new HashSet<>();

        Arrays.stream(targetStoresPath.resolve(SNAPSHOT_DIRECTORY_NAME).toFile().listFiles()).
                sorted().
                forEach(snapshot -> {
                    Set<String> snapshotNames = Arrays.stream(snapshot.listFiles()).map(File::getName).collect(toSet());
                    previousSnapshots.stream().
                            filter(previousSnapshot -> !snapshotNames.contains(previousSnapshot.getName())).
                            forEach(previousSnapshot -> {
                                try {
                                    Path targetPath = snapshot.toPath().resolve(previousSnapshot.getName());
                                    Path sourcePath = previousSnapshot.toPath();
                                    long count = countTransactionId(transactionIdPattern, sourcePath);
                                    if (count != 1L) {
                                        throw new StoreException("transactionId not found once", args -> args.add("found count", count));
                                    }
                                    BigInteger newTransactionId = new BigInteger(snapshot.getName());
                                    replaceTransactionIdValue(transactionIdRegexReplace, sourcePath, targetPath, newTransactionId.toString());
                                } catch (IOException e) {
                                    throw new UncheckedIOException(e);
                                }
                            });
                    previousSnapshots.clear();
                    previousSnapshots.addAll(Arrays.stream(snapshot.listFiles()).collect(toSet()));
                });
    }
private static void completeStoreSnapshotWithMissingInstanceSnapshots(Path targetStoresPath) {
        String transactionIdRegexAlone = "\"transactionId\"\\s*:\\s*\\d+\\s*,";
        String transactionIdRegexReplace = "(.*\"transactionId\"\\s*:\\s*)\\d+(\\s*,.*)";
        Pattern transactionIdPattern = compile(transactionIdRegexAlone);
        Set<File> previousSnapshots = new HashSet<>();

        Arrays.stream(targetStoresPath.resolve(SNAPSHOT_DIRECTORY_NAME).toFile().listFiles()).
                sorted().
                forEach(snapshot -> {
                    Set<String> snapshotNames = Arrays.stream(snapshot.listFiles()).map(File::getName).collect(toSet());
                    previousSnapshots.stream().
                            filter(previousSnapshot -> !snapshotNames.contains(previousSnapshot.getName())).
                            forEach(previousSnapshot -> {
                                try {
                                    Path targetPath = snapshot.toPath().resolve(previousSnapshot.getName());
                                    Path sourcePath = previousSnapshot.toPath();
                                    long count = countTransactionId(transactionIdPattern, sourcePath);
                                    if (count != 1L) {
                                        throw new StoreException("transactionId not found once", args -> args.add("found count", count));
                                    }
                                    BigInteger newTransactionId = new BigInteger(snapshot.getName());
                                    replaceTransactionIdValue(transactionIdRegexReplace, sourcePath, targetPath, newTransactionId.toString());
                                } catch (IOException e) {
                                    throw new UncheckedIOException(e);
                                }
                            });
                    previousSnapshots.clear();
                    previousSnapshots.addAll(Arrays.stream(snapshot.listFiles()).collect(toSet()));
                });
    }
private static void completeStoreSnapshotWithMissingInstanceSnapshots ( Path targetStoresPath ) { String transactionIdRegexAlone = "\"transactionId\"\\s*:\\s*\\d+\\s*," ; String transactionIdRegexReplace = "(.*\"transactionId\"\\s*:\\s*)\\d+(\\s*,.*)" ; Pattern transactionIdPattern = compile ( transactionIdRegexAlone ) ; Set < File > previousSnapshots = new HashSet <> ( ) ; Arrays . stream ( targetStoresPath . resolve ( SNAPSHOT_DIRECTORY_NAME ) . toFile ( ) . listFiles ( ) ) . sorted ( ) . forEach ( snapshot -> { Set < String > snapshotNames = Arrays . stream ( snapshot . listFiles ( ) ) . map ( File :: getName ) . collect ( toSet ( ) ) ; previousSnapshots . stream ( ) . filter ( previousSnapshot -> ! snapshotNames . contains ( previousSnapshot . getName ( ) ) ) . forEach ( previousSnapshot -> { try { Path targetPath = snapshot . toPath ( ) . resolve ( previousSnapshot . getName ( ) ) ; Path sourcePath = previousSnapshot . toPath ( ) ; long count = countTransactionId ( transactionIdPattern , sourcePath ) ; if ( count != 1L ) { throw new StoreException ( "transactionId not found once" , args -> args . add ( "found count" , count ) ) ; } BigInteger newTransactionId = new BigInteger ( snapshot . getName ( ) ) ; replaceTransactionIdValue ( transactionIdRegexReplace , sourcePath , targetPath , newTransactionId . toString ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } ) ; previousSnapshots . clear ( ) ; previousSnapshots . addAll ( Arrays . stream ( snapshot . listFiles ( ) ) . collect ( toSet ( ) ) ) ; } ) ; }
Complete snapshot N with lacking instance snapshots from snapshot N - 1

@param targetStoresPath path to store target iron
Complete snapshot N with lacking instance snapshots from snapshot N - 1