morrySnow commented on code in PR #65644: URL: https://github.com/apache/doris/pull/65644#discussion_r3604570056
########## fe/fe-extension-loader/src/main/java/org/apache/doris/extension/loader/PluginRegistry.java: ########## @@ -0,0 +1,197 @@ +// 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.doris.extension.loader; + +import org.apache.doris.extension.spi.PluginFactory; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * Process-wide registry of loaded plugins across all plugin families + * (filesystem, connector, authentication, lineage, ...). + * + * <p>This is the single fact source behind {@code information_schema.plugins}. + * It only stores load-time snapshots (plain strings); listing the registry + * never executes plugin code. + * + * <p>Rules: + * <ul> + * <li>Primary key is {@code (type, name)}. The first registration wins; + * later registrations with the same key are rejected, never silently + * overridden. Family managers register built-ins before external plugins, + * so a directory jar can never displace a built-in row.</li> + * <li>Rows only exist for successfully loaded plugins. Load failures are + * reported via logs by the loading side and never enter the registry.</li> + * </ul> + */ +public final class PluginRegistry { + + /** Where a plugin was loaded from. */ + public enum PluginSource { + /** Bundled on the FE classpath, discovered via ServiceLoader. */ + BUILTIN, + /** Loaded from a plugin directory jar. */ + EXTERNAL + } + + /** Immutable load-time snapshot of one plugin. */ + public static final class PluginRecord { + private final String type; + private final String name; + private final String version; + private final String description; + private final PluginSource source; + private final Instant loadTime; + + public PluginRecord(String type, String name, String version, String description, + PluginSource source, Instant loadTime) { + this.type = Objects.requireNonNull(type, "type"); + this.name = Objects.requireNonNull(name, "name"); Review Comment: 用更有意义的错误信息 -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
