2017-05-24 1 views
0

쿼리 및 실행 계획을 가지고 있으므로 스냅 샷을 찍어서 수신 측에서 복원하고 다시 실행하기를 원합니다.siddhi 스냅 샷 개념의 이해

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

답변

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

위에서 언급 한 방식으로 로컬 컴퓨터에서 올바르게 작동합니다. 소켓을 사용하여 네트워크를 통해 스냅 샷을 보내고 분산 환경에서 작동하도록해야합니다. –