16
16
import io .nats .client .support .JsonValue ;
17
17
import org .jspecify .annotations .Nullable ;
18
18
19
+ import java .time .ZonedDateTime ;
19
20
import java .util .List ;
20
21
21
22
import static io .nats .client .support .ApiConstants .*;
22
- import static io .nats .client .support .JsonValueUtils .readString ;
23
- import static io .nats .client .support .JsonValueUtils .readValue ;
23
+ import static io .nats .client .support .JsonValueUtils .*;
24
24
25
25
/**
26
26
* Information about the cluster a stream is part of.
27
27
*/
28
28
public class ClusterInfo {
29
+
29
30
private final String name ;
30
31
private final String leader ;
32
+ private final ZonedDateTime leaderSince ;
31
33
private final List <Replica > replicas ;
32
34
33
35
static ClusterInfo optionalInstance (JsonValue v ) {
@@ -38,6 +40,7 @@ static ClusterInfo optionalInstance(JsonValue v) {
38
40
name = readString (v , NAME );
39
41
leader = readString (v , LEADER );
40
42
replicas = Replica .optionalListOf (readValue (v , REPLICAS ));
43
+ leaderSince = readDate (v , LEADER_SINCE );
41
44
}
42
45
43
46
/**
@@ -58,6 +61,11 @@ public String getLeader() {
58
61
return leader ;
59
62
}
60
63
64
+ @ Nullable
65
+ public ZonedDateTime getLeaderSince () {
66
+ return leaderSince ;
67
+ }
68
+
61
69
/**
62
70
* The members of the RAFT cluster. May be null if there are no replicas.
63
71
* @return the replicas or null
@@ -70,9 +78,10 @@ public List<Replica> getReplicas() {
70
78
@ Override
71
79
public String toString () {
72
80
return "ClusterInfo{" +
73
- "name='" + name + '\'' +
74
- ", leader='" + leader + '\'' +
75
- ", replicas=" + replicas +
76
- '}' ;
81
+ "name='" + name + '\'' +
82
+ ", leader='" + leader + '\'' +
83
+ ", leaderSince=" + leaderSince +
84
+ ", replicas=" + replicas +
85
+ '}' ;
77
86
}
78
87
}
0 commit comments