public Integer call()

in polaris-synchronizer/cli/src/main/java/org/apache/polaris/tools/sync/polaris/SyncPolarisCommand.java [122:159]


  public Integer call() throws Exception {
    SynchronizationPlanner planner = SynchronizationPlanner.builder(new BaseStrategyPlanner(strategy))
            .conditionallyWrapBy(diffOnly, ModificationAwarePlanner::new)
            .conditionallyWrapBy(catalogNameRegex != null, p -> new CatalogNameFilterPlanner(catalogNameRegex, p))
            .wrapBy(AccessControlAwarePlanner::new)
            .build();

    // auto generate omnipotent principals with write access on the target, read only access on source
    sourceProperties.put(PolarisApiService.ICEBERG_WRITE_ACCESS_PROPERTY, Boolean.toString(false));
    targetProperties.put(PolarisApiService.ICEBERG_WRITE_ACCESS_PROPERTY, Boolean.toString(true));

    try (
            PolarisService source = PolarisServiceFactory.createPolarisService(
                    PolarisServiceFactory.ServiceType.API, sourceProperties);
            PolarisService target = PolarisServiceFactory.createPolarisService(
                    PolarisServiceFactory.ServiceType.API, targetProperties);
            ETagManager etagManager = ETagManagerFactory.createETagManager(etagManagerType, etagManagerProperties)
    ) {
      PolarisSynchronizer synchronizer =
              new PolarisSynchronizer(
                      consoleLog,
                      haltOnFailure,
                      planner,
                      source,
                      target,
                      etagManager,
                      diffOnly);
      synchronizer.syncPrincipalRoles();
      if (shouldSyncPrincipals) {
        consoleLog.warn("Principal migration will reset credentials on the target Polaris instance. " +
                "Principal migration will log the new target Principal credentials to stdout.");
        synchronizer.syncPrincipals();
      }
      synchronizer.syncCatalogs();
    }

    return 0;
  }