侧边栏壁纸
  • 累计撰写 781 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论
标签搜索
MC

RequestSystem

Dettan
2021-07-10 / 0 评论 / 0 点赞 / 82 阅读 / 1,533 字
温馨提示:
本文最后更新于 2022-04-30,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

tick
1.
com.minecolonies.coremod.colony.requestsystem.management.manager.StandardRequestManager tick()
2.
com.minecolonies.coremod.colony.requestsystem.resolvers.StandardRetryingRequestResolver
@Override
public void tick()
{
    manager.getLogger().debug("Starting reassignment.");
//Lets decrement all delays
getAllAssignedRequests().forEach(t -> {
    Integer current = delays.remove(t);
    delays.put(t, --current);
});

//Lets get all keys with 0 residual delay:
final Set<IToken<?>> retryables = delays.keySet().stream().filter(t -> delays.get(t) == 0).collect(Collectors.toSet());
final Set<IToken<?>> successfully = retryables.stream().filter(t -> {
    final Set<IToken<?>> blackList = assignedRequests.get(t) < getMaximalTries() ? ImmutableSet.of() : ImmutableSet.of(id);

    Integer currentAttempt = assignedRequests.get(t);

    this.setCurrent(t);
    final IToken<?> resultingResolver;

    try
    {
        resultingResolver = manager.reassignRequest(t, blackList);
    }
    catch (Exception ex)
    {
        assignedRequests.remove(t);
        delays.remove(t);
        return false;
    }

    this.setCurrent(null);

    assignedRequests.put(t, ++currentAttempt);

    if (resultingResolver != null && !resultingResolver.equals(getId()))
    {
        assignedRequests.remove(t);
        delays.remove(t);
    }

    return resultingResolver != null;
}).collect(Collectors.toSet());

successfully.forEach(t -> {
    manager.getLogger().debug("Failed to reassign a retryable request: " + id);
});

manager.getLogger().debug("Finished reassignment.");

}






0

评论区