Skip to content

Commit

Permalink
Rename RepairSchedulerPerCluster to ForCluster and add some more pars…
Browse files Browse the repository at this point in the history
…ed json fields
  • Loading branch information
burmanm committed Dec 14, 2020
1 parent 4842f5f commit db8ffff
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 77 deletions.
40 changes: 20 additions & 20 deletions reaper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ReaperClient interface {

RepairSchedules(ctx context.Context) ([]RepairSchedule, error)

RepairSchedulesPerCluster(ctx context.Context, clusterName string) ([]RepairSchedule, error)
RepairSchedulesForCluster(ctx context.Context, clusterName string) ([]RepairSchedule, error)
}

type Client struct {
Expand Down Expand Up @@ -181,7 +181,7 @@ func (c *Client) AddCluster(ctx context.Context, cluster string, seed string) er
resp, err := c.httpClient.Do(req)
if err != nil {
select {
case <- ctx.Done():
case <-ctx.Done():
return ctx.Err()
default:
}
Expand Down Expand Up @@ -227,7 +227,7 @@ func (c *Client) RepairSchedules(ctx context.Context) ([]RepairSchedule, error)
return c.fetchRepairSchedules(ctx, rel)
}

func (c *Client) RepairSchedulesPerCluster(ctx context.Context, clusterName string) ([]RepairSchedule, error) {
func (c *Client) RepairSchedulesForCluster(ctx context.Context, clusterName string) ([]RepairSchedule, error) {
rel := &url.URL{Path: fmt.Sprintf("/repair_schedule/cluster/%s", clusterName)}
return c.fetchRepairSchedules(ctx, rel)
}
Expand Down Expand Up @@ -263,7 +263,7 @@ func (c *Client) doRequest(ctx context.Context, req *http.Request, v interface{}
resp, err := c.httpClient.Do(req)
if err != nil {
select {
case <- ctx.Done():
case <-ctx.Done():
return nil, ctx.Err()
default:
}
Expand All @@ -284,35 +284,35 @@ func (c *Client) doRequest(ctx context.Context, req *http.Request, v interface{}

func newCluster(state *clusterStatus) *Cluster {
cluster := Cluster{
Name: state.Name,
JmxUsername: state.JmxUsername,
Name: state.Name,
JmxUsername: state.JmxUsername,
JmxPasswordSet: state.JmxPasswordSet,
Seeds: state.Seeds,
NodeState: NodeState{},
Seeds: state.Seeds,
NodeState: NodeState{},
}

for _, gs := range state.NodeStatus.EndpointStates {
gossipState := GossipState{
SourceNode: gs.SourceNode,
SourceNode: gs.SourceNode,
EndpointNames: gs.EndpointNames,
TotalLoad: gs.TotalLoad,
DataCenters: map[string]DataCenterState{},
TotalLoad: gs.TotalLoad,
DataCenters: map[string]DataCenterState{},
}
for dc, dcStateInternal := range gs.Endpoints {
dcState := DataCenterState{Name: dc, Racks: map[string]RackState{}}
for rack, endpoints := range dcStateInternal {
rackState := RackState{Name: rack}
for _, ep := range endpoints {
endpoint := EndpointState{
Endpoint: ep.Endpoint,
DataCenter: ep.DataCenter,
Rack: ep.Rack,
HostId: ep.HostId,
Status: ep.Status,
Severity: ep.Severity,
Endpoint: ep.Endpoint,
DataCenter: ep.DataCenter,
Rack: ep.Rack,
HostId: ep.HostId,
Status: ep.Status,
Severity: ep.Severity,
ReleaseVersion: ep.ReleaseVersion,
Tokens: ep.Tokens,
Load: ep.Load,
Tokens: ep.Tokens,
Load: ep.Load,
}
rackState.Endpoints = append(rackState.Endpoints, endpoint)
}
Expand All @@ -332,4 +332,4 @@ func getBodyAsString(resp *http.Response) (string, error) {
return "", err
}
return string(body), nil
}
}
82 changes: 25 additions & 57 deletions reaper/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package reaper

import "time"

type Cluster struct {
Name string
JmxUsername string
Expand Down Expand Up @@ -47,54 +49,20 @@ type GetClusterResult struct {
}

type RepairSchedule struct {
Id string `json:"id"`
Owner string `json:"owner,omitempty"`
State string `json:"state,omitempty"`
Intensity float64 `json:"intensity,omitempty"`
ClusterName string `json:"cluster_name,omitempty"`
KeyspaceName string `json:"keyspace_name,omitempty"`
RepairParallism string `json:"repair_parallelism,omitempty"`
IncrementalRepair bool `json:"incremental_repair,omitempty"`
ThreadCount int `json:"repair_thread_count,omitempty"`
UnitId string `json:"repair_unit_id,omitempty"`

//public enum State {
//ACTIVE,
//PAUSED,
//DELETED
//}

//public enum RepairParallelism {
//SEQUENTIAL("sequential"),
//PARALLEL("parallel"),
//DATACENTER_AWARE("dc_parallel");

/*
[
{
"id": "9ee7f6e0-3575-11eb-8fca-273b55edb18f",
"owner": "auto-scheduling",
"state": "ACTIVE",
"intensity": 0.8999999761581421,
"cluster_name": "k8ssandra",
"keyspace_name": "reaper_db",
"column_families": [],
"incremental_repair": false,
"segment_count": 0,
"repair_parallelism": "DATACENTER_AWARE",
"scheduled_days_between": 7,
"nodes": [],
"datacenters": [],
"blacklisted_tables": [],
"segment_count_per_node": 64,
"repair_thread_count": 1,
"repair_unit_id": "9ee6be60-3575-11eb-8fca-273b55edb18f",
"creation_time": "2020-12-03T14:41:25Z",
"pause_time": "2020-12-03T14:46:28Z",
"next_activation": "2020-12-10T14:46:25Z"
}
]
*/
Id string `json:"id"`
Owner string `json:"owner,omitempty"`
State string `json:"state,omitempty"`
Intensity float64 `json:"intensity,omitempty"`
ClusterName string `json:"cluster_name,omitempty"`
KeyspaceName string `json:"keyspace_name,omitempty"`
RepairParallism string `json:"repair_parallelism,omitempty"`
IncrementalRepair bool `json:"incremental_repair,omitempty"`
ThreadCount int `json:"repair_thread_count,omitempty"`
UnitId string `json:"repair_unit_id,omitempty"`
DaysBetween int `json:"scheduled_days_between,omitempty"`
Created time.Time `json:"creation_time,omitempty"`
Paused time.Time `json:"pause_time,omitempty"`
NextActivation time.Time `json:"next_activation,omitempty"`
}

// All the following types are used internally by the client and not part of the public API
Expand All @@ -112,20 +80,20 @@ type nodeStatus struct {
}

type gossipStatus struct {
SourceNode string `json:"sourceNode"`
SourceNode string `json:"sourceNode"`
EndpointNames []string `json:"endpointNames,omitempty"`
TotalLoad float64 `json:"totalLoad,omitempty"`
TotalLoad float64 `json:"totalLoad,omitempty"`
Endpoints map[string]map[string][]endpointStatus
}

type endpointStatus struct {
Endpoint string `json:"endpoint"`
DataCenter string `json:"dc"`
Rack string `json:"rack"`
HostId string `json:"hostId"`
Status string `json:"status"`
Endpoint string `json:"endpoint"`
DataCenter string `json:"dc"`
Rack string `json:"rack"`
HostId string `json:"hostId"`
Status string `json:"status"`
Severity float64 `json:"severity"`
ReleaseVersion string `json:"releaseVersion"`
Tokens string `json:"tokens"`
ReleaseVersion string `json:"releaseVersion"`
Tokens string `json:"tokens"`
Load float64 `json:"load"`
}

0 comments on commit db8ffff

Please sign in to comment.