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 2022/04/12 11:57:39 UTC
[GitHub] [ignite-3] tkalkirill opened a new pull request, #773: IGNITE-16797 DDL support for Storage specific parameters
tkalkirill opened a new pull request, #773:
URL: https://github.com/apache/ignite-3/pull/773
https://issues.apache.org/jira/browse/IGNITE-16797
--
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] tkalkirill commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851075164
##########
modules/storage-api/src/test/java/org/apache/ignite/internal/storage/DataStorageModulesTest.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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.storage;
+
+import static org.apache.ignite.configuration.schemas.store.UnknownDataStorageConfigurationSchema.UNKNOWN_DATA_STORAGE;
+import static org.apache.ignite.internal.storage.DataStorageModulesTest.FirstDataStorageConfigurationSchema.FIRST;
+import static org.apache.ignite.internal.storage.DataStorageModulesTest.SecondDataStorageConfigurationSchema.SECOND;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.configuration.annotation.PolymorphicConfigInstance;
+import org.apache.ignite.configuration.annotation.Value;
+import org.apache.ignite.configuration.schemas.store.DataStorageConfigurationSchema;
+import org.apache.ignite.internal.configuration.ConfigurationRegistry;
+import org.apache.ignite.internal.storage.engine.StorageEngine;
+import org.apache.ignite.internal.testframework.WorkDirectory;
+import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ * For {@link DataStorageModules} testing.
+ */
+@ExtendWith(WorkDirectoryExtension.class)
+public class DataStorageModulesTest {
+ @WorkDirectory
+ private Path workDir;
+
+ /**
+ * Test extension of {@link DataStorageConfigurationSchema}.
+ */
+ @PolymorphicConfigInstance(FIRST)
+ public static class FirstDataStorageConfigurationSchema extends DataStorageConfigurationSchema {
+ static final String FIRST = "first";
+
+ @Value(hasDefault = true)
+ public String strVal = "foo";
+
+ @Value(hasDefault = true)
+ public int intVal = 100;
+ }
+
+ /**
+ * Test extension of {@link DataStorageConfigurationSchema}.
+ */
+ @PolymorphicConfigInstance(SECOND)
+ public static class SecondDataStorageConfigurationSchema extends DataStorageConfigurationSchema {
+ static final String SECOND = "second";
+
+ @Value(hasDefault = true)
+ public String strVal = "bar";
+
+ @Value(hasDefault = true)
+ public long longVal = 500L;
+ }
+
+ @Test
+ void testDuplicateName() {
+ String sameName = FIRST;
+
+ IllegalStateException exception = assertThrows(
+ IllegalStateException.class,
+ () -> new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(sameName, FirstDataStorageConfigurationSchema.class),
+ createMockedStorageEngineFactory(sameName, SecondDataStorageConfigurationSchema.class)
+ ))
+ );
+
+ assertThat(exception.getMessage(), Matchers.startsWith("Duplicate name"));
+ }
+
+ @Test
+ void testInvalidName() {
+ IllegalStateException exception = assertThrows(
+ IllegalStateException.class,
+ () -> new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(UNKNOWN_DATA_STORAGE, FirstDataStorageConfigurationSchema.class)
+ ))
+ );
+
+ assertThat(exception.getMessage(), Matchers.startsWith("Invalid name"));
+ }
+
+ @Test
+ void testNamesDoNotMatch() {
+ IllegalStateException exception = assertThrows(
+ IllegalStateException.class,
+ () -> new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(SECOND, FirstDataStorageConfigurationSchema.class)
+ ))
+ );
+
+ assertThat(exception.getMessage(), Matchers.startsWith("Names do not match"));
+ }
+
+ @Test
+ void testCreateDataEngines() {
+ DataStorageModules dataStorageModules = new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(FIRST, FirstDataStorageConfigurationSchema.class),
+ createMockedStorageEngineFactory(SECOND, SecondDataStorageConfigurationSchema.class)
+ ));
+
+ Map<String, StorageEngine> engines = dataStorageModules.createStorageEngines(mock(ConfigurationRegistry.class), workDir);
+
+ assertThat(engines, aMapWithSize(2));
+
+ assertTrue(engines.containsKey(FIRST));
+ assertTrue(engines.containsKey(SECOND));
+
+ assertNotSame(engines.get(FIRST), engines.get(SECOND));
+ }
+
+ @Test
+ void testCollectSchemasFields() {
+ DataStorageModules dataStorageModules = new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(FIRST, FirstDataStorageConfigurationSchema.class),
+ createMockedStorageEngineFactory(SECOND, SecondDataStorageConfigurationSchema.class)
+ ));
+
+ Map<String, Map<String, Class<?>>> fields = dataStorageModules.collectSchemasFields();
+
+ assertThat(fields, aMapWithSize(2));
+
+ assertThat(fields.get(FIRST), equalTo(Map.of("strVal", String.class, "intVal", int.class)));
+
+ assertThat(fields.get(SECOND), equalTo(Map.of("strVal", String.class, "longVal", long.class)));
+ }
+
+ static DataStorageModule createMockedStorageEngineFactory(
Review Comment:
Fix it
--
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] tkalkirill commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851100095
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModule.java:
##########
@@ -15,24 +15,29 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.storage.engine;
+package org.apache.ignite.internal.storage;
import java.nio.file.Path;
import org.apache.ignite.configuration.schemas.store.DataStorageConfigurationSchema;
import org.apache.ignite.internal.configuration.ConfigurationRegistry;
-import org.apache.ignite.internal.storage.StorageException;
+import org.apache.ignite.internal.storage.engine.StorageEngine;
/**
- * Factory for creating storage engines.
+ * Data storage module.
*/
-public interface StorageEngineFactory {
+public interface DataStorageModule {
/**
- * Returns the unique name of the storage engine.
+ * Returns the unique name of the data storage.
*
* <p>Used to map {@link DataStorageConfigurationSchema#name} to {@link StorageEngine}.
*/
String name();
+ /**
+ * Returns the data storage configuration schema.
+ */
+ Class<? extends DataStorageConfigurationSchema> schema();
Review Comment:
Removed this method.
--
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] ibessonov commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
ibessonov commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r850378528
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageManager.java:
##########
@@ -118,6 +96,73 @@ public Consumer<DataStorageChange> defaultTableDataStorageConsumer(String defaul
};
}
+ /**
+ * Returns the default data storage.
+ *
+ * @param defaultDataStorageView View of {@link TablesConfigurationSchema#defaultDataStorage}. For the case {@link
+ * UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} and there is only one engine, then it will be the default.
+ */
+ public String defaultDataStorage(String defaultDataStorageView) {
+ return !defaultDataStorageView.equals(UNKNOWN_DATA_STORAGE) || engines.size() > 1
+ ? defaultDataStorageView : first(engines.keySet());
+ }
+
+ /**
+ * Creates a consumer that will change the {@link DataStorageConfigurationSchema data storage} for the {@link
+ * TableConfigurationSchema#dataStorage}.
+ *
+ * @param dataStorage Data storage, {@link UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} is invalid.
+ * @param values {@link Value Values} for the data storage. Mapping: field name -> field value.
+ */
+ public Consumer<DataStorageChange> tableDataStorageConsumer(String dataStorage, Map<String, Object> values) {
+ assert !dataStorage.equals(UNKNOWN_DATA_STORAGE);
+
+ ConfigurationSource configurationSource = new ConfigurationSource() {
+ /** {@inheritDoc} */
+ @Override
+ public String polymorphicTypeId(String fieldName) {
+ throw new UnsupportedOperationException("polymorphicTypeId");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void descend(ConstructableTreeNode node) {
+ for (Entry<String, Object> e : values.entrySet()) {
+ assert e.getKey() != null;
+ assert e.getValue() != null : e.getKey();
+
+ ConfigurationSource leafSource = new ConfigurationSource() {
+ /** {@inheritDoc} */
+ @Override
+ public <T> T unwrap(Class<T> clazz) {
+ return clazz.cast(e.getValue());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void descend(ConstructableTreeNode node) {
+ throw new UnsupportedOperationException("descend");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String polymorphicTypeId(String fieldName) {
+ throw new UnsupportedOperationException("polymorphicTypeId");
+ }
+ };
+
+ node.construct(e.getKey(), leafSource, true);
+ }
+ }
+ };
+
+ return tableDataStorageChange -> {
+ tableDataStorageChange.convert(dataStorage);
+
+ configurationSource.descend(((ConstructableTreeNode) tableDataStorageChange));
Review Comment:
Please remove extra parentheses
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModule.java:
##########
@@ -15,24 +15,29 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.storage.engine;
+package org.apache.ignite.internal.storage;
import java.nio.file.Path;
import org.apache.ignite.configuration.schemas.store.DataStorageConfigurationSchema;
import org.apache.ignite.internal.configuration.ConfigurationRegistry;
-import org.apache.ignite.internal.storage.StorageException;
+import org.apache.ignite.internal.storage.engine.StorageEngine;
/**
- * Factory for creating storage engines.
+ * Data storage module.
*/
-public interface StorageEngineFactory {
+public interface DataStorageModule {
/**
- * Returns the unique name of the storage engine.
+ * Returns the unique name of the data storage.
*
* <p>Used to map {@link DataStorageConfigurationSchema#name} to {@link StorageEngine}.
*/
String name();
+ /**
+ * Returns the data storage configuration schema.
+ */
+ Class<? extends DataStorageConfigurationSchema> schema();
Review Comment:
Technically speaking, this is redundant. I don't necessarily think that you should remove it, just saying
##########
modules/storage-api/src/test/java/org/apache/ignite/internal/storage/DataStorageModulesTest.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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.storage;
+
+import static org.apache.ignite.configuration.schemas.store.UnknownDataStorageConfigurationSchema.UNKNOWN_DATA_STORAGE;
+import static org.apache.ignite.internal.storage.DataStorageModulesTest.FirstDataStorageConfigurationSchema.FIRST;
+import static org.apache.ignite.internal.storage.DataStorageModulesTest.SecondDataStorageConfigurationSchema.SECOND;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.configuration.annotation.PolymorphicConfigInstance;
+import org.apache.ignite.configuration.annotation.Value;
+import org.apache.ignite.configuration.schemas.store.DataStorageConfigurationSchema;
+import org.apache.ignite.internal.configuration.ConfigurationRegistry;
+import org.apache.ignite.internal.storage.engine.StorageEngine;
+import org.apache.ignite.internal.testframework.WorkDirectory;
+import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ * For {@link DataStorageModules} testing.
+ */
+@ExtendWith(WorkDirectoryExtension.class)
+public class DataStorageModulesTest {
+ @WorkDirectory
+ private Path workDir;
+
+ /**
+ * Test extension of {@link DataStorageConfigurationSchema}.
+ */
+ @PolymorphicConfigInstance(FIRST)
+ public static class FirstDataStorageConfigurationSchema extends DataStorageConfigurationSchema {
+ static final String FIRST = "first";
+
+ @Value(hasDefault = true)
+ public String strVal = "foo";
+
+ @Value(hasDefault = true)
+ public int intVal = 100;
+ }
+
+ /**
+ * Test extension of {@link DataStorageConfigurationSchema}.
+ */
+ @PolymorphicConfigInstance(SECOND)
+ public static class SecondDataStorageConfigurationSchema extends DataStorageConfigurationSchema {
+ static final String SECOND = "second";
+
+ @Value(hasDefault = true)
+ public String strVal = "bar";
+
+ @Value(hasDefault = true)
+ public long longVal = 500L;
+ }
+
+ @Test
+ void testDuplicateName() {
+ String sameName = FIRST;
+
+ IllegalStateException exception = assertThrows(
+ IllegalStateException.class,
+ () -> new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(sameName, FirstDataStorageConfigurationSchema.class),
+ createMockedStorageEngineFactory(sameName, SecondDataStorageConfigurationSchema.class)
+ ))
+ );
+
+ assertThat(exception.getMessage(), Matchers.startsWith("Duplicate name"));
+ }
+
+ @Test
+ void testInvalidName() {
+ IllegalStateException exception = assertThrows(
+ IllegalStateException.class,
+ () -> new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(UNKNOWN_DATA_STORAGE, FirstDataStorageConfigurationSchema.class)
+ ))
+ );
+
+ assertThat(exception.getMessage(), Matchers.startsWith("Invalid name"));
+ }
+
+ @Test
+ void testNamesDoNotMatch() {
+ IllegalStateException exception = assertThrows(
+ IllegalStateException.class,
+ () -> new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(SECOND, FirstDataStorageConfigurationSchema.class)
+ ))
+ );
+
+ assertThat(exception.getMessage(), Matchers.startsWith("Names do not match"));
+ }
+
+ @Test
+ void testCreateDataEngines() {
+ DataStorageModules dataStorageModules = new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(FIRST, FirstDataStorageConfigurationSchema.class),
+ createMockedStorageEngineFactory(SECOND, SecondDataStorageConfigurationSchema.class)
+ ));
+
+ Map<String, StorageEngine> engines = dataStorageModules.createStorageEngines(mock(ConfigurationRegistry.class), workDir);
+
+ assertThat(engines, aMapWithSize(2));
+
+ assertTrue(engines.containsKey(FIRST));
+ assertTrue(engines.containsKey(SECOND));
+
+ assertNotSame(engines.get(FIRST), engines.get(SECOND));
+ }
+
+ @Test
+ void testCollectSchemasFields() {
+ DataStorageModules dataStorageModules = new DataStorageModules(List.of(
+ createMockedStorageEngineFactory(FIRST, FirstDataStorageConfigurationSchema.class),
+ createMockedStorageEngineFactory(SECOND, SecondDataStorageConfigurationSchema.class)
+ ));
+
+ Map<String, Map<String, Class<?>>> fields = dataStorageModules.collectSchemasFields();
+
+ assertThat(fields, aMapWithSize(2));
+
+ assertThat(fields.get(FIRST), equalTo(Map.of("strVal", String.class, "intVal", int.class)));
+
+ assertThat(fields.get(SECOND), equalTo(Map.of("strVal", String.class, "longVal", long.class)));
+ }
+
+ static DataStorageModule createMockedStorageEngineFactory(
Review Comment:
Please rename this method
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageManager.java:
##########
@@ -118,6 +96,73 @@ public Consumer<DataStorageChange> defaultTableDataStorageConsumer(String defaul
};
}
+ /**
+ * Returns the default data storage.
+ *
+ * @param defaultDataStorageView View of {@link TablesConfigurationSchema#defaultDataStorage}. For the case {@link
+ * UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} and there is only one engine, then it will be the default.
+ */
+ public String defaultDataStorage(String defaultDataStorageView) {
Review Comment:
I'm still confident that this method is absolutely useless in practice
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite-3] tkalkirill commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851074880
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageManager.java:
##########
@@ -118,6 +96,73 @@ public Consumer<DataStorageChange> defaultTableDataStorageConsumer(String defaul
};
}
+ /**
+ * Returns the default data storage.
+ *
+ * @param defaultDataStorageView View of {@link TablesConfigurationSchema#defaultDataStorage}. For the case {@link
+ * UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} and there is only one engine, then it will be the default.
+ */
+ public String defaultDataStorage(String defaultDataStorageView) {
+ return !defaultDataStorageView.equals(UNKNOWN_DATA_STORAGE) || engines.size() > 1
+ ? defaultDataStorageView : first(engines.keySet());
+ }
+
+ /**
+ * Creates a consumer that will change the {@link DataStorageConfigurationSchema data storage} for the {@link
+ * TableConfigurationSchema#dataStorage}.
+ *
+ * @param dataStorage Data storage, {@link UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} is invalid.
+ * @param values {@link Value Values} for the data storage. Mapping: field name -> field value.
+ */
+ public Consumer<DataStorageChange> tableDataStorageConsumer(String dataStorage, Map<String, Object> values) {
+ assert !dataStorage.equals(UNKNOWN_DATA_STORAGE);
+
+ ConfigurationSource configurationSource = new ConfigurationSource() {
+ /** {@inheritDoc} */
+ @Override
+ public String polymorphicTypeId(String fieldName) {
+ throw new UnsupportedOperationException("polymorphicTypeId");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void descend(ConstructableTreeNode node) {
+ for (Entry<String, Object> e : values.entrySet()) {
+ assert e.getKey() != null;
+ assert e.getValue() != null : e.getKey();
+
+ ConfigurationSource leafSource = new ConfigurationSource() {
+ /** {@inheritDoc} */
+ @Override
+ public <T> T unwrap(Class<T> clazz) {
+ return clazz.cast(e.getValue());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void descend(ConstructableTreeNode node) {
+ throw new UnsupportedOperationException("descend");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String polymorphicTypeId(String fieldName) {
+ throw new UnsupportedOperationException("polymorphicTypeId");
+ }
+ };
+
+ node.construct(e.getKey(), leafSource, true);
+ }
+ }
+ };
+
+ return tableDataStorageChange -> {
+ tableDataStorageChange.convert(dataStorage);
+
+ configurationSource.descend(((ConstructableTreeNode) tableDataStorageChange));
Review Comment:
Fix it
--
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] tkalkirill commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851074475
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageManager.java:
##########
@@ -118,6 +96,73 @@ public Consumer<DataStorageChange> defaultTableDataStorageConsumer(String defaul
};
}
+ /**
+ * Returns the default data storage.
+ *
+ * @param defaultDataStorageView View of {@link TablesConfigurationSchema#defaultDataStorage}. For the case {@link
+ * UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} and there is only one engine, then it will be the default.
+ */
+ public String defaultDataStorage(String defaultDataStorageView) {
Review Comment:
Discussed personally, we decided to leave it as long as we have the possibility of one storage in the product.
--
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] tkalkirill commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851123026
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModules.java:
##########
@@ -112,12 +104,50 @@ public Map<String, StorageEngine> createStorageEngines(
/**
* Collects {@link DataStorageConfigurationSchema data storage schema} fields (with {@link Value}).
*
+ * @param polymorphicSchemaExtensions {@link PolymorphicConfigInstance Polymorphic schema extensions} that contain extensions of {@link
+ * DataStorageConfigurationSchema}.
* @return Mapping: {@link DataStorageModule#name Data storage name} -> filed name -> field type.
+ * @throws IllegalStateException If the {@link DataStorageConfigurationSchema data storage schemas} are not valid.
*/
- public Map<String, Map<String, Class<?>>> collectSchemasFields() {
+ public Map<String, Map<String, Class<?>>> collectSchemasFields(Collection<Class<?>> polymorphicSchemaExtensions) {
+ Map<String, Class<? extends DataStorageConfigurationSchema>> schemas = polymorphicSchemaExtensions.stream()
+ .filter(DataStorageConfigurationSchema.class::isAssignableFrom)
+ .collect(toUnmodifiableMap(
+ schemaCls -> schemaName((Class<? extends DataStorageConfigurationSchema>) schemaCls),
+ schemaCls -> (Class<? extends DataStorageConfigurationSchema>) schemaCls
+ ));
+
+ Set<String> dataStorageNames = modules.stream()
Review Comment:
Fix it.
--
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] tkalkirill commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851125143
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModules.java:
##########
@@ -112,12 +104,50 @@ public Map<String, StorageEngine> createStorageEngines(
/**
* Collects {@link DataStorageConfigurationSchema data storage schema} fields (with {@link Value}).
*
+ * @param polymorphicSchemaExtensions {@link PolymorphicConfigInstance Polymorphic schema extensions} that contain extensions of {@link
+ * DataStorageConfigurationSchema}.
* @return Mapping: {@link DataStorageModule#name Data storage name} -> filed name -> field type.
+ * @throws IllegalStateException If the {@link DataStorageConfigurationSchema data storage schemas} are not valid.
*/
- public Map<String, Map<String, Class<?>>> collectSchemasFields() {
+ public Map<String, Map<String, Class<?>>> collectSchemasFields(Collection<Class<?>> polymorphicSchemaExtensions) {
+ Map<String, Class<? extends DataStorageConfigurationSchema>> schemas = polymorphicSchemaExtensions.stream()
+ .filter(DataStorageConfigurationSchema.class::isAssignableFrom)
+ .collect(toUnmodifiableMap(
+ schemaCls -> schemaName((Class<? extends DataStorageConfigurationSchema>) schemaCls),
+ schemaCls -> (Class<? extends DataStorageConfigurationSchema>) schemaCls
+ ));
+
+ Set<String> dataStorageNames = modules.stream()
+ .map(DataStorageModule::name)
+ .collect(toSet());
+
+ if (!dataStorageNames.equals(schemas.keySet())) {
+ List<String> dataStorageWithoutSchema = dataStorageNames.stream()
Review Comment:
Fix it.
--
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] tkalkirill commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851123914
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModules.java:
##########
@@ -112,12 +104,50 @@ public Map<String, StorageEngine> createStorageEngines(
/**
* Collects {@link DataStorageConfigurationSchema data storage schema} fields (with {@link Value}).
*
+ * @param polymorphicSchemaExtensions {@link PolymorphicConfigInstance Polymorphic schema extensions} that contain extensions of {@link
+ * DataStorageConfigurationSchema}.
* @return Mapping: {@link DataStorageModule#name Data storage name} -> filed name -> field type.
+ * @throws IllegalStateException If the {@link DataStorageConfigurationSchema data storage schemas} are not valid.
*/
- public Map<String, Map<String, Class<?>>> collectSchemasFields() {
+ public Map<String, Map<String, Class<?>>> collectSchemasFields(Collection<Class<?>> polymorphicSchemaExtensions) {
+ Map<String, Class<? extends DataStorageConfigurationSchema>> schemas = polymorphicSchemaExtensions.stream()
+ .filter(DataStorageConfigurationSchema.class::isAssignableFrom)
+ .collect(toUnmodifiableMap(
+ schemaCls -> schemaName((Class<? extends DataStorageConfigurationSchema>) schemaCls),
+ schemaCls -> (Class<? extends DataStorageConfigurationSchema>) schemaCls
+ ));
+
+ Set<String> dataStorageNames = modules.stream()
+ .map(DataStorageModule::name)
+ .collect(toSet());
+
+ if (!dataStorageNames.equals(schemas.keySet())) {
+ List<String> dataStorageWithoutSchema = dataStorageNames.stream()
+ .filter(not(schemas.keySet()::contains))
Review Comment:
**containsKey** is fine, correct it
--
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] ibessonov commented on a diff in pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
ibessonov commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851118474
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModules.java:
##########
@@ -112,12 +104,50 @@ public Map<String, StorageEngine> createStorageEngines(
/**
* Collects {@link DataStorageConfigurationSchema data storage schema} fields (with {@link Value}).
*
+ * @param polymorphicSchemaExtensions {@link PolymorphicConfigInstance Polymorphic schema extensions} that contain extensions of {@link
+ * DataStorageConfigurationSchema}.
* @return Mapping: {@link DataStorageModule#name Data storage name} -> filed name -> field type.
+ * @throws IllegalStateException If the {@link DataStorageConfigurationSchema data storage schemas} are not valid.
*/
- public Map<String, Map<String, Class<?>>> collectSchemasFields() {
+ public Map<String, Map<String, Class<?>>> collectSchemasFields(Collection<Class<?>> polymorphicSchemaExtensions) {
+ Map<String, Class<? extends DataStorageConfigurationSchema>> schemas = polymorphicSchemaExtensions.stream()
+ .filter(DataStorageConfigurationSchema.class::isAssignableFrom)
+ .collect(toUnmodifiableMap(
+ schemaCls -> schemaName((Class<? extends DataStorageConfigurationSchema>) schemaCls),
+ schemaCls -> (Class<? extends DataStorageConfigurationSchema>) schemaCls
+ ));
+
+ Set<String> dataStorageNames = modules.stream()
Review Comment:
Ok, so:
modules is a Set that you retrieve by calling "this.modules = modules.values();", it's a proxy.
And after that you convert it back into the map with streams and all this magic. Why can't you store Map as a field?
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModules.java:
##########
@@ -112,12 +104,50 @@ public Map<String, StorageEngine> createStorageEngines(
/**
* Collects {@link DataStorageConfigurationSchema data storage schema} fields (with {@link Value}).
*
+ * @param polymorphicSchemaExtensions {@link PolymorphicConfigInstance Polymorphic schema extensions} that contain extensions of {@link
+ * DataStorageConfigurationSchema}.
* @return Mapping: {@link DataStorageModule#name Data storage name} -> filed name -> field type.
+ * @throws IllegalStateException If the {@link DataStorageConfigurationSchema data storage schemas} are not valid.
*/
- public Map<String, Map<String, Class<?>>> collectSchemasFields() {
+ public Map<String, Map<String, Class<?>>> collectSchemasFields(Collection<Class<?>> polymorphicSchemaExtensions) {
+ Map<String, Class<? extends DataStorageConfigurationSchema>> schemas = polymorphicSchemaExtensions.stream()
+ .filter(DataStorageConfigurationSchema.class::isAssignableFrom)
+ .collect(toUnmodifiableMap(
+ schemaCls -> schemaName((Class<? extends DataStorageConfigurationSchema>) schemaCls),
+ schemaCls -> (Class<? extends DataStorageConfigurationSchema>) schemaCls
+ ));
+
+ Set<String> dataStorageNames = modules.stream()
+ .map(DataStorageModule::name)
+ .collect(toSet());
+
+ if (!dataStorageNames.equals(schemas.keySet())) {
+ List<String> dataStorageWithoutSchema = dataStorageNames.stream()
+ .filter(not(schemas.keySet()::contains))
Review Comment:
is there a "containsKey" method? Or simply "contains" maybe?
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageModules.java:
##########
@@ -112,12 +104,50 @@ public Map<String, StorageEngine> createStorageEngines(
/**
* Collects {@link DataStorageConfigurationSchema data storage schema} fields (with {@link Value}).
*
+ * @param polymorphicSchemaExtensions {@link PolymorphicConfigInstance Polymorphic schema extensions} that contain extensions of {@link
+ * DataStorageConfigurationSchema}.
* @return Mapping: {@link DataStorageModule#name Data storage name} -> filed name -> field type.
+ * @throws IllegalStateException If the {@link DataStorageConfigurationSchema data storage schemas} are not valid.
*/
- public Map<String, Map<String, Class<?>>> collectSchemasFields() {
+ public Map<String, Map<String, Class<?>>> collectSchemasFields(Collection<Class<?>> polymorphicSchemaExtensions) {
+ Map<String, Class<? extends DataStorageConfigurationSchema>> schemas = polymorphicSchemaExtensions.stream()
+ .filter(DataStorageConfigurationSchema.class::isAssignableFrom)
+ .collect(toUnmodifiableMap(
+ schemaCls -> schemaName((Class<? extends DataStorageConfigurationSchema>) schemaCls),
+ schemaCls -> (Class<? extends DataStorageConfigurationSchema>) schemaCls
+ ));
+
+ Set<String> dataStorageNames = modules.stream()
+ .map(DataStorageModule::name)
+ .collect(toSet());
+
+ if (!dataStorageNames.equals(schemas.keySet())) {
+ List<String> dataStorageWithoutSchema = dataStorageNames.stream()
Review Comment:
Please extract content of this "if" into a method. It is self-contained and pretty big
--
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] ibessonov merged pull request #773: IGNITE-16797 DDL support for Storage specific parameters
Posted by GitBox <gi...@apache.org>.
ibessonov merged PR #773:
URL: https://github.com/apache/ignite-3/pull/773
--
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