-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ui/replication/primary reindexing (#8906)
* fix typo * fetch replication/mode/status and pass to dashboard component * add reindexing stage to AlertBanner; use real value for isReindexing * remove dr since we don't need it anymore * add indentation * remove TODO * capitalize reindexing_stage and make progress 0 by default * remove Toggle since we don't need it anymore * get allllll the variables at once * only run secondary details test on enterprise
- Loading branch information
Noelle Daley
authored
May 6, 2020
1 parent
c5ce3a2
commit be645f3
Showing
10 changed files
with
130 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import ApplicationAdapter from './application'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
getStatusUrl(mode) { | ||
return this.buildURL() + `/replication/${mode}/status`; | ||
}, | ||
|
||
fetchStatus(mode) { | ||
let url = this.getStatusUrl(mode); | ||
return this.ajax(url, 'GET', { unauthenticated: true }).then(resp => { | ||
return resp.data; | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import DS from 'ember-data'; | ||
const { attr } = DS; | ||
|
||
/* sample response | ||
{ | ||
"request_id": "d81bba81-e8a1-0ee9-240e-a77d36e3e08f", | ||
"lease_id": "", | ||
"renewable": false, | ||
"lease_duration": 0, | ||
"data": { | ||
"cluster_id": "ab7d4191-d1a3-b4d6-6297-5a41af6154ae", | ||
"known_secondaries": [ | ||
"test" | ||
], | ||
"last_performance_wal": 72, | ||
"last_reindex_epoch": "1588281113", | ||
"last_wal": 73, | ||
"merkle_root": "c8d258d376f01d98156f74e8d8f82ea2aca8dc4a", | ||
"mode": "primary", | ||
"primary_cluster_addr": "", | ||
"reindex_building_progress": 26838, | ||
"reindex_building_total": 305443, | ||
"reindex_in_progress": true, | ||
"reindex_stage": "building", | ||
"state": "running" | ||
}, | ||
"wrap_info": null, | ||
"warnings": null, | ||
"auth": null | ||
} | ||
*/ | ||
|
||
export default DS.Model.extend({ | ||
status: attr('object'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ApplicationSerializer from './application'; | ||
|
||
export default ApplicationSerializer.extend({ | ||
normalizeResponse(store, primaryModelClass, payload, id, requestType) { | ||
const normalizedPayload = { | ||
id: payload.id, | ||
status: payload.data, | ||
}; | ||
|
||
return this._super(store, primaryModelClass, normalizedPayload, id, requestType); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import { clusterStates } from 'core/helpers/cluster-states'; | ||
import { capitalize } from '@ember/string'; | ||
import layout from '../templates/components/replication-dashboard'; | ||
|
||
export default Component.extend({ | ||
layout, | ||
data: null, | ||
replicationDetails: null, | ||
isSecondary: null, | ||
dr: null, | ||
isSyncing: computed('replicationDetails', 'isSecondary', function() { | ||
const { state } = this.replicationDetails; | ||
const isSecondary = this.isSecondary; | ||
return isSecondary && state && clusterStates([state]).isSyncing; | ||
}), | ||
isReindexing: computed('data', function() { | ||
// TODO: make this a real value | ||
return false; | ||
isReindexing: computed('replicationDetails', function() { | ||
const { replicationDetails } = this; | ||
return !!replicationDetails.reindex_in_progress; | ||
}), | ||
reindexingStage: computed('replicationDetails', function() { | ||
const { replicationDetails } = this; | ||
const stage = replicationDetails.reindex_stage; | ||
// specify the stage if we have one | ||
if (stage) { | ||
return `: ${capitalize(stage)}`; | ||
} | ||
return ''; | ||
}), | ||
reindexingProgress: computed('replicationDetails', function() { | ||
// TODO: use this value to display a progress bar | ||
const { reindex_building_progress, reindex_building_total } = this.replicationDetails; | ||
let progress = 0; | ||
|
||
if (reindex_building_progress && reindex_building_total) { | ||
// convert progress to a percentage | ||
progress = (reindex_building_progress / reindex_building_total) * 100; | ||
} | ||
|
||
return progress; | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 16 additions & 7 deletions
23
ui/lib/core/addon/templates/components/replication-page.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
<div class="replication-page"> | ||
{{yield (hash | ||
header=(component 'replication-header' data=model title=replicationMode isSecondary=isSecondary) | ||
toggle=(component 'replication-toggle') | ||
dashboard=(component 'replication-dashboard' data=model isSecondary=isSecondary replicationDetails=replicationDetails clusterMode=clusterMode) | ||
isDisabled=isDisabled | ||
message=message | ||
)}} | ||
{{yield | ||
(hash | ||
header=(component 'replication-header' data=model title=replicationMode isSecondary=isSecondary) | ||
toggle=(component 'replication-toggle') | ||
dashboard=(component | ||
'replication-dashboard' | ||
data=model | ||
isSecondary=isSecondary | ||
replicationDetails=replicationDetails | ||
clusterMode=clusterMode | ||
reindexingDetails=reindexingDetails | ||
) | ||
isDisabled=isDisabled | ||
message=message | ||
) | ||
}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters