zstan commented on a change in pull request #518:
URL: https://github.com/apache/ignite-3/pull/518#discussion_r796402381



##########
File path: 
modules/index/src/main/java/org/apache/ignite/internal/idx/IndexManagerImpl.java
##########
@@ -0,0 +1,409 @@
+/*
+ * 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.idx;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.ignite.configuration.ConfigurationChangeException;
+import 
org.apache.ignite.configuration.notifications.ConfigurationNamedListListener;
+import 
org.apache.ignite.configuration.notifications.ConfigurationNotificationEvent;
+import org.apache.ignite.configuration.schemas.table.IndexColumnView;
+import org.apache.ignite.configuration.schemas.table.SortedIndexView;
+import org.apache.ignite.configuration.schemas.table.TableConfiguration;
+import org.apache.ignite.configuration.schemas.table.TableIndexChange;
+import org.apache.ignite.configuration.schemas.table.TableIndexView;
+import org.apache.ignite.configuration.schemas.table.TablesConfiguration;
+import 
org.apache.ignite.internal.configuration.schema.ExtendedTableConfiguration;
+import org.apache.ignite.internal.idx.event.IndexEvent;
+import org.apache.ignite.internal.idx.event.IndexEventParameters;
+import org.apache.ignite.internal.manager.AbstractProducer;
+import org.apache.ignite.internal.manager.IgniteComponent;
+import org.apache.ignite.internal.schema.Column;
+import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.storage.index.SortedIndexColumnCollation;
+import org.apache.ignite.internal.storage.index.SortedIndexColumnDescriptor;
+import org.apache.ignite.internal.storage.index.SortedIndexDescriptor;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.table.distributed.TableManager;
+import org.apache.ignite.internal.util.IgniteSpinBusyLock;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.lang.IgniteLogger;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.lang.IndexAlreadyExistsException;
+import org.apache.ignite.lang.IndexNotFoundException;
+import org.apache.ignite.lang.NodeStoppingException;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Internal index manager facade provides low-level methods for indexes 
operations.
+ */
+public class IndexManagerImpl extends AbstractProducer<IndexEvent, 
IndexEventParameters> implements IndexManager, IgniteComponent {
+    private static final IgniteLogger LOG = 
IgniteLogger.forClass(IndexManagerImpl.class);
+
+    private final TablesConfiguration tablesCfg;
+
+    private final TableManager tblMgr;
+
+    /** Indexes by canonical name. */
+    private final Map<String, InternalSortedIndex> idxsByName = new 
ConcurrentHashMap<>();
+
+    /** Busy lock to stop synchronously. */
+    private final IgniteSpinBusyLock busyLock = new IgniteSpinBusyLock();
+
+    /** Prevents double stopping the component. */
+    private final AtomicBoolean stopGuard = new AtomicBoolean();
+
+    /**
+     * Constructor.
+     *
+     * @param tablesCfg      Tables configuration.
+     */
+    public IndexManagerImpl(
+            TableManager tblMgr,
+            TablesConfiguration tablesCfg
+    ) {
+        this.tblMgr = tblMgr;
+        this.tablesCfg = tablesCfg;
+    }
+
+    @Override
+    public void start() {
+        tablesCfg.tables().any().indices().listenElements(
+                new ConfigurationNamedListListener<>() {
+                    @Override
+                    public @NotNull CompletableFuture<?> onCreate(@NotNull 
ConfigurationNotificationEvent<TableIndexView> ctx) {
+                        TableConfiguration tbl = 
ctx.config(TableConfiguration.class);
+                        String tblName = tbl.name().value();
+                        String idxName = ctx.newValue().name();
+
+                        if (!busyLock.enterBusy()) {
+                            fireEvent(IndexEvent.CREATE,
+                                    new IndexEventParameters(
+                                            idxName,
+                                            tblName),
+                                    new NodeStoppingException());
+
+                            return CompletableFuture.completedFuture(new 
NodeStoppingException());
+                        }
+                        try {
+                            onIndexCreate(ctx);
+                        } catch (Exception e) {
+                            fireEvent(
+                                    IndexEvent.CREATE,
+                                    new IndexEventParameters(
+                                            idxName,
+                                            tblName),
+                                    e

Review comment:
       strange formatting and if it`s ok bu other check style it`s no ok from 
human readable practice .. 




-- 
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]


Reply via email to