xxubai commented on code in PR #4073: URL: https://github.com/apache/amoro/pull/4073#discussion_r2852047152
########## amoro-ams/src/main/java/org/apache/amoro/server/table/TableRuntimePlugin.java: ########## @@ -0,0 +1,47 @@ +/* + * 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.amoro.server.table; + +import org.apache.amoro.AmoroTable; +import org.apache.amoro.ServerTableIdentifier; +import org.apache.amoro.TableRuntime; +import org.apache.amoro.table.TableRuntimeFactory; +import org.apache.amoro.table.TableRuntimeStore; + +import javax.annotation.Nullable; + +import java.util.List; + +public interface TableRuntimePlugin { + + boolean accept(ServerTableIdentifier tableIdentifier); + + void initialize(List<TableRuntime> tableRuntimes); + + void onTableCreated(@Nullable AmoroTable<?> amoroTable, TableRuntime tableRuntime); Review Comment: The interface is named TableXXX. Should we simplify the method names, for example to onCreate? ########## amoro-ams/src/main/java/org/apache/amoro/server/table/TableRuntimePlugin.java: ########## @@ -0,0 +1,47 @@ +/* + * 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.amoro.server.table; + +import org.apache.amoro.AmoroTable; +import org.apache.amoro.ServerTableIdentifier; +import org.apache.amoro.TableRuntime; +import org.apache.amoro.table.TableRuntimeFactory; +import org.apache.amoro.table.TableRuntimeStore; + +import javax.annotation.Nullable; + +import java.util.List; + +public interface TableRuntimePlugin { Review Comment: **1. TableRuntimePlugin violates Single Responsibility Principle** This interface mixes two distinct concerns: - Factory/decorator role: accept() + createTableRuntime() intercepts and decorates TableRuntime creation. - Lifecycle listener role: initialize() / onTableCreated() / onTableDropped() / dispose() observes table lifecycle events. These should be separated. The factory/decorator logic belongs in the TableRuntimeFactory hierarchy (e.g. as a decorator pattern), while the lifecycle observation should be its own interface. Mixing them forces every plugin implementor to deal with both concerns even if they only care about one. **2. Semantic overlap between TableRuntimePlugin.accept() and TableRuntimeFactory.accept()** In DefaultTableService.createTableRuntime(), there is a two-phase accept chain: first TableRuntimeFactory.accept(identifier, properties) selects the factory, then TableRuntimePlugin.accept(identifier) selects the plugin to intercept creation. These two have overlapping semantics — both decide "does this component handle this table?" — but with inconsistent signatures (TableRuntimeFactory receives table properties, TableRuntimePlugin does not). This dual-accept flow is confusing and error-prone. Consider unifying the entry point so there is a single, clear decision path for table runtime creation. -- 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]
