nva commented on code in PR #7091: URL: https://github.com/apache/ignite-3/pull/7091#discussion_r2601504808
########## modules/api/src/main/java/org/apache/ignite/table/partition/PartitionDistribution.java: ########## @@ -0,0 +1,135 @@ +/* + * 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.table.partition; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.table.Tuple; +import org.apache.ignite.table.mapper.Mapper; + +/** + * The partition distribution provides the ability to obtain information about table partitions. + * This interface can be used to get all partitions of a table, the location of the primary replica of a partition, + * the partition for a specific table key. + */ +public interface PartitionDistribution { + /** + * Asynchronously gets a list with all partitions. + * + * @return Future with list with all partitions. + */ + CompletableFuture<List<Partition>> partitionsAsync(); + + /** + * Gets a list with all partitions. + * + * @return List with all partitions. + */ + List<Partition> partitions(); + + /** + * Asynchronously gets map with all partitions and their locations as of the time of the call. + * + * <p>Note: This assignment may become outdated if a re-assigment happens on the cluster. + * + * @return Future with map from partition to cluster node where primary replica of the partition is located as of the time of the call. + */ + CompletableFuture<Map<Partition, ClusterNode>> primaryReplicasAsync(); + + /** + * Asynchronously gets all partitions hosted by the current node as a primary replica. Review Comment: Fixed. ########## modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientPartitionManager.java: ########## @@ -54,11 +57,24 @@ class ClientPartitionManager implements PartitionManager { } @Override - public CompletableFuture<ClusterNode> primaryReplicaAsync(Partition partition) { - if (!(partition instanceof HashPartition)) { - throw new IllegalArgumentException("Unsupported partition type: " + partition); + public CompletableFuture<List<Partition>> partitionsAsync() { + int partitionCount = tbl.tryGetPartitionCount(); + + if (partitionCount != -1) { + return completedFuture(getPartitions(partitionCount)); } + return tbl.getPartitionAssignment() + .thenApply(ignored -> getPartitions(tbl.tryGetPartitionCount())); Review Comment: Fixed -- 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]
