1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.tikv.common.meta;
19
20 import com.fasterxml.jackson.annotation.JsonCreator;
21 import com.fasterxml.jackson.annotation.JsonProperty;
22 import java.io.Serializable;
23
24 public class TiFlashReplicaInfo implements Serializable {
25 private final long count;
26 private final String[] locationLabels;
27 private final boolean available;
28 private final long[] availablePartitionIDs;
29
30 @JsonCreator
31 public TiFlashReplicaInfo(
32 @JsonProperty("Count") long count,
33 @JsonProperty("LocationLabels") String[] locationLabels,
34 @JsonProperty("Available") boolean available,
35 @JsonProperty("AvailablePartitionIDs") long[] availablePartitionIDs) {
36 this.count = count;
37 this.locationLabels = locationLabels;
38 this.available = available;
39 this.availablePartitionIDs = availablePartitionIDs;
40 }
41
42 public boolean isPartitionAvailable(long pid) {
43 for (long id : availablePartitionIDs) {
44 if (id == pid) {
45 return true;
46 }
47 }
48 return false;
49 }
50
51 public long getCount() {
52 return count;
53 }
54
55 public String[] getLocationLabels() {
56 return locationLabels;
57 }
58
59 public boolean isAvailable() {
60 return available;
61 }
62
63 public long[] getAvailablePartitionIDs() {
64 return availablePartitionIDs;
65 }
66 }