mansehajsingh commented on code in PR #4:
URL: https://github.com/apache/polaris-tools/pull/4#discussion_r2045433528


##########
polaris-synchronizer/api/src/main/java/org/apache/polaris/tools/sync/polaris/PolarisSynchronizer.java:
##########
@@ -0,0 +1,1135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.tools.sync.polaris;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iceberg.BaseTable;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.SupportsNamespaces;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.polaris.core.admin.model.Catalog;
+import org.apache.polaris.core.admin.model.CatalogRole;
+import org.apache.polaris.core.admin.model.GrantResource;
+import org.apache.polaris.core.admin.model.PrincipalRole;
+import org.apache.polaris.core.admin.model.PrincipalWithCredentials;
+import org.apache.polaris.tools.sync.polaris.access.AccessControlService;
+import org.apache.polaris.tools.sync.polaris.catalog.BaseTableWithETag;
+import org.apache.polaris.tools.sync.polaris.catalog.ETagService;
+import org.apache.polaris.tools.sync.polaris.catalog.NotModifiedException;
+import org.apache.polaris.tools.sync.polaris.catalog.PolarisCatalog;
+import org.apache.polaris.tools.sync.polaris.planning.SynchronizationPlanner;
+import org.apache.polaris.tools.sync.polaris.planning.plan.SynchronizationPlan;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Encapsulates idempotent and failure-safe logic to perform Polaris entity 
syncs. Performs logging
+ * with configurability and all actions related to the generated sync plans.
+ */
+public class PolarisSynchronizer {
+
+  private final Logger clientLogger;
+
+  private final SynchronizationPlanner syncPlanner;
+
+  private final PolarisService source;
+
+  private final PolarisService target;
+
+  private final PrincipalWithCredentials sourceOmnipotentPrincipal;
+
+  private final PrincipalWithCredentials targetOmnipotentPrincipal;
+
+  private final PrincipalRole sourceOmnipotentPrincipalRole;
+
+  private final PrincipalRole targetOmnipotentPrincipalRole;
+
+  private final AccessControlService sourceAccessControlService;
+
+  private final AccessControlService targetAccessControlService;
+
+  private final ETagService etagService;
+
+  public PolarisSynchronizer(
+      Logger clientLogger,
+      SynchronizationPlanner synchronizationPlanner,
+      PrincipalWithCredentials sourceOmnipotentPrincipal,
+      PrincipalWithCredentials targetOmnipotentPrincipal,
+      PolarisService source,
+      PolarisService target,
+      ETagService etagService) {
+    this.clientLogger =
+        clientLogger == null ? 
LoggerFactory.getLogger(PolarisSynchronizer.class) : clientLogger;
+    this.syncPlanner = synchronizationPlanner;
+    this.sourceOmnipotentPrincipal = sourceOmnipotentPrincipal;
+    this.targetOmnipotentPrincipal = targetOmnipotentPrincipal;
+    this.source = source;
+    this.target = target;
+    this.sourceAccessControlService = new AccessControlService(source);
+    this.targetAccessControlService = new AccessControlService(target);
+
+    this.sourceOmnipotentPrincipalRole =
+        sourceAccessControlService.getOmnipotentPrincipalRoleForPrincipal(
+            sourceOmnipotentPrincipal.getPrincipal().getName());
+    this.targetOmnipotentPrincipalRole =
+        targetAccessControlService.getOmnipotentPrincipalRoleForPrincipal(
+            targetOmnipotentPrincipal.getPrincipal().getName());
+    this.etagService = etagService;
+  }
+
+  /**
+   * Calculates the total number of sync tasks to complete.
+   *
+   * @param plan the plan to scan for cahnges
+   * @return the nuber of syncs to perform
+   */
+  private int totalSyncsToComplete(SynchronizationPlan<?> plan) {
+    return plan.entitiesToCreate().size()
+        + plan.entitiesToOverwrite().size()
+        + plan.entitiesToRemove().size();
+  }
+
+  /** Sync principal roles from source to target. */

Review Comment:
   If we don't have strong opinions here, I think `migrate` might be fine. I 
think `migrate` opens up the least amount of assumptions of what this tool is 
supposed to do. I agree `synchronization` is pretty ambiguous. While I like 
`replicator,` replication to me is less applicable to how most people will be 
using this tool, which is to perform a bulk migration from Polaris 1 to Polaris 
2.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to