public Map syncTableAcrossCatalogs()

in xtable-core/src/main/java/org/apache/xtable/conversion/ConversionController.java [125:161]


  public Map<String, SyncResult> syncTableAcrossCatalogs(
      ConversionConfig config, Map<String, ConversionSourceProvider> conversionSourceProvider) {
    if (config.getTargetTables() == null || config.getTargetTables().isEmpty()) {
      throw new IllegalArgumentException("Please provide at-least one format to sync");
    }
    try (ConversionSource conversionSource =
        conversionSourceProvider
            .get(config.getSourceTable().getFormatName())
            .getConversionSourceInstance(config.getSourceTable())) {
      ExtractFromSource source = ExtractFromSource.of(conversionSource);
      Map<String, SyncResult> tableFormatSyncResults =
          syncTableFormats(config, source, config.getSyncMode());
      Map<String, SyncResult> catalogSyncResults = new HashMap<>();
      for (TargetTable targetTable : config.getTargetTables()) {
        Map<CatalogTableIdentifier, CatalogSyncClient> catalogSyncClients =
            config.getTargetCatalogs().get(targetTable).stream()
                .collect(
                    Collectors.toMap(
                        TargetCatalogConfig::getCatalogTableIdentifier,
                        targetCatalog ->
                            catalogConversionFactory.createCatalogSyncClient(
                                targetCatalog.getCatalogConfig(),
                                targetTable.getFormatName(),
                                conf)));
        catalogSyncResults.put(
            targetTable.getFormatName(),
            syncCatalogsForTargetTable(
                targetTable,
                catalogSyncClients,
                conversionSourceProvider.get(targetTable.getFormatName())));
      }
      mergeSyncResults(tableFormatSyncResults, catalogSyncResults);
      return tableFormatSyncResults;
    } catch (IOException ioException) {
      throw new ReadException("Failed to close source converter", ioException);
    }
  }