PakhomovAlexander commented on code in PR #2044:
URL: https://github.com/apache/ignite-3/pull/2044#discussion_r1196784081
##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/UnitStatus.java:
##########
@@ -95,61 +86,32 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
- UnitStatus that = (UnitStatus) o;
- return Objects.equals(id, that.id) && Objects.equals(versionToStatus,
that.versionToStatus);
+
+ UnitStatus meta = (UnitStatus) o;
+
+ if (id != null ? !id.equals(meta.id) : meta.id != null) {
+ return false;
+ }
+ if (version != null ? !version.equals(meta.version) : meta.version !=
null) {
+ return false;
+ }
+ return status == meta.status;
}
- /** {@inheritDoc} */
@Override
public int hashCode() {
- return Objects.hash(id, versionToStatus);
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (version != null ? version.hashCode() : 0);
+ result = 31 * result + (status != null ? status.hashCode() : 0);
+ return result;
}
@Override
public String toString() {
- return "UnitStatus{"
+ return "UnitMeta{"
Review Comment:
Class is called `UnitStatus ` but you print it like `UnitMeta `, Why?
##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/UnitStatuses.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.ignite.internal.deployunit.version.Version;
+import org.apache.ignite.internal.rest.api.deployment.DeploymentStatus;
+
+/**
+ * Deployment unit status.
+ */
+public class UnitStatuses {
+ /**
+ * Unit identifier.
+ */
+ private final String id;
+
+ /**
+ * Map from existing unit version to list of nodes consistent ids where
unit deployed.
+ */
+ private final Map<Version, DeploymentStatus> versionToStatus;
+
+ /**
+ * Constructor.
+ *
+ * @param id Unit identifier.
+ * @param versionToConsistentIds Map from existing unit version to list
+ * of nodes consistent ids where unit deployed.
+ */
+ private UnitStatuses(String id,
+ Map<Version, DeploymentStatus> versionToConsistentIds) {
+ this.id = id;
+ this.versionToStatus =
Collections.unmodifiableMap(versionToConsistentIds);
+ }
+
+ /**
+ * Returns unit identifier.
+ *
+ * @return unit identifier.
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
+ * Returns unit version.
+ *
+ * @return unit version.
+ */
+ public Set<Version> versions() {
+ return Collections.unmodifiableSet(versionToStatus.keySet());
+ }
+
+ public DeploymentStatus status(Version version) {
+ return versionToStatus.get(version);
+ }
+
+ /**
+ * Builder provider.
+ *
+ * @param id Identifier of unit. Not null and not blank.
+ * @return Instance of {@link UnitStatusBuilder}.
+ */
+ public static UnitStatusBuilder builder(String id) {
+ Objects.requireNonNull(id);
+
+ return new UnitStatusBuilder(id);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ UnitStatuses that = (UnitStatuses) o;
+ return Objects.equals(id, that.id) && Objects.equals(versionToStatus,
that.versionToStatus);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, versionToStatus);
+ }
+
+ @Override
+ public String toString() {
+ return "UnitStatus{"
Review Comment:
```suggestion
return "UnitStatuses{"
```
##########
modules/code-deployment/src/main/java/org/apache/ignite/internal/deployunit/UnitStatuses.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.ignite.internal.deployunit.version.Version;
+import org.apache.ignite.internal.rest.api.deployment.DeploymentStatus;
+
+/**
+ * Deployment unit status.
+ */
+public class UnitStatuses {
+ /**
+ * Unit identifier.
+ */
+ private final String id;
+
+ /**
+ * Map from existing unit version to list of nodes consistent ids where
unit deployed.
+ */
+ private final Map<Version, DeploymentStatus> versionToStatus;
+
+ /**
+ * Constructor.
+ *
+ * @param id Unit identifier.
+ * @param versionToConsistentIds Map from existing unit version to list
+ * of nodes consistent ids where unit deployed.
+ */
+ private UnitStatuses(String id,
+ Map<Version, DeploymentStatus> versionToConsistentIds) {
+ this.id = id;
+ this.versionToStatus =
Collections.unmodifiableMap(versionToConsistentIds);
+ }
+
+ /**
+ * Returns unit identifier.
+ *
+ * @return unit identifier.
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
+ * Returns unit version.
+ *
+ * @return unit version.
+ */
+ public Set<Version> versions() {
+ return Collections.unmodifiableSet(versionToStatus.keySet());
+ }
+
+ public DeploymentStatus status(Version version) {
+ return versionToStatus.get(version);
+ }
+
+ /**
+ * Builder provider.
+ *
+ * @param id Identifier of unit. Not null and not blank.
+ * @return Instance of {@link UnitStatusBuilder}.
+ */
+ public static UnitStatusBuilder builder(String id) {
+ Objects.requireNonNull(id);
+
+ return new UnitStatusBuilder(id);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ UnitStatuses that = (UnitStatuses) o;
+ return Objects.equals(id, that.id) && Objects.equals(versionToStatus,
that.versionToStatus);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, versionToStatus);
+ }
+
+ @Override
+ public String toString() {
+ return "UnitStatus{"
+ + "id='" + id + '\''
+ + ", versionToStatus=" + versionToStatus
+ + '}';
+ }
+
+ /**
+ * Builder for {@link UnitStatuses}.
+ */
+ public static class UnitStatusBuilder {
Review Comment:
```suggestion
public static class UnitStatusesBuilder {
```
--
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]