1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB

This commit is contained in:
Frank Celler 2012-05-25 15:40:00 +02:00
commit 426bbb307c
10 changed files with 174 additions and 60 deletions

View File

@ -58,12 +58,14 @@ namespace triagens {
int port,
double requestTimeout,
double connectTimeout,
size_t connectRetries) :
size_t connectRetries,
bool warn = true) :
_hostname(hostname),
_port(port),
_requestTimeout(requestTimeout),
_connectTimeout(connectTimeout),
_connectRetries(connectRetries),
_warn(warn),
_writeBuffer(TRI_UNKNOWN_MEM_ZONE),
_readBuffer(TRI_UNKNOWN_MEM_ZONE) {
@ -129,7 +131,9 @@ namespace triagens {
}
if (isWorking() && _errorMessage=="" ) {
LOGGER_ERROR << "Request timeout reached.";
if (_warn) {
LOGGER_WARNING << "Request timeout reached.";
}
_errorMessage = "Request timeout reached.";
}
@ -153,14 +157,15 @@ namespace triagens {
_numConnectRetries++;
}
else {
LOGGER_ERROR << "Could not connect to '" << _hostname << ":" << _port << "'! Connection is dead";
if (_warn) {
LOGGER_WARNING << "Could not connect to '" << _hostname << ":" << _port << "'! Connection is dead";
}
_state = DEAD;
return;
}
if (_hostname == "" || _port == 0) {
_errorMessage = "Could not connect to '" + _hostname + ":" + StringUtils::itoa(_port) + "'";
LOGGER_ERROR << "Could not connect to '" << _hostname << ":" << _port << "'! Connection is dead";
_state = DEAD;
return;
}

View File

@ -90,7 +90,8 @@ namespace triagens {
int port,
double requestTimeout,
double connectTimeout,
size_t connectRetries);
size_t connectRetries,
bool warn);
////////////////////////////////////////////////////////////////////////////////
/// @brief destructs a http client
@ -302,6 +303,7 @@ namespace triagens {
double _requestTimeout;
double _connectTimeout;
size_t _connectRetries;
bool _warn;
socket_t _socket;

View File

@ -66,12 +66,13 @@ namespace triagens {
int port,
double requestTimeout,
size_t retries,
double connectionTimeout) : _client(0), _httpResult(0) {
double connectionTimeout,
bool warn) : _client(0), _httpResult(0) {
_connected = false;
_lastHttpReturnCode = 0;
_lastErrorMessage = "";
_client = new SimpleHttpClient(hostname, port, requestTimeout, retries, connectionTimeout);
_client = new SimpleHttpClient(hostname, port, requestTimeout, retries, connectionTimeout, warn);
// connect to server and get version number
map<string, string> headerFields;

View File

@ -81,7 +81,8 @@ namespace triagens {
int port,
double requestTimeout,
size_t retries,
double connectionTimeout);
double connectionTimeout,
bool warn);
////////////////////////////////////////////////////////////////////////////////
/// @brief destructor

View File

@ -64,9 +64,9 @@ using namespace triagens::v8client;
static string DEFAULT_SERVER_NAME = "localhost";
static int DEFAULT_SERVER_PORT = 8529;
static double DEFAULT_REQUEST_TIMEOUT = 10.0;
static int64_t DEFAULT_REQUEST_TIMEOUT = 300;
static size_t DEFAULT_RETRIES = 5;
static double DEFAULT_CONNECTION_TIMEOUT = 1.0;
static int64_t DEFAULT_CONNECTION_TIMEOUT = 5;
////////////////////////////////////////////////////////////////////////////////
/// @brief server address
@ -86,6 +86,18 @@ V8ClientConnection* clientConnection = 0;
static uint64_t maxUploadSize = 500000;
////////////////////////////////////////////////////////////////////////////////
/// @brief connect timeout (in s)
////////////////////////////////////////////////////////////////////////////////
static int64_t connectTimeout = DEFAULT_CONNECTION_TIMEOUT;
////////////////////////////////////////////////////////////////////////////////
/// @brief request timeout (in s)
////////////////////////////////////////////////////////////////////////////////
static int64_t requestTimeout = DEFAULT_REQUEST_TIMEOUT;
static string QuoteChar = "\"";
static string SeparatorChar = ",";
static string FileName = "";
@ -164,6 +176,8 @@ static void ParseProgramOptions (int argc, char* argv[]) {
("quote", &QuoteChar, "quote character")
("separator", &SeparatorChar, "separator character")
("max-upload-size", &maxUploadSize, "maximum size of import chunks")
("connect-timeout", &connectTimeout, "connect timeout in seconds")
("request-timeout", &requestTimeout, "request timeout in seconds")
;
vector<string> myargs;
@ -218,6 +232,17 @@ int main (int argc, char* argv[]) {
// parse the program options
ParseProgramOptions(argc, argv);
// check connection args
if (connectTimeout <= 0) {
cout << "invalid value for connect-timeout." << endl;
return EXIT_FAILURE;
}
if (requestTimeout <= 0) {
cout << "invalid value for request-timeout." << endl;
return EXIT_FAILURE;
}
// processComandLineArguments(argc, argv);
if (! splitServerAdress(ServerAddress, DEFAULT_SERVER_NAME, DEFAULT_SERVER_PORT)) {
if (ServerAddress.length()) {
@ -228,10 +253,11 @@ int main (int argc, char* argv[]) {
clientConnection = new V8ClientConnection(
DEFAULT_SERVER_NAME,
DEFAULT_SERVER_PORT,
DEFAULT_REQUEST_TIMEOUT,
(double) requestTimeout,
DEFAULT_RETRIES,
DEFAULT_CONNECTION_TIMEOUT);
(double) connectTimeout,
true);
if (clientConnection->isConnected()) {
printf("Connected to Arango DB %s:%d Version %s\n",
clientConnection->getHostname().c_str(),
@ -239,12 +265,14 @@ int main (int argc, char* argv[]) {
clientConnection->getVersion().c_str());
cout << "----------------------------------------" << endl;
cout << "collection : " << CollectionName << endl;
cout << "create : " << (CreateCollection ? "yes" : "no") << endl;
cout << "file : " << FileName << endl;
cout << "type : " << TypeImport << endl;
cout << "quote : " << QuoteChar << endl;
cout << "separator : " << SeparatorChar << endl;
cout << "collection : " << CollectionName << endl;
cout << "create : " << (CreateCollection ? "yes" : "no") << endl;
cout << "file : " << FileName << endl;
cout << "type : " << TypeImport << endl;
cout << "quote : " << QuoteChar << endl;
cout << "separator : " << SeparatorChar << endl;
cout << "connect timeout : " << connectTimeout << endl;
cout << "request timeout : " << requestTimeout << endl;
cout << "----------------------------------------" << endl;
ImportHelper ih(clientConnection->getHttpClient(), maxUploadSize);
@ -257,7 +285,7 @@ int main (int argc, char* argv[]) {
ih.setQuote(QuoteChar[0]);
}
else {
cout << "Wrong lenght of quote character." << endl;
cout << "Wrong length of quote character." << endl;
return EXIT_FAILURE;
}
@ -265,7 +293,7 @@ int main (int argc, char* argv[]) {
ih.setSeparator(SeparatorChar[0]);
}
else {
cout << "Wrong lenght of separator character." << endl;
cout << "Wrong length of separator character." << endl;
return EXIT_FAILURE;
}

View File

@ -83,9 +83,9 @@ using namespace triagens::arango;
static string DEFAULT_SERVER_NAME = "localhost";
static int DEFAULT_SERVER_PORT = 8529;
static double DEFAULT_REQUEST_TIMEOUT = 10.0;
static int64_t DEFAULT_REQUEST_TIMEOUT = 300;
static size_t DEFAULT_RETRIES = 5;
static double DEFAULT_CONNECTION_TIMEOUT = 1.0;
static int64_t DEFAULT_CONNECTION_TIMEOUT = 5;
////////////////////////////////////////////////////////////////////////////////
/// @brief quite start
@ -189,6 +189,18 @@ regex_t intRegex;
static uint64_t maxUploadSize = 500000;
////////////////////////////////////////////////////////////////////////////////
/// @brief connect timeout (in s)
////////////////////////////////////////////////////////////////////////////////
static int64_t connectTimeout = DEFAULT_CONNECTION_TIMEOUT;
////////////////////////////////////////////////////////////////////////////////
/// @brief request timeout (in s)
////////////////////////////////////////////////////////////////////////////////
static int64_t requestTimeout = DEFAULT_REQUEST_TIMEOUT;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
@ -534,6 +546,8 @@ static void ParseProgramOptions (int argc, char* argv[]) {
("pretty-print", "pretty print values")
("no-colors", "deactivate color support")
("no-auto-complete", "disable auto completion")
("connect-timeout", &connectTimeout, "connect timeout in seconds")
("request-timeout", &requestTimeout, "request timeout in seconds")
("unit-tests", &UnitTests, "do not start as shell, run unit tests instead")
("max-upload-size", &maxUploadSize, "maximum size of import chunks")
(hidden, true)
@ -649,10 +663,8 @@ static v8::Handle<v8::Value> ClientConnection_ConstructorCallback (v8::Arguments
string server = DEFAULT_SERVER_NAME;
int port = DEFAULT_SERVER_PORT;
double requestTimeout = DEFAULT_REQUEST_TIMEOUT;
size_t retries = DEFAULT_RETRIES;
double connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
if (argv.Length() > 0 && argv[0]->IsString()) {
string definition = TRI_ObjectToString(argv[0]);
@ -663,7 +675,7 @@ static v8::Handle<v8::Value> ClientConnection_ConstructorCallback (v8::Arguments
}
V8ClientConnection* connection = new V8ClientConnection(server, port, requestTimeout, retries, connectionTimeout);
V8ClientConnection* connection = new V8ClientConnection(server, port, (double) requestTimeout, retries, (double) connectTimeout, false);
if (connection->isConnected()) {
printf("Connected to Arango DB %s:%d Version %s\n",
@ -1153,6 +1165,17 @@ int main (int argc, char* argv[]) {
// parse the program options
ParseProgramOptions(argc, argv);
// check connection args
if (connectTimeout <= 0) {
cout << "invalid value for connect-timeout." << endl;
return EXIT_FAILURE;
}
if (requestTimeout <= 0) {
cout << "invalid value for request-timeout." << endl;
return EXIT_FAILURE;
}
v8::HandleScope handle_scope;
@ -1193,9 +1216,10 @@ int main (int argc, char* argv[]) {
clientConnection = new V8ClientConnection(
DEFAULT_SERVER_NAME,
DEFAULT_SERVER_PORT,
DEFAULT_REQUEST_TIMEOUT,
(double) requestTimeout,
DEFAULT_RETRIES,
DEFAULT_CONNECTION_TIMEOUT);
(double) connectTimeout,
false);
}
// .............................................................................

View File

@ -15,6 +15,10 @@ table.dataTable thead th {
*cursor: hand;
}
#subCenterView table.dataTable thead th {
cursor: default !important;
}
table.dataTable tfoot th {
padding: 3px 10px;
}

View File

@ -7,8 +7,8 @@
}
.writeable {
width: 100%;
word-wrap: break-word;
width:auto !important;
}
#delete {
@ -346,6 +346,13 @@ form {
float:right;
}
#formatshellJSONyesno {
float:right;
padding-right:10px;
margin-top: -3px;
color: #797979;
}
#formatJSONyesno {
margin-top: -40px;
float:right;
@ -654,7 +661,7 @@ form {
line-height: 1;
text-align: center;
text-shadow: 0 1px 0 #fff;
width: 80px;
width: 90px;
}
#menue button.minimal:hover {
background: #d9d9d9;

View File

@ -1,7 +1,7 @@
<html>
<head>
<title>WebAdmin</title>
<title>ArangoDB - WebAdmin</title>
<style type="text/css" title="screen">
@import "css/layout.css";
@import "css/jquery.snippet.css";
@ -161,8 +161,8 @@
</button>
<form id="uploadFile" action="/_api/import/?collection=...&createCollection=false" method=POST enctype="multipart/form-data">
<input type="submit" value="Import" />
<input type="file" name="filename" />
<input id="uploadFileImport" type="submit" value="Import" />
<input id="uploadFileSearch" type="file" name="filename" />
</form>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="documentsTableID" width="100%">
@ -397,6 +397,11 @@
<input type="text" class="editBox" id="avocshContent"></input><button class="minimal" id="submitAvoc">Ok</button>
</form>
<button class="minimal" id="refreshShell">Refresh</button>
<form action="#" id="formatshellJSONyesno">
Format JSON?
<input type="radio" name="formatshellJSONyesno" value=true checked>yes</input>
<input type="radio" name="formatshellJSONyesno" value=false>no</input>
</form>
<a href="http://www.arangodb.org/manuals/UserManual.html" target="_blank">ArangoDB Shell - click for more information</a>
</div>
@ -410,12 +415,11 @@
<a id="aqlinfo" href="http://www.arangodb.org/manuals/Aql.html" target="_blank">ArangoDB Query Language - click for more information</a>
<br></br>
</form>
<form action="#" id="formatJSONyesno">
Format JSON?
<input type="radio" name="formatJSONyesno" value=true checked>yes</input>
<input type="radio" name="formatJSONyesno" value=false>no</input>
</form>
<form action="#" id="formatJSONyesno">
Format JSON?
<input type="radio" name="formatJSONyesno" value=true checked>yes</input>
<input type="radio" name="formatJSONyesno" value=false>no</input>
</form>
</div>
</div>

View File

@ -12,6 +12,7 @@ var welcomeMSG = ""
+ " \n"
+ "Welcome to arangosh 0.5.1. Copyright (c) 2012 triAGENS GmbH."
// documents global vars
var collectionCount;
var totalCollectionCount;
@ -23,10 +24,16 @@ var checkCollectionName;
var printedHelp = false;
var open = false;
var rowCounter = 0;
var shArray = [];
$(document).ready(function() {
showCursor();
//hide incomplete functions
$("#uploadFile").attr("disabled", "disabled");
$("#uploadFileImport").attr("disabled", "disabled");
$("#uploadFileSearch").attr("disabled", "disabled");
///////////////////////////////////////////////////////////////////////////////
/// global variables
///////////////////////////////////////////////////////////////////////////////
@ -160,7 +167,7 @@ var collectionTable = $('#collectionsTableID').dataTable({
"bAutoWidth": false,
"iDisplayLength": -1,
"bJQueryUI": true,
"aoColumns": [{"sWidth":"120px", "bSortable":false}, {"sWidth": "200px"}, {"sWidth": "200px"}, {"sWidth": "200px"}, {"sWidth": "200px"}, null ],
"aoColumns": [{"sWidth":"150px", "bSortable":false}, {"sWidth": "200px"}, {"sWidth": "200px"}, null, {"sWidth": "200px"}, {"sWidth": "200px"} ],
"aoColumnDefs": [{ "sClass": "alignRight", "aTargets": [ 4, 5 ] }],
"oLanguage": {"sEmptyTable": "No collections"}
});
@ -176,12 +183,11 @@ var documentEditTable = $('#documentEditTableID').dataTable({
"bSortable": false,
"bLengthChange": false,
"bDeferRender": true,
"bAutoWidth": true,
"iDisplayLength": -1,
"bJQueryUI": true,
"aoColumns": [{ "sClass":"center", "sClass":"read_only","bSortable": false, "sWidth": "30px"},
{"sClass":"writeable", "bSortable": false, "sWidth":"250px" },
{"sClass":"writeable", "bSortable": false },
{"sClass":"writeable", "bSortable": false, "sWidth":"300px" },
{"sClass":"writeable", "bSortable": false},
{"bVisible": false } ],
"oLanguage": {"sEmptyTable": "No documents"}
});
@ -218,7 +224,7 @@ var documentsTable = $('#documentsTableID').dataTable({
"bAutoWidth": true,
"iDisplayLength": -1,
"bJQueryUI": true,
"aoColumns": [{ "sClass":"center", "sClass":"read_only","bSortable": false, "sWidth": "70px"},
"aoColumns": [{ "sClass":"read_only","bSortable": false, "sWidth": "80px"},
{"sClass":"read_only","bSortable": false, "sWidth": "125px"},
{"sClass":"read_only","bSortable": false, "sWidth": "60px"},
{"bSortable": false}],
@ -344,6 +350,7 @@ var logTable = $('#logTableID').dataTable({
///////////////////////////////////////////////////////////////////////////////
else if (location.hash.substr(0, 12) == "#collection?" ) {
$("#addNewDocButton").removeAttr("disabled");
tableView = true;
$('#toggleNewDocButtonText').text('Edit Source');
@ -386,6 +393,7 @@ var logTable = $('#logTableID').dataTable({
else if (location.hash.substr(0, 14) == "#editDocument?") {
tableView = true;
$("#addEditedDocRowButton").removeAttr("disabled");
$('#toggleEditedDocButton').val('Edit Source');
$('#documentEditSourceView').hide();
@ -716,9 +724,13 @@ var logTable = $('#logTableID').dataTable({
createnav ("ArangoDB Shell");
$('#avocshContent').focus();
if (printedHelp === false) {
print(welcomeMSG + HELP);
print(welcomeMSG + require("arangosh").HELP);
printedHelp = true;
start_pretty_print();
}
$("#avocshContent").autocomplete({
source: shArray
});
}
///////////////////////////////////////////////////////////////////////////////
@ -805,7 +817,6 @@ var logTable = $('#logTableID').dataTable({
});
}
catch(e) {
console.log(e);
alert("Please make sure the entered value is a valid json string.");
}
}
@ -903,7 +914,6 @@ var logTable = $('#logTableID').dataTable({
});
}
catch(e) {
console.log(e);
alert("Please make sure the entered value is a valid json string.");
}
}
@ -949,6 +959,7 @@ var logTable = $('#logTableID').dataTable({
$('#documentEditSourceView').toggle();
tableView = false;
$('#toggleEditedDocButtonText').text('Edit Table');
$("#addEditedDocRowButton").attr("disabled", "disabled");
}
else {
try {
@ -968,10 +979,10 @@ var logTable = $('#logTableID').dataTable({
$('#documentEditSourceView').toggle();
tableView = true;
$('#toggleEditedDocButtonText').text('Edit Source');
$("#addEditedDocRowButton").removeAttr("disabled");
}
catch(e) {
console.log(e);
alert("Please make sure the entered value is a valid json string.");
}
@ -1072,6 +1083,7 @@ var logTable = $('#logTableID').dataTable({
$('#NewDocumentSourceView').toggle();
tableView = false;
$('#toggleNewDocButtonText').text('Edit Table');
$("#addNewDocButton").attr("disabled", "disabled");
}
catch(e) {
@ -1097,8 +1109,8 @@ var logTable = $('#logTableID').dataTable({
$('#NewDocumentTableView').toggle();
$('#NewDocumentSourceView').toggle();
tableView = true;
var img = $(this).find('img');
img.attr('src', '/_admin/html/media/icons/off_icon16.png');
$('#toggleNewDocButtonText').text('Edit Source');
$("#addNewDocButton").removeAttr("disabled");
}
catch(e) {
@ -1185,10 +1197,29 @@ var logTable = $('#logTableID').dataTable({
///////////////////////////////////////////////////////////////////////////////
/// submit avocsh content
///////////////////////////////////////////////////////////////////////////////
var lastFormatQuestion = true;
$('#submitAvoc').live('click', function () {
var data = $('#avocshContent').val();
var r = [ ];
for (var i = 0; i < shArray.length; ++i) {
if (shArray[i] != data) {
r.push(shArray[i]);
}
}
shArray = r;
if (shArray.length > 4) {
shArray.shift();
}
shArray.push(data);
$("#avocshContent").autocomplete({
source: shArray
});
if (data == "help") {
data = "help()";
}
@ -1196,8 +1227,19 @@ var logTable = $('#logTableID').dataTable({
location.reload();
return false;
}
formatQuestion = JSON.parse($('input:radio[name=formatshellJSONyesno]:checked').val());
if (formatQuestion != lastFormatQuestion) {
if (formatQuestion == true) {
start_pretty_print();
lastFormatQuestion = true;
}
if (formatQuestion == false) {
stop_pretty_print();
lastFormatQuestion = false;
}
}
var client = "arangosh> " + escapeHTML(data) + "<br>";
$('#avocshWindow').append('<b class="avocshClient">' + client + '</b>');
evaloutput(data);
@ -1206,8 +1248,6 @@ var logTable = $('#logTableID').dataTable({
return false;
});
$('#refreshShell').live('click', function () {
location.reload();
return false;
@ -1217,8 +1257,8 @@ var logTable = $('#logTableID').dataTable({
///////////////////////////////////////////////////////////////////////////////
$('#submitQuery').live('click', function () {
var data = {query:$('#queryContent').val()};
var formattedJSON;
var data = {query:$('#queryContent').val()};
var formattedJSON;
$.ajax({
type: "POST",
url: "/_api/cursor",
@ -1237,7 +1277,6 @@ var logTable = $('#logTableID').dataTable({
}
},
error: function(data) {
console.log(data);
var temp = JSON.parse(data.responseText);
$("#queryOutput").empty();
$("#queryOutput").append('<a class="queryError"><font color=red>[' + temp.errorNum + '] ' + temp.errorMessage + '</font></a>');
@ -1948,8 +1987,8 @@ function showCursor() {
}
function cutByResolution (string) {
if (string.length > 150) {
return escaped(string.substr(0, 150)) + '...';
if (string.length > 100) {
return escaped(string.substr(0, 100)) + '...';
}
return escaped(string);
}
@ -2237,7 +2276,6 @@ $('#submitDocPageInput').live('click', function () {
}
else {
console.log("out of reach");
return false;
}
}