diff --git a/reaper/client.go b/reaper/client.go index 0bddab5..386b64c 100644 --- a/reaper/client.go +++ b/reaper/client.go @@ -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 { @@ -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: } @@ -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) } @@ -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: } @@ -284,19 +284,19 @@ 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{}} @@ -304,15 +304,15 @@ func newCluster(state *clusterStatus) *Cluster { 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) } @@ -332,4 +332,4 @@ func getBodyAsString(resp *http.Response) (string, error) { return "", err } return string(body), nil -} \ No newline at end of file +} diff --git a/reaper/types.go b/reaper/types.go index 5746b42..39b2655 100644 --- a/reaper/types.go +++ b/reaper/types.go @@ -1,5 +1,7 @@ package reaper +import "time" + type Cluster struct { Name string JmxUsername string @@ -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 @@ -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"` }