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


##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/key/UnitKey.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.deployunit.key;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.Base64.Encoder;
+import org.apache.ignite.lang.ByteArray;
+
+/**
+ * Helper for deployment units metastore keys generation.
+ */
+public final class UnitKey {
+    private static final String DEPLOY_UNIT_PREFIX = "deploy-unit.";
+
+    private static final String UNITS_PREFIX = DEPLOY_UNIT_PREFIX + "units.";
+
+    private UnitKey() {

Review Comment:
   I ask this every time I see a private constructor, so don't take it 
personally.
   Can you please explain, why you need it? Have you ever encountered a single 
person that tried to instantiate utility class?



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeploymentManagerImpl.java:
##########
@@ -246,104 +240,46 @@ public CompletableFuture<Void> undeployAsync(String id, 
Version version) {
     @Override
     public CompletableFuture<List<UnitStatus>> unitsAsync() {
         CompletableFuture<List<UnitStatus>> result = new CompletableFuture<>();
-        Map<String, UnitStatusBuilder> map = new HashMap<>();
-        metaStorage.prefix(new ByteArray(UNITS_PREFIX))
-                .subscribe(new Subscriber<>() {
-                    @Override
-                    public void onSubscribe(Subscription subscription) {
-                        subscription.request(Long.MAX_VALUE);
-                    }
-
-                    @Override
-                    public void onNext(Entry item) {
-                        UnitMeta meta = 
UnitMetaSerializer.deserialize(item.value());
-                        map.computeIfAbsent(meta.id(), UnitStatus::builder)
-                                .append(meta.version(), 
meta.consistentIdLocation());
-                    }
-
-                    @Override
-                    public void onError(Throwable throwable) {
-                        result.completeExceptionally(throwable);
-                    }
-
-                    @Override
-                    public void onComplete() {
-                        
result.complete(map.values().stream().map(UnitStatusBuilder::build).collect(Collectors.toList()));
-                    }
-                });
+        metaStorage.prefix(all())

Review Comment:
   `allUnits()` maybe? Static import hides the context, it's not clear, what 
exactly is this "all"



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/metastore/EntrySubscriber.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.deployunit.metastore;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Flow.Subscriber;
+import java.util.concurrent.Flow.Subscription;
+import org.apache.ignite.internal.metastorage.Entry;
+
+/**
+ * Implementation of {@link Subscriber} based on {@link Entry}.
+ *
+ * @param <R> Result value type.
+ */
+public class EntrySubscriber<R> implements Subscriber<Entry> {
+    private final CompletableFuture<R> result;
+
+    private final Accumulator<R> collector;

Review Comment:
   You should probably call it `accumulator`



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/metastore/ListAccumulator.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.deployunit.metastore;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+import org.apache.ignite.internal.metastorage.Entry;
+
+/**
+ * Plain list accumulator.
+ *
+ * @param <T> Result value type.

Review Comment:
   The fact that resulting list will be sorted is not documented, and it's 
apparent from the class name.



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/metastore/AccumulateException.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.deployunit.metastore;
+
+/**
+ * Boxed exception for accumulation errors.

Review Comment:
   What's a "boxed exception"? I've never seen this phrase



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/metastore/AccumulateException.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.deployunit.metastore;
+
+/**
+ * Boxed exception for accumulation errors.

Review Comment:
   Should it extend IgniteInternalCheckedException?



##########
modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/DeploymentCodeApi.java:
##########
@@ -190,4 +190,25 @@ CompletableFuture<Collection<String>> versions(
     @Get("units/{unitId}/status")
     CompletableFuture<UnitStatusDto> status(
             @PathVariable("unitId") @Schema(name = "unitId", required = true) 
String unitId);
+
+    /**
+     * Find unit by node consistent id.
+     */
+    @Operation(operationId = "byConsistentId", description = "Status of units 
which deployed on node.")
+    @ApiResponse(responseCode = "200",
+            description = "All statutes returned successful.",

Review Comment:
   ```suggestion
               description = "All statutes returned successfully.",
   ```



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