mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into sparse-indexes
This commit is contained in:
commit
b377a36577
|
@ -796,6 +796,128 @@
|
|||
|
||||
}());
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- Commandline argument handling
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Structured to flat commandline arguments
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function toArgv(structure) {
|
||||
"use strict";
|
||||
var vec = [];
|
||||
for (var key in structure) {
|
||||
if (structure.hasOwnProperty(key)) {
|
||||
if (key === 'commandSwitches') {
|
||||
var multivec="";
|
||||
for (var i = 0; i < structure[key].length; i ++) {
|
||||
if (structure[key][i].length > 1) {
|
||||
vec.push(structure[key][i]);
|
||||
}
|
||||
else {
|
||||
multivec += structure[key][i];
|
||||
}
|
||||
}
|
||||
if (multivec.length > 0) {
|
||||
vec.push(multivec);
|
||||
}
|
||||
}
|
||||
else if (key === 'flatCommands') {
|
||||
vec = vec.concat(structure[key]);
|
||||
}
|
||||
else {
|
||||
vec.push('--' + key);
|
||||
vec.push(structure[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief arv to Structured
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function parseArvg(argv, startOffset) {
|
||||
"use strict";
|
||||
|
||||
function setOption(ret, option, value) {
|
||||
if (option.indexOf(':') > 0) {
|
||||
var n = option.indexOf(':');
|
||||
var topOption = option.slice(0, n);
|
||||
if (!ret.hasOwnProperty(topOption)) {
|
||||
ret.topOption = {};
|
||||
}
|
||||
setOption(ret.topOption, option.slice(n, option.length), value);
|
||||
}
|
||||
else if (argv[i+1] === 'true') {
|
||||
ret[option] = true;
|
||||
}
|
||||
else if (argv[i+1] === 'false') {
|
||||
ret[option] = false;
|
||||
}
|
||||
else if (!isNaN(argv[i+1])) {
|
||||
ret[option] = parseInt(argv[i+1]);
|
||||
}
|
||||
else {
|
||||
ret[option] = argv[i+1];
|
||||
}
|
||||
}
|
||||
function setSwitch(ret, option) {
|
||||
if (!ret.hasOwnProperty('commandSwitches')) {
|
||||
ret.commandSwitches = [];
|
||||
}
|
||||
ret.commandSwitches.push(option);
|
||||
}
|
||||
|
||||
function setSwitchVec(ret, option) {
|
||||
for (var i = 0; i < option.length; i ++ ) {
|
||||
setSwitch(ret, option[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function setFlatCommand(ret, thisString) {
|
||||
if (!ret.hasOwnProperty('flatCommands')) {
|
||||
ret.flatCommands = [];
|
||||
}
|
||||
ret.flatCommands.push(thisString);
|
||||
}
|
||||
|
||||
var inFlat = false;
|
||||
var ret = {};
|
||||
for (var i = startOffset; i < argv.length; i++) {
|
||||
var thisString = argv[i];
|
||||
if (!inFlat) {
|
||||
if ((thisString.length > 2) &&
|
||||
(thisString.slice(0,2) === '--')) {
|
||||
var option = thisString.slice(2, thisString.length);
|
||||
if ((argv.length > i) &&
|
||||
(argv[i+1].slice(0,1) !== '-')) {
|
||||
setOption(ret, option, argv[i+1]);
|
||||
i ++;
|
||||
}
|
||||
else {
|
||||
setSwitch(ret, option);
|
||||
}
|
||||
}
|
||||
else if (thisString === '--') {
|
||||
inFlat = true;
|
||||
}
|
||||
else if ((thisString.length > 1) &&
|
||||
(thisString.slice(0, 1) === '-')) {
|
||||
setSwitchVec(ret, thisString.slice(1, thisString.length));
|
||||
}
|
||||
else {
|
||||
setFlatCommand(ret, thisString);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setFlatCommand(ret, thisString);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- PRINTING
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -234,27 +234,27 @@ launchActions.startAgent = function (dispatchers, cmd, isRelaunch) {
|
|||
var clusterUrl = "http://" + clusterBind;
|
||||
var agencyUrl = "http://" + extBind;
|
||||
|
||||
var args = ["--data-dir", agentDataDir,
|
||||
"--name", instanceName,
|
||||
"--bind-addr", extBind,
|
||||
"--addr", extEndpoint,
|
||||
"--peer-bind-addr", clusterBind,
|
||||
"--peer-addr", clusterEndPoint,
|
||||
"--initial-cluster-state", "new",
|
||||
"--initial-cluster", instanceName + "=" + clusterUrl
|
||||
// the following might speed up etcd, but it might also
|
||||
// make it more unstable:
|
||||
// ,"-peer-heartbeat-timeout=10",
|
||||
// "-peer-election-timeout=20"
|
||||
];
|
||||
var args = {
|
||||
"data-dir": agentDataDir,
|
||||
"name": instanceName,
|
||||
"bind-addr": extBind,
|
||||
"addr": extEndpoint,
|
||||
"peer-bind-addr": clusterBind,
|
||||
"peer-addr": clusterEndPoint,
|
||||
"initial-cluster-state": "new",
|
||||
"initial-cluster": instanceName + "=" + clusterUrl
|
||||
// the following might speed up etcd, but it might also
|
||||
// make it more unstable:
|
||||
// ,"peer-heartbeat-timeout": "10",
|
||||
// "peer-election-timeout": "20"
|
||||
};
|
||||
var i;
|
||||
if (cmd.peers.length > 0) {
|
||||
args.push("-peers");
|
||||
var st = getAddrPort(cmd.peers[0]);
|
||||
for (i = 1; i < cmd.peers.length; i++) {
|
||||
st = st + "," + getAddrPort(cmd.peers[i]);
|
||||
}
|
||||
args.push(st);
|
||||
args.peers = st;
|
||||
}
|
||||
var agentPath = cmd.agentPath;
|
||||
if (agentPath === "") {
|
||||
|
@ -264,8 +264,7 @@ launchActions.startAgent = function (dispatchers, cmd, isRelaunch) {
|
|||
return {"error":true, "isStartAgent": true,
|
||||
"errorMessage": "agency binary not found at '" + agentPath + "'"};
|
||||
}
|
||||
|
||||
var pid = executeExternal(agentPath, args);
|
||||
var pid = executeExternal(agentPath, toArgv(args));
|
||||
var res;
|
||||
var count = 0;
|
||||
while (++count < 20) {
|
||||
|
@ -298,7 +297,7 @@ launchActions.sendConfiguration = function (dispatchers, cmd, isRelaunch) {
|
|||
if (res === true) {
|
||||
return {"error":false, "isSendConfiguration": true};
|
||||
}
|
||||
return {"error":true, "isSendConfiguration": true, "suberror": res};
|
||||
return {"error":true, "isSendConfiguration": true, "suberror": res, errorMessage : yaml.safeDump(res)};
|
||||
};
|
||||
|
||||
launchActions.startServers = function (dispatchers, cmd, isRelaunch) {
|
||||
|
|
|
@ -119,86 +119,7 @@ function resultsToXml(results, baseName) {
|
|||
}
|
||||
|
||||
|
||||
function parseArvg(argv, startOffset) {
|
||||
"use strict";
|
||||
|
||||
function setOption(ret, option, value) {
|
||||
if (option.indexOf(':') > 0) {
|
||||
var n = option.indexOf(':');
|
||||
topOption = option.slice(0, n);
|
||||
if (!ret.hasOwnProperty(topOption)) {
|
||||
ret.topOption = {};
|
||||
}
|
||||
setOption(ret.topOption, option.slice(n, options.length), value);
|
||||
}
|
||||
else if (argv[i+1] === 'true') {
|
||||
ret[option] = true;
|
||||
}
|
||||
else if (argv[i+1] === 'false') {
|
||||
ret[option] = false;
|
||||
}
|
||||
else if (!isNaN(argv[i+1])) {
|
||||
ret[option] = parseInt(argv[i+1]);
|
||||
}
|
||||
else {
|
||||
ret[option] = argv[i+1];
|
||||
}
|
||||
}
|
||||
function setSwitch(ret, option) {
|
||||
if (!ret.hasOwnProperty('commandSwitches')) {
|
||||
ret.commandSwitches = [];
|
||||
}
|
||||
ret.commandSwitches.pushBack(option);
|
||||
}
|
||||
|
||||
function setSwitchVec(ret, option) {
|
||||
for (var i = 0; i < option.length; i ++ ) {
|
||||
setSwitch(ret, option[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function setFlatCommand(ret, thisString) {
|
||||
if (!ret.hasOwnProperty('flatCommands')) {
|
||||
ret.flatCommands = [];
|
||||
}
|
||||
ret.flatCommands.pushBack(thisString);
|
||||
}
|
||||
|
||||
var inFlat = false;
|
||||
var ret = {};
|
||||
for (var i = startOffset; i < argv.length; i++) {
|
||||
var thisString = argv[i];
|
||||
if (!inFlat) {
|
||||
if ((thisString.length > 2) &&
|
||||
(thisString.slice(0,2) === '--')) {
|
||||
var option = thisString.slice(2, thisString.length);
|
||||
if ((argv.length > i) &&
|
||||
(argv[i+1].slice(0,1) !== '-')) {
|
||||
setOption(ret, option, argv[i+1]);
|
||||
i ++;
|
||||
}
|
||||
else {
|
||||
setSwitch(ret, option);
|
||||
}
|
||||
}
|
||||
else if (thisString === '--') {
|
||||
inFlat = true;
|
||||
}
|
||||
else if ((thisString.length > 1) &&
|
||||
(thisString.slice(0, 1) === '-')) {
|
||||
setSwitchVec(ret, thisString.slice(1, thisString.length));
|
||||
}
|
||||
else {
|
||||
setFlatCommand(ret, thisString);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setFlatCommand(ret, thisString);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
function main (argv) {
|
||||
"use strict";
|
||||
|
@ -215,8 +136,8 @@ function main (argv) {
|
|||
}
|
||||
}
|
||||
catch (x) {
|
||||
print("failed to parse the json options");
|
||||
print(x);
|
||||
print("failed to parse the json options: " + x.message);
|
||||
rint(x.stack);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +145,7 @@ function main (argv) {
|
|||
start_pretty_print();
|
||||
|
||||
try {
|
||||
r = UnitTest.UnitTest(test,options);
|
||||
r = UnitTest.UnitTest(test,options);
|
||||
}
|
||||
catch (x) {
|
||||
print("Caught exception during test execution!");
|
||||
|
|
Loading…
Reference in New Issue