Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config node use IoTDBDescriptor #12730

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.iotdb.rpc.TSStatusCode;

import com.google.common.util.concurrent.SettableFuture;
import org.apache.ratis.util.MemoizedSupplier;
import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.block.TsBlockBuilder;
Expand All @@ -66,8 +67,8 @@ public class AuthorityChecker {
private static final String NO_PERMISSION_PROMOTION =
"No permissions for this operation, please add privilege ";

private static final IAuthorityFetcher authorityFetcher =
new ClusterAuthorityFetcher(new BasicAuthorityCache());
private static final MemoizedSupplier<IAuthorityFetcher> authorityFetcher =
MemoizedSupplier.valueOf(() -> new ClusterAuthorityFetcher(new BasicAuthorityCache()));

private static final PerformanceOverviewMetrics PERFORMANCE_OVERVIEW_METRICS =
PerformanceOverviewMetrics.getInstance();
Expand All @@ -77,24 +78,24 @@ private AuthorityChecker() {
}

public static IAuthorityFetcher getAuthorityFetcher() {
return authorityFetcher;
return authorityFetcher.get();
}

public static boolean invalidateCache(String username, String rolename) {
return authorityFetcher.getAuthorCache().invalidateCache(username, rolename);
return authorityFetcher.get().getAuthorCache().invalidateCache(username, rolename);
}

public static TSStatus checkUser(String userName, String password) {
return authorityFetcher.checkUser(userName, password);
return authorityFetcher.get().checkUser(userName, password);
}

public static SettableFuture<ConfigTaskResult> queryPermission(AuthorStatement authorStatement) {
return authorityFetcher.queryPermission(authorStatement);
return authorityFetcher.get().queryPermission(authorStatement);
}

public static SettableFuture<ConfigTaskResult> operatePermission(
AuthorStatement authorStatement) {
return authorityFetcher.operatePermission(authorStatement);
return authorityFetcher.get().operatePermission(authorStatement);
}

/** Check whether specific Session has the authorization to given plan. */
Expand Down Expand Up @@ -166,43 +167,46 @@ public static TSStatus getTSStatus(
public static boolean checkFullPathPermission(
String userName, PartialPath fullPath, int permission) {
return authorityFetcher
.get()
.checkUserPathPrivileges(userName, Collections.singletonList(fullPath), permission)
.isEmpty();
}

public static List<Integer> checkFullPathListPermission(
String userName, List<PartialPath> fullPaths, int permission) {
return authorityFetcher.checkUserPathPrivileges(userName, fullPaths, permission);
return authorityFetcher.get().checkUserPathPrivileges(userName, fullPaths, permission);
}

public static List<Integer> checkPatternPermission(
String userName, List<PartialPath> pathPatterns, int permission) {
return authorityFetcher.checkUserPathPrivileges(userName, pathPatterns, permission);
return authorityFetcher.get().checkUserPathPrivileges(userName, pathPatterns, permission);
}

public static PathPatternTree getAuthorizedPathTree(String userName, int permission)
throws AuthException {
return authorityFetcher.getAuthorizedPatternTree(userName, permission);
return authorityFetcher.get().getAuthorizedPatternTree(userName, permission);
}

public static boolean checkSystemPermission(String userName, int permission) {
return authorityFetcher.checkUserSysPrivileges(userName, permission).getCode()
return authorityFetcher.get().checkUserSysPrivileges(userName, permission).getCode()
== TSStatusCode.SUCCESS_STATUS.getStatusCode();
}

public static boolean checkGrantOption(
String userName, String[] privilegeList, List<PartialPath> nodeNameList) {
for (String s : privilegeList) {
if (!authorityFetcher.checkUserPrivilegeGrantOpt(
userName, nodeNameList, PrivilegeType.valueOf(s.toUpperCase()).ordinal())) {
if (!authorityFetcher
.get()
.checkUserPrivilegeGrantOpt(
userName, nodeNameList, PrivilegeType.valueOf(s.toUpperCase()).ordinal())) {
return false;
}
}
return true;
}

public static boolean checkRole(String username, String rolename) {
return authorityFetcher.checkRole(username, rolename);
return authorityFetcher.get().checkRole(username, rolename);
}

public static void buildTSBlock(
Expand Down
Loading