List of usage examples for com.mongodb.client.model CountOptions maxTime
public CountOptions maxTime(final long maxTime, final TimeUnit timeUnit)
From source file:io.djigger.collector.accessors.stackref.ThreadInfoAccessorImpl.java
License:Open Source License
public long count(Bson mongoQuery, Date from, Date to, long timeout, TimeUnit timeUnit) throws TimeoutException { mongoQuery = buildQuery(mongoQuery, from, to); CountOptions options = new CountOptions(); options.maxTime(timeout, timeUnit); try {//from ww w. ja va 2s. com return threadInfoCollection.count(mongoQuery, options); } catch (MongoExecutionTimeoutException e) { throw new TimeoutException("Count exceeded time limit"); } }