本文整理汇总了C++中ArangoClient::createEndpoint方法的典型用法代码示例。如果您正苦于以下问题:C++ ArangoClient::createEndpoint方法的具体用法?C++ ArangoClient::createEndpoint怎么用?C++ ArangoClient::createEndpoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArangoClient
的用法示例。
在下文中一共展示了ArangoClient::createEndpoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char* argv[]) {
int ret = EXIT_SUCCESS;
arangodumpEntryFunction();
TRIAGENS_C_INITIALISE(argc, argv);
TRIAGENS_REST_INITIALISE(argc, argv);
TRI_InitialiseLogging(false);
// .............................................................................
// set defaults
// .............................................................................
int err = 0;
OutputDirectory = FileUtils::currentDirectory(&err).append(TRI_DIR_SEPARATOR_STR).append("dump");
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
// use a minimum value for batches
if (ChunkSize < 1024 * 128) {
ChunkSize = 1024 * 128;
}
if (TickStart < TickEnd) {
cerr << "invalid values for --tick-start or --tick-end" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// .............................................................................
// create output directory
// .............................................................................
bool isDirectory = false;
if (OutputDirectory != "") {
isDirectory = TRI_IsDirectory(OutputDirectory.c_str());
}
if (OutputDirectory == "" ||
(TRI_ExistsFile(OutputDirectory.c_str()) && ! isDirectory)) {
cerr << "cannot write to output directory '" << OutputDirectory << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
if (isDirectory && ! Overwrite) {
cerr << "output directory '" << OutputDirectory << "' already exists. use --overwrite to overwrite data in in it" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// .............................................................................
// set-up client connection
// .............................................................................
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == 0) {
cerr << "invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
Connection = GeneralClientConnection::factory(BaseClient.endpointServer(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
BaseClient.sslProtocol());
if (Connection == 0) {
cerr << "out of memory" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
Client = new SimpleHttpClient(Connection, BaseClient.requestTimeout(), false);
if (Client == 0) {
cerr << "out of memory" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
Client->setLocationRewriter(0, &rewriteLocation);
Client->setUserNamePassword("/", BaseClient.username(), BaseClient.password());
const string versionString = GetArangoVersion();
if (! Connection->isConnected()) {
cerr << "Could not connect to endpoint '" << BaseClient.endpointString()
<< "', database: '" << BaseClient.databaseName() << "', username: '" << BaseClient.username() << "'" << endl;
cerr << "Error message: '" << Client->getErrorMessage() << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// successfully connected
// validate server version
int major = 0;
int minor = 0;
//.........这里部分代码省略.........
示例2: main
int main (int argc, char* argv[]) {
int ret = EXIT_SUCCESS;
LocalEntryFunction();
TRIAGENS_C_INITIALIZE(argc, argv);
TRIAGENS_REST_INITIALIZE(argc, argv);
TRI_InitializeLogging(false);
// .............................................................................
// set defaults
// .............................................................................
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
// use a minimum value for batches
if (ChunkSize < 1024 * 128) {
ChunkSize = 1024 * 128;
}
if (! InputDirectory.empty() &&
InputDirectory.back() == TRI_DIR_SEPARATOR_CHAR) {
// trim trailing slash from path because it may cause problems on ... Windows
TRI_ASSERT(InputDirectory.size() > 0);
InputDirectory.pop_back();
}
// .............................................................................
// check input directory
// .............................................................................
if (InputDirectory == "" || ! TRI_IsDirectory(InputDirectory.c_str())) {
cerr << "Error: input directory '" << InputDirectory << "' does not exist" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
if (! ImportStructure && ! ImportData) {
cerr << "Error: must specify either --create-collection or --import-data" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
// .............................................................................
// set-up client connection
// .............................................................................
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == nullptr) {
cerr << "Error: invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
Connection = GeneralClientConnection::factory(BaseClient.endpointServer(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
BaseClient.sslProtocol());
Client = new SimpleHttpClient(Connection, BaseClient.requestTimeout(), false);
Client->setLocationRewriter(nullptr, &rewriteLocation);
Client->setUserNamePassword("/", BaseClient.username(), BaseClient.password());
string versionString = GetArangoVersion();
if (CreateDatabase && LastErrorCode == TRI_ERROR_ARANGO_DATABASE_NOT_FOUND) {
// database not found, but database creation requested
std::string old = BaseClient.databaseName();
cout << "Creating database '" << old << "'" << endl;
BaseClient.setDatabaseName("_system");
int res = TryCreateDatabase(old);
if (res != TRI_ERROR_NO_ERROR) {
cerr << "Could not create database '" << old << "'" << endl;
cerr << "Error message: '" << Client->getErrorMessage() << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
// restore old database name
BaseClient.setDatabaseName(old);
// re-fetch version
versionString = GetArangoVersion();
}
if (! Connection->isConnected()) {
cerr << "Could not connect to endpoint " << BaseClient.endpointServer()->getSpecification() << endl;
cerr << "Error message: '" << Client->getErrorMessage() << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr);
}
//.........这里部分代码省略.........
示例3: main
int main (int argc, char* argv[]) {
int ret = EXIT_SUCCESS;
arangorestoreEntryFunction();
TRIAGENS_C_INITIALISE(argc, argv);
TRIAGENS_REST_INITIALISE(argc, argv);
TRI_InitialiseLogging(false);
// .............................................................................
// set defaults
// .............................................................................
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
// use a minimum value for batches
if (ChunkSize < 1024 * 128) {
ChunkSize = 1024 * 128;
}
// .............................................................................
// check input directory
// .............................................................................
if (InputDirectory == "" || ! TRI_IsDirectory(InputDirectory.c_str())) {
cerr << "input directory '" << InputDirectory << "' does not exist" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
if (! ImportStructure && ! ImportData) {
cerr << "must specify either --create-collection or --import-data" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// .............................................................................
// set-up client connection
// .............................................................................
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == 0) {
cerr << "invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
Connection = GeneralClientConnection::factory(BaseClient.endpointServer(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
BaseClient.sslProtocol());
if (Connection == 0) {
cerr << "out of memory" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
Client = new SimpleHttpClient(Connection, BaseClient.requestTimeout(), false);
if (Client == 0) {
cerr << "out of memory" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
Client->setLocationRewriter(0, &rewriteLocation);
Client->setUserNamePassword("/", BaseClient.username(), BaseClient.password());
const string versionString = GetArangoVersion();
if (! Connection->isConnected()) {
cerr << "Could not connect to endpoint " << BaseClient.endpointServer()->getSpecification() << endl;
cerr << "Error message: '" << Client->getErrorMessage() << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// successfully connected
cout << "Server version: " << versionString << endl;
// validate server version
int major = 0;
int minor = 0;
if (sscanf(versionString.c_str(), "%d.%d", &major, &minor) != 2) {
cerr << "invalid server version '" << versionString << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
if (major < 1 ||
major > 2 ||
(major == 1 && minor < 4)) {
// we can connect to 1.4, 2.0 and higher only
cerr << "got incompatible server version '" << versionString << "'" << endl;
if (! Force) {
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
//.........这里部分代码省略.........
示例4: main
int main (int argc, char* argv[]) {
int ret = EXIT_SUCCESS;
arangobEntryFunction();
TRIAGENS_C_INITIALIZE(argc, argv);
TRIAGENS_REST_INITIALIZE(argc, argv);
TRI_InitializeLogging(false);
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
// .............................................................................
// set-up client connection
// .............................................................................
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == nullptr) {
LOG_FATAL_AND_EXIT("invalid value for --server.endpoint ('%s')", BaseClient.endpointString().c_str());
}
BenchmarkOperation* testCase = GetTestCase(TestCase);
if (testCase == nullptr) {
LOG_FATAL_AND_EXIT("invalid test case name '%s'", TestCase.c_str());
return EXIT_FAILURE; // will not be reached
}
Status("starting threads...");
BenchmarkCounter<unsigned long> operationsCounter(0, (unsigned long) Operations);
ConditionVariable startCondition;
vector<Endpoint*> endpoints;
vector<BenchmarkThread*> threads;
const double stepSize = (double) Operations / (double) ThreadConcurrency;
int64_t realStep = (int64_t) stepSize;
if (stepSize - (double) ((int64_t) stepSize) > 0.0) {
realStep++;
}
if (realStep % 1000 != 0) {
realStep += 1000 - (realStep % 1000);
}
// add some more offset so we don't get into trouble with threads of different speed
realStep += 10000;
// start client threads
for (int i = 0; i < ThreadConcurrency; ++i) {
Endpoint* endpoint = Endpoint::clientFactory(BaseClient.endpointString());
endpoints.push_back(endpoint);
BenchmarkThread* thread = new BenchmarkThread(testCase,
&startCondition,
&UpdateStartCounter,
i,
(unsigned long) BatchSize,
&operationsCounter,
endpoint,
BaseClient.databaseName(),
BaseClient.username(),
BaseClient.password(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
BaseClient.sslProtocol(),
KeepAlive,
Async,
verbose);
threads.push_back(thread);
thread->setOffset((size_t) (i * realStep));
thread->start();
}
// give all threads a chance to start so they will not miss the broadcast
while (GetStartCounter() < ThreadConcurrency) {
usleep(5000);
}
if (Delay) {
Status("sleeping (startup delay)...");
sleep(10);
}
Status("executing tests...");
double start = TRI_microtime();
// broadcast the start signal to all threads
{
CONDITION_LOCKER(guard, startCondition);
guard.broadcast();
//.........这里部分代码省略.........
示例5: main
int main (int argc, char* argv[]) {
TRIAGENS_C_INITIALISE(argc, argv);
TRIAGENS_REST_INITIALISE(argc, argv);
TRI_InitialiseLogging(false);
int ret = EXIT_SUCCESS;
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
// .............................................................................
// set-up MRuby objects
// .............................................................................
// create a new ruby shell
mrb_state* mrb = MR_OpenShell();
TRI_InitMRUtils(mrb);
// .............................................................................
// set-up client connection
// .............................................................................
// check if we want to connect to a server
bool useServer = (BaseClient.endpointString() != "none");
if (useServer) {
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == 0) {
LOGGER_FATAL_AND_EXIT("invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')");
}
ClientConnection = createConnection(mrb);
InitMRClientConnection(mrb, ClientConnection);
}
// .............................................................................
// banner
// .............................................................................
// http://www.network-science.de/ascii/ Font: ogre
if (! BaseClient.quiet()) {
char const* g = TRI_SHELL_COLOR_GREEN;
char const* r = TRI_SHELL_COLOR_RED;
char const* z = TRI_SHELL_COLOR_RESET;
if (! BaseClient.colors()) {
g = "";
r = "";
z = "";
}
printf("%s %s _ _ %s\n", g, r, z);
printf("%s __ _ _ __ __ _ _ __ __ _ ___ %s(_)_ __| |__ %s\n", g, r, z);
printf("%s / _` | '__/ _` | '_ \\ / _` |/ _ \\%s| | '__| '_ \\ %s\n", g, r, z);
printf("%s| (_| | | | (_| | | | | (_| | (_) %s| | | | |_) |%s\n", g, r, z);
printf("%s \\__,_|_| \\__,_|_| |_|\\__, |\\___/%s|_|_| |_.__/ %s\n", g, r, z);
printf("%s |___/ %s %s\n", g, r, z);
cout << endl << "Welcome to arangosh " << TRI_VERSION_FULL << ". Copyright (c) 2012 triAGENS GmbH" << endl;
#ifdef TRI_MRUBY_VERSION
cout << "Using MRUBY " << TRI_MRUBY_VERSION << " engine. Copyright (c) 2012 mruby developers." << endl;
#endif
#ifdef TRI_READLINE_VERSION
cout << "Using READLINE " << TRI_READLINE_VERSION << endl;
#endif
cout << endl;
BaseClient.printWelcomeInfo();
if (useServer) {
if (ClientConnection->isConnected()) {
if (! BaseClient.quiet()) {
cout << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
<< "' Version " << ClientConnection->getVersion() << endl;
}
}
else {
cerr << "Could not connect to endpoint '" << BaseClient.endpointString() << "'" << endl;
cerr << "Error message '" << ClientConnection->getErrorMessage() << "'" << endl;
}
}
}
// .............................................................................
// read files
// .............................................................................
// load java script from js/bootstrap/*.h files
if (StartupPath.empty()) {
StartupLoader.defineScript("common/bootstrap/error.rb", MR_common_bootstrap_error);
//.........这里部分代码省略.........
示例6: main
int main (int argc, char* argv[]) {
int ret = EXIT_SUCCESS;
arangoimpEntryFunction();
TRIAGENS_C_INITIALISE(argc, argv);
TRIAGENS_REST_INITIALISE(argc, argv);
TRI_InitialiseLogging(false);
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
// .............................................................................
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
// .............................................................................
// set-up client connection
// .............................................................................
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == 0) {
cerr << "invalid value for --server.endpoint ('" << BaseClient.endpointString() << "')" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
ClientConnection = new V8ClientConnection(BaseClient.endpointServer(),
BaseClient.databaseName(),
BaseClient.username(),
BaseClient.password(),
BaseClient.requestTimeout(),
BaseClient.connectTimeout(),
ArangoClient::DEFAULT_RETRIES,
BaseClient.sslProtocol(),
false);
if (! ClientConnection->isConnected() ||
ClientConnection->getLastHttpReturnCode() != HttpResponse::OK) {
cerr << "Could not connect to endpoint '" << BaseClient.endpointServer()->getSpecification()
<< "', database: '" << BaseClient.databaseName() << "'" << endl;
cerr << "Error message: '" << ClientConnection->getErrorMessage() << "'" << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// successfully connected
cout << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
<< "', version " << ClientConnection->getVersion() << ", database: '"
<< BaseClient.databaseName() << "', username: '" << BaseClient.username() << "'" << endl;
cout << "----------------------------------------" << endl;
cout << "database: " << BaseClient.databaseName() << endl;
cout << "collection: " << CollectionName << endl;
cout << "create: " << (CreateCollection ? "yes" : "no") << endl;
cout << "file: " << FileName << endl;
cout << "type: " << TypeImport << endl;
if (TypeImport == "csv") {
cout << "quote: " << Quote << endl;
cout << "separator: " << Separator << endl;
}
cout << "connect timeout: " << BaseClient.connectTimeout() << endl;
cout << "request timeout: " << BaseClient.requestTimeout() << endl;
cout << "----------------------------------------" << endl;
ImportHelper ih(ClientConnection->getHttpClient(), ChunkSize);
// create colletion
if (CreateCollection) {
ih.setCreateCollection(true);
}
// quote
if (Quote.length() <= 1) {
ih.setQuote(Quote);
}
else {
cerr << "Wrong length of quote character." << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// separator
if (Separator.length() == 1) {
ih.setSeparator(Separator);
}
else {
cerr << "Separator must be exactly one character." << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
// collection name
if (CollectionName == "") {
cerr << "Collection name is missing." << endl;
TRI_EXIT_FUNCTION(EXIT_FAILURE, NULL);
}
//.........这里部分代码省略.........