.net - apache ignite .net 计划任务

标签 .net ignite

基于项目documentation ,在java版本中存在一些基于cron的调度。但我在 .net 实现中没有找到任何类似的东西。

我的任务是每天使用长时间运行的作业更新我的缓存。在这种情况下(.net 版本没有内置调度功能)我考虑创建应用程序,它将在客户端模式下运行 ignite 并使用数据更新缓存。并使用 Windows 任务计划程序运行此应用程序。

有更好的解决方案吗?或者也许是一个很好的例子?

收到答复后实现的解决方案:

二手FluentScheduler用于定期安排作业。不幸的是HangFire我本来打算用的,没成功。如果包含当前执行调度程序的节点由于某种原因发生故障或离线,则服务会在其余节点之一上启动,并且不会丢失任何调度作业。

调度程序作业代码

public class CacheUpdateRegistry : Registry
{
    private readonly IIgnite _ignite;

    public CacheUpdateRegistry(IIgnite ignite)
    {
        _ignite = ignite;

        // output to console current node id as example each 2 seconds
        Schedule(() => Console.WriteLine("Recurring on node: + " + _ignite.GetCluster().GetLocalNode().Id)).ToRunNow().AndEvery(2).Seconds();
    }

}

服务代码:

public class CacheUpdateSchedulerService : IService
{
        [InstanceResource]
        private readonly IIgnite _ignite;

    public void Init(IServiceContext context)
    {
        Console.WriteLine("CacheUpdateSchedulerService initialized");
        obManager.Initialize(new CacheUpdateRegistry(_ignite));
    }

    // other code removed for brevity

}

点燃节点代码:

var services = _ignite.GetServices();
services.DeployClusterSingleton("cacheUpdateScheduler", new CacheUpdateSchedulerService());

最佳答案

Java 中的 Ignite Scheduler API 非常基础且仅限本地。实际上,它与 Ignite 几乎没有任何关系。

这就是为什么我们决定在 .NET 端省略此 API:使用 Timer 可以实现同样的效果。类。

关于.net - apache ignite .net 计划任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46919766/

相关文章:

java - 根据要求使用已投入使用的 Spring Boot 启动 ignite

hadoop - Apache Ignite Hadoop Accelerator MapReduce作业不在JobHistory服务器中

ssl - 点燃 pod 之间的 TLS 通信

c# - 将按钮绑定(bind)到不同的 ViewModel [MVVM]

c# - 可以在给定 AutomationId 值的情况下实例化 AutomationElement 类型吗?

java - 使用 JDBC 连接将记录插入到 Apache Ignite Cluster 时出现异常

java - Apache Ignite 2.6.0 - 6 节点集群分区模式下的高延迟

c# - 如何使用带有 C# 的 Granados 通过 SSH 隧道转发端口

.net - 如何调试 Windows Store 应用程序中的内存泄漏?

c# - WebBrowser 控件的问题