abstractdog commented on code in PR #426: URL: https://github.com/apache/tez/pull/426#discussion_r2321250196
########## tez-api/src/main/java/org/apache/tez/client/registry/AMRecord.java: ########## @@ -0,0 +1,104 @@ +/** + * 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.tez.client.registry; + +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.registry.client.types.ServiceRecord; +import org.apache.hadoop.yarn.api.records.ApplicationId; + + +/** + * Represents an instance of an AM (DAGClientServer) in the AM registry. + */ +@InterfaceAudience.Public +public class AMRecord { + private static final String APP_ID_RECORD_KEY = "appId"; + private static final String HOST_RECORD_KEY = "host"; + private static final String PORT_RECORD_KEY = "port"; + private static final String OPAQUE_ID_KEY = "id"; + + private final ApplicationId appId; + private final String host; + private final int port; + private final String id; + + public AMRecord(ApplicationId appId, String host, int port, String id) { + this.appId = appId; + this.host = host; + this.port = port; + //If id is not provided, convert to empty string + this.id = (id == null) ? "" : id; + } + + public AMRecord(AMRecord other) { + this.appId = other.getApplicationId(); + this.host = other.getHost(); + this.port = other.getPort(); + this.id = other.getId(); + } + + public AMRecord(ServiceRecord serviceRecord) { + this.appId = ApplicationId.fromString(serviceRecord.get(APP_ID_RECORD_KEY)); + this.host = serviceRecord.get(HOST_RECORD_KEY); + this.port = Integer.parseInt(serviceRecord.get(PORT_RECORD_KEY)); + this.id = serviceRecord.get(OPAQUE_ID_KEY); + } + + public ApplicationId getApplicationId() { + return appId; + } + + public String getHost() { + return host; + } + + public int getPort() { + return port; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object other) { + if (other instanceof AMRecord otherRecord) { Review Comment: yeah, that branch is part of traditional equals method, let me add -- 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: issues-unsubscr...@tez.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org