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/06/01 17:24:02 UTC

[GitHub] [ignite-3] rpuch commented on a diff in pull request #816: IGNITE-16943: Implement Micronaut REST

rpuch commented on code in PR #816:
URL: https://github.com/apache/ignite-3/pull/816#discussion_r886896182


##########
modules/cli/src/integrationTest/java/org/apache/ignite/cli/ItConfigCommandTest.java:
##########
@@ -113,9 +109,7 @@ public void setAndGetWithManualHost() {
 
         assertEquals(0, exitCode);
 
-        DocumentContext document = JsonPath.parse(removeTrailingQuotes(unescapeQuotes(out.toString(UTF_8))));
-
-        assertEquals(1, document.read("$.network.shutdownQuietPeriod", Integer.class));
+        assertTrue(out.toString(UTF_8).contains("\"shutdownQuietPeriod\" : 1"));

Review Comment:
   I suggest using Hamcrest assertions, like this:
   
   ```
   assertThat(out.toString(UTF_8), containsString(...));
   ```
   
   for such assertions. They produce more useful error messages on failures that make it easier to understand what was expected and what actually happened.



##########
modules/cluster-management/src/integrationTest/java/org/apache/ignite/internal/cluster/management/rest/ItClusterManagementControllerTest.java:
##########
@@ -0,0 +1,176 @@
+/*
+ * 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.cluster.management.rest;
+
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import io.micronaut.context.annotation.Bean;
+import io.micronaut.context.annotation.Factory;
+import io.micronaut.context.annotation.Replaces;
+import io.micronaut.http.HttpRequest;
+import io.micronaut.http.HttpResponse;
+import io.micronaut.http.HttpStatus;
+import io.micronaut.http.client.HttpClient;
+import io.micronaut.http.client.annotation.Client;
+import io.micronaut.http.client.exceptions.HttpClientResponseException;
+import io.micronaut.runtime.server.EmbeddedServer;
+import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
+import jakarta.inject.Inject;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.cluster.management.ClusterInitializer;
+import org.apache.ignite.internal.cluster.management.MockNode;
+import org.apache.ignite.internal.rest.api.ErrorResult;
+import org.apache.ignite.internal.testframework.WorkDirectory;
+import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.apache.ignite.network.ClusterService;
+import org.apache.ignite.network.NetworkAddress;
+import org.apache.ignite.network.StaticNodeFinder;
+import org.jetbrains.annotations.NotNull;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ * Cluster management REST test.
+ */
+@MicronautTest
+@ExtendWith(WorkDirectoryExtension.class)
+public class ItClusterManagementControllerTest {
+
+    private static final int PORT_BASE = 10000;
+
+    private static final List<MockNode> cluster = new ArrayList<>();
+    static ClusterService clusterService;
+    @WorkDirectory
+    private static Path workDir;
+    @Inject
+    EmbeddedServer server;
+    @Inject
+    @Client("/management/v1/cluster/init/")
+    HttpClient client;
+    @Inject
+    ClusterInitializer clusterInitializer;
+
+    @BeforeAll
+    static void setUp(TestInfo testInfo) throws IOException {
+        var addr1 = new NetworkAddress("localhost", PORT_BASE);
+        var addr2 = new NetworkAddress("localhost", PORT_BASE + 1);
+
+        var nodeFinder = new StaticNodeFinder(List.of(addr1, addr2));
+
+        cluster.add(new MockNode(testInfo, addr1, nodeFinder, workDir.resolve("node0")));
+        cluster.add(new MockNode(testInfo, addr2, nodeFinder, workDir.resolve("node1")));
+
+        for (MockNode node : cluster) {
+            node.start();
+        }
+
+        clusterService = cluster.get(0).clusterService();
+    }
+
+    @AfterAll
+    static void tearDown() {
+        for (MockNode node : cluster) {
+            node.beforeNodeStop();
+        }
+
+        for (MockNode node : cluster) {
+            node.stop();
+        }
+    }
+
+    @Test
+    void testControllerLoaded() {
+        assertNotNull(server.getApplicationContext().getBean(ClusterManagementController.class));
+    }
+
+    @Test
+    void testInitNoSuchNode() {
+        // Given body with nodename that does not exist
+        String givenInvalidBody = "{\"metaStorageNodes\": [\"nodename\"], \"cmgNodes\": [], \"clusterName\": \"cluster\"}";
+
+        // When
+        var thrown = assertThrows(
+                HttpClientResponseException.class,
+                () -> client.toBlocking().exchange(HttpRequest.POST("", givenInvalidBody))
+        );
+
+        // Then
+        assertThat(thrown.getResponse().getStatus(), is(equalTo((HttpStatus.BAD_REQUEST))));
+        // And
+        var errorResult = getErrorResult(thrown);
+        assertEquals("INVALID_NODES", errorResult.type());
+    }
+
+    @Test
+    void testInitAlreadyInitializedWithAnotherNodes() {
+        // Given cluster initialized
+        String givenFirstRequestBody =
+                "{\"metaStorageNodes\": [\"" + cluster.get(0).clusterService().localConfiguration().getName() + "\"], \"cmgNodes\": [], "
+                        + "\"clusterName\": \"cluster\"}";
+
+        // When
+        HttpResponse<Object> response = client.toBlocking().exchange(HttpRequest.POST("", givenFirstRequestBody));
+
+        // Then
+        assertThat(response.getStatus(), is(equalTo((HttpStatus.OK))));
+        // And
+        assertThat(cluster.get(0).startFuture(), willCompleteSuccessfully());
+
+        // Given second request with different node name
+        String givenSecondRequestBody =
+                "{\"metaStorageNodes\": [\"" + cluster.get(1).clusterService().localConfiguration().getName() + "\"], \"cmgNodes\": [], "
+                        + "\"clusterName\": \"cluster\" }";
+
+        // When
+        var thrown = assertThrows(
+                HttpClientResponseException.class,
+                () -> client.toBlocking().exchange(HttpRequest.POST("", givenSecondRequestBody))
+        );
+
+        // Then
+        assertThat(thrown.getResponse().getStatus(), is(equalTo((HttpStatus.CONFLICT))));
+        // And
+        var errorResult = getErrorResult(thrown);
+        assertEquals("ALREADY_INITIALIZED", errorResult.type());
+
+    }
+
+    @Factory
+    @Bean
+    @Replaces(ClusterManagementRestFactory.class)
+    public ClusterManagementRestFactory clusterManagementRestFactory() {
+        return new ClusterManagementRestFactory(clusterService);
+    }
+
+    @NotNull

Review Comment:
   If I'm not misttaken, we decided to not use `@NotNull` annotation. If something is not annotated with `@Nullable`, it is treated as non-nullable, that's it.



##########
modules/configuration/src/test/java/org/apache/ignite/internal/rest/configuration/ClusterConfigurationControllerTest.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.rest.configuration;
+
+import io.micronaut.context.annotation.Bean;
+import io.micronaut.context.annotation.Replaces;
+import io.micronaut.http.client.HttpClient;
+import io.micronaut.http.client.annotation.Client;
+import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
+import jakarta.inject.Inject;
+import jakarta.inject.Named;
+import org.apache.ignite.internal.configuration.ConfigurationRegistry;
+import org.apache.ignite.internal.configuration.rest.presentation.ConfigurationPresentation;
+import org.apache.ignite.internal.configuration.rest.presentation.hocon.HoconPresentation;
+
+/**
+ * Functional test for {@link ClusterConfigurationController}.
+ */
+@MicronautTest
+class ClusterConfigurationControllerTest extends ConfigurationControllerBaseTest {
+
+    @Inject
+    @Client("/management/v1/configuration/cluster/")
+    HttpClient client;
+
+    @Override
+    HttpClient client() {
+        return client;
+    }
+

Review Comment:
   An excessive blank line?



##########
modules/configuration/src/main/java/org/apache/ignite/internal/rest/configuration/exception/handler/ConfigPathUnrecognizedExceptionHandler.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.rest.configuration.exception.handler;
+
+import io.micronaut.context.annotation.Requires;
+import io.micronaut.http.HttpRequest;
+import io.micronaut.http.HttpResponse;
+import io.micronaut.http.MediaType;
+import io.micronaut.http.annotation.Produces;
+import io.micronaut.http.server.exceptions.ExceptionHandler;
+import jakarta.inject.Singleton;
+import org.apache.ignite.internal.rest.api.ErrorResult;
+import org.apache.ignite.internal.rest.configuration.exception.ConfigPathUnrecognizedException;
+
+/**
+ * Handles {@link ConfigPathUnrecognizedException} and represents it as a rest response.
+ */
+@Produces(MediaType.APPLICATION_JSON)
+@Singleton
+@Requires(classes = {ConfigPathUnrecognizedException.class, ExceptionHandler.class})
+public class ConfigPathUnrecognizedExceptionHandler implements
+        ExceptionHandler<ConfigPathUnrecognizedException, HttpResponse<ErrorResult>> {
+
+    @Override
+    public HttpResponse<ErrorResult> handle(HttpRequest request, ConfigPathUnrecognizedException exception) {
+        final ErrorResult errorResult = new ErrorResult("CONFIG_PATH_UNRECOGNIZED", exception.getMessage());

Review Comment:
   `final` seems redundant here as the method is just 2 lines



##########
modules/configuration/src/main/java/org/apache/ignite/internal/rest/configuration/AbstractConfigurationController.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.rest.configuration;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import org.apache.ignite.configuration.validation.ConfigurationValidationException;
+import org.apache.ignite.internal.configuration.rest.presentation.ConfigurationPresentation;
+import org.apache.ignite.internal.rest.configuration.exception.ConfigPathUnrecognizedException;
+import org.apache.ignite.internal.rest.configuration.exception.InvalidConfigFormatException;
+import org.apache.ignite.lang.IgniteException;
+
+/**
+ * Base configuration controller.
+ */
+public class AbstractConfigurationController {

Review Comment:
   I suggest making this class `abstract`, as its name implies



##########
modules/cli/src/main/java/org/apache/ignite/cli/builtins/config/ConfigurationClient.java:
##########
@@ -81,7 +81,7 @@ public String get(
     ) {
         var req = HttpRequest
                 .newBuilder()
-                .header("Content-Type", "application/json");
+                .header("Content-Type", "text/plain");

Review Comment:
   It's not a JSON, but it's not just *any* plain text. Could we use a specific content type here? For example, here https://www.w3schools.io/file/hocon-introduction/ they suggest `application/hocon`; it does not seem to be registered with IANA, but it looks logical.



##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/rest/ClusterManagementController.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.cluster.management.rest;
+
+import io.micronaut.http.MediaType;
+import io.micronaut.http.annotation.Body;
+import io.micronaut.http.annotation.Consumes;
+import io.micronaut.http.annotation.Controller;
+import io.micronaut.http.annotation.Post;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import java.util.concurrent.ExecutionException;
+import org.apache.ignite.internal.cluster.management.ClusterInitializer;
+import org.apache.ignite.internal.cluster.management.rest.exception.InvalidNodesInitClusterException;
+import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.lang.IgniteInternalException;
+import org.apache.ignite.lang.IgniteLogger;
+
+/**
+ * Cluster management controller.
+ */
+@Controller("/management/v1/cluster/init")
+@ApiResponse(responseCode = "400", description = "Incorrect body")

Review Comment:
   `400` could potentially mean that something else is wrong with the request, not just its body. Should we be so specific here? Would 'Bad request' or 'Invalid request' be a safer alternative?



##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/RestComponent.java:
##########
@@ -17,151 +17,147 @@
 
 package org.apache.ignite.internal.rest;
 
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.handler.logging.LogLevel;
-import io.netty.handler.logging.LoggingHandler;
+import io.micronaut.context.ApplicationContext;
+import io.micronaut.http.server.exceptions.ServerStartupException;
+import io.micronaut.openapi.annotation.OpenAPIInclude;
+import io.micronaut.runtime.Micronaut;
+import io.micronaut.runtime.exceptions.ApplicationStartupException;
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.info.Contact;
+import io.swagger.v3.oas.annotations.info.Info;
+import io.swagger.v3.oas.annotations.info.License;
 import java.net.BindException;
-import java.net.InetSocketAddress;
-import java.util.function.Consumer;
+import java.util.List;
+import java.util.Map;
 import org.apache.ignite.configuration.schemas.rest.RestConfiguration;
 import org.apache.ignite.configuration.schemas.rest.RestView;
-import org.apache.ignite.internal.configuration.ConfigurationManager;
-import org.apache.ignite.internal.configuration.ConfigurationRegistry;
+import org.apache.ignite.internal.cluster.management.rest.ClusterManagementController;
 import org.apache.ignite.internal.manager.IgniteComponent;
-import org.apache.ignite.internal.rest.api.RestHandlersRegister;
-import org.apache.ignite.internal.rest.api.Routes;
-import org.apache.ignite.internal.rest.netty.RestApiInitializer;
-import org.apache.ignite.internal.rest.routes.Router;
-import org.apache.ignite.internal.rest.routes.SimpleRouter;
-import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.internal.rest.api.RestFactory;
+import org.apache.ignite.internal.rest.configuration.ClusterConfigurationController;
+import org.apache.ignite.internal.rest.configuration.NodeConfigurationController;
 import org.apache.ignite.lang.IgniteInternalException;
 import org.apache.ignite.lang.IgniteLogger;
-import org.apache.ignite.network.NettyBootstrapFactory;
 
 /**
- * Rest component is responsible for starting REST endpoints.
+ * Rest module is responsible for starting a REST endpoints for accessing and managing configuration.
  *
- * <p>It is started on port 10300 by default, but it is possible to change this in configuration itself. Refer to default config file in
+ * <p>It is started on port 10300 by default but it is possible to change this in configuration itself. Refer to default config file in
  * resources for the example.
  */
-public class RestComponent implements RestHandlersRegister, IgniteComponent {
+@OpenAPIDefinition(info = @Info(title = "Ignite REST module", version = "3.0.0-alpha", license = @License(name = "Apache 2.0", url = "https://ignite.apache.org"), contact = @Contact(email = "user@ignite.apache.org")))
+@OpenAPIInclude(classes = {ClusterConfigurationController.class, NodeConfigurationController.class, ClusterManagementController.class})
+public class RestComponent implements IgniteComponent {
+    /** Default port. */
+    public static final int DFLT_PORT = 10300;
+
     /** Ignite logger. */
     private final IgniteLogger log = IgniteLogger.forClass(RestComponent.class);
 
-    /** Node configuration register. */
-    private final ConfigurationRegistry nodeCfgRegistry;
-
-    /** Netty bootstrap factory. */
-    private final NettyBootstrapFactory bootstrapFactory;
-
-    private final SimpleRouter router = new SimpleRouter();
-
-    /** Netty channel. */
-    private volatile Channel channel;
+    /** Factories that produce beans needed for REST controllers. */
+    private final List<RestFactory> restFactories;
+    private final RestConfiguration restConfiguration;
+    /** Server host. */
+    private final String host = "localhost";
+    /** Micronaut application context. */
+    private ApplicationContext context;
+    /** Server port. */
+    private int port;
 
     /**
      * Creates a new instance of REST module.
-     *
-     * @param nodeCfgMgr       Node configuration manager.
-     * @param bootstrapFactory Netty bootstrap factory.
      */
-    public RestComponent(ConfigurationManager nodeCfgMgr, NettyBootstrapFactory bootstrapFactory) {
-        nodeCfgRegistry = nodeCfgMgr.configurationRegistry();
-
-        this.bootstrapFactory = bootstrapFactory;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void registerHandlers(Consumer<Routes> registerAction) {
-        registerAction.accept(router);
+    public RestComponent(List<RestFactory> restFactories, RestConfiguration restConfiguration) {
+        this.restFactories = restFactories;
+        this.restConfiguration = restConfiguration;
     }
 
     /** {@inheritDoc} */
     @Override
     public void start() {
-        if (channel != null) {
-            throw new IgniteException("RestModule is already started.");
-        }
-
-        channel = startRestEndpoint(router).channel();
-    }
-
-    /**
-     * Start endpoint.
-     *
-     * @param router Dispatcher of http requests.
-     * @return Future which will be notified when this channel is closed.
-     * @throws RuntimeException if this module cannot be bound to a port.
-     */
-    private ChannelFuture startRestEndpoint(Router router) {
-        RestView restConfigurationView = nodeCfgRegistry.getConfiguration(RestConfiguration.KEY).value();
+        RestView restConfigurationView = restConfiguration.value();
 
         int desiredPort = restConfigurationView.port();
         int portRange = restConfigurationView.portRange();
 
-        int port = 0;
-        Channel ch = null;
-
-        ServerBootstrap bootstrap = bootstrapFactory.createServerBootstrap()
-                .handler(new LoggingHandler(LogLevel.INFO))
-                .childHandler(new RestApiInitializer(router));
-
         for (int portCandidate = desiredPort; portCandidate <= desiredPort + portRange; portCandidate++) {
-            ChannelFuture bindRes = bootstrap.bind(portCandidate).awaitUninterruptibly();
-
-            if (bindRes.isSuccess()) {
-                ch = bindRes.channel();
+            try {
+                context = buildMicronautContext(portCandidate).start();
                 port = portCandidate;
+                log.info("REST protocol started successfully");
                 break;
-            } else if (!(bindRes.cause() instanceof BindException)) {
-                throw new RuntimeException(bindRes.cause());
+            } catch (ApplicationStartupException e) {
+                log.error("Got exception " + e.getCause() + " during node start on port " + portCandidate + " , trying again");
             }
         }
 
-        if (ch == null) {
-            String msg = "Cannot start REST endpoint. "
-                    + "All ports in range [" + desiredPort + ", " + (desiredPort + portRange) + "] are in use.";
+        if (context == null) {
+            String msg = "Cannot start REST endpoint. " + "All ports in range [" + desiredPort + ", " + (desiredPort + portRange)
+                    + "] are in use.";
 
             log.error(msg);
 
             throw new RuntimeException(msg);
         }
+    }
+
+    private Micronaut buildMicronautContext(int portCandidate) {
+        Micronaut micronaut = Micronaut.build("");
+        setFactories(micronaut);
+        return micronaut
+                .properties(Map.of("micronaut.server.port", portCandidate))
+                .banner(false)
+                .mapError(ServerStartupException.class, this::mapServerStartupException)
+                .mapError(ApplicationStartupException.class, ex -> -1);
+    }
 
-        if (log.isInfoEnabled()) {
-            log.info("REST protocol started successfully on port " + port);
+    private void setFactories(Micronaut micronaut) {
+        for (var factory : restFactories) {
+            micronaut.singletons(factory);
         }
+    }
 
-        return ch.closeFuture();
+    private int mapServerStartupException(ServerStartupException exception) {
+        if (exception.getCause() instanceof BindException) {
+            return -1;

Review Comment:
   What do these 1 and -1 mean in this case?



##########
modules/cli/src/integrationTest/java/org/apache/ignite/cli/ItConfigCommandTest.java:
##########
@@ -113,9 +109,7 @@ public void setAndGetWithManualHost() {
 
         assertEquals(0, exitCode);
 
-        DocumentContext document = JsonPath.parse(removeTrailingQuotes(unescapeQuotes(out.toString(UTF_8))));
-
-        assertEquals(1, document.read("$.network.shutdownQuietPeriod", Integer.class));
+        assertTrue(out.toString(UTF_8).contains("\"shutdownQuietPeriod\" : 1"));

Review Comment:
   Also, the test before the modification makes less checks on the returned value. The old test seemed to check (implicitly) that the returned value was a valid JSON; also, it looks like now the test is a bit fragile because it will fail if whitespace policy changes.
   
   Is this caused by changing the content type from application/json to text/plain? As we know that this is not just a plain text, but a HOCON document, would it be possible to restore the parsing to make sure it's a valid HOCON?



##########
modules/configuration/src/main/java/org/apache/ignite/internal/rest/configuration/ClusterConfigurationController.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.rest.configuration;
+
+import io.micronaut.http.MediaType;
+import io.micronaut.http.annotation.Body;
+import io.micronaut.http.annotation.Consumes;
+import io.micronaut.http.annotation.Controller;
+import io.micronaut.http.annotation.Get;
+import io.micronaut.http.annotation.Patch;
+import io.micronaut.http.annotation.PathVariable;
+import io.micronaut.http.annotation.Produces;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.inject.Named;
+import org.apache.ignite.internal.configuration.rest.presentation.ConfigurationPresentation;
+
+/**
+ * Cluster configuration controller.
+ */
+@Controller("/management/v1/configuration/cluster/")
+@ApiResponse(responseCode = "400", description = "Incorrect configuration")
+@ApiResponse(responseCode = "500", description = "Internal error")
+@Tag(name = "clusterConfiguration")
+public class ClusterConfigurationController extends AbstractConfigurationController {
+
+    public ClusterConfigurationController(@Named("clusterCfgPresentation") ConfigurationPresentation<String> clusterCfgPresentation) {
+        super(clusterCfgPresentation);
+    }
+
+    /**
+     * Returns cluster configuration in HOCON format.
+     *
+     * @return the whole cluster configuration in HOCON format.
+     */
+    @Operation(operationId = "getClusterConfiguration")
+    @ApiResponse(
+            responseCode = "200",
+            content = @Content(mediaType = MediaType.TEXT_PLAIN, schema = @Schema(type = "string")),
+            description = "Get cluster configuration")
+    @Produces(MediaType.TEXT_PLAIN)

Review Comment:
   `application/hocon`?



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