com.mongodb.Mongo.getMongoOptions()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中com.mongodb.Mongo.getMongoOptions()方法的一些代码示例,展示了Mongo.getMongoOptions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mongo.getMongoOptions()方法的具体详情如下:
包路径:com.mongodb.Mongo
类名称:Mongo
方法名:getMongoOptions

Mongo.getMongoOptions介绍

[英]Returns the mongo options.

Changes to MongoOptions that are done after connection are not reflected.
[中]返回mongo选项。
连接后对Mongoopions所做的更改不会反映出来。

代码示例

代码示例来源:origin: jmkgreen/morphia

/**
   * @return
   */
  public DBDecoderFactory getDecoderFact() {
    return decoderFactory != null ? decoderFactory : mongo.getMongoOptions().dbDecoderFactory;
  }
}

代码示例来源:origin: stackoverflow.com

public boolean mongoRunningAt(String uri) {
  try {
    Mongo mongo = new Mongo(new MongoURI(uri));
    try {
      Socket socket = mongo.getMongoOptions().socketFactory.createSocket();
      socket.connect(mongo.getAddress().getSocketAddress());
      socket.close();
    } catch (IOException ex) {
      return false;
    }
    mongo.close();
    return true;
  } catch (UnknownHostException e) {
    return false;
  }
}

代码示例来源:origin: Aresyi/smart-api

private void config() {
  MongoOptions op = mongo.getMongoOptions();
  op.setAutoConnectRetry(autoConnectRetry);
  op.setConnectTimeout(connectTimeout);
  op.setMaxWaitTime(maxWaitTime);
  op.setMaxAutoConnectRetryTime(maxAutoConnectRetryTime);
  op.setSocketKeepAlive(socketKeepAlive);
  op.setSocketTimeout(socketTimeout);
}

相关文章