当前位置: 首页>>代码示例>>C++>>正文


C++ ArangoClient::requestTimeout方法代码示例

本文整理汇总了C++中ArangoClient::requestTimeout方法的典型用法代码示例。如果您正苦于以下问题:C++ ArangoClient::requestTimeout方法的具体用法?C++ ArangoClient::requestTimeout怎么用?C++ ArangoClient::requestTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArangoClient的用法示例。


在下文中一共展示了ArangoClient::requestTimeout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createConnection

static MRubyClientConnection* createConnection (mrb_state* mrb) {
  return new MRubyClientConnection(mrb,
                                   BaseClient.endpointServer(),
                                   BaseClient.username(),
                                   BaseClient.password(),
                                   BaseClient.requestTimeout(),
                                   BaseClient.connectTimeout(),
                                   ArangoClient::DEFAULT_RETRIES,
                                   false);
}
开发者ID:FikiHafana,项目名称:ArangoDB,代码行数:10,代码来源:arangoirb.cpp

示例2: 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;
//.........这里部分代码省略.........
开发者ID:BenjaminLagendijk,项目名称:ArangoDB,代码行数:101,代码来源:arangodump.cpp

示例3: 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);
  }
//.........这里部分代码省略.........
开发者ID:CedarLogic,项目名称:arangodb,代码行数:101,代码来源:arangorestore.cpp

示例4: 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);
//.........这里部分代码省略.........
开发者ID:bdacode,项目名称:ArangoDB,代码行数:101,代码来源:arangorestore.cpp

示例5: 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();
//.........这里部分代码省略.........
开发者ID:janavolkova9,项目名称:arangodb,代码行数:101,代码来源:arangob.cpp

示例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);
  }

//.........这里部分代码省略.........
开发者ID:LongLiveCHIEF,项目名称:ArangoDB,代码行数:101,代码来源:arangoimp.cpp


注:本文中的ArangoClient::requestTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。