AMashenkov commented on code in PR #2494: URL: https://github.com/apache/ignite-3/pull/2494#discussion_r1307449298
########## modules/system-view/src/main/java/org/apache/ignite/internal/systemview/ClusterSystemView.java: ########## @@ -0,0 +1,89 @@ +/* + * 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.ignite.internal.systemview; + +import java.util.List; +import java.util.function.Supplier; +import org.apache.ignite.internal.util.AsyncCursor; + +/** + * Cluster wide view definition. + * + * <pre> + * // Creates definition of a cluster-wide system view. + * var tablesView = Cluster.<Table>clusterViewBuilder() + * .name("TABLES") + * .addColumn("ID", Integer.class, Table::id) + * .addColumn("SCHEMA_ID", Integer.class, Table::schemaId) + * .addColumn("NAME", String.class, Table::name) + * .dataProvider(() -> toAsyncCursor(tableManager.tables())) + * .build(); + * </pre> + * + * @param <T> System view data type. + * @see SystemView + */ +public class ClusterSystemView<T> extends SystemView<T> { + + /** + * Constructor. + * + * @param name View name. + * @param columns List of columns. + * @param dataProvider Data provider. + */ + ClusterSystemView(String name, + List<SystemViewColumn<T, ?>> columns, + Supplier<AsyncCursor<T>> dataProvider) { + + super(name, columns, dataProvider); + } + + /** + * Creates an instance of a builder to construct cluster-wide system views. + * + * @param <T> Type of elements returned by a system view. + * @return Returns a builder to construct cluster-wide system views. + */ + public static <T> Builder<T> builder() { Review Comment: It may be better to move `builder()`factory method to `SystemView` class to have a single point for creating all the views. Thus, developer don't have to remember class names and kind of views. ``` var builder = SystemView.clusterViewBuilder(); var builder = SystemView.nodeViewBuilder(); ... ``` Or maybe make them inner classes ``` var builder = SystemView.ClusterView.builder(); var builder = SystemView.NodeView.builder(); ``` or ``` var builder = SystemView.Builders.clusterView(); var builder = SystemView.Builders.nodeView(); ``` WDYT? -- 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]
