mirror of https://gitee.com/bigwinds/arangodb
issue #94: removed unfriendly log message
This commit is contained in:
parent
46ced25901
commit
ee9e7c7787
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -81,7 +81,8 @@ namespace triagens {
|
|||
int port,
|
||||
double requestTimeout,
|
||||
size_t retries,
|
||||
double connectionTimeout);
|
||||
double connectionTimeout,
|
||||
bool warn);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
|
|
|
@ -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 = 300;
|
||||
static int64_t DEFAULT_REQUEST_TIMEOUT = 300;
|
||||
static size_t DEFAULT_RETRIES = 5;
|
||||
static double DEFAULT_CONNECTION_TIMEOUT = 5;
|
||||
static int64_t DEFAULT_CONNECTION_TIMEOUT = 5;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief server address
|
||||
|
@ -255,7 +255,8 @@ int main (int argc, char* argv[]) {
|
|||
DEFAULT_SERVER_PORT,
|
||||
(double) requestTimeout,
|
||||
DEFAULT_RETRIES,
|
||||
(double) connectTimeout);
|
||||
(double) connectTimeout,
|
||||
true);
|
||||
|
||||
if (clientConnection->isConnected()) {
|
||||
printf("Connected to Arango DB %s:%d Version %s\n",
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
// .............................................................................
|
||||
|
|
Loading…
Reference in New Issue