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

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

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

Mongo.getClusterDescription介绍

暂无

代码示例

代码示例来源:origin: org.mongodb/mongo-java-driver

/**
 * Gets the maximum size for a BSON object supported by the current master server. Note that this value may change over time depending
 * on which server is master.
 *
 * @return the maximum size, or 0 if not obtained from servers yet.
 * @throws MongoException if there's a failure
 */
@Deprecated
@SuppressWarnings("deprecation")
public int getMaxBsonObjectSize() {
  List<ServerDescription> primaries = getClusterDescription().getPrimaries();
  return primaries.isEmpty() ? ServerDescription.getDefaultMaxDocumentSize() : primaries.get(0).getMaxDocumentSize();
}

代码示例来源:origin: org.mongodb/mongo-java-driver

/**
 * Gets the address of the current master
 *
 * @return the address
 */
@Deprecated
@SuppressWarnings("deprecation")
@Nullable
public ServerAddress getAddress() {
  ClusterDescription description = getClusterDescription();
  if (description.getPrimaries().isEmpty()) {
    return null;
  }
  return description.getPrimaries().get(0).getAddress();
}

代码示例来源:origin: org.mongodb/mongo-java-driver

/**
 * Get the status of the replica set cluster.
 *
 * @return replica set status information
 */
@SuppressWarnings("deprecation")
@Deprecated
@Nullable
public ReplicaSetStatus getReplicaSetStatus() {
  ClusterDescription clusterDescription = getClusterDescription();
  return clusterDescription.getType() == REPLICA_SET && clusterDescription.getConnectionMode() == MULTIPLE
      ? new ReplicaSetStatus(delegate.getCluster()) : null; // this is intended behavior in 2.x
}

代码示例来源:origin: org.mongodb/mongodb-driver

/**
 * Gets the maximum size for a BSON object supported by the current master server. Note that this value may change over time depending
 * on which server is master.
 *
 * @return the maximum size, or 0 if not obtained from servers yet.
 * @throws MongoException if there's a failure
 */
@Deprecated
@SuppressWarnings("deprecation")
public int getMaxBsonObjectSize() {
  List<ServerDescription> primaries = getClusterDescription().getPrimaries();
  return primaries.isEmpty() ? ServerDescription.getDefaultMaxDocumentSize() : primaries.get(0).getMaxDocumentSize();
}

代码示例来源:origin: org.mongodb/mongodb-driver

/**
 * Gets the address of the current master
 *
 * @return the address
 */
@Deprecated
@SuppressWarnings("deprecation")
@Nullable
public ServerAddress getAddress() {
  ClusterDescription description = getClusterDescription();
  if (description.getPrimaries().isEmpty()) {
    return null;
  }
  return description.getPrimaries().get(0).getAddress();
}

代码示例来源:origin: org.mongodb/mongodb-driver

/**
 * Get the status of the replica set cluster.
 *
 * @return replica set status information
 */
@SuppressWarnings("deprecation")
@Deprecated
@Nullable
public ReplicaSetStatus getReplicaSetStatus() {
  ClusterDescription clusterDescription = getClusterDescription();
  return clusterDescription.getType() == REPLICA_SET && clusterDescription.getConnectionMode() == MULTIPLE
      ? new ReplicaSetStatus(delegate.getCluster()) : null; // this is intended behavior in 2.x
}

相关文章