ptupitsyn commented on code in PR #1698: URL: https://github.com/apache/ignite-3/pull/1698#discussion_r1114112679
########## modules/api/src/main/java/org/apache/ignite/deployment/IgniteDeployment.java: ########## @@ -0,0 +1,96 @@ +/* + * 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.deployment; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.deployment.version.Version; + +/** + * Provides access to the Deployment Unit functionality. + */ +public interface IgniteDeployment { + /** + * Deploy provided unit to current node with latest version. + * + * @param id Unit identifier. Not empty and not null. + * @param deploymentUnit Unit content. + * @return Future with success or not result. + */ + default CompletableFuture<Boolean> deployAsync(String id, DeploymentUnit deploymentUnit) { + return deployAsync(id, Version.LATEST, deploymentUnit); + } + + /** + * Deploy provided unit to current node. + * After deploy finished, this deployment unit will be place to CMG group asynchronously. + * + * @param id Unit identifier. Not empty and not null. + * @param version Unit version. + * @param deploymentUnit Unit content. + * @return Future with success or not result. + */ + CompletableFuture<Boolean> deployAsync(String id, Version version, DeploymentUnit deploymentUnit); + + /** + * Undeploy latest version of unit with corresponding identifier. + * + * @param id Unit identifier. Not empty and not null. + * @return Future completed when unit will be undeployed. + * In case when specified unit not exist future will be failed. + */ + default CompletableFuture<Void> undeployAsync(String id) { + return undeployAsync(id, Version.LATEST); + } + + /** + * Undeploy unit with corresponding identifier and version. + * Note that unit files will be deleted asynchronously. + * + * @param id Unit identifier. + * @param version Unit version. + * @return Future completed when unit will be undeployed. + * In case when specified unit not exist future will be failed. + */ + CompletableFuture<Void> undeployAsync(String id, Version version); + + /** + * List of all deployed units identifiers. Review Comment: ```suggestion * Lists all deployed units. ``` ########## modules/api/src/main/java/org/apache/ignite/deployment/IgniteDeployment.java: ########## @@ -0,0 +1,96 @@ +/* + * 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.deployment; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.deployment.version.Version; + +/** + * Provides access to the Deployment Unit functionality. + */ +public interface IgniteDeployment { + /** + * Deploy provided unit to current node with latest version. + * + * @param id Unit identifier. Not empty and not null. + * @param deploymentUnit Unit content. + * @return Future with success or not result. + */ + default CompletableFuture<Boolean> deployAsync(String id, DeploymentUnit deploymentUnit) { + return deployAsync(id, Version.LATEST, deploymentUnit); + } + + /** + * Deploy provided unit to current node. + * After deploy finished, this deployment unit will be place to CMG group asynchronously. + * + * @param id Unit identifier. Not empty and not null. + * @param version Unit version. + * @param deploymentUnit Unit content. + * @return Future with success or not result. + */ + CompletableFuture<Boolean> deployAsync(String id, Version version, DeploymentUnit deploymentUnit); + + /** + * Undeploy latest version of unit with corresponding identifier. + * + * @param id Unit identifier. Not empty and not null. + * @return Future completed when unit will be undeployed. + * In case when specified unit not exist future will be failed. + */ + default CompletableFuture<Void> undeployAsync(String id) { + return undeployAsync(id, Version.LATEST); + } + + /** + * Undeploy unit with corresponding identifier and version. + * Note that unit files will be deleted asynchronously. + * + * @param id Unit identifier. + * @param version Unit version. + * @return Future completed when unit will be undeployed. + * In case when specified unit not exist future will be failed. + */ + CompletableFuture<Void> undeployAsync(String id, Version version); + + /** + * List of all deployed units identifiers. + * + * @return Future with result. + */ + CompletableFuture<List<UnitStatus>> listAsync(); + + /** + * List with all deployed versions of required unit identifiers. Review Comment: ```suggestion * List all deployed versions of the specified unit. ``` ########## modules/api/src/main/java/org/apache/ignite/deployment/UnitStatus.java: ########## @@ -0,0 +1,108 @@ +/* + * 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.deployment; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.apache.ignite.deployment.version.Version; +import org.apache.ignite.internal.tostring.S; + +/** + * Deployment unit status. + */ +public class UnitStatus { + /** + * Unit identifier. + */ + private final String id; + + /** + * Map from existed unit version to list of nodes consistent ids where unit deployed. + */ + private final Map<Version, List<String>> versionToConsistentIds; + + public UnitStatus(String id, Map<Version, List<String>> versionToConsistentIds) { Review Comment: Missing argument validation. ########## modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/UnitMetaSerializer.java: ########## @@ -0,0 +1,86 @@ +/* + * 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.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.apache.ignite.deployment.version.Version; + +/** + * Serializer for {@link UnitMeta}. + */ +public class UnitMetaSerializer { + private static final String SEPARATOR = ";"; + private static final String LIST_SEPARATOR = ":"; + + /** + * Constructor. + */ + private UnitMetaSerializer() { + + } + + + /** + * Serialize unit meta. + * + * @param meta Unit meta. + * @return Serialized unit meta. + */ + public static byte[] serialize(UnitMeta meta) { + StringBuilder sb = new StringBuilder(); + + sb.append(meta.getId()).append(SEPARATOR) Review Comment: Let's change this to `BinaryTuple` as part of current PR. I don't think we should merge this custom separator-based serialization logic. ########## modules/api/src/main/java/org/apache/ignite/deployment/UnitStatus.java: ########## @@ -0,0 +1,108 @@ +/* + * 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.deployment; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.apache.ignite.deployment.version.Version; +import org.apache.ignite.internal.tostring.S; + +/** + * Deployment unit status. + */ +public class UnitStatus { + /** + * Unit identifier. + */ + private final String id; + + /** + * Map from existed unit version to list of nodes consistent ids where unit deployed. + */ + private final Map<Version, List<String>> versionToConsistentIds; + + public UnitStatus(String id, Map<Version, List<String>> versionToConsistentIds) { + this.id = id; + this.versionToConsistentIds = Collections.unmodifiableMap(versionToConsistentIds); + } + + public String getId() { Review Comment: ```suggestion public String id() { ``` ########## modules/api/src/main/java/org/apache/ignite/deployment/UnitStatus.java: ########## @@ -0,0 +1,108 @@ +/* + * 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.deployment; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.apache.ignite.deployment.version.Version; +import org.apache.ignite.internal.tostring.S; + +/** + * Deployment unit status. + */ +public class UnitStatus { + /** + * Unit identifier. + */ + private final String id; + + /** + * Map from existed unit version to list of nodes consistent ids where unit deployed. + */ + private final Map<Version, List<String>> versionToConsistentIds; + + public UnitStatus(String id, Map<Version, List<String>> versionToConsistentIds) { Review Comment: I think we can make this `private`, since there is a builder class. ########## modules/api/src/main/java/org/apache/ignite/deployment/UnitStatus.java: ########## @@ -0,0 +1,108 @@ +/* + * 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.deployment; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.apache.ignite.deployment.version.Version; +import org.apache.ignite.internal.tostring.S; + +/** + * Deployment unit status. + */ +public class UnitStatus { + /** + * Unit identifier. + */ + private final String id; + + /** + * Map from existed unit version to list of nodes consistent ids where unit deployed. Review Comment: `existed` is not correct here, did you mean `existing`? ########## modules/api/src/main/java/org/apache/ignite/deployment/IgniteDeployment.java: ########## @@ -0,0 +1,96 @@ +/* + * 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.deployment; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.deployment.version.Version; + +/** + * Provides access to the Deployment Unit functionality. + */ +public interface IgniteDeployment { + /** + * Deploy provided unit to current node with latest version. + * + * @param id Unit identifier. Not empty and not null. + * @param deploymentUnit Unit content. + * @return Future with success or not result. + */ + default CompletableFuture<Boolean> deployAsync(String id, DeploymentUnit deploymentUnit) { + return deployAsync(id, Version.LATEST, deploymentUnit); + } + + /** + * Deploy provided unit to current node. + * After deploy finished, this deployment unit will be place to CMG group asynchronously. + * + * @param id Unit identifier. Not empty and not null. + * @param version Unit version. + * @param deploymentUnit Unit content. + * @return Future with success or not result. + */ + CompletableFuture<Boolean> deployAsync(String id, Version version, DeploymentUnit deploymentUnit); + + /** + * Undeploy latest version of unit with corresponding identifier. + * + * @param id Unit identifier. Not empty and not null. + * @return Future completed when unit will be undeployed. + * In case when specified unit not exist future will be failed. + */ + default CompletableFuture<Void> undeployAsync(String id) { + return undeployAsync(id, Version.LATEST); + } + + /** + * Undeploy unit with corresponding identifier and version. + * Note that unit files will be deleted asynchronously. + * + * @param id Unit identifier. + * @param version Unit version. + * @return Future completed when unit will be undeployed. + * In case when specified unit not exist future will be failed. + */ + CompletableFuture<Void> undeployAsync(String id, Version version); + + /** + * List of all deployed units identifiers. + * + * @return Future with result. + */ + CompletableFuture<List<UnitStatus>> listAsync(); Review Comment: ```suggestion CompletableFuture<List<UnitStatus>> unitsAsync(); ``` -- 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]
