ibessonov commented on a change in pull request #460:
URL: https://github.com/apache/ignite-3/pull/460#discussion_r752912956



##########
File path: 
modules/api/src/test/java/org/apache/ignite/configuration/CoreDistributedConfigurationModuleTest.java
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.configuration;
+
+import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresent;
+import static 
org.apache.ignite.configuration.annotation.ConfigurationType.DISTRIBUTED;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.anEmptyMap;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.is;
+
+import java.util.Optional;
+import java.util.ServiceLoader;
+import java.util.ServiceLoader.Provider;
+import org.apache.ignite.configuration.schemas.runner.ClusterConfiguration;
+import org.apache.ignite.configuration.schemas.store.DataStorageConfiguration;
+import 
org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema;
+import 
org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema;
+import 
org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema;
+import org.apache.ignite.configuration.schemas.table.TablesConfiguration;
+import org.apache.ignite.configuration.validation.ConfigurationModule;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for {@link CoreDistributedConfigurationModule}.
+ */
+class CoreDistributedConfigurationModuleTest {
+    private final CoreDistributedConfigurationModule module = new 
CoreDistributedConfigurationModule();
+
+    @Test
+    void typeIsDistributed() {
+        assertThat(module.type(), is(DISTRIBUTED));
+    }
+
+    @Test
+    void hasClusterConfigurationRoot() {
+        assertThat(module.rootKeys(), hasItem(ClusterConfiguration.KEY));
+    }
+
+    @Test
+    void hasTablesConfigurationRoot() {
+        assertThat(module.rootKeys(), hasItem(TablesConfiguration.KEY));
+    }
+
+    @Test
+    void hasDataStorageConfigurationRoot() {
+        assertThat(module.rootKeys(), hasItem(DataStorageConfiguration.KEY));
+    }
+
+    @Test
+    void providesNoValidators() {
+        assertThat(module.validators(), is(anEmptyMap()));
+    }
+
+    @Test
+    void providesNoInternalSchemaExtensions() {
+        assertThat(module.internalSchemaExtensions(), is(empty()));
+    }
+
+    @Test
+    void providesHashIndexConfigurationSchemaAsPolymorphicExtension() {
+        assertThat(module.polymorphicSchemaExtensions(), 
hasItem(HashIndexConfigurationSchema.class));
+    }
+
+    @Test
+    void providesSortedIndexConfigurationSchemaAsPolymorphicExtension() {
+        assertThat(module.polymorphicSchemaExtensions(), 
hasItem(SortedIndexConfigurationSchema.class));
+    }
+
+    @Test
+    void providesPartialIndexConfigurationSchemaAsPolymorphicExtension() {
+        assertThat(module.polymorphicSchemaExtensions(), 
hasItem(PartialIndexConfigurationSchema.class));
+    }
+
+    @Test
+    void isLoadedByServiceLoader() {
+        Optional<ConfigurationModule> maybeModule = 
ServiceLoader.load(ConfigurationModule.class).stream()
+                .map(Provider::get)
+                .filter(module -> module instanceof 
CoreDistributedConfigurationModule)
+                .findAny();
+
+        assertThat(maybeModule, isPresent());

Review comment:
       So, the entire library is added to dependency to write "assertThat(foo, 
isPresent())" instead of "assertTrue(foo.isPresent())", right? There must be a 
strong advantage that I just can't see, a better error message maybe? I'm 
confused

##########
File path: 
modules/table/src/main/resources/META-INF/services/org.apache.ignite.configuration.validation.ConfigurationModule
##########
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+org.apache.ignite.internal.configuration.TableDistributedConfigurationModule

Review comment:
       BTW, I know that you're good with maven. Are there ways to generate 
service files in meta-inf during the build?

##########
File path: 
modules/runner/src/main/java/org/apache/ignite/internal/configuration/ServiceLoaderModulesProvider.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.configuration;
+
+import java.util.ServiceLoader;
+import java.util.stream.Stream;
+import org.apache.ignite.configuration.validation.ConfigurationModule;
+
+/**
+ * TODO: javadoc.
+ */
+public class ServiceLoaderModulesProvider implements 
ConfigurationModulesProvider {

Review comment:
       I'm not sure that interface/implementation is really required here, do 
we expect other implementations?

##########
File path: 
modules/api/src/main/java/org/apache/ignite/configuration/CoreLocalConfigurationModule.java
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.configuration;
+
+import static java.util.Collections.emptyList;
+import static java.util.Collections.emptyMap;
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ignite.configuration.annotation.ConfigurationType;
+import 
org.apache.ignite.configuration.schemas.clientconnector.ClientConnectorConfiguration;
+import org.apache.ignite.configuration.schemas.network.NetworkConfiguration;
+import org.apache.ignite.configuration.schemas.rest.RestConfiguration;
+import org.apache.ignite.configuration.schemas.runner.NodeConfiguration;
+import org.apache.ignite.configuration.validation.ConfigurationModule;

Review comment:
       This package doesn't seem right to me

##########
File path: 
modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/SchemaDistributedConfigurationModule.java
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.schema.configuration;
+
+import static java.util.Collections.emptyList;
+import static java.util.Collections.emptyMap;
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.configuration.RootKey;
+import org.apache.ignite.configuration.annotation.ConfigurationType;
+import 
org.apache.ignite.configuration.schemas.clientconnector.ClientConnectorConfiguration;
+import org.apache.ignite.configuration.schemas.network.NetworkConfiguration;
+import org.apache.ignite.configuration.schemas.rest.RestConfiguration;
+import org.apache.ignite.configuration.schemas.runner.NodeConfiguration;
+import org.apache.ignite.configuration.schemas.table.ColumnTypeValidator;
+import org.apache.ignite.configuration.schemas.table.TableValidator;
+import org.apache.ignite.configuration.validation.ConfigurationModule;
+import org.apache.ignite.configuration.validation.Validator;
+
+/**
+ *
+ */
+public class SchemaDistributedConfigurationModule implements 
ConfigurationModule {
+    @Override
+    public ConfigurationType type() {
+        return ConfigurationType.DISTRIBUTED;
+    }
+
+    @Override
+    public Collection<RootKey<?, ?>> rootKeys() {
+        return emptyList();
+    }
+
+    @Override
+    public Map<Class<? extends Annotation>, Set<Validator<? extends 
Annotation, ?>>> validators() {
+        return Map.of(
+                TableValidator.class, Set.of(TableValidatorImpl.INSTANCE),
+                ColumnTypeValidator.class, 
Set.of(ColumnTypeValidatorImpl.INSTANCE)
+        );
+    }
+
+    @Override
+    public Collection<Class<?>> internalSchemaExtensions() {

Review comment:
       Maybe we should have a default implementation that returns empty 
collections.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to