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;
|
data.distributeShardsLike = object.distributeShardsLike;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pattern = new RegExp(/^[0-9]+$/);
|
||||||
if (object.replicationFactor) {
|
if (object.replicationFactor) {
|
||||||
data.replicationFactor = object.replicationFactor;
|
data.replicationFactor = object.replicationFactor;
|
||||||
var pattern = new RegExp(/^[0-9]+$/);
|
|
||||||
if (pattern.test(object.replicationFactor)) {
|
if (pattern.test(object.replicationFactor)) {
|
||||||
// looks like a number
|
// looks like a number
|
||||||
data.replicationFactor = JSON.parse(object.replicationFactor);
|
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({
|
$.ajax({
|
||||||
cache: false,
|
cache: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
|
@ -247,7 +247,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
changeCollection: function (wfs, journalSize, indexBuckets, replicationFactor, callback) {
|
changeCollection: function (wfs, journalSize, indexBuckets, replicationFactor, minReplicationFactor, callback) {
|
||||||
var result = false;
|
var result = false;
|
||||||
if (wfs === 'true') {
|
if (wfs === 'true') {
|
||||||
wfs = true;
|
wfs = true;
|
||||||
|
@ -263,6 +263,9 @@
|
||||||
if (replicationFactor) {
|
if (replicationFactor) {
|
||||||
data.replicationFactor = parseInt(replicationFactor, 10);
|
data.replicationFactor = parseInt(replicationFactor, 10);
|
||||||
}
|
}
|
||||||
|
if (minReplicationFactor) {
|
||||||
|
data.minReplicationFactor = parseInt(minReplicationFactor, 10);
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache: false,
|
cache: false,
|
||||||
|
|
|
@ -351,6 +351,7 @@
|
||||||
var collName = $('#new-collection-name').val();
|
var collName = $('#new-collection-name').val();
|
||||||
var collSize = $('#new-collection-size').val();
|
var collSize = $('#new-collection-size').val();
|
||||||
var replicationFactor = $('#new-replication-factor').val();
|
var replicationFactor = $('#new-replication-factor').val();
|
||||||
|
var minReplicationFactor = $('#new-min-replication-factor').val();
|
||||||
var collType = $('#new-collection-type').val();
|
var collType = $('#new-collection-type').val();
|
||||||
var collSync = $('#new-collection-sync').val();
|
var collSync = $('#new-collection-sync').val();
|
||||||
var shards = 1;
|
var shards = 1;
|
||||||
|
@ -361,6 +362,9 @@
|
||||||
if (replicationFactor === '') {
|
if (replicationFactor === '') {
|
||||||
replicationFactor = 1;
|
replicationFactor = 1;
|
||||||
}
|
}
|
||||||
|
if (minReplicationFactor === '') {
|
||||||
|
minReplicationFactor = 1;
|
||||||
|
}
|
||||||
if ($('#is-satellite-collection').val() === 'true') {
|
if ($('#is-satellite-collection').val() === 'true') {
|
||||||
replicationFactor = 'satellite';
|
replicationFactor = 'satellite';
|
||||||
}
|
}
|
||||||
|
@ -426,11 +430,22 @@
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.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 = {
|
var tmpObj = {
|
||||||
collName: collName,
|
collName: collName,
|
||||||
wfs: wfs,
|
wfs: wfs,
|
||||||
isSystem: isSystem,
|
isSystem: isSystem,
|
||||||
replicationFactor: replicationFactor,
|
replicationFactor: replicationFactor,
|
||||||
|
minReplicationFactor: minReplicationFactor,
|
||||||
collType: collType,
|
collType: collType,
|
||||||
shards: shards,
|
shards: shards,
|
||||||
shardKeys: shardKeys
|
shardKeys: shardKeys
|
||||||
|
@ -444,9 +459,11 @@
|
||||||
if (distributeShardsLike !== '') {
|
if (distributeShardsLike !== '') {
|
||||||
tmpObj.distributeShardsLike = distributeShardsLike;
|
tmpObj.distributeShardsLike = distributeShardsLike;
|
||||||
}
|
}
|
||||||
this.collection.newCollection(tmpObj, callback);
|
if (!abort) {
|
||||||
window.modalView.hide();
|
this.collection.newCollection(tmpObj, callback);
|
||||||
arangoHelper.arangoNotification('Collection', 'Collection "' + collName + '" will be created.');
|
window.modalView.hide();
|
||||||
|
arangoHelper.arangoNotification('Collection', 'Collection "' + collName + '" will be created.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.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') {
|
if (self.engine.name !== 'rocksdb') {
|
||||||
advancedTableContent.push(
|
advancedTableContent.push(
|
||||||
|
@ -633,10 +668,13 @@
|
||||||
$('#is-satellite-collection').on('change', function (element) {
|
$('#is-satellite-collection').on('change', function (element) {
|
||||||
if ($('#is-satellite-collection').val() === 'true') {
|
if ($('#is-satellite-collection').val() === 'true') {
|
||||||
$('#new-replication-factor').prop('disabled', true);
|
$('#new-replication-factor').prop('disabled', true);
|
||||||
|
$('#new-min-replication-factor').prop('disabled', true);
|
||||||
} else {
|
} else {
|
||||||
$('#new-replication-factor').prop('disabled', false);
|
$('#new-replication-factor').prop('disabled', false);
|
||||||
|
$('#new-min-replication-factor').prop('disabled', false);
|
||||||
}
|
}
|
||||||
$('#new-replication-factor').val('').focus().focusout();
|
$('#new-replication-factor').val('').focus().focusout();
|
||||||
|
$('#new-min-replication-factor').val('').focus().focusout();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,15 +157,29 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var callbackRename = function (error) {
|
var callbackRename = function (error) {
|
||||||
|
var abort = false;
|
||||||
if (error) {
|
if (error) {
|
||||||
arangoHelper.arangoError('Collection error: ' + error.responseText);
|
arangoHelper.arangoError('Collection error: ' + error.responseText);
|
||||||
} else {
|
} else {
|
||||||
var wfs = $('#change-collection-sync').val();
|
var wfs = $('#change-collection-sync').val();
|
||||||
var replicationFactor;
|
var replicationFactor;
|
||||||
|
var minReplicationFactor;
|
||||||
|
|
||||||
if (frontendConfig.isCluster) {
|
if (frontendConfig.isCluster) {
|
||||||
replicationFactor = $('#change-replication-factor').val();
|
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);
|
}.bind(this);
|
||||||
|
|
||||||
|
@ -412,6 +426,16 @@
|
||||||
true
|
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 {
|
} else {
|
||||||
tableContent.push(
|
tableContent.push(
|
||||||
window.modalView.createTextEntry(
|
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