Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Resolved the cache invalidation of the partition->leader shard in ClientCache
  • Loading branch information
haohao0103 committed Jul 12, 2024
1 parent e1bd708 commit de5e358
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public void reset() {
groups = new ConcurrentHashMap<>();
stores = new ConcurrentHashMap<>();
caches = new ConcurrentHashMap<>();
initialized.set(false);

Check warning on line 293 in hugegraph-pd/hg-pd-client/src/main/java/org/apache/hugegraph/pd/client/ClientCache.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-pd/hg-pd-client/src/main/java/org/apache/hugegraph/pd/client/ClientCache.java#L293

Added line #L293 was not covered by tests
}

public Shard getLeader(int partitionId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ private KVPair<Metapb.Partition, Metapb.Shard> getKvPair(String graphName, byte[
public KVPair<Metapb.Partition, Metapb.Shard> getPartition(String graphName, byte[] key) throws
PDException {
// 先查cache,cache没有命中,在调用PD
KVPair<Metapb.Partition, Metapb.Shard> partShard = cache.getPartitionByKey(graphName, key);
int code = PartitionUtils.calcHashcode(key);
KVPair<Metapb.Partition, Metapb.Shard> partShard = this.getPartitionByCode(graphName, code);

Check warning on line 465 in hugegraph-pd/hg-pd-client/src/main/java/org/apache/hugegraph/pd/client/PDClient.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-pd/hg-pd-client/src/main/java/org/apache/hugegraph/pd/client/PDClient.java#L464-L465

Added lines #L464 - L465 were not covered by tests
partShard = getKvPair(graphName, key, partShard);
return partShard;
}
Expand Down

0 comments on commit de5e358

Please sign in to comment.