Make helium app work

This commit is contained in:
Lee moon soo 2016-11-22 18:22:19 -08:00
parent 0a5b4d1953
commit b01d70ff1d
10 changed files with 51 additions and 53 deletions

View file

@ -269,7 +269,7 @@ public class InterpreterOutput extends OutputStream {
public void writeResource(String resourceName) throws IOException {
InterpreterResultMessageOutput out = getCurrentOutputForWriting();
out.write(resourceName);
out.writeResource(resourceName);
}
public List<InterpreterResultMessage> toInterpreterResultMessage() throws IOException {

View file

@ -143,7 +143,7 @@ public class InterpreterResultMessageOutput extends OutputStream {
}
public void setResourceSearchPaths(List<String> resourceSearchPaths) {
resourceSearchPaths = resourceSearchPaths;
this.resourceSearchPaths = resourceSearchPaths;
}
public void writeResource(String resourceName) throws IOException {

View file

@ -111,17 +111,16 @@ public class ZeppelinApplicationDevServer extends ZeppelinDevServer {
return;
}
InterpreterResult result = (InterpreterResult) results.get(0).get();
InterpreterResultMessage result = (InterpreterResultMessage) results.get(0).get();
Gson gson = new Gson();
String resultJson = gson.toJson(result);
StringBuffer transferResult = new StringBuffer();
transferResult.append("$z.result = " + resultJson + ";\n");
// TODO
/*
if (result.type() == InterpreterResult.Type.TABLE) {
if (result.getType() == InterpreterResult.Type.TABLE) {
transferResult.append("$z.scope.loadTableData($z.result);\n");
}
*/
transferResult.append("$z.scope._devmodeResult = $z.result;\n");
app.printStringAsJavascript(transferResult.toString());
}

View file

@ -278,7 +278,7 @@ public class RemoteInterpreterEventClient implements ResourcePoolConnector {
Map<String, Object> appendOutput = new HashMap<>();
appendOutput.put("noteId", noteId);
appendOutput.put("paragraphId", paragraphId);
appendOutput.put("index", index);
appendOutput.put("index", Integer.toString(index));
appendOutput.put("appId", appId);
appendOutput.put("data", output);
@ -294,11 +294,11 @@ public class RemoteInterpreterEventClient implements ResourcePoolConnector {
Map<String, Object> appendOutput = new HashMap<>();
appendOutput.put("noteId", noteId);
appendOutput.put("paragraphId", paragraphId);
appendOutput.put("index", index);
appendOutput.put("index", Integer.toString(index));
appendOutput.put("appId", appId);
appendOutput.put("type", type);
appendOutput.put("data", output);
logger.info("onAppoutputUpdate = {}", output);
sendEvent(new RemoteInterpreterEvent(
RemoteInterpreterEventType.OUTPUT_UPDATE,
gson.toJson(appendOutput)));

View file

@ -452,16 +452,17 @@ public class RemoteInterpreterServer
resultMessages.addAll(result.message());
// put result into resource pool
// TODO
/*
if (combinedResult.type() == InterpreterResult.Type.TABLE) {
context.getResourcePool().put(
context.getNoteId(),
context.getParagraphId(),
WellKnownResourceName.ZeppelinTableResult.toString(),
combinedResult);
if (resultMessages.size() > 0) {
int lastMessageIndex = resultMessages.size() - 1;
if (resultMessages.get(lastMessageIndex).getType() ==
InterpreterResult.Type.TABLE) {
context.getResourcePool().put(
context.getNoteId(),
context.getParagraphId(),
WellKnownResourceName.ZeppelinTableResult.toString(),
resultMessages.get(lastMessageIndex));
}
}
*/
return new InterpreterResult(result.code(), resultMessages);
} finally {
InterpreterContext.remove();
@ -856,21 +857,33 @@ public class RemoteInterpreterServer
protected InterpreterOutput createAppOutput(final String noteId,
final String paragraphId,
final String appId) {
return null;
// TODO
/*
return new InterpreterOutput(new InterpreterOutputListener() {
@Override
public void onAppend(InterpreterResultMessageOutput out, byte[] line) {
eventClient.onAppOutputAppend(noteId, paragraphId, appId, new String(line));
public void onUpdateAll(InterpreterOutput out) {
}
@Override
public void onUpdate(InterpreterResultMessageOutput out, byte[] output) {
eventClient.onAppOutputUpdate(noteId, paragraphId, appId, new String(output));
public void onClose(InterpreterOutput out) {
}
@Override
public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
eventClient.onAppOutputAppend(noteId, paragraphId, index, appId, new String(line));
}
@Override
public void onUpdate(int index, InterpreterResultMessageOutput out) {
try {
eventClient.onAppOutputUpdate(noteId, paragraphId, index, appId,
out.getType(), new String(out.toByteArray()));
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
});
*/
}
private ApplicationContext getApplicationContext(
@ -954,15 +967,15 @@ public class RemoteInterpreterServer
System.err.println("Resource " + res.get());
}
runningApp.app.run(resource);
// TODO
/*
List<InterpreterResultMessage> outputMessage = context.out.toInterpreterResultMessage();
context.out.flush();
InterpreterResultMessageOutput out = context.out.getOutputAt(0);
eventClient.onAppOutputUpdate(
context.getNoteId(),
context.getParagraphId(),
0,
applicationInstanceId,
output);
*/
out.getType(),
new String(out.toByteArray()));
return new RemoteApplicationResult(true, "");
} catch (ApplicationException | IOException e) {
return new RemoteApplicationResult(false, e.getMessage());

View file

@ -119,14 +119,6 @@
noteVarShareService.put($scope.paragraph.id + '_paragraphScope', paragraphScope);
initializeDefault();
/*
var activeApp = _.get($scope.paragraph.config, 'helium.activeApp');
if (activeApp) {
var app = _.find($scope.apps, {id: activeApp});
renderApp(app);
}
*/
};
var initializeDefault = function() {

View file

@ -60,6 +60,11 @@ limitations under the License.
ng-include src="'app/notebook/paragraph/result/result.html'"
>
</div>
<div id="{{paragraph.id}}_error"
class="error text"
ng-if="paragraph.status == 'ERROR'"
ng-bind="paragraph.errorMessage">
</div>
</div>
<div ng-include src="'app/notebook/paragraph/paragraph-control.html'"></div>

View file

@ -53,16 +53,10 @@ limitations under the License.
<img id="{{id}}_img"
ng-if="type == 'IMG'"
ng-src="{{getBase64ImageSrc(result.data)}}" />
<div id="{{id}}_error"
class="error text"
ng-if="paragraph.status == 'ERROR'"
ng-bind="paragraph.errorMessage">
</div>
</div>
<div ng-repeat="app in apps">
<div id="p{{app.id}}"
ng-show="paragraph.config.helium.activeApp == app.id">
ng-show="config.helium.activeApp == app.id">
</div>
</div>

View file

@ -148,11 +148,6 @@
}
console.log('updateResult %o %o %o %o', result, newConfig, paragraphRef, index);
/*
var oldActiveApp = _.get($scope.paragraph.config, 'helium.activeApp');
var newActiveApp = _.get(data.paragraph.config, 'helium.activeApp');
*/
updateData(result, newConfig, paragraph, resultIndex);
renderResult($scope.type, true);
});

View file

@ -56,7 +56,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
@Before
public void setUp() throws Exception {
tmpDir = new File(System.getProperty("java.io.tmpdir")+"/ZeppelinLTest_"+System.currentTimeMillis());
tmpDir = new File(System.getProperty("java.io.tmpdir")+"/ZepelinLTest_"+System.currentTimeMillis());
tmpDir.mkdirs();
File confDir = new File(tmpDir, "conf");
confDir.mkdirs();