mirror of https://gitee.com/bigwinds/arangodb
added minReplicationFactor to the user interface, preparation for the collection api changes
This commit is contained in:
parent
771a85a29c
commit
e8c7f08207
|
@ -176,15 +176,23 @@
|
|||
data.distributeShardsLike = object.distributeShardsLike;
|
||||
}
|
||||
|
||||
var pattern = new RegExp(/^[0-9]+$/);
|
||||
if (object.replicationFactor) {
|
||||
data.replicationFactor = object.replicationFactor;
|
||||
var pattern = new RegExp(/^[0-9]+$/);
|
||||
if (pattern.test(object.replicationFactor)) {
|
||||
// looks like a number
|
||||
data.replicationFactor = JSON.parse(object.replicationFactor);
|
||||
}
|
||||
}
|
||||
|
||||
if (object.minReplicationFactor) {
|
||||
data.minReplicationFactor = object.minReplicationFactor;
|
||||
if (pattern.test(object.minReplicationFactor)) {
|
||||
// looks like a number
|
||||
data.minReplicationFactor = JSON.parse(object.minReplicationFactor);
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: 'POST',
|
||||
|
|
|
@ -247,7 +247,7 @@
|
|||
});
|
||||
},
|
||||
|
||||
changeCollection: function (wfs, journalSize, indexBuckets, replicationFactor, callback) {
|
||||
changeCollection: function (wfs, journalSize, indexBuckets, replicationFactor, minReplicationFactor, callback) {
|
||||
var result = false;
|
||||
if (wfs === 'true') {
|
||||
wfs = true;
|
||||
|
@ -263,6 +263,9 @@
|
|||
if (replicationFactor) {
|
||||
data.replicationFactor = parseInt(replicationFactor, 10);
|
||||
}
|
||||
if (minReplicationFactor) {
|
||||
data.minReplicationFactor = parseInt(minReplicationFactor, 10);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
|
|
@ -351,6 +351,7 @@
|
|||
var collName = $('#new-collection-name').val();
|
||||
var collSize = $('#new-collection-size').val();
|
||||
var replicationFactor = $('#new-replication-factor').val();
|
||||
var minReplicationFactor = $('#new-min-replication-factor').val();
|
||||
var collType = $('#new-collection-type').val();
|
||||
var collSync = $('#new-collection-sync').val();
|
||||
var shards = 1;
|
||||
|
@ -361,6 +362,9 @@
|
|||
if (replicationFactor === '') {
|
||||
replicationFactor = 1;
|
||||
}
|
||||
if (minReplicationFactor === '') {
|
||||
minReplicationFactor = 1;
|
||||
}
|
||||
if ($('#is-satellite-collection').val() === 'true') {
|
||||
replicationFactor = 'satellite';
|
||||
}
|
||||
|
@ -426,11 +430,22 @@
|
|||
}
|
||||
}.bind(this);
|
||||
|
||||
var abort = false;
|
||||
try {
|
||||
if (Number.parseInt(minReplicationFactor) > Number.parseInt(replicationFactor)) {
|
||||
// validation here, as our Joi integration misses some core features
|
||||
arangoHelper.arangoError("New Collection", "Minimal replication factor is not allowed to be greater then replication factor");
|
||||
abort = true;
|
||||
}
|
||||
} catch (ignore) {
|
||||
}
|
||||
|
||||
var tmpObj = {
|
||||
collName: collName,
|
||||
wfs: wfs,
|
||||
isSystem: isSystem,
|
||||
replicationFactor: replicationFactor,
|
||||
minReplicationFactor: minReplicationFactor,
|
||||
collType: collType,
|
||||
shards: shards,
|
||||
shardKeys: shardKeys
|
||||
|
@ -444,9 +459,11 @@
|
|||
if (distributeShardsLike !== '') {
|
||||
tmpObj.distributeShardsLike = distributeShardsLike;
|
||||
}
|
||||
this.collection.newCollection(tmpObj, callback);
|
||||
window.modalView.hide();
|
||||
arangoHelper.arangoNotification('Collection', 'Collection "' + collName + '" will be created.');
|
||||
if (!abort) {
|
||||
this.collection.newCollection(tmpObj, callback);
|
||||
window.modalView.hide();
|
||||
arangoHelper.arangoNotification('Collection', 'Collection "' + collName + '" will be created.');
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
|
@ -580,6 +597,24 @@
|
|||
]
|
||||
)
|
||||
);
|
||||
advancedTableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
'new-min-replication-factor',
|
||||
'Mininum replication factor',
|
||||
'',
|
||||
'Numeric value. Must be at least 1 and must be smaller or equal compared to the replicationFactor. Minimal number of copies of the data in the cluster.',
|
||||
'',
|
||||
false,
|
||||
[
|
||||
{
|
||||
rule: Joi.string().allow('').optional().regex(/^[1-9]*$/),
|
||||
msg: 'Must be a number. Must be at least 1 and has to be smaller or equal compared to the replicationFactor.'
|
||||
}
|
||||
// TODO: Due our validation mechanism, no reference to replicationFactor is possible here.
|
||||
// So we cannot easily verify if minReplication > replicationFactor...
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
if (self.engine.name !== 'rocksdb') {
|
||||
advancedTableContent.push(
|
||||
|
@ -633,10 +668,13 @@
|
|||
$('#is-satellite-collection').on('change', function (element) {
|
||||
if ($('#is-satellite-collection').val() === 'true') {
|
||||
$('#new-replication-factor').prop('disabled', true);
|
||||
$('#new-min-replication-factor').prop('disabled', true);
|
||||
} else {
|
||||
$('#new-replication-factor').prop('disabled', false);
|
||||
$('#new-min-replication-factor').prop('disabled', false);
|
||||
}
|
||||
$('#new-replication-factor').val('').focus().focusout();
|
||||
$('#new-min-replication-factor').val('').focus().focusout();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,15 +157,29 @@
|
|||
};
|
||||
|
||||
var callbackRename = function (error) {
|
||||
var abort = false;
|
||||
if (error) {
|
||||
arangoHelper.arangoError('Collection error: ' + error.responseText);
|
||||
} else {
|
||||
var wfs = $('#change-collection-sync').val();
|
||||
var replicationFactor;
|
||||
var minReplicationFactor;
|
||||
|
||||
if (frontendConfig.isCluster) {
|
||||
replicationFactor = $('#change-replication-factor').val();
|
||||
minReplicationFactor = $('#change-min-replication-factor').val();
|
||||
try {
|
||||
if (Number.parseInt(minReplicationFactor) > Number.parseInt(replicationFactor)) {
|
||||
// validation here, as our Joi integration misses some core features
|
||||
arangoHelper.arangoError("Change Collection", "Minimal replication factor is not allowed to be greater then replication factor");
|
||||
abort = true;
|
||||
}
|
||||
} catch (ignore) {
|
||||
}
|
||||
}
|
||||
if (!abort) {
|
||||
this.model.changeCollection(wfs, journalSize, indexBuckets, replicationFactor, minReplicationFactor, callbackChange);
|
||||
}
|
||||
this.model.changeCollection(wfs, journalSize, indexBuckets, replicationFactor, callbackChange);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
|
@ -412,6 +426,16 @@
|
|||
true
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createReadOnlyEntry(
|
||||
'change-min-replication-factor',
|
||||
'Minimal replication factor',
|
||||
data.minReplicationFactor,
|
||||
'This collection is a satellite collection. The minReplicationFactor is not changeable.',
|
||||
'',
|
||||
true
|
||||
)
|
||||
);
|
||||
} else {
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
|
@ -429,6 +453,22 @@
|
|||
]
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
'change-min-replication-factor',
|
||||
'Minimal Replication factor',
|
||||
data.minReplicationFactor,
|
||||
'Numeric value. Must be at least 1 and must be smaller or equal compared to the replicationFactor. Minimal number of copies of the data in the cluster.',
|
||||
'',
|
||||
true,
|
||||
[
|
||||
{
|
||||
rule: Joi.string().allow('').optional().regex(/^[1-9]*$/),
|
||||
msg: 'Must be a number. Must be at least 1 and has to be smaller or equal compared to the replicationFactor.'
|
||||
}
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue