@@ -127,29 +127,27 @@ const (
127127 ReshapeCompactionType CompactionType = "RESHAPE"
128128)
129129
130- // NodeStatusInfo represents a nodetool status line.
131- type NodeStatusInfo struct {
132- HostID string
133- Addr string
134- Status NodeStatus
135- State NodeState
130+ // NodeStatusAndStateInfo represents a node's status and state (like in nodetool status).
131+ type NodeStatusAndStateInfo struct {
132+ NodeStatusInfo
133+ State NodeState
136134}
137135
138- func (s NodeStatusInfo ) String () string {
136+ func (s NodeStatusAndStateInfo ) String () string {
139137 return fmt .Sprintf ("host: %s, Status: %s%s" , s .Addr , s .Status , s .State )
140138}
141139
142140// IsUN returns true if host is Up and NORMAL meaning it's a fully functional
143141// live node.
144- func (s NodeStatusInfo ) IsUN () bool {
142+ func (s NodeStatusAndStateInfo ) IsUN () bool {
145143 return s .Status == NodeStatusUp && s .State == NodeStateNormal
146144}
147145
148- // NodeStatusInfoSlice adds functionality to Status response.
149- type NodeStatusInfoSlice []NodeStatusInfo
146+ // NodeStatusAndStateInfoSlice adds functionality to Status response.
147+ type NodeStatusAndStateInfoSlice []NodeStatusAndStateInfo
150148
151149// Hosts returns slice of address of all nodes.
152- func (s NodeStatusInfoSlice ) Hosts () []string {
150+ func (s NodeStatusAndStateInfoSlice ) Hosts () []string {
153151 var hosts []string
154152 for _ , h := range s {
155153 hosts = append (hosts , h .Addr )
@@ -158,7 +156,7 @@ func (s NodeStatusInfoSlice) Hosts() []string {
158156}
159157
160158// HostIDs returns slice of HostID of all nodes.
161- func (s NodeStatusInfoSlice ) HostIDs () []string {
159+ func (s NodeStatusAndStateInfoSlice ) HostIDs () []string {
162160 var hostIDs []string
163161 for _ , h := range s {
164162 hostIDs = append (hostIDs , h .HostID )
@@ -167,7 +165,7 @@ func (s NodeStatusInfoSlice) HostIDs() []string {
167165}
168166
169167// LiveHosts returns slice of address of nodes in UN state.
170- func (s NodeStatusInfoSlice ) LiveHosts () []string {
168+ func (s NodeStatusAndStateInfoSlice ) LiveHosts () []string {
171169 var hosts []string
172170 for _ , h := range s {
173171 if h .IsUN () {
@@ -178,7 +176,7 @@ func (s NodeStatusInfoSlice) LiveHosts() []string {
178176}
179177
180178// DownHosts returns slice of address of nodes that are down.
181- func (s NodeStatusInfoSlice ) DownHosts () []string {
179+ func (s NodeStatusAndStateInfoSlice ) DownHosts () []string {
182180 var hosts []string
183181 for _ , h := range s {
184182 if h .Status == NodeStatusDown {
@@ -189,7 +187,7 @@ func (s NodeStatusInfoSlice) DownHosts() []string {
189187}
190188
191189// DownHostIDs returns slice of HostID of nodes that are down.
192- func (s NodeStatusInfoSlice ) DownHostIDs () []string {
190+ func (s NodeStatusAndStateInfoSlice ) DownHostIDs () []string {
193191 var hostIDs []string
194192 for _ , h := range s {
195193 if h .Status == NodeStatusDown {
@@ -198,3 +196,43 @@ func (s NodeStatusInfoSlice) DownHostIDs() []string {
198196 }
199197 return hostIDs
200198}
199+
200+ // NodeStatusInfo represents the status (Up/Down) of a node.
201+ type NodeStatusInfo struct {
202+ HostID string
203+ Addr string
204+ Status NodeStatus
205+ }
206+
207+ type NodeStatusInfoSlice []NodeStatusInfo
208+
209+ // UpHostIDs returns slice of HostID of nodes that are up.
210+ func (s NodeStatusInfoSlice ) UpHostIDs () []string {
211+ var hosts []string
212+ for _ , h := range s {
213+ if h .Status == NodeStatusUp {
214+ hosts = append (hosts , h .Addr )
215+ }
216+ }
217+ return hosts
218+ }
219+
220+ // HostIDs returns slice of HostID of all nodes.
221+ func (s NodeStatusInfoSlice ) HostIDs () []string {
222+ var hostIDs []string
223+ for _ , h := range s {
224+ hostIDs = append (hostIDs , h .HostID )
225+ }
226+ return hostIDs
227+ }
228+
229+ // DownHostIDs returns slice of HostID of nodes that are down.
230+ func (s NodeStatusInfoSlice ) DownHostIDs () []string {
231+ var hosts []string
232+ for _ , h := range s {
233+ if h .Status == NodeStatusDown {
234+ hosts = append (hosts , h .HostID )
235+ }
236+ }
237+ return hosts
238+ }
0 commit comments