@@ -34,6 +34,28 @@ type serverModeRequest struct {
3434 Mode ServerMode `json:"mode"`
3535}
3636
37+ // ShutdownInfo stores information about shutdown of the coordinator.
38+ type ShutdownInfo struct {
39+ // AQLCursors stores a number of AQL cursors that are still active.
40+ AQLCursors int `json:"AQLcursors"`
41+ // Transactions stores a number of ongoing transactions.
42+ Transactions int `json:"transactions"`
43+ // PendingJobs stores a number of ongoing asynchronous requests.
44+ PendingJobs int `json:"pendingJobs"`
45+ // DoneJobs stores a number of finished asynchronous requests, whose result has not yet been collected.
46+ DoneJobs int `json:"doneJobs"`
47+ // PregelConductors stores a number of ongoing Pregel jobs.
48+ PregelConductors int `json:"pregelConductors"`
49+ // LowPrioOngoingRequests stores a number of ongoing low priority requests.
50+ LowPrioOngoingRequests int `json:"lowPrioOngoingRequests"`
51+ // LowPrioQueuedRequests stores a number of queued low priority requests.
52+ LowPrioQueuedRequests int `json:"lowPrioQueuedRequests"`
53+ // AllClear is set if all operations are closed.
54+ AllClear bool `json:"allClear"`
55+ // SoftShutdownOngoing describes whether a soft shutdown of the Coordinator is in progress.
56+ SoftShutdownOngoing bool `json:"softShutdownOngoing"`
57+ }
58+
3759// ServerMode returns the current mode in which the server/cluster is operating.
3860// This call needs ArangoDB 3.3 and up.
3961func (c * client ) ServerMode (ctx context.Context ) (ServerMode , error ) {
@@ -138,3 +160,48 @@ func (c *client) Statistics(ctx context.Context) (ServerStatistics, error) {
138160 }
139161 return data , nil
140162}
163+
164+ // ShutdownV2 shuts down a specific coordinator, optionally removing it from the cluster with a graceful manner.
165+ // When `graceful` is true then run soft shutdown process and the `ShutdownInfoV2` can be used to check the progress.
166+ // It is available since versions: v3.7.12, v3.8.1, v3.9.0.
167+ func (c * client ) ShutdownV2 (ctx context.Context , removeFromCluster , graceful bool ) error {
168+ req , err := c .conn .NewRequest ("DELETE" , "_admin/shutdown" )
169+ if err != nil {
170+ return WithStack (err )
171+ }
172+ if removeFromCluster {
173+ req .SetQuery ("remove_from_cluster" , "1" )
174+ }
175+ if graceful {
176+ req .SetQuery ("soft" , "true" )
177+ }
178+ resp , err := c .conn .Do (ctx , req )
179+ if err != nil {
180+ return WithStack (err )
181+ }
182+ if err := resp .CheckStatus (200 ); err != nil {
183+ return WithStack (err )
184+ }
185+ return nil
186+ }
187+
188+ // ShutdownInfoV2 returns information about shutdown progress.
189+ // It is available since versions: v3.7.12, v3.8.1, v3.9.0.
190+ func (c * client ) ShutdownInfoV2 (ctx context.Context ) (ShutdownInfo , error ) {
191+ req , err := c .conn .NewRequest ("GET" , "_admin/shutdown" )
192+ if err != nil {
193+ return ShutdownInfo {}, WithStack (err )
194+ }
195+ resp , err := c .conn .Do (ctx , req )
196+ if err != nil {
197+ return ShutdownInfo {}, WithStack (err )
198+ }
199+ if err := resp .CheckStatus (200 ); err != nil {
200+ return ShutdownInfo {}, WithStack (err )
201+ }
202+ data := ShutdownInfo {}
203+ if err := resp .ParseBody ("" , & data ); err != nil {
204+ return ShutdownInfo {}, WithStack (err )
205+ }
206+ return data , nil
207+ }
0 commit comments