Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Caideyipi committed Jan 26, 2025
1 parent 990e2f8 commit d44f72c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.getExclusionString;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.getInclusionString;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.parseOptions;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.tableOnlySyncPrefix;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.treeOnlySyncPrefix;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.tableOnlySyncPrefixes;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.treeOnlySyncPrefixes;

/**
* {@link ConfigRegionListeningFilter} is to classify the {@link ConfigPhysicalPlan}s to help {@link
Expand Down Expand Up @@ -130,12 +130,12 @@ public class ConfigRegionListeningFilter {
Collections.unmodifiableList(
Arrays.asList(ConfigPhysicalPlanType.DropRole, ConfigPhysicalPlanType.RDropRole)));

// Tree
// Both
OPTION_PLAN_MAP.put(
new PartialPath("auth.role.grant.tree"),
new PartialPath("auth.role.grant"),
Collections.singletonList(ConfigPhysicalPlanType.GrantRole));
OPTION_PLAN_MAP.put(
new PartialPath("auth.role.revoke.tree"),
new PartialPath("auth.role.revoke"),
Collections.singletonList(ConfigPhysicalPlanType.RevokeRole));

// Table
Expand Down Expand Up @@ -174,7 +174,7 @@ public class ConfigRegionListeningFilter {
Collections.unmodifiableList(
Arrays.asList(ConfigPhysicalPlanType.DropUser, ConfigPhysicalPlanType.RUpdateUser)));

// Tree
// Both
OPTION_PLAN_MAP.put(
new PartialPath("auth.user.grant"),
Collections.unmodifiableList(
Expand All @@ -199,9 +199,7 @@ public class ConfigRegionListeningFilter {
ConfigPhysicalPlanType.RGrantUserAny,
ConfigPhysicalPlanType.RGrantUserDBPriv,
ConfigPhysicalPlanType.RGrantUserTBPriv,
ConfigPhysicalPlanType.RGrantUserSysPri,
ConfigPhysicalPlanType.GrantRoleToUser,
ConfigPhysicalPlanType.RGrantUserRole)));
ConfigPhysicalPlanType.RGrantUserSysPri)));
OPTION_PLAN_MAP.put(
new PartialPath("auth.role.revoke.table"),
Collections.unmodifiableList(
Expand All @@ -210,9 +208,7 @@ public class ConfigRegionListeningFilter {
ConfigPhysicalPlanType.RRevokeUserAny,
ConfigPhysicalPlanType.RRevokeUserDBPriv,
ConfigPhysicalPlanType.RRevokeUserTBPriv,
ConfigPhysicalPlanType.RRevokeUserSysPri,
ConfigPhysicalPlanType.RevokeRoleFromUser,
ConfigPhysicalPlanType.RRevokeUserRole)));
ConfigPhysicalPlanType.RRevokeUserSysPri)));
} catch (final IllegalPathException ignore) {
// There won't be any exceptions here
}
Expand Down Expand Up @@ -243,11 +239,11 @@ public static Set<ConfigPhysicalPlanType> parseListeningPlanTypeSet(
exclusionOptions.forEach(exclusion -> planTypes.removeAll(getOptionsByPrefix(exclusion)));

if (!TreePattern.isTreeModelDataAllowToBeCaptured(parameters)) {
planTypes.removeAll(getOptionsByPrefix(treeOnlySyncPrefix));
treeOnlySyncPrefixes.forEach(prefix -> planTypes.removeAll(getOptionsByPrefix(prefix)));
}

if (!TablePattern.isTableModelDataAllowToBeCaptured(parameters)) {
planTypes.removeAll(getOptionsByPrefix(tableOnlySyncPrefix));
tableOnlySyncPrefixes.forEach(prefix -> planTypes.removeAll(getOptionsByPrefix(prefix)));
}

return planTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.getExclusionString;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.getInclusionString;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.parseOptions;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.tableOnlySyncPrefix;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.treeOnlySyncPrefix;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.tableOnlySyncPrefixes;
import static org.apache.iotdb.commons.pipe.datastructure.options.PipeInclusionOptions.treeOnlySyncPrefixes;

/**
* {@link SchemaRegionListeningFilter} is to classify the {@link PlanNode}s to help {@link
Expand Down Expand Up @@ -118,11 +118,11 @@ public static Set<PlanNodeType> parseListeningPlanTypeSet(final PipeParameters p
exclusionOptions.forEach(exclusion -> planTypes.removeAll(getOptionsByPrefix(exclusion)));

if (!TreePattern.isTreeModelDataAllowToBeCaptured(parameters)) {
planTypes.removeAll(getOptionsByPrefix(treeOnlySyncPrefix));
planTypes.removeAll(getOptionsByPrefix(treeOnlySyncPrefixes));
}

if (!TablePattern.isTableModelDataAllowToBeCaptured(parameters)) {
planTypes.removeAll(getOptionsByPrefix(tableOnlySyncPrefix));
planTypes.removeAll(getOptionsByPrefix(tableOnlySyncPrefixes));
}
return planTypes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -45,10 +46,22 @@
public class PipeInclusionOptions {

private static final Logger LOGGER = LoggerFactory.getLogger(PipeInclusionOptions.class);
public static final PartialPath treeOnlySyncPrefix =
new PartialPath(new String[] {"schema", "timeseries"});
public static final PartialPath tableOnlySyncPrefix =
new PartialPath(new String[] {"schema", "table"});
public static final List<PartialPath> treeOnlySyncPrefixes =
Collections.unmodifiableList(
Arrays.asList(
new PartialPath(new String[] {"schema", "timeseries"}),
new PartialPath(new String[] {"auth", "role", "grant", "tree"}),
new PartialPath(new String[] {"auth", "role", "revoke", "tree"}),
new PartialPath(new String[] {"auth", "user", "grant", "tree"}),
new PartialPath(new String[] {"auth", "user", "revoke", "tree"})));
public static final List<PartialPath> tableOnlySyncPrefixes =
Collections.unmodifiableList(
Arrays.asList(
new PartialPath(new String[] {"schema", "table"}),
new PartialPath(new String[] {"auth", "role", "grant", "table"}),
new PartialPath(new String[] {"auth", "role", "revoke", "table"}),
new PartialPath(new String[] {"auth", "user", "grant", "table"}),
new PartialPath(new String[] {"auth", "user", "revoke", "table"})));
public static final String ALL = "all";

private static final Set<PartialPath> OPTIONS = new HashSet<>();
Expand Down

0 comments on commit d44f72c

Please sign in to comment.