Skip to content

Commit

Permalink
Merge pull request #505 from pcnfernando/dokcer_push_integration
Browse files Browse the repository at this point in the history
Maintain templated Siddhi app in runtime
  • Loading branch information
suhothayan committed Oct 1, 2019
2 parents 7bf0daf + a4c48c6 commit e107e4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Expand Up @@ -24,11 +24,13 @@
import io.siddhi.distribution.editor.core.exception.InvalidExecutionStateException;
import io.siddhi.distribution.editor.core.exception.NoSuchStreamException;
import io.siddhi.distribution.editor.core.util.DebugCallbackEvent;
import io.siddhi.distribution.editor.core.util.SourceEditorUtils;
import io.siddhi.query.api.definition.Attribute;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;

/**
Expand All @@ -44,11 +46,17 @@ public class DebugRuntime {
private transient LinkedBlockingQueue<DebugCallbackEvent> callbackEventsQueue;

public DebugRuntime(String siddhiAppName, String siddhiApp) {
this.siddhiAppName = siddhiAppName;
this.siddhiApp = siddhiApp;
callbackEventsQueue = new LinkedBlockingQueue<>(10);
createRuntime(siddhiApp);
}

public DebugRuntime(String siddhiAppName, String siddhiApp, Map<String, String> variableMap) {
this.siddhiAppName = siddhiAppName;
this.siddhiApp = siddhiApp;
callbackEventsQueue = new LinkedBlockingQueue<>(10);
createRuntime();
createRuntime(SourceEditorUtils.populateSiddhiAppWithVars(variableMap, siddhiApp));
}

public String getSiddhiAppName() {
Expand Down Expand Up @@ -122,7 +130,7 @@ public void stop() {
siddhiAppRuntime = null;
}
callbackEventsQueue.clear();
createRuntime();
createRuntime(siddhiApp);
}

public void reload(String siddhiApp) {
Expand Down Expand Up @@ -177,8 +185,7 @@ public LinkedBlockingQueue<DebugCallbackEvent> getCallbackEventsQueue() {
return callbackEventsQueue;
}

private void createRuntime() {

private void createRuntime(String siddhiApp) {
try {
if (siddhiApp != null && !siddhiApp.isEmpty()) {
siddhiAppRuntime = EditorDataHolder.getSiddhiManager()
Expand Down
Expand Up @@ -765,8 +765,7 @@ public Response startWithVariables(String appStartRequestString) {
if (appStartRequest.getVariables().size() > 0) {
DebugRuntime existingRuntime = EditorDataHolder.getSiddhiAppMap().get(siddhiAppName);
String siddhiApp = existingRuntime.getSiddhiApp();
siddhiApp = SourceEditorUtils.populateSiddhiAppWithVars(appStartRequest.getVariables(), siddhiApp);
DebugRuntime runtimeHolder = new DebugRuntime(siddhiAppName, siddhiApp);
DebugRuntime runtimeHolder = new DebugRuntime(siddhiAppName, siddhiApp, appStartRequest.getVariables());
EditorDataHolder.getSiddhiAppMap().put(siddhiAppName, runtimeHolder);

}
Expand Down

0 comments on commit e107e4b

Please sign in to comment.