tkalkirill commented on code in PR #4442:
URL: https://github.com/apache/ignite-3/pull/4442#discussion_r1773099518


##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/recovery/system/SystemDisasterRecoveryController.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.recovery.system;
+
+import io.micronaut.context.annotation.Requires;
+import io.micronaut.http.annotation.Controller;
+import java.util.concurrent.CompletableFuture;
+import 
org.apache.ignite.internal.disaster.system.SystemDisasterRecoveryManager;
+import org.apache.ignite.internal.rest.ResourceHolder;
+import org.apache.ignite.internal.rest.api.recovery.system.ResetClusterRequest;
+import 
org.apache.ignite.internal.rest.api.recovery.system.SystemDisasterRecoveryApi;
+import 
org.apache.ignite.internal.rest.exception.handler.ClusterResetExceptionHandler;
+import 
org.apache.ignite.internal.rest.exception.handler.IgniteInternalExceptionHandler;
+
+/**
+ * Controller for system groups disaster recovery.
+ */

Review Comment:
   ```suggestion
   /** Controller for system groups disaster recovery. */
   ```



##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/recovery/system/SystemDisasterRecoveryFactory.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.recovery.system;
+
+import io.micronaut.context.annotation.Bean;
+import io.micronaut.context.annotation.Factory;
+import jakarta.inject.Singleton;
+import 
org.apache.ignite.internal.disaster.system.SystemDisasterRecoveryManager;
+import org.apache.ignite.internal.rest.RestFactory;
+
+/**
+ * Factory that defines beans required for the System Disaster Recovery Rest 
module.
+ */

Review Comment:
   ```suggestion
   /** Factory that defines beans required for the System Disaster Recovery 
Rest module. */
   ```



##########
modules/rest-api/src/main/java/org/apache/ignite/internal/rest/exception/handler/ClusterResetExceptionHandler.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.exception.handler;
+
+import io.micronaut.context.annotation.Requires;
+import io.micronaut.http.HttpRequest;
+import io.micronaut.http.HttpResponse;
+import io.micronaut.http.server.exceptions.ExceptionHandler;
+import jakarta.inject.Singleton;
+import 
org.apache.ignite.internal.disaster.system.exception.ClusterResetException;
+import org.apache.ignite.internal.lang.IgniteInternalException;
+import org.apache.ignite.internal.rest.api.Problem;
+import org.apache.ignite.internal.rest.constants.HttpCode;
+import org.apache.ignite.internal.rest.problem.HttpProblemResponse;
+
+/**
+ * Handles {@link ClusterResetExceptionHandler} and represents it as a rest 
response.
+ */

Review Comment:
   ```suggestion
   /** Handles {@link ClusterResetExceptionHandler} and represents it as a rest 
response. */
   ```



##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/recovery/system/SystemDisasterRecoveryFactory.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.recovery.system;
+
+import io.micronaut.context.annotation.Bean;
+import io.micronaut.context.annotation.Factory;
+import jakarta.inject.Singleton;
+import 
org.apache.ignite.internal.disaster.system.SystemDisasterRecoveryManager;
+import org.apache.ignite.internal.rest.RestFactory;
+
+/**
+ * Factory that defines beans required for the System Disaster Recovery Rest 
module.
+ */
+@Factory
+public class SystemDisasterRecoveryFactory implements RestFactory {
+    private SystemDisasterRecoveryManager systemDisasterRecoveryManager;
+
+    public SystemDisasterRecoveryFactory(SystemDisasterRecoveryManager 
systemDisasterRecoveryManager) {
+        this.systemDisasterRecoveryManager = systemDisasterRecoveryManager;
+    }
+
+    @Bean
+    @Singleton
+    public SystemDisasterRecoveryManager systemDisasterRecoveryManager() {
+        return systemDisasterRecoveryManager;
+    }
+
+    @Override
+    public void cleanResources() {
+        systemDisasterRecoveryManager = null;

Review Comment:
   There will be no data races?



##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/recovery/system/SystemDisasterRecoveryController.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.recovery.system;
+
+import io.micronaut.context.annotation.Requires;
+import io.micronaut.http.annotation.Controller;
+import java.util.concurrent.CompletableFuture;
+import 
org.apache.ignite.internal.disaster.system.SystemDisasterRecoveryManager;
+import org.apache.ignite.internal.rest.ResourceHolder;
+import org.apache.ignite.internal.rest.api.recovery.system.ResetClusterRequest;
+import 
org.apache.ignite.internal.rest.api.recovery.system.SystemDisasterRecoveryApi;
+import 
org.apache.ignite.internal.rest.exception.handler.ClusterResetExceptionHandler;
+import 
org.apache.ignite.internal.rest.exception.handler.IgniteInternalExceptionHandler;
+
+/**
+ * Controller for system groups disaster recovery.
+ */
+@Controller("/management/v1/recovery/cluster")
+@Requires(classes = {IgniteInternalExceptionHandler.class, 
ClusterResetExceptionHandler.class})
+public class SystemDisasterRecoveryController implements 
SystemDisasterRecoveryApi, ResourceHolder {
+    private SystemDisasterRecoveryManager systemDisasterRecoveryManager;
+
+    public SystemDisasterRecoveryController(SystemDisasterRecoveryManager 
systemDisasterRecoveryManager) {
+        this.systemDisasterRecoveryManager = systemDisasterRecoveryManager;
+    }
+
+    @Override
+    public CompletableFuture<Void> reset(ResetClusterRequest command) {
+        return 
systemDisasterRecoveryManager.resetCluster(command.cmgNodeNames());
+    }
+
+    @Override
+    public void cleanResources() {
+        systemDisasterRecoveryManager = null;

Review Comment:
   There will be no data races?



##########
modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/recovery/system/ResetClusterRequest.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.api.recovery.system;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import java.util.List;
+import java.util.Objects;
+import org.apache.ignite.internal.tostring.S;
+
+/** Request to reset cluster. */
+@Schema(description = "Reset cluster.")
+public class ResetClusterRequest {
+    @Schema(description = "Names of the proposed CMG node names.")
+    private final List<String> cmgNodeNames;

Review Comment:
   Will `toString` print a list?



##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -1159,6 +1160,7 @@ private RestComponent createRestComponent(String name) {
         Supplier<RestFactory> restManagerFactory = () -> new 
RestManagerFactory(restManager);
         Supplier<RestFactory> computeRestFactory = () -> new 
ComputeRestFactory(compute);
         Supplier<RestFactory> disasterRecoveryFactory = () -> new 
DisasterRecoveryFactory(disasterRecoveryManager);
+        Supplier<RestFactory> systemDisasterRecoveryFactory = () -> new 
SystemDisasterRecoveryFactory(systemDisasterRecoveryManager);

Review Comment:
   How many suppliers are there...
   Do you think it's possible to get rid of them somehow in another ticket?



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