use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project zeppelin by apache.
the class ConfInterpreterTest method testEmptyConf.
@Test
public void testEmptyConf() throws InterpreterException {
assertTrue(interpreterFactory.getInterpreter("test.conf", executionContext) instanceof ConfInterpreter);
ConfInterpreter confInterpreter = (ConfInterpreter) interpreterFactory.getInterpreter("test.conf", executionContext);
InterpreterContext context = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
InterpreterResult result = confInterpreter.interpret("", context);
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
assertTrue(interpreterFactory.getInterpreter("test", executionContext) instanceof RemoteInterpreter);
RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("test", executionContext);
assertEquals(6, remoteInterpreter.getProperties().size());
assertEquals("value_1", remoteInterpreter.getProperty("property_1"));
assertEquals("value_3", remoteInterpreter.getProperty("property_3"));
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project SSM by Intel-bigdata.
the class InterpreterFactory method createRemoteRepl.
Interpreter createRemoteRepl(String interpreterPath, String interpreterSessionKey, String className, Properties property, String interpreterSettingId, String userName, Boolean isUserImpersonate, InterpreterRunner interpreterRunner) {
int connectTimeout = conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT);
String localRepoPath = conf.getInterpreterLocalRepoPath() + "/" + interpreterSettingId;
int maxPoolSize = conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_MAX_POOL_SIZE);
String interpreterRunnerPath;
if (null != interpreterRunner) {
interpreterRunnerPath = interpreterRunner.getPath();
Path p = Paths.get(interpreterRunnerPath);
if (!p.isAbsolute()) {
interpreterRunnerPath = Joiner.on(File.separator).join(interpreterPath, interpreterRunnerPath);
}
} else {
interpreterRunnerPath = conf.getInterpreterRemoteRunnerPath();
}
RemoteInterpreter remoteInterpreter = new RemoteInterpreter(property, interpreterSessionKey, className, interpreterRunnerPath, interpreterPath, localRepoPath, connectTimeout, maxPoolSize, remoteInterpreterProcessListener, appEventListener, userName, isUserImpersonate, conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_OUTPUT_LIMIT));
remoteInterpreter.addEnv(env);
return new LazyOpenInterpreter(remoteInterpreter);
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project zeppelin by apache.
the class Paragraph method recover.
public void recover() {
try {
LOGGER.info("Recovering paragraph: {}", getId());
this.interpreter = getBindedInterpreter();
InterpreterSetting interpreterSetting = ((ManagedInterpreterGroup) interpreter.getInterpreterGroup()).getInterpreterSetting();
Map<String, Object> config = interpreterSetting.getConfig(interpreter.getClassName());
mergeConfig(config);
if (shouldSkipRunParagraph()) {
LOGGER.info("Skip to run blank paragraph. {}", getId());
setStatus(Job.Status.FINISHED);
return;
}
setStatus(Status.READY);
localProperties.put("isRecover", "true");
for (List<Interpreter> sessions : this.interpreter.getInterpreterGroup().values()) {
for (Interpreter intp : sessions) {
// exclude ConfInterpreter
if (intp instanceof RemoteInterpreter) {
((RemoteInterpreter) intp).setOpened(true);
}
}
}
if (getConfig().get("enabled") == null || (Boolean) getConfig().get("enabled")) {
setAuthenticationInfo(getAuthenticationInfo());
interpreter.getScheduler().submit(this);
}
} catch (InterpreterNotFoundException e) {
InterpreterResult intpResult = new InterpreterResult(InterpreterResult.Code.ERROR, String.format("Interpreter %s not found", this.intpText));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
} catch (Throwable e) {
InterpreterResult intpResult = new InterpreterResult(InterpreterResult.Code.ERROR, "Unexpected exception: " + ExceptionUtils.getStackTrace(e));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
}
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project zeppelin by apache.
the class RemoteSchedulerTest method testAbortOnPending.
@Test
public void testAbortOnPending() throws Exception {
final RemoteInterpreter intpA = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", note1Id, "mock");
intpA.open();
Scheduler scheduler = intpA.getScheduler();
Job<Object> job1 = new Job<Object>("jobId1", "jobName1", null) {
Object results;
InterpreterContext context = InterpreterContext.builder().setNoteId("noteId").setParagraphId("jobId1").setResourcePool(new LocalResourcePool("pool1")).build();
@Override
public Object getReturn() {
return results;
}
@Override
public int progress() {
return 0;
}
@Override
public Map<String, Object> info() {
return null;
}
@Override
protected Object jobRun() throws Throwable {
intpA.interpret("1000", context);
return "1000";
}
@Override
protected boolean jobAbort() {
if (isRunning()) {
try {
intpA.cancel(context);
} catch (InterpreterException e) {
e.printStackTrace();
}
}
return true;
}
@Override
public void setResult(Object results) {
this.results = results;
}
};
Job<Object> job2 = new Job<Object>("jobId2", "jobName2", null) {
public Object results;
InterpreterContext context = InterpreterContext.builder().setNoteId("noteId").setParagraphId("jobId2").setResourcePool(new LocalResourcePool("pool1")).build();
@Override
public Object getReturn() {
return results;
}
@Override
public int progress() {
return 0;
}
@Override
public Map<String, Object> info() {
return null;
}
@Override
protected Object jobRun() throws Throwable {
intpA.interpret("1000", context);
return "1000";
}
@Override
protected boolean jobAbort() {
if (isRunning()) {
try {
intpA.cancel(context);
} catch (InterpreterException e) {
e.printStackTrace();
}
}
return true;
}
@Override
public void setResult(Object results) {
this.results = results;
}
};
job2.setResult("result2");
scheduler.submit(job1);
scheduler.submit(job2);
int cycles = 0;
while (!job1.isRunning() && cycles < MAX_WAIT_CYCLES) {
Thread.sleep(TICK_WAIT);
cycles++;
}
assertTrue(job1.isRunning());
assertEquals(Status.PENDING, job2.getStatus());
job2.abort();
cycles = 0;
while (!job1.isTerminated() && cycles < MAX_WAIT_CYCLES) {
Thread.sleep(TICK_WAIT);
cycles++;
}
assertNotNull(job1.getDateFinished());
assertTrue(job1.isTerminated());
assertNull(job2.getDateFinished());
assertTrue(job2.isTerminated());
assertEquals("result2", job2.getReturn());
intpA.close();
schedulerSvc.removeScheduler("test");
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project zeppelin by apache.
the class FileSystemRecoveryStorageTest method testMultipleInterpreterProcess.
@Test
public void testMultipleInterpreterProcess() throws InterpreterException, IOException {
InterpreterSetting interpreterSetting = interpreterSettingManager.getByName("test");
interpreterSetting.getOption().setPerUser(InterpreterOption.ISOLATED);
Interpreter interpreter1 = interpreterSetting.getDefaultInterpreter("user1", note1Id);
RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
InterpreterContext context1 = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
remoteInterpreter1.interpret("hello", context1);
assertEquals(1, interpreterSettingManager.getRecoveryStorage().restore().size());
Interpreter interpreter2 = interpreterSetting.getDefaultInterpreter("user2", note2Id);
RemoteInterpreter remoteInterpreter2 = (RemoteInterpreter) interpreter2;
InterpreterContext context2 = InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
remoteInterpreter2.interpret("hello", context2);
assertEquals(2, interpreterSettingManager.getRecoveryStorage().restore().size());
interpreterSettingManager.restart(interpreterSetting.getId(), "user1", note1Id);
assertEquals(1, interpreterSettingManager.getRecoveryStorage().restore().size());
interpreterSetting.close();
assertEquals(0, interpreterSettingManager.getRecoveryStorage().restore().size());
}
Aggregations