valepakh commented on code in PR #6625:
URL: https://github.com/apache/ignite-3/pull/6625#discussion_r2362301056


##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeployDeploymentUnitProcessor.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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;
+
+import static java.nio.file.StandardCopyOption.ATOMIC_MOVE;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map.Entry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Implementation of {@link DeploymentUnitProcessor} that deploys deployment 
unit content to the file system.
+ *
+ * <p>This processor extracts and deploys files from deployment units to a 
specified target directory.
+ * It handles both regular deployment units (containing individual files as 
input streams) and ZIP-based
+ * deployment units (containing compressed archives that need extraction).
+ *
+ * <p>The deployment process ensures atomic file operations by:
+ * <ul>
+ *     <li>First copying files to temporary locations with a {@code .tmp} 
suffix</li>
+ *     <li>Then atomically moving them to their final destinations</li>
+ *     <li>Creating necessary parent directories as needed</li>
+ * </ul>
+ *
+ * <p>This approach prevents partial deployments and ensures that files are 
either fully deployed
+ * or not deployed at all, maintaining consistency during the deployment 
process.
+ *
+ * <p>Type parameters:
+ * <ul>
+ *     <li>{@code Path} - the argument type representing the target deployment 
directory</li>
+ *     <li>{@code Void} - the return type (no meaningful return value)</li>
+ * </ul>
+ */
+public class DeployDeploymentUnitProcessor implements 
DeploymentUnitProcessor<Path, Void> {
+    /** Suffix used for temporary files during the deployment process. */
+    private static final String TMP_SUFFIX = ".tmp";
+
+    /** {@inheritDoc} */

Review Comment:
   Let's remove all of these.



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeployDeploymentUnitProcessor.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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;
+
+import static java.nio.file.StandardCopyOption.ATOMIC_MOVE;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map.Entry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Implementation of {@link DeploymentUnitProcessor} that deploys deployment 
unit content to the file system.
+ *
+ * <p>This processor extracts and deploys files from deployment units to a 
specified target directory.
+ * It handles both regular deployment units (containing individual files as 
input streams) and ZIP-based
+ * deployment units (containing compressed archives that need extraction).
+ *
+ * <p>The deployment process ensures atomic file operations by:
+ * <ul>
+ *     <li>First copying files to temporary locations with a {@code .tmp} 
suffix</li>
+ *     <li>Then atomically moving them to their final destinations</li>
+ *     <li>Creating necessary parent directories as needed</li>
+ * </ul>
+ *
+ * <p>This approach prevents partial deployments and ensures that files are 
either fully deployed
+ * or not deployed at all, maintaining consistency during the deployment 
process.
+ *
+ * <p>Type parameters:
+ * <ul>
+ *     <li>{@code Path} - the argument type representing the target deployment 
directory</li>
+ *     <li>{@code Void} - the return type (no meaningful return value)</li>
+ * </ul>
+ */
+public class DeployDeploymentUnitProcessor implements 
DeploymentUnitProcessor<Path, Void> {

Review Comment:
   DeploymentUnitProcessorImpl?



##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeploymentUnitProcessor.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import java.io.IOException;
+
+/**
+ * Processor interface for handling deployment unit content operations.
+ *
+ * <p>This interface defines a contract for processing deployment units, 
providing methods to handle
+ * both regular deployment units and ZIP-based deployment units. 
Implementations of this interface
+ * can perform various operations on deployment unit content such as 
deployment, validation, 
+ * transformation, or extraction.
+ *
+ * <p>The processor uses a generic approach with two type parameters:
+ * <ul>
+ *     <li>{@code T} - the type of argument passed to processing methods</li>
+ *     <li>{@code R} - the type of result returned by processing methods</li>
+ * </ul>
+ *
+ * <p>This design allows for flexible implementations that can process 
deployment units with
+ * different argument types and return different result types based on the 
specific use case.
+ *
+ * @param <T> the type of argument passed to the processing methods
+ * @param <R> the type of result returned by the processing methods
+ */
+public interface DeploymentUnitProcessor<T, R> {
+    /**
+     * Processes the content of a regular deployment unit.
+     *
+     * <p>This method handles deployment units that contain a collection of 
files represented
+     * as input streams. The implementation should process each file in the 
deployment unit
+     * according to the specific processor's logic.
+     *
+     * @param unit the deployment unit containing the content to be processed
+     * @param arg the argument to be used during processing
+     * @return the result of the processing operation
+     * @throws IOException if an I/O error occurs during processing
+     */
+    R processContent(DeploymentUnitImpl unit, T arg) throws IOException;

Review Comment:
   I don't understand what's the point of return type here. It's always `Void` 
and it's not used in any way.



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