TanYuxin-tyx commented on code in PR #22330: URL: https://github.com/apache/flink/pull/22330#discussion_r1180122114
########## flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/storage/TieredStorageMasterClient.java: ########## @@ -0,0 +1,62 @@ +/* + * 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.flink.runtime.io.network.partition.hybrid.tiered.storage; + +import org.apache.flink.runtime.io.network.partition.hybrid.tiered.common.TieredStorageJobId; +import org.apache.flink.runtime.io.network.partition.hybrid.tiered.common.TieredStoragePartitionId; +import org.apache.flink.runtime.io.network.partition.hybrid.tiered.tier.TierMasterAgent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** Client of the Tiered Storage used by the master. */ +public class TieredStorageMasterClient { + + private final List<TierMasterAgent> tiers; + + private final Map<TieredStorageJobId, List<TieredStoragePartitionId>> jobPartitionIds; + + private final ResourceRegistry resourceRegistry; + + public TieredStorageMasterClient( + List<TierMasterAgent> tiers, ResourceRegistry resourceRegistry) { + this.tiers = tiers; + this.resourceRegistry = resourceRegistry; + this.jobPartitionIds = new HashMap<>(); + } + + public void registerResource(TieredStorageJobId jobId, TieredStoragePartitionId partitionId) { + jobPartitionIds.computeIfAbsent(jobId, ignore -> new ArrayList<>()).add(partitionId); + resourceRegistry.registerResource( + partitionId, () -> tiers.forEach(TierMasterAgent::release)); Review Comment: These methods have been renamed into `addPartition` and `releasePartition`. Each tier itself will decide what to do, i.e., register or release resources. (These codes are not added now, because they will be added when implementing each tier.) -- 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...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org