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/04 12:23:22 UTC

[GitHub] [ignite-3] ibessonov commented on a diff in pull request #754: IGNITE-16691 Storage Configuration refactoring and improvements

ibessonov commented on code in PR #754:
URL: https://github.com/apache/ignite-3/pull/754#discussion_r841544036


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/TableValidatorImpl.java:
##########
@@ -63,70 +58,26 @@ public void validate(TableValidator annotation, ValidationContext<NamedListView<
                         + newTable.columns().size() + " columns"));
             }
 
-            validateDataRegion(oldTables == null ? null : oldTables.get(tableName), newTable, ctx);
+            validateDataStorage(oldTables == null ? null : oldTables.get(tableName), newTable, ctx);
 
             validateNamedListKeys(newTable, ctx);
         }
     }
 
-    /**
-     * Checks that data region configuration is valid. Check involves data region existence and region type preservation if it's updated.
-     *
-     * @param oldTable Previous configuration, maybe {@code null}.
-     * @param newTable New configuration.
-     * @param ctx      Validation context.
-     */
-    private static void validateDataRegion(@Nullable TableView oldTable, TableView newTable, ValidationContext<?> ctx) {
-        DataStorageView oldDbCfg = ctx.getOldRoot(DataStorageConfiguration.KEY);
-        DataStorageView newDbCfg = ctx.getNewRoot(DataStorageConfiguration.KEY);
-
-        if (oldTable != null && Objects.equals(oldTable.dataRegion(), newTable.dataRegion())) {
-            return;
-        }
-
-        DataRegionView newRegion = dataRegion(newDbCfg, newTable.dataRegion());
-
-        if (newRegion == null) {
-            ctx.addIssue(new ValidationIssue(String.format(
-                    "Data region '%s' configured for table '%s' isn't found",
-                    newTable.dataRegion(),
-                    newTable.name()
-            )));
-
-            return;
-        }
-
-        if (oldDbCfg == null || oldTable == null) {
-            return;
-        }
-
-        DataRegionView oldRegion = dataRegion(oldDbCfg, oldTable.dataRegion());
-
-        if (!oldRegion.type().equalsIgnoreCase(newRegion.type())) {
-            ctx.addIssue(new ValidationIssue(String.format(
-                    "Unable to move table '%s' from region '%s' to region '%s' because it has different type (old=%s, new=%s)",
-                    newTable.name(),
-                    oldTable.dataRegion(),
-                    newTable.dataRegion(),
-                    oldRegion.type(),
-                    newRegion.type()
-            )));
-        }
-    }
-
-    /**
-     * Retrieves data region configuration.
-     *
-     * @param dbCfg      Data storage configuration.
-     * @param regionName Data region name.
-     * @return Data region configuration.
-     */
-    private static DataRegionView dataRegion(DataStorageView dbCfg, String regionName) {
-        if (regionName.equals(DEFAULT_DATA_REGION_NAME)) {
-            return dbCfg.defaultRegion();
+    private static void validateDataStorage(@Nullable TableView oldTable, TableView newTable, ValidationContext<?> ctx) {
+        if (oldTable != null) {
+            String oldDataStorage = oldTable.dataStorage().name();

Review Comment:
   It is immutable, right? Why would you validate it one more time?



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/PageMemoryStorageEngineFactory.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.pagememory;
+
+import java.nio.file.Path;
+import org.apache.ignite.internal.configuration.ConfigurationRegistry;
+import org.apache.ignite.internal.pagememory.io.PageIoRegistry;
+import org.apache.ignite.internal.storage.StorageException;
+import org.apache.ignite.internal.storage.engine.StorageEngine;
+import org.apache.ignite.internal.storage.engine.StorageEngineFactory;
+import org.apache.ignite.internal.storage.pagememory.configuration.schema.PageMemoryStorageEngineConfiguration;
+
+/**
+ * Implementation for creating {@link PageMemoryStorageEngine}s.
+ */
+public class PageMemoryStorageEngineFactory implements StorageEngineFactory {
+    /** {@inheritDoc} */
+    @Override
+    public StorageEngine createEngine(ConfigurationRegistry configRegistry, Path storagePath) throws StorageException {
+        PageMemoryStorageEngineConfiguration engineConfig = configRegistry.getConfiguration(PageMemoryStorageEngineConfiguration.KEY);
+
+        assert engineConfig != null;
+
+        PageIoRegistry ioRegistry = new PageIoRegistry();

Review Comment:
   We should make it more flexible in the future



##########
modules/storage-api/README.md:
##########
@@ -0,0 +1,56 @@
+# Storage API
+
+This module contains the API for working with data storages.
+
+## Adding a new data store
+
+To add a new data storage you need:
+
+* Add a new module;
+* Implement interfaces:
+    * `org.apache.ignite.internal.storage.engine.StorageEngineFactory`;
+    * `org.apache.ignite.internal.storage.engine.StorageEngine`;
+    * `org.apache.ignite.internal.storage.engine.TableStorage`;
+    * `org.apache.ignite.internal.storage.PartitionStorage`;
+    * `org.apache.ignite.internal.storage.index.SortedIndexStorage`;
+* Add configuration:
+    * Add an inheritor of `org.apache.ignite.configuration.schemas.store.DataStorageConfigurationSchema`, with type equal
+      to `org.apache.ignite.internal.storage.engine.StorageEngine.name`;
+    * If necessary, add a specific configuration of the data storage engine;
+    * Implement `org.apache.ignite.internal.configuration.ConfigurationModule`;
+* Add services (which are loaded via `java.util.ServiceLoader.load(java.lang.Class<S>)`):
+    * Implementation of `org.apache.ignite.internal.storage.engine.StorageEngineFactory`;
+    * Implementation of `org.apache.ignite.internal.configuration.ConfigurationModule`.
+
+Take `org.apache.ignite.internal.storage.chm.TestConcurrentHashMapStorageEngine` as an example.
+
+## Usage
+
+Used in table configuration see `org.apache.ignite.configuration.schemas.table.TableConfigurationSchema.dataStorage`.

Review Comment:
   I don't understand this sentence



##########
modules/storage-api/README.md:
##########
@@ -0,0 +1,56 @@
+# Storage API
+
+This module contains the API for working with data storages.
+
+## Adding a new data store
+
+To add a new data storage you need:
+
+* Add a new module;
+* Implement interfaces:
+    * `org.apache.ignite.internal.storage.engine.StorageEngineFactory`;
+    * `org.apache.ignite.internal.storage.engine.StorageEngine`;
+    * `org.apache.ignite.internal.storage.engine.TableStorage`;
+    * `org.apache.ignite.internal.storage.PartitionStorage`;
+    * `org.apache.ignite.internal.storage.index.SortedIndexStorage`;
+* Add configuration:
+    * Add an inheritor of `org.apache.ignite.configuration.schemas.store.DataStorageConfigurationSchema`, with type equal
+      to `org.apache.ignite.internal.storage.engine.StorageEngine.name`;
+    * If necessary, add a specific configuration of the data storage engine;
+    * Implement `org.apache.ignite.internal.configuration.ConfigurationModule`;
+* Add services (which are loaded via `java.util.ServiceLoader.load(java.lang.Class<S>)`):
+    * Implementation of `org.apache.ignite.internal.storage.engine.StorageEngineFactory`;
+    * Implementation of `org.apache.ignite.internal.configuration.ConfigurationModule`.
+
+Take `org.apache.ignite.internal.storage.chm.TestConcurrentHashMapStorageEngine` as an example.
+
+## Usage
+
+Used in table configuration see `org.apache.ignite.configuration.schemas.table.TableConfigurationSchema.dataStorage`.
+
+Configuration example in HOCON:
+```
+tables.table {
+    name = schema.table,
+    columns.id {name = id, type.type = STRING, nullable = true},
+    primaryKey {columns = [id], colocationColumns = [id]},
+    indices.foo {type = HASH, name = foo, colNames = [id]},
+    dataSorage {name = rocksdb, dataRegion = default}

Review Comment:
   typo



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