-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ui/replication/primary reindexing #8906
Changes from 6 commits
97f272e
1949055
b333431
c4c25da
835f3b1
bf50358
8fd2ec3
0d6ec72
8a91c08
f8630bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
}); | ||
}, | ||
}); |
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'), | ||
}); |
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); | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import layout from '../templates/components/replication-page'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
const MODE = { | ||
dr: 'Disaster Recovery', | ||
|
@@ -9,6 +11,26 @@ const MODE = { | |
|
||
export default Component.extend({ | ||
layout, | ||
store: service(), | ||
reindexingDetails: null, | ||
|
||
didReceiveAttrs() { | ||
this._super(arguments); | ||
this.getReplicationModeStatus.perform(); | ||
}, | ||
getReplicationModeStatus: task(function*() { | ||
let resp; | ||
const { replicationMode } = this.model; | ||
try { | ||
resp = yield this.get('store') | ||
.adapterFor('replication-mode') | ||
.fetchStatus(replicationMode); | ||
} catch (e) { | ||
console.log(e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to set some sort of error on the page if we aren't able to get the status? Or is that even a realistic scenario? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great question! i think we should be fine in this scenario because if we can't find the reindexing status we just wouldn't show the reindexing alert at the top of the page. the only reason i could see us getting an API error here is if the replication mode wasn't set, but i don't think that should ever happen 'cause these components are only used on pages where replication is already enabled & thus the mode is set. :) |
||
} | ||
this.set('reindexingDetails', resp); | ||
}), | ||
|
||
replicationMode: computed('model.{replicationMode}', function() { | ||
// dr or performance 🤯 | ||
let mode = this.model.replicationMode; | ||
|
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: these two lines can be combined like:
const { reindex_building_progress, reindex_building_total } = this.replicationDetails;