Skip to content

Commit a3a0334

Browse files
committed
Fix
1 parent bc142e5 commit a3a0334

File tree

3 files changed

+95
-2
lines changed

3 files changed

+95
-2
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/ConfigRegionListeningFilter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,13 @@ public class ConfigRegionListeningFilter {
195195
new PartialPath("auth.role.grant.table"),
196196
Collections.unmodifiableList(
197197
Arrays.asList(
198-
ConfigPhysicalPlanType.RGrantUserAll,
199198
ConfigPhysicalPlanType.RGrantUserAny,
200199
ConfigPhysicalPlanType.RGrantUserDBPriv,
201200
ConfigPhysicalPlanType.RGrantUserTBPriv)));
202201
OPTION_PLAN_MAP.put(
203202
new PartialPath("auth.role.revoke.table"),
204203
Collections.unmodifiableList(
205204
Arrays.asList(
206-
ConfigPhysicalPlanType.RRevokeUserAll,
207205
ConfigPhysicalPlanType.RRevokeUserAny,
208206
ConfigPhysicalPlanType.RRevokeUserDBPriv,
209207
ConfigPhysicalPlanType.RRevokeUserTBPriv)));

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/IoTDBConfigRegionExtractor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public class IoTDBConfigRegionExtractor extends IoTDBNonDataRegionExtractor {
6464
new PipeConfigPhysicalPlanTablePatternParseVisitor();
6565
public static final PipeConfigPhysicalPlanTreeScopeParseVisitor TREE_SCOPE_PARSE_VISITOR =
6666
new PipeConfigPhysicalPlanTreeScopeParseVisitor();
67+
public static final PipeConfigPhysicalPlanTableScopeParseVisitor TABLE_SCOPE_PARSE_VISITOR =
68+
new PipeConfigPhysicalPlanTableScopeParseVisitor();
6769

6870
private Set<ConfigPhysicalPlanType> listenedTypeSet = new HashSet<>();
6971

@@ -159,6 +161,15 @@ public static Optional<ConfigPhysicalPlan> parseConfigPlan(
159161
}
160162
if (!treePattern.isTreeModelDataAllowedToBeCaptured() && result.isPresent()) {
161163
result = TREE_SCOPE_PARSE_VISITOR.process(result.get(), null);
164+
if (!result.isPresent()) {
165+
return result;
166+
}
167+
}
168+
if (!tablePattern.isTableModelDataAllowedToBeCaptured() && result.isPresent()) {
169+
result = TABLE_SCOPE_PARSE_VISITOR.process(result.get(), null);
170+
if (!result.isPresent()) {
171+
return result;
172+
}
162173
}
163174
return result;
164175
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.confignode.manager.pipe.extractor;
21+
22+
import org.apache.iotdb.commons.auth.entity.PrivilegeType;
23+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
24+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
25+
import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanVisitor;
26+
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorRelationalPlan;
27+
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorTreePlan;
28+
29+
import java.util.Collections;
30+
import java.util.Optional;
31+
import java.util.Set;
32+
import java.util.stream.Collectors;
33+
34+
public class PipeConfigPhysicalPlanTableScopeParseVisitor
35+
extends ConfigPhysicalPlanVisitor<Optional<ConfigPhysicalPlan>, Void> {
36+
@Override
37+
public Optional<ConfigPhysicalPlan> visitPlan(final ConfigPhysicalPlan plan, final Void context) {
38+
return Optional.of(plan);
39+
}
40+
41+
@Override
42+
public Optional<ConfigPhysicalPlan> visitRGrantUserAll(
43+
final AuthorRelationalPlan plan, final Void context) {
44+
return visitTableAuthorPlan(plan, ConfigPhysicalPlanType.GrantUser);
45+
}
46+
47+
@Override
48+
public Optional<ConfigPhysicalPlan> visitRGrantRoleAll(
49+
final AuthorRelationalPlan plan, final Void context) {
50+
return visitTableAuthorPlan(plan, ConfigPhysicalPlanType.GrantRole);
51+
}
52+
53+
@Override
54+
public Optional<ConfigPhysicalPlan> visitRRevokeUserAll(
55+
final AuthorRelationalPlan plan, final Void context) {
56+
return visitTableAuthorPlan(plan, ConfigPhysicalPlanType.RevokeUser);
57+
}
58+
59+
@Override
60+
public Optional<ConfigPhysicalPlan> visitRRevokeRoleAll(
61+
final AuthorRelationalPlan plan, final Void context) {
62+
return visitTableAuthorPlan(plan, ConfigPhysicalPlanType.RevokeRole);
63+
}
64+
65+
private Optional<ConfigPhysicalPlan> visitTableAuthorPlan(
66+
final AuthorRelationalPlan authorRelationalPlan, final ConfigPhysicalPlanType type) {
67+
final Set<Integer> permissions =
68+
authorRelationalPlan.getPermissions().stream()
69+
.filter(permission -> PrivilegeType.values()[permission].forRelationalSys())
70+
.collect(Collectors.toSet());
71+
return !permissions.isEmpty()
72+
? Optional.of(
73+
new AuthorTreePlan(
74+
type,
75+
authorRelationalPlan.getUserName(),
76+
authorRelationalPlan.getRoleName(),
77+
authorRelationalPlan.getPassword(),
78+
authorRelationalPlan.getNewPassword(),
79+
permissions,
80+
authorRelationalPlan.getGrantOpt(),
81+
Collections.emptyList()))
82+
: Optional.empty();
83+
}
84+
}

0 commit comments

Comments
 (0)