You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/10/08 11:05:52 UTC

[GitHub] [ignite-3] vldpyatkov opened a new pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

vldpyatkov opened a new pull request #388:
URL: https://github.com/apache/ignite-3/pull/388


   …ough the required table is already created


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725890158



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";

Review comment:
       Seems, that we rather should use one-liner for javadoc here and below. 




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725908335



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }

Review comment:
       Let's add else clause and also check that there's no table with TABLE_NAME and corresponding id on ignite1.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726479020



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);

Review comment:
       Done.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726481254



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.

Review comment:
       Fixed.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726503121



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {

Review comment:
       Ok.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726939531



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);

Review comment:
       Added 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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725898081



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {

Review comment:
       createDropTable**T**est




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726478236



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {

Review comment:
       Renamed to testCreateDropTable.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726124112



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";

Review comment:
       Ok. fixed.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726843387



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
##########
@@ -30,4 +31,12 @@
      * @return Table or {@code null} when not exists.
      */
     TableImpl table(IgniteUuid id);
+
+    /**
+     * Gets a table future by id, if it was created before or {@code null}.
+     *
+     * @param id Table id.
+     * @return Future representing pending completion of the operation.
+     */
+    CompletableFuture<TableImpl> tableAsync(IgniteUuid id);

Review comment:
       What about `ListenerRemovedException`?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726029954



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -861,10 +866,28 @@ private void dropTableLocally(String name, IgniteUuid tblId, List<List<ClusterNo
 
         tbl = tablesById.get(id);
 
-        if (tbl != null && getTblFut.complete(tbl) || getTblFut.complete(null))
+        if (tbl != null && getTblFut.complete(tbl) ||
+            !isTableConfigured(id) && getTblFut.complete(null))
             removeListener(TableEvent.CREATE, clo, null);
 
-        return getTblFut.join();
+        return getTblFut;
+    }
+
+    /**
+     * @param id Table id.
+     * @return True when the table is configured into cluster, false otherwise.
+     */
+    private boolean isTableConfigured(IgniteUuid id) {
+        NamedListView<TableView> directTablesCfg = ((DirectConfigurationProperty<NamedListView<TableView>>)tablesCfg.tables()).directValue();
+
+        for (String name : directTablesCfg.namedListKeys()) {

Review comment:
       As was discussed let's add todo here with ticket https://issues.apache.org/jira/browse/IGNITE-15721




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726848126



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,313 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /** Schema name. */
+    public static final String SCHEMA = "PUBLIC";
+
+    /** Short table name. */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /** Table name. */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /** Nodes bootstrap configuration. */
+    private final ArrayList<Function<String, String>> nodesBootstrapCfg = new ArrayList<>() {{
+        add((metostorNodeName) -> "{\n" +

Review comment:
       typo metostorNodeName -> met**a**storNodeName




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726941545



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
##########
@@ -30,4 +31,12 @@
      * @return Table or {@code null} when not exists.
      */
     TableImpl table(IgniteUuid id);
+
+    /**
+     * Gets a table future by id, if it was created before or {@code null}.
+     *
+     * @param id Table id.
+     * @return Future representing pending completion of the operation.
+     */
+    CompletableFuture<TableImpl> tableAsync(IgniteUuid id);

Review comment:
       The exception is never thrown here.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725961035



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(

Review comment:
       Well, despite the fact that inhibitor concept looks fine to me, I don't like an idea on using reflection for setting metaStorageManager spy. Are there any other options?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726482092



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);

Review comment:
       It is a tricky way for register new Watch with Inhibitor to Metastor.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725972836



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -861,10 +866,28 @@ private void dropTableLocally(String name, IgniteUuid tblId, List<List<ClusterNo
 
         tbl = tablesById.get(id);
 
-        if (tbl != null && getTblFut.complete(tbl) || getTblFut.complete(null))
+        if (tbl != null && getTblFut.complete(tbl) ||
+            !isTableConfigured(id) && getTblFut.complete(null))
             removeListener(TableEvent.CREATE, clo, null);
 
-        return getTblFut.join();
+        return getTblFut;
+    }
+
+    /**
+     * @param id Table id.
+     * @return True when the table is configured into cluster, false otherwise.

Review comment:
       > is configured into cluster
   
   Could you please rephrase, it seems a little bit confusing.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725913158



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }

Review comment:
       How it is possible through API?
   Look at tableByNameFut and tableByIdFut thay that are already stuck here.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726480165



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));

Review comment:
       Removed.
   Just in a first time when I ran the test, Configuration manager failed on an empty named collection.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726940671



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);
+
+        return inhibitor;
+    }
+
+    /**
+     * Listener which wraps another one to inhibit events.
+     */
+    private static class WatchListenerInhibitor implements WatchListener {
+        /** Inhibited events. */
+        private final ArrayList<WatchEvent> inhibitEvents = new ArrayList<>();
+
+        /** Inhibit flag. */
+        private boolean inhibit = false;
+
+        /** Wrapped listener */
+        private WatchListener realListener;
+
+        /**
+         * Sets a wrapped listener.
+         *
+         * @param realListener Listener to wrap.
+         */
+        public void setRealListener(WatchListener realListener) {
+            this.realListener = realListener;
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized boolean onUpdate(WatchEvent evt) {
+            if (!inhibit)
+                return realListener.onUpdate(evt);
+
+            return inhibitEvents.add(evt);
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized void onError(Throwable e) {
+            realListener.onError(e);

Review comment:
       Yes, it will.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov closed pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov closed pull request #388:
URL: https://github.com/apache/ignite-3/pull/388


   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726480724



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();

Review comment:
       Fixed.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov closed pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov closed pull request #388:
URL: https://github.com/apache/ignite-3/pull/388


   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726837739



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }

Review comment:
       Yep, you are right.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726859153



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,313 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /** Schema name. */
+    public static final String SCHEMA = "PUBLIC";
+
+    /** Short table name. */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /** Table name. */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /** Nodes bootstrap configuration. */
+    private final ArrayList<Function<String, String>> nodesBootstrapCfg = new ArrayList<>() {{
+        add((metostorNodeName) -> "{\n" +

Review comment:
       Yep, you are right.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726480520



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);

Review comment:
       Ok.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726945250



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -861,10 +866,28 @@ private void dropTableLocally(String name, IgniteUuid tblId, List<List<ClusterNo
 
         tbl = tablesById.get(id);
 
-        if (tbl != null && getTblFut.complete(tbl) || getTblFut.complete(null))
+        if (tbl != null && getTblFut.complete(tbl) ||
+            !isTableConfigured(id) && getTblFut.complete(null))
             removeListener(TableEvent.CREATE, clo, null);
 
-        return getTblFut.join();
+        return getTblFut;
+    }
+
+    /**
+     * @param id Table id.
+     * @return True when the table is configured into cluster, false otherwise.
+     */
+    private boolean isTableConfigured(IgniteUuid id) {
+        NamedListView<TableView> directTablesCfg = ((DirectConfigurationProperty<NamedListView<TableView>>)tablesCfg.tables()).directValue();
+
+        for (String name : directTablesCfg.namedListKeys()) {

Review comment:
       Added.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726485028



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(

Review comment:
       Added TODO about the issue IGNITE-15723




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725909396



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);

Review comment:
       For better clarity I'd rename inhibitor to node1Inhibitor or ignite1Inhibitor or similar.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726847095



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,313 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /** Schema name. */
+    public static final String SCHEMA = "PUBLIC";
+
+    /** Short table name. */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /** Table name. */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /** Nodes bootstrap configuration. */
+    private final ArrayList<Function<String, String>> nodesBootstrapCfg = new ArrayList<>() {{
+        add((metostorNodeName) -> "{\n" +

Review comment:
       Why you use metostorNodeName as a key for all nodes configuration?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726839578



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);

Review comment:
       In that case I'd add a comment here, that will explain this. Up to you, though.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726947812



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,313 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /** Schema name. */
+    public static final String SCHEMA = "PUBLIC";
+
+    /** Short table name. */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /** Table name. */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /** Nodes bootstrap configuration. */
+    private final ArrayList<Function<String, String>> nodesBootstrapCfg = new ArrayList<>() {{
+        add((metostorNodeName) -> "{\n" +

Review comment:
       Done.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725966082



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
##########
@@ -30,4 +31,12 @@
      * @return Table or {@code null} when not exists.
      */
     TableImpl table(IgniteUuid id);
+
+    /**
+     * Gets a table future by id, if it was created before or {@code null}.
+     *
+     * @param id Table id.
+     * @return Future representing pending completion of the operation.
+     */
+    CompletableFuture<TableImpl> tableAsync(IgniteUuid id);

Review comment:
       Seems that we should also specify possible exceptions here. 
   >or {@code null}.
   Do you mean that we'll get null instead of future future.get will return null?

##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
##########
@@ -30,4 +31,12 @@
      * @return Table or {@code null} when not exists.
      */
     TableImpl table(IgniteUuid id);
+
+    /**
+     * Gets a table future by id, if it was created before or {@code null}.
+     *
+     * @param id Table id.
+     * @return Future representing pending completion of the operation.
+     */
+    CompletableFuture<TableImpl> tableAsync(IgniteUuid id);

Review comment:
       Seems that we should also specify possible exceptions here. 
   >or {@code null}.
   
   Do you mean that we'll get null instead of future future.get will return null?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725890158



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";

Review comment:
       Seems, that we rather should use one-liner for javadoc here.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726482092



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);

Review comment:
       It needs for register new Watch with Inhibitor to Metastor.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725909961



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();

Review comment:
       stop




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726477718



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +

Review comment:
       Done.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726491776



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
##########
@@ -30,4 +31,12 @@
      * @return Table or {@code null} when not exists.
      */
     TableImpl table(IgniteUuid id);
+
+    /**
+     * Gets a table future by id, if it was created before or {@code null}.
+     *
+     * @param id Table id.
+     * @return Future representing pending completion of the operation.
+     */
+    CompletableFuture<TableImpl> tableAsync(IgniteUuid id);

Review comment:
       I fixed java doc, but I do not know about exceptions which will possible, because the code troughs nothing.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725962110



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);
+
+        return inhibitor;
+    }
+
+    /**
+     * Listener which wraps another one to inhibit events.
+     */
+    private static class WatchListenerInhibitor implements WatchListener {
+        /** Inhibited events. */
+        private final ArrayList<WatchEvent> inhibitEvents = new ArrayList<>();
+
+        /** Inhibit flag. */
+        private boolean inhibit = false;
+
+        /** Wrapped listener */
+        private WatchListener realListener;
+
+        /**
+         * Sets a wrapped listener.
+         *
+         * @param realListener Listener to wrap.
+         */
+        public void setRealListener(WatchListener realListener) {
+            this.realListener = realListener;
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized boolean onUpdate(WatchEvent evt) {
+            if (!inhibit)
+                return realListener.onUpdate(evt);
+
+            return inhibitEvents.add(evt);
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized void onError(Throwable e) {
+            realListener.onError(e);

Review comment:
       Should we also collect errors in case of inhibitor.start like we do it for common events?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725959839



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);

Review comment:
       Why we need this?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726845331



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);
+
+        return inhibitor;
+    }
+
+    /**
+     * Listener which wraps another one to inhibit events.
+     */
+    private static class WatchListenerInhibitor implements WatchListener {
+        /** Inhibited events. */
+        private final ArrayList<WatchEvent> inhibitEvents = new ArrayList<>();
+
+        /** Inhibit flag. */
+        private boolean inhibit = false;
+
+        /** Wrapped listener */
+        private WatchListener realListener;
+
+        /**
+         * Sets a wrapped listener.
+         *
+         * @param realListener Listener to wrap.
+         */
+        public void setRealListener(WatchListener realListener) {
+            this.realListener = realListener;
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized boolean onUpdate(WatchEvent evt) {
+            if (!inhibit)
+                return realListener.onUpdate(evt);
+
+            return inhibitEvents.add(evt);
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized void onError(Throwable e) {
+            realListener.onError(e);

Review comment:
       Do you mean onError is propagated to listener immediately ignoring the fact that inhibitor is started? If true, it seems fine to me.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726941545



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
##########
@@ -30,4 +31,12 @@
      * @return Table or {@code null} when not exists.
      */
     TableImpl table(IgniteUuid id);
+
+    /**
+     * Gets a table future by id, if it was created before or {@code null}.
+     *
+     * @param id Table id.
+     * @return Future representing pending completion of the operation.
+     */
+    CompletableFuture<TableImpl> tableAsync(IgniteUuid id);

Review comment:
       The exception be never thrown here.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726496381



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -861,10 +866,28 @@ private void dropTableLocally(String name, IgniteUuid tblId, List<List<ClusterNo
 
         tbl = tablesById.get(id);
 
-        if (tbl != null && getTblFut.complete(tbl) || getTblFut.complete(null))
+        if (tbl != null && getTblFut.complete(tbl) ||
+            !isTableConfigured(id) && getTblFut.complete(null))
             removeListener(TableEvent.CREATE, clo, null);
 
-        return getTblFut.join();
+        return getTblFut;
+    }
+
+    /**
+     * @param id Table id.
+     * @return True when the table is configured into cluster, false otherwise.

Review comment:
       Done.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725891825



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +

Review comment:
       What about using TestInfo for node name generation?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725906479



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));

Review comment:
       Why we need this?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725902433



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);

Review comment:
       meta**l**storageEventsInhibitor




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vldpyatkov commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
vldpyatkov commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r726494641



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.
+     *
+     * @param ignite Ignite.
+     * @return Listener inhibitor.
+     * @throws Exception If something wrong when creating the listener inhibitor.
+     */
+    private WatchListenerInhibitor metalstorageEventsInhibitor(Ignite ignite) throws Exception {
+        MetaStorageManager metaMngr = (MetaStorageManager)ReflectionUtils.tryToReadFieldValue(
+            IgniteImpl.class,
+            "metaStorageMgr",
+            (IgniteImpl)ignite
+        ).get();
+
+        assertNotNull(metaMngr);
+
+        WatchAggregator aggregator = (WatchAggregator)ReflectionUtils.tryToReadFieldValue(
+            MetaStorageManager.class,
+            "watchAggregator",
+            metaMngr
+        ).get();
+
+        assertNotNull(aggregator);
+
+        WatchAggregator aggregatorSpy = Mockito.spy(aggregator);
+
+        WatchListenerInhibitor inhibitor = new WatchListenerInhibitor();
+
+        doAnswer(mock -> {
+            Optional<AggregatedWatch> op = (Optional<AggregatedWatch>)mock.callRealMethod();
+
+            assertTrue(op.isPresent());
+
+            inhibitor.setRealListener(op.get().listener());
+
+            return Optional.of(new AggregatedWatch(op.get().keyCriterion(), op.get().revision(), inhibitor));
+        }).when(aggregatorSpy).watch(anyLong(), any());
+
+        IgniteTestUtils.setFieldValue(metaMngr, "watchAggregator", aggregatorSpy);
+
+        metaMngr.unregisterWatch(-1);
+
+        return inhibitor;
+    }
+
+    /**
+     * Listener which wraps another one to inhibit events.
+     */
+    private static class WatchListenerInhibitor implements WatchListener {
+        /** Inhibited events. */
+        private final ArrayList<WatchEvent> inhibitEvents = new ArrayList<>();
+
+        /** Inhibit flag. */
+        private boolean inhibit = false;
+
+        /** Wrapped listener */
+        private WatchListener realListener;
+
+        /**
+         * Sets a wrapped listener.
+         *
+         * @param realListener Listener to wrap.
+         */
+        public void setRealListener(WatchListener realListener) {
+            this.realListener = realListener;
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized boolean onUpdate(WatchEvent evt) {
+            if (!inhibit)
+                return realListener.onUpdate(evt);
+
+            return inhibitEvents.add(evt);
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized void onError(Throwable e) {
+            realListener.onError(e);

Review comment:
       While this approach is a part of the test, where an exception is not expected.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725912270



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {
+            assertNull(ignite.tables().table(TABLE_NAME));
+
+            assertNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+        }
+
+        inhibitor.startInhibit();
+    }
+
+    /**
+     * Creates the specific listener with can inhibit events for real Metastore listener.

Review comment:
       typo: with -> that or which




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #388: IGNITE-15396 TableManager#table(UUID) could return null value even th…

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #388:
URL: https://github.com/apache/ignite-3/pull/388#discussion_r725910638



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITTablesApiTest.java
##########
@@ -0,0 +1,308 @@
+/*
+ * 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.runner.app;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.metastorage.client.WatchEvent;
+import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
+import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
+import org.apache.ignite.internal.table.IgniteTablesInternal;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.Mockito;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.doAnswer;
+
+/**
+ * Integration tests to check consistent of java API on different nodes.
+ */
+public class ITTablesApiTest extends IgniteAbstractTest {
+    /**
+     * Schema name.
+     */
+    public static final String SCHEMA = "PUBLIC";
+
+    /**
+     * Short table name.
+     */
+    public static final String SHORT_TABLE_NAME = "tbl1";
+
+    /**
+     * Table name.
+     */
+    public static final String TABLE_NAME = SCHEMA + "." + SHORT_TABLE_NAME;
+
+    /**
+     * Nodes bootstrap configuration.
+     */
+    private final LinkedHashMap<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
+        put("node0", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3344,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node1", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3345,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+
+        put("node2", "{\n" +
+            "  \"node\": {\n" +
+            "    \"metastorageNodes\":[ \"node0\" ]\n" +
+            "  },\n" +
+            "  \"network\": {\n" +
+            "    \"port\":3346,\n" +
+            "    \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
+            "  }\n" +
+            "}");
+    }};
+
+    /**
+     * Cluster nodes.
+     */
+    private final ArrayList<Ignite> clusterNodes = new ArrayList<>();
+
+    /**
+     * @throws Exception If failed.
+     */
+    @BeforeEach
+    void beforeEach() throws Exception {
+        nodesBootstrapCfg.forEach((nodeName, configStr) ->
+            clusterNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
+        );
+    }
+
+    /**
+     * @throws Exception If fialed.
+     */
+    @AfterEach
+    void afterEach() throws Exception {
+        IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+    }
+
+    /**
+     * Checks that if a table would be created/dropped into any cluster node, this is visible to all other nodes.
+     *
+     * @throws Exception If fialrd.
+     */
+    @Test
+    public void createDropTabletest() throws Exception {
+        clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
+        clusterNodes.forEach(ign -> assertNull(((IgniteTablesInternal)ign.tables()).table(new IgniteUuid(UUID.randomUUID(), 1L))));
+
+        Ignite ignite1 = clusterNodes.get(1);
+
+        WatchListenerInhibitor inhibitor = metalstorageEventsInhibitor(ignite1);
+
+        inhibitor.startInhibit();
+
+        Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
+
+        IgniteUuid tblId = ((TableImpl)table).tableId();
+
+        CompletableFuture tableByNameFut = CompletableFuture.supplyAsync(() -> {
+            return ignite1.tables().table(TABLE_NAME);
+        });
+
+        CompletableFuture tableByIdFut = CompletableFuture.supplyAsync(() -> {
+            return ((IgniteTablesInternal)ignite1.tables()).table(tblId);
+        });
+
+        for (Ignite ignite: clusterNodes) {
+            if (ignite != ignite1) {
+                assertNotNull(ignite.tables().table(TABLE_NAME));
+
+                assertNotNull(((IgniteTablesInternal)ignite.tables()).table(tblId));
+            }
+        }
+
+        assertFalse(tableByNameFut.isDone());
+        assertFalse(tableByIdFut.isDone());
+
+        inhibitor.stopInhibit();
+
+        assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
+        assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
+
+        inhibitor.startInhibit();
+
+        clusterNodes.get(0).tables().dropTable(TABLE_NAME);
+
+        for (Ignite ignite : clusterNodes) {

Review comment:
       I'd also add a comment describing why we will get null on ignite1 event in case of started inhibitor.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org