Понимание концепции моментального снимка сиддхи

У меня есть запрос и план выполнения, я хочу сделать его снимок, чтобы восстановить его на стороне получателя и начать выполнение снова.

  1. Какой формат должен быть отправлен получателю?
  2. Как восстановить на стороне получателя?

Ниже приведен код, который я взял из репозитория Siddhi.

 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();

person Mujahid Masood    schedule 24.05.2017    source источник


Ответы (1)


Вы можете использовать PersistenceStore, чтобы сохранить состояние (моментальный снимок) плана выполнения и восстановить его позже. Пожалуйста, обратитесь к следующему PersistenceTestCase, чтобы получить представление о его использовании. то есть;

    // 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();
person Grainier    schedule 30.05.2017