adoroszlai commented on code in PR #5417: URL: https://github.com/apache/ozone/pull/5417#discussion_r1949091534
########## hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/protocol/DatanodeID.java: ########## @@ -0,0 +1,111 @@ +/* + * 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.hadoop.hdds.protocol; + +import org.apache.hadoop.hdds.protocol.proto.HddsProtos; +import org.apache.hadoop.hdds.protocol.proto.HddsProtos.DatanodeIDProto; + +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * DatanodeID is the primary identifier of the Datanode. + * They are unique for every Datanode in the cluster. + * <p> + * This class is immutable and thread safe. + */ +public final class DatanodeID implements Comparable<DatanodeID> { + + private static final ConcurrentMap<UUID, DatanodeID> CACHE = new ConcurrentHashMap<>(); + + private final UUID uuid; + private final String uuidString; Review Comment: Should we keep using `StringWithByteString` to cache both `String` and `ByteString` representation? Since we still send `string uuid`, I guess the performance improvement from HDDS-10811 is relevant. If you agree, the `ByteString` value should be exposed via a method and used in `DatanodeDetails` to `setUuidBytes` instead of `setUuid`. (Sorry my previous suggestion about `id.toString()` was suboptimal.) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
