Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Provide snapshot-topologies support in orchestrator-client (and via api) #912

Merged
merged 7 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions go/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,17 @@ func (this *HttpAPI) asciiTopology(params martini.Params, r render.Render, req *
Respond(r, &APIResponse{Code: OK, Message: fmt.Sprintf("Topology for cluster %s", clusterName), Details: asciiOutput})
}

// SnapshotTopologies triggers orchestrator to record a snapshot of host/master for all known hosts.
func (this *HttpAPI) SnapshotTopologies(params martini.Params, r render.Render, req *http.Request) {
start := time.Now()
if err := inst.SnapshotTopologies(); err != nil {
Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err), Details: fmt.Sprintf("Took %v", time.Since(start))})
return
}

Respond(r, &APIResponse{Code: OK, Message: "Topology Snapshot completed", Details: fmt.Sprintf("Took %v", time.Since(start))})
}

// AsciiTopology returns an ascii graph of cluster's instances
func (this *HttpAPI) AsciiTopology(params martini.Params, r render.Render, req *http.Request) {
this.asciiTopology(params, r, req, false)
Expand Down Expand Up @@ -3634,6 +3645,7 @@ func (this *HttpAPI) RegisterRequests(m *martini.ClassicMartini) {
this.registerAPIRequest(m, "topology/:host/:port", this.AsciiTopology)
this.registerAPIRequest(m, "topology-tabulated/:clusterHint", this.AsciiTopologyTabulated)
this.registerAPIRequest(m, "topology-tabulated/:host/:port", this.AsciiTopologyTabulated)
this.registerAPIRequest(m, "snapshot-topologies", this.SnapshotTopologies)

// Key-value:
this.registerAPIRequest(m, "submit-masters-to-kv-stores", this.SubmitMastersToKvStores)
Expand Down
7 changes: 6 additions & 1 deletion resources/bin/orchestrator-client
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ function ascii_topology_tabulated {
echo "$api_response" | jq -r '.Details'
}

function snapshot_topologies {
api "snapshot-topologies"
echo "$api_response" | jq -r '.Details'
}

function search {
assert_nonempty "instance" "$instance"
api "search?s=$(urlencode "$instance")"
Expand Down Expand Up @@ -852,6 +857,7 @@ function run_command {

"topology") ascii_topology ;; # Show an ascii-graph of a replication topology, given a member of that topology
"topology-tabulated") ascii_topology_tabulated ;; # Show an ascii-graph of a replication topology, given a member of that topology, in tabulated format
"snapshot-topologies") snapshot_topologies ;; # Trigger topology snapshot (recording host/master settings for all hosts)
"clusters") clusters ;; # List all clusters known to orchestrator
"clusters-alias") clusters_alias ;; # List all clusters known to orchestrator
"search") search ;; # Search for instances matching given substring
Expand Down Expand Up @@ -958,7 +964,6 @@ function run_command {
"raft-health") raft_health ;; # Whether node is part of a healthy raft group
"raft-leader-hostname") raft_leader_hostname ;; # Get hostname of raft leader, assuming raft setup
"raft-elect-leader") raft_elect_leader ;; # Request raft re-elections, provide hint for new leader's identity

*) fail "Unsupported command $command" ;;
esac
}
Expand Down