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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/ClusterWideStorageProfileValidator.java:
##########
@@ -53,33 +51,38 @@ public CompletableFuture<Void> validate(Collection<String> 
storageProfiles) {
         );
 
         if (missedStorageProfileNames.isEmpty()) {
-            return;
+            return CompletableFuture.completedFuture(null);

Review Comment:
   ```suggestion
               return nullCompletedFuture();
   ```



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/ClusterWideStorageProfileValidator.java:
##########
@@ -53,33 +51,38 @@ public CompletableFuture<Void> validate(Collection<String> 
storageProfiles) {
         );
 
         if (missedStorageProfileNames.isEmpty()) {
-            return;
+            return CompletableFuture.completedFuture(null);
         }
 
-        try {
-            missedStorageProfileNames = 
logicalTopologyService.logicalTopologyOnLeader()
+        return logicalTopologyService.logicalTopologyOnLeader()
                     .thenApply(topologySnapshot -> 
findStorageProfileNotPresentedInLogicalTopologySnapshot(
                             storageProfiles,
                             topologySnapshot
-                    )).get(10, TimeUnit.SECONDS);
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
-            String msg = format(
-                    "Storage profile {} doesn't exist in local topology 
snapshot with profiles [{}], and distributed refresh failed.",
-                    missedStorageProfileNames,
-                    
localLogicalTopologySnapshot.nodes().stream().map(LogicalNode::storageProfiles).collect(Collectors.toSet())
-            );
-
-            throw new SqlException(STMT_VALIDATION_ERR, msg, e);
-        }
-
-        if (!missedStorageProfileNames.isEmpty()) {
-            throw new SqlException(STMT_VALIDATION_ERR, format(
-                    "Some storage profiles don't exist 
[missedProfileNames={}].",
-                    missedStorageProfileNames
-            ));
-        }
-
-        return completedFuture(null);
+                    )).handle((missedProfileNames, e) -> {
+                        if (e != null) {
+                            String msg = format(
+                                    "Storage profiles {} doesn't exist in 
local topology snapshot with profiles [{}], "

Review Comment:
   ```suggestion
                                       "Storage profiles {} don't exist in 
local topology snapshot with profiles [{}], "
   ```



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/ClusterWideStorageProfileValidator.java:
##########
@@ -53,33 +51,38 @@ public CompletableFuture<Void> validate(Collection<String> 
storageProfiles) {
         );
 
         if (missedStorageProfileNames.isEmpty()) {
-            return;
+            return CompletableFuture.completedFuture(null);
         }
 
-        try {
-            missedStorageProfileNames = 
logicalTopologyService.logicalTopologyOnLeader()
+        return logicalTopologyService.logicalTopologyOnLeader()
                     .thenApply(topologySnapshot -> 
findStorageProfileNotPresentedInLogicalTopologySnapshot(
                             storageProfiles,
                             topologySnapshot
-                    )).get(10, TimeUnit.SECONDS);
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
-            String msg = format(
-                    "Storage profile {} doesn't exist in local topology 
snapshot with profiles [{}], and distributed refresh failed.",
-                    missedStorageProfileNames,
-                    
localLogicalTopologySnapshot.nodes().stream().map(LogicalNode::storageProfiles).collect(Collectors.toSet())
-            );
-
-            throw new SqlException(STMT_VALIDATION_ERR, msg, e);
-        }
-
-        if (!missedStorageProfileNames.isEmpty()) {
-            throw new SqlException(STMT_VALIDATION_ERR, format(
-                    "Some storage profiles don't exist 
[missedProfileNames={}].",
-                    missedStorageProfileNames
-            ));
-        }
-
-        return completedFuture(null);
+                    )).handle((missedProfileNames, e) -> {
+                        if (e != null) {
+                            String msg = format(
+                                    "Storage profiles {} doesn't exist in 
local topology snapshot with profiles [{}], "
+                                            + "and distributed refresh 
failed.",
+                                    missedStorageProfileNames,
+                                    localLogicalTopologySnapshot
+                                            .nodes()
+                                            .stream()
+                                            .map(LogicalNode::storageProfiles)
+                                            .collect(Collectors.toSet())

Review Comment:
   Let's import `Collectors#toSet()` statically so the code reads 
`collect(toSet())`, almost in plain English



-- 
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-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to