use of org.apache.zeppelin.rest.message.InterpreterInstallationRequest in project zeppelin by apache.
the class InterpreterServiceTest method downloadInterpreter.
@Test
public void downloadInterpreter() throws IOException {
final String interpreterName = "test-interpreter";
String artifactName = "junit:junit:4.11";
Path specificInterpreterPath = Files.createDirectory(Paths.get(interpreterDir.toString(), interpreterName));
DependencyResolver dependencyResolver = new DependencyResolver(localRepoDir.toString());
doNothing().when(mockInterpreterSettingManager).refreshInterpreterTemplates();
interpreterService.downloadInterpreter(new InterpreterInstallationRequest(interpreterName, artifactName), dependencyResolver, specificInterpreterPath, new SimpleServiceCallback<String>() {
@Override
public void onStart(String message, ServiceContext context) {
assertEquals("Starting to download " + interpreterName + " interpreter", message);
}
@Override
public void onSuccess(String message, ServiceContext context) {
assertEquals(interpreterName + " downloaded", message);
}
@Override
public void onFailure(Exception ex, ServiceContext context) {
fail();
}
});
verify(mockInterpreterSettingManager, times(1)).refreshInterpreterTemplates();
}
use of org.apache.zeppelin.rest.message.InterpreterInstallationRequest in project zeppelin by apache.
the class InterpreterServiceTest method interpreterAlreadyExistWithDifferentName.
@Test(expected = Exception.class)
public void interpreterAlreadyExistWithDifferentName() throws Exception {
String interpreterName = "in";
Files.createDirectory(Paths.get(interpreterDir.toString(), interpreterName));
String anotherButSameInterpreterName = "zeppelin-" + interpreterName;
interpreterService.installInterpreter(new InterpreterInstallationRequest(anotherButSameInterpreterName, "artifact"), null);
}
use of org.apache.zeppelin.rest.message.InterpreterInstallationRequest in project zeppelin by apache.
the class InterpreterServiceTest method interpreterAlreadyExist.
@Test(expected = Exception.class)
public void interpreterAlreadyExist() throws Exception {
String alreadyExistName = "aen";
Path specificInterpreterDir = Files.createDirectory(Paths.get(interpreterDir.toString(), alreadyExistName));
interpreterService.installInterpreter(new InterpreterInstallationRequest(alreadyExistName, "artifact"), null);
}
use of org.apache.zeppelin.rest.message.InterpreterInstallationRequest in project zeppelin by apache.
the class InterpreterRestApi method installInterpreter.
/**
* Install interpreter
*/
@POST
@Path("install")
@ZeppelinApi
public Response installInterpreter(@NotNull String message) {
LOGGER.info("Install interpreter: {}", message);
InterpreterInstallationRequest request = InterpreterInstallationRequest.fromJson(message);
try {
interpreterService.installInterpreter(request, new SimpleServiceCallback<String>() {
@Override
public void onStart(String message, ServiceContext context) {
Message m = new Message(OP.INTERPRETER_INSTALL_STARTED);
Map<String, Object> data = new HashMap<>();
data.put("result", "Starting");
data.put("message", message);
m.data = data;
notebookServer.broadcast(m);
}
@Override
public void onSuccess(String message, ServiceContext context) {
Message m = new Message(OP.INTERPRETER_INSTALL_RESULT);
Map<String, Object> data = new HashMap<>();
data.put("result", "Succeed");
data.put("message", message);
m.data = data;
notebookServer.broadcast(m);
}
@Override
public void onFailure(Exception ex, ServiceContext context) {
Message m = new Message(OP.INTERPRETER_INSTALL_RESULT);
Map<String, Object> data = new HashMap<>();
data.put("result", "Failed");
data.put("message", ex.getMessage());
m.data = data;
notebookServer.broadcast(m);
}
});
} catch (Throwable t) {
return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, t.getMessage()).build();
}
return new JsonResponse<>(Status.OK).build();
}
Aggregations