mansehajsingh commented on code in PR #10:
URL: https://github.com/apache/polaris-tools/pull/10#discussion_r2056915952
##########
polaris-synchronizer/cli/src/main/java/org/apache/polaris/tools/sync/polaris/SyncPolarisCommand.java:
##########
@@ -120,11 +121,23 @@ public class SyncPolarisCommand implements
Callable<Integer> {
)
private boolean haltOnFailure;
+ @CommandLine.Option(
+ names = {"--catalog-name-regex"},
+ description = "If specified, only catalogs with names that match the
provided RegEx will be staged for " +
+ "synchronization. This applies to catalogs on both the
source and target."
+ )
+ private String catalogNameRegex;
+
@Override
public Integer call() throws Exception {
- SynchronizationPlanner sourceParityPlanner = new
SourceParitySynchronizationPlanner();
- SynchronizationPlanner modificationAwareSourceParityPlanner = new
ModificationAwarePlanner(sourceParityPlanner);
- SynchronizationPlanner accessControlAwarePlanner = new
AccessControlAwarePlanner(modificationAwareSourceParityPlanner);
+ SynchronizationPlanner planner = new SourceParitySynchronizationPlanner();
+ planner = new ModificationAwarePlanner(planner);
+
+ if (catalogNameRegex != null) {
+ planner = new CatalogNameFilterPlanner(catalogNameRegex, planner);
+ }
+
+ planner = new AccessControlAwarePlanner(planner);
Review Comment:
The order does matter! They each filter the inputs before the inputs reach
the lower ones. Think of it like this:
* We start out with two inputs, `principalRolesSource = [ role1, role2,
omnipotent-princpal-XXXX ]` and `principalRolesTarget = [ role1, role2, role3,
omnipotent-principal-YYYY ]`.
1. `AccessControlAwarePlanner` filters out the roles for the omnipotent
principal, so that `ModificationAwarePlanner` sees: `principalRolesSource = [
role1, role2 ]` and `principalRolesTarget = [ role1, role2, role3 ]`.
2. Lets say role2 changed a property over time but role1 was the same on the
source and target, so then, `ModificationAwarePlanner` filters out role1, so
that `SourceParitySynchronizationPlanner` sees:
`principalRolesSource = [ role2 ]` and `principalRolesTarget = [ role2,
role3 ]`
3. `SourceParitySynchronizationPlanner` now applies a base level strategy
and plans an overwrite for role2 and a remove for role3.
It's kind of like a filter chain, but one where links compose each other.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]