首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >了解siddhi快照概念

了解siddhi快照概念
EN

Stack Overflow用户
提问于 2017-05-24 12:12:37
回答 1查看 305关注 0票数 0

我有查询和执行计划,我想要快照,以便我可以恢复它在接收端,并开始执行它。

  1. 应向接收方发送何种格式?
  2. 如何在接收端恢复?

下面是我从Siddhi存储库获取的一些代码。

代码语言:javascript
复制
 SiddhiManager siddhiManager = new SiddhiManager();
    String query =
            "define stream inStream(meta_roomNumber int,meta_temperature double);" +
                    "from inStream#window(10)[meta_temperature > 50]\n" +
                    "select *" +
                    "insert into outStream;";

    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(query);

    executionPlanRuntime.start();
    SiddhiContext siddhicontext = new SiddhiContext();

    context.setSiddhiContext(siddhicontext);
    context.setSnapshotService(new SnapshotService(context));
    executionPlanRuntime.snapshot();
EN

回答 1

Stack Overflow用户

发布于 2017-05-30 16:32:00

您可以使用PersistenceStore来持久化执行计划的状态(快照),并在以后恢复它。请参考下面的PersistenceTestCase来了解它的用法。即;

代码语言:javascript
复制
    // Create executionPlanRuntime
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);

    // Register Callbacks, InputHandlers
    executionPlanRuntime.addCallback("query1", queryCallback);
    stream1 = executionPlanRuntime.getInputHandler("Stream1");

    // Start executionPlanRuntime
    executionPlanRuntime.start();

    // Send events
    stream1.send(new Object[]{"WSO2", 25.6f, 100});
    Thread.sleep(100);
    stream1.send(new Object[]{"GOOG", 47.6f, 100});
    Thread.sleep(100);

    // Persist the state
    executionPlanRuntime.persist();

    // Shutdown the running execution plan
    executionPlanRuntime.shutdown();

    // Create new executionPlanRuntime
    executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);

    // Register Callbacks, InputHandlers
    executionPlanRuntime.addCallback("query1", queryCallback);
    stream1 = executionPlanRuntime.getInputHandler("Stream1");

    // Start executionPlanRuntime
    executionPlanRuntime.start();

    // Restore to previously persisted state
    executionPlanRuntime.restoreLastRevision();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44158116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档