sohami commented on a change in pull request #1762: [DRILL-7191 / DRILL-7026]: RM state blob persistence in Zookeeper and Integration of Distributed queue configuration with Planner URL: https://github.com/apache/drill/pull/1762#discussion_r279985736
########## File path: exec/java-exec/src/main/java/org/apache/drill/common/DrillNode.java ########## @@ -0,0 +1,88 @@ +/* + * 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.drill.common; + +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; + +/** + * DrillNode encapsulates a drillendpoint. DrillbitEndpoint is a protobuf generated class which requires + * all the member variables to be equal for DrillbitEndpoints to be equal. DrillNode relaxes this requirement + * by only comparing required variables. + */ +public class DrillNode { + private final DrillbitEndpoint endpoint; + + public DrillNode(DrillbitEndpoint endpoint) { + this.endpoint = endpoint; + } + + public static DrillNode create(DrillbitEndpoint endpoint) { + return new DrillNode(endpoint); + } + + public boolean equals(Object other) { + if (!(other instanceof DrillNode)) { + return false; + } + + DrillbitEndpoint otherEndpoint = ((DrillNode) other).endpoint; + return endpoint.getAddress().equals(otherEndpoint.getAddress()) && + endpoint.getUserPort() == otherEndpoint.getUserPort() && + endpoint.getControlPort() == otherEndpoint.getControlPort() && + endpoint.getDataPort() == otherEndpoint.getDataPort() && + endpoint.getVersion().equals(otherEndpoint.getVersion()); Review comment: looks like all the fields in `DrillbitEndpoint` are optional, so we should check if the field is present or not before calling equals on it. Just like done for `hashCode()` below or refer `equals` in generated file for DrillbitEndpoint. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
