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


Java MongoCursor.close方法代码示例

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


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

示例1: getModerationLogs

import org.jongo.MongoCursor; //导入方法依赖的package包/类
public static Optional<List<ModerationLog>> getModerationLogs(CurseGUID channelId) {
    try {
        List<ModerationLog> commandRet = new ArrayList<>();
        MongoCursor<ModerationLog> commands = jongo.getCollection(MONGO_MODERATION_LOGGING_COLLECTION).find("{channelID: '" + channelId.serialize() + "'}")
                .as(ModerationLog.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting moderation data", e);
        return Optional.empty();
    }

}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:17,代码来源:MongoConnection.java

示例2: getMessageLog

import org.jongo.MongoCursor; //导入方法依赖的package包/类
public static Optional<List<ModerationLog>> getMessageLog(CurseGUID channelId, Date eventTime) {
    try {
        List<ModerationLog> commandRet = new ArrayList<>();
        MongoCursor<ModerationLog> commands = jongo.getCollection(MONGO_MODERATION_LOGGING_COLLECTION)
                .find("{channelID: '" + channelId.serialize() + "' , messageTime: 'ISODate(" + eventTime.toString() + ")'}")
                .as(ModerationLog.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting moderation data", e);
        return Optional.empty();
    }
}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:17,代码来源:MongoConnection.java

示例3: getCurseChecksForAuthor

import org.jongo.MongoCursor; //导入方法依赖的package包/类
public static Optional<List<MongoCurseforgeCheck>> getCurseChecksForAuthor(@Nonnull String author) {
    try {
        List<MongoCurseforgeCheck> commandRet = new ArrayList<>();
        MongoCursor<MongoCurseforgeCheck> commands = jongo.getCollection(MONGO_COMMANDS_COLLECTION).find("{author: '" + author + "'}")
                .as(MongoCurseforgeCheck.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting checks", e);
        return Optional.empty();
    }

}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:17,代码来源:MongoConnection.java

示例4: getCommandsForServer

import org.jongo.MongoCursor; //导入方法依赖的package包/类
@Nonnull
//TODO should this use streams?
public static Optional<List<MongoCommand>> getCommandsForServer(CurseGUID serverID) {
    try {
        List<MongoCommand> commandRet = new ArrayList<>();
        MongoCursor<MongoCommand> commands = jongo.getCollection(MONGO_COMMANDS_COLLECTION).find("{serverID: '" + serverID.serialize() + "'}")
                .as(MongoCommand.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting commands for server", e);
        return Optional.empty();
    }
}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:18,代码来源:MongoConnection.java

示例5: send

import org.jongo.MongoCursor; //导入方法依赖的package包/类
@Override
public void send() {
    Map<String, T> jobs = getJobs();
    MongoCollection collection = mongoDBService.getCollection(Constants.DB.TO_SEND);
    for (Map.Entry<String, T> entry : jobs.entrySet()) {
        String toSendQuery = "{jobId:'" + entry.getKey() + "'}";
        try {
            MongoCursor<ToSend> messageCursor = collection.find(toSendQuery).as(ToSend.class);
            for (ToSend message : messageCursor) {
                send(entry.getValue(), message);
            }
            collection.remove(toSendQuery);
            messageCursor.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:20,代码来源:AbstractMessenger.java

示例6: getPluginConfigs

import org.jongo.MongoCursor; //导入方法依赖的package包/类
/**
 * @return active configs set for selected plugin
 */
protected Set<T> getPluginConfigs() {
    HashSet<T> configsByType = Sets.newHashSet();
    MongoCollection collection = mongoDBService.getCollection(getConfigTableName());
    try {
        MongoCursor<? extends ConfigDTO> mongoCursor = collection.find("{type:'" + configTemplate.getType() + "'}")
                .as(configTemplate.getClass());

        for (ConfigDTO configDTO : mongoCursor) {
            configsByType.add((T) configDTO);
        }
        mongoCursor.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return configsByType;
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:20,代码来源:AbstractPlugin.java

示例7: process

import org.jongo.MongoCursor; //导入方法依赖的package包/类
@Override
public void process() {
    MongoCollection builds = mongoDBService.getCollection(Constants.DB.BUILDS);
    for (Map.Entry<String, WatchdogProcessorConfigDTO> entry : getJobs().entrySet()) {
        long boundTime = System.currentTimeMillis() - Integer.parseInt(entry.getValue().getTimeout()) * 60000;
        String queryToSend = String.format("{jobId:'%s', processed:'false', startTime:{$lt: '%s'}, status: '%s'}",
                entry.getKey(), boundTime, CiReport.Status.IN_PROGRESS);
        try {
            MongoCursor<CiReport> ciReports = builds.find(queryToSend).as(CiReport.class);
            if (ciReports.count() > 0) {
                putMessage(entry.getKey(), SUBJECT, BODY);
            }
            markReportsAsProcessed(builds, ciReports);
            ciReports.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:20,代码来源:StatusWatchdogProcessor.java

示例8: getCurseChecks

import org.jongo.MongoCursor; //导入方法依赖的package包/类
public static Optional<List<MongoCurseforgeCheck>> getCurseChecks() {
    try {
        List<MongoCurseforgeCheck> commandRet = new ArrayList<>();
        MongoCursor<MongoCurseforgeCheck> commands = jongo.getCollection(MONGO_CURSECHECKS_COLLECTION).find()
                .as(MongoCurseforgeCheck.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting checks", e);
        return Optional.empty();
    }
}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:16,代码来源:MongoConnection.java

示例9: process

import org.jongo.MongoCursor; //导入方法依赖的package包/类
@Override
public void process() {
    Map<String, StatusChangedProcessorConfigDTO> jobs = getJobs();

    MongoCollection collection = mongoDBService.getCollection(Constants.DB.BUILDS);
    for (Map.Entry<String, StatusChangedProcessorConfigDTO> entry : jobs.entrySet()) {
        String toSendQuery = "{jobId:'" + entry.getKey() + "', processed:'false'}";
        try {
            MongoCursor<CiReport> ciReports = collection.find(toSendQuery).as(CiReport.class);
            int count = ciReports.count();
            CiReport firstReport = null;
            for (int i = 0; i < count - 1; i++) {
                CiReport report = ciReports.next();
                if (firstReport == null) {
                    firstReport = report;
                }
                report.setProcessed(true);
                collection.update("{id:'" + report.getId() + "'}", report);
            }
            if (ciReports.hasNext()) {
                CiReport lastReport = ciReports.next();
                CiReport.Status firstStatus = firstReport.getStatus();
                generateMessage(entry.getKey(), entry.getValue(), firstStatus, lastReport);

            }
            ciReports.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:33,代码来源:StatusChangedProcessor.java

示例10: process

import org.jongo.MongoCursor; //导入方法依赖的package包/类
@Override
public void process() {

    if (!disableForDemo) {
        // if (lastRun == null) {
        // lastRun = LocalDate.now();
        // } else {
        // if (Duration.between(lastRun, LocalDate.now()).toDays() == 0) {
        // return;
        // }
        // }
    }

    Map<String, DailyReportProcessorConfigDTO> jobs = getJobs();

    MongoCollection collection = mongoDBService.getCollection(Constants.DB.BUILDS);
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, -1);
    long timeInMills = calendar.getTimeInMillis();

    for (Map.Entry<String, DailyReportProcessorConfigDTO> entry : jobs.entrySet()) {
        String query = String.format("{ $and : [" + "   {jobId : '%s'}, " + "   {startTime : {$gt: %d}}, "
                + "   {processed:false}" + "]}", entry.getKey(), timeInMills);
        DailyStatistic statistic = new DailyStatistic();
        try {
            MongoCursor<CiReport> dailyReports = collection.find(query).as(CiReport.class);
            if (dailyReports.count() > 0) {
                while (dailyReports.hasNext()) {
                    CiReport report = dailyReports.next();
                    statistic.putReportToStatistic(report);
                }
                if (statistic.isNotEmpty()) {
                    generateReport(entry.getKey(), statistic);
                }
                dailyReports.close();
                collection.update(query).with("{processed:true}");
            }
        } catch (IOException ex) {
            LOGGER.error("Fail to close db cursor", ex);
        }
    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:43,代码来源:DailyReportProcessor.java


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