Java 类com.mongodb.MongoExecutionTimeoutException 实例源码

项目:djigger    文件:ThreadInfoAccessorImpl.java   
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 {
        return threadInfoCollection.count(mongoQuery, options);
    } catch(MongoExecutionTimeoutException e) {
        throw new TimeoutException("Count exceeded time limit");
    }
}
项目:lightblue-mongo    文件:MongoCRUDController.java   
private Error analyzeException(Exception e, final String otherwise, final String msg, boolean specialHandling) {
    if (e instanceof Error) {
        return (Error) e;
    }

    if (e instanceof MongoException) {
        MongoException me = (MongoException) e;
        if (me.getCode() == 18) {
            return Error.get(CrudConstants.ERR_AUTH_FAILED, e.getMessage());
        } else if (me instanceof MongoTimeoutException
                || me instanceof MongoExecutionTimeoutException) {
            LOGGER.error(CrudConstants.ERR_DATASOURCE_TIMEOUT, e);
            return Error.get(CrudConstants.ERR_DATASOURCE_TIMEOUT, e.getMessage());
        } else if (me instanceof DuplicateKeyException) {
            return Error.get(MongoCrudConstants.ERR_DUPLICATE, e.getMessage());
        } else if (me instanceof MongoSocketException) {
            LOGGER.error(MongoCrudConstants.ERR_CONNECTION_ERROR, e);
            return Error.get(MongoCrudConstants.ERR_CONNECTION_ERROR, e.getMessage());
        } else {
            LOGGER.error(MongoCrudConstants.ERR_MONGO_ERROR, e);
            return Error.get(MongoCrudConstants.ERR_MONGO_ERROR, e.getMessage());
        }
    } else if (msg == null) {
        return Error.get(otherwise, e.getMessage());
    } else if (specialHandling) {
        return Error.get(otherwise, msg, e);
    } else {
        return Error.get(otherwise, msg);
    }
}
项目:pentaho-mongodb-plugin    文件:MongoDbOutput.java   
private static boolean isTimeoutException( MongoException me ) {
  return ( me instanceof MongoExecutionTimeoutException );
}