ptupitsyn commented on code in PR #1865:
URL: https://github.com/apache/ignite-3/pull/1865#discussion_r1155730465


##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/DeploymentManagerImpl.java:
##########
@@ -121,36 +131,43 @@ public CompletableFuture<Boolean> deployAsync(String id, 
Version version, Deploy
             return CompletableFuture.failedFuture(new 
DeploymentUnitReadException(e));
         }
 
-        CompletableFuture<Boolean> result = metastore.putIfNotExist(id, 
version, meta)
+        return metastore.putIfNotExist(id, version, meta)
                 .thenCompose(success -> {
                     if (success) {
-                        return deployer.deploy(id, version.render(), 
deploymentUnit.name(), unitContent);
-                    }
-                    LOG.error("Failed to deploy meta of unit " + id + ":" + 
version);
-                    return CompletableFuture.failedFuture(
-                            new DeploymentUnitAlreadyExistsException(id,
-                                    "Unit " + id + ":" + version + " already 
exists"));
-                })
-                .thenCompose(deployed -> {
-                    if (deployed) {
-                        return metastore.updateMeta(id, version,
-                                meta1 -> 
meta1.addConsistentId(clusterService.topologyService().localMember().name()));
-                    }
-                    return CompletableFuture.completedFuture(false);
-                })
-                .thenApply(completed -> {
-                    if (completed) {
-                        messaging.startDeployAsyncToCmg(id, version, 
deploymentUnit.name(), unitContent)
-                                .thenAccept(ids -> metastore.updateMeta(id, 
version, unitMeta -> {
-                                    for (String consistentId : ids) {
-                                        unitMeta.addConsistentId(consistentId);
+                        return tracker.track(id, version, deployer.deploy(id, 
version.render(), deploymentUnit.name(), unitContent)
+                                .thenCompose(deployed -> {
+                                    if (deployed) {
+                                        return metastore.updateMeta(id, 
version,
+                                                unitMeta -> unitMeta
+                                                        
.addConsistentId(clusterService.topologyService().localMember().name()));
+                                    }
+                                    return 
CompletableFuture.completedFuture(false);
+                                })
+                                .thenApply(completed -> {
+                                    if (completed) {
+                                        messaging.startDeployAsyncToCmg(id, 
version, deploymentUnit.name(), unitContent)
+                                                .thenAccept(ids -> 
metastore.updateMeta(id, version, unitMeta -> {
+                                                    for (String consistentId : 
ids) {
+                                                        
unitMeta.addConsistentId(consistentId);
+                                                    }
+                                                    
unitMeta.updateStatus(DEPLOYED);
+                                                }));
                                     }
-                                    unitMeta.updateStatus(DEPLOYED);
+                                    return completed;
                                 }));
+                    } else {
+                        if (force) {
+                            return undeployAsync(id, version)
+                                    .thenCompose(v -> deployAsync(id, version, 
deploymentUnit));
+                        }
+                        LOG.warn("Failed to deploy meta of unit " + id + ":" + 
version + " to metastore. "
+                                + "Already exist.");

Review Comment:
   ```suggestion
                                   + "Already exists.");
   ```



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