use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project zeppelin by apache.
the class LocalRecoveryStorageTest method testSingleInterpreterProcess.
@Test
public void testSingleInterpreterProcess() throws InterpreterException, IOException {
InterpreterSetting interpreterSetting = interpreterSettingManager.getByName("test");
interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED);
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());
interpreterSetting.close();
assertEquals(0, interpreterSettingManager.getRecoveryStorage().restore().size());
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project zeppelin by apache.
the class ConfInterpreterTest method testCorrectConf.
@Test
public void testCorrectConf() 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("property_1\tnew_value\nnew_property\tdummy_value", context);
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
assertTrue(interpreterFactory.getInterpreter("test", executionContext) instanceof RemoteInterpreter);
RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("test", executionContext);
remoteInterpreter.interpret("hello world", context);
assertEquals(7, remoteInterpreter.getProperties().size());
assertEquals("new_value", remoteInterpreter.getProperty("property_1"));
assertEquals("dummy_value", remoteInterpreter.getProperty("new_property"));
assertEquals("value_3", remoteInterpreter.getProperty("property_3"));
// rerun the paragraph with the same properties would result in SUCCESS
result = confInterpreter.interpret("property_1\tnew_value\nnew_property\tdummy_value", context);
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
// run the paragraph with the same properties would result in ERROR
result = confInterpreter.interpret("property_1\tnew_value_2\nnew_property\tdummy_value", context);
assertEquals(InterpreterResult.Code.ERROR, result.code);
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project zeppelin by apache.
the class SessionConfInterpreterTest method testUserSessionConfInterpreter.
@Test
public void testUserSessionConfInterpreter() throws InterpreterException {
InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
ManagedInterpreterGroup mockInterpreterGroup = mock(ManagedInterpreterGroup.class);
when(mockInterpreterSetting.getInterpreterGroup("group_1")).thenReturn(mockInterpreterGroup);
Properties properties = new Properties();
properties.setProperty("property_1", "value_1");
properties.setProperty("property_2", "value_2");
SessionConfInterpreter confInterpreter = new SessionConfInterpreter(properties, "session_1", "group_1", mockInterpreterSetting);
RemoteInterpreter remoteInterpreter = new RemoteInterpreter(properties, "session_1", "clasName", "user1");
List<Interpreter> interpreters = new ArrayList<>();
interpreters.add(confInterpreter);
interpreters.add(remoteInterpreter);
when(mockInterpreterGroup.get("session_1")).thenReturn(interpreters);
InterpreterResult result = confInterpreter.interpret("property_1\tupdated_value_1\nproperty_3\tvalue_3", mock(InterpreterContext.class));
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
assertEquals(3, remoteInterpreter.getProperties().size());
assertEquals("updated_value_1", remoteInterpreter.getProperty("property_1"));
assertEquals("value_2", remoteInterpreter.getProperty("property_2"));
assertEquals("value_3", remoteInterpreter.getProperty("property_3"));
remoteInterpreter.setOpened(true);
result = confInterpreter.interpret("property_1\tupdated_value_1\nproperty_3\tvalue_3", mock(InterpreterContext.class));
assertEquals(InterpreterResult.Code.ERROR, result.code);
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project SSM by Intel-bigdata.
the class DistributedResourcePoolTest method setUp.
@Before
public void setUp() throws Exception {
env = new HashMap<>();
env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath());
Properties p = new Properties();
intp1 = new RemoteInterpreter(p, "note", MockInterpreterResourcePool.class.getName(), new File(INTERPRETER_SCRIPT).getAbsolutePath(), "fake", "fakeRepo", env, 10 * 1000, null, null, "anonymous", false);
intpGroup1 = new InterpreterGroup("intpGroup1");
intpGroup1.put("note", new LinkedList<Interpreter>());
intpGroup1.get("note").add(intp1);
intp1.setInterpreterGroup(intpGroup1);
intp2 = new RemoteInterpreter(p, "note", MockInterpreterResourcePool.class.getName(), new File(INTERPRETER_SCRIPT).getAbsolutePath(), "fake", "fakeRepo", env, 10 * 1000, null, null, "anonymous", false);
intpGroup2 = new InterpreterGroup("intpGroup2");
intpGroup2.put("note", new LinkedList<Interpreter>());
intpGroup2.get("note").add(intp2);
intp2.setInterpreterGroup(intpGroup2);
context = new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), null, null, new LinkedList<InterpreterContextRunner>(), null);
intp1.open();
intp2.open();
eventPoller1 = new RemoteInterpreterEventPoller(null, null);
eventPoller1.setInterpreterGroup(intpGroup1);
eventPoller1.setInterpreterProcess(intpGroup1.getRemoteInterpreterProcess());
eventPoller2 = new RemoteInterpreterEventPoller(null, null);
eventPoller2.setInterpreterGroup(intpGroup2);
eventPoller2.setInterpreterProcess(intpGroup2.getRemoteInterpreterProcess());
eventPoller1.start();
eventPoller2.start();
}
use of org.apache.zeppelin.interpreter.remote.RemoteInterpreter in project SSM by Intel-bigdata.
the class RemoteSchedulerTest method test.
@Test
public void test() throws Exception {
Properties p = new Properties();
final InterpreterGroup intpGroup = new InterpreterGroup();
Map<String, String> env = new HashMap<>();
env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath());
final RemoteInterpreter intpA = new RemoteInterpreter(p, "note", MockInterpreterA.class.getName(), new File(INTERPRETER_SCRIPT).getAbsolutePath(), "fake", "fakeRepo", env, 10 * 1000, this, null, "anonymous", false);
intpGroup.put("note", new LinkedList<Interpreter>());
intpGroup.get("note").add(intpA);
intpA.setInterpreterGroup(intpGroup);
intpA.open();
Scheduler scheduler = schedulerSvc.createOrGetRemoteScheduler("test", "note", intpA.getInterpreterProcess(), 10);
Job job = new Job("jobId", "jobName", null, 200) {
Object results;
@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", new InterpreterContext("note", "jobId", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("pool1"), new LinkedList<InterpreterContextRunner>(), null));
return "1000";
}
@Override
protected boolean jobAbort() {
return false;
}
@Override
public void setResult(Object results) {
this.results = results;
}
};
scheduler.submit(job);
int cycles = 0;
while (!job.isRunning() && cycles < MAX_WAIT_CYCLES) {
Thread.sleep(TICK_WAIT);
cycles++;
}
assertTrue(job.isRunning());
Thread.sleep(5 * TICK_WAIT);
assertEquals(0, scheduler.getJobsWaiting().size());
assertEquals(1, scheduler.getJobsRunning().size());
cycles = 0;
while (!job.isTerminated() && cycles < MAX_WAIT_CYCLES) {
Thread.sleep(TICK_WAIT);
cycles++;
}
assertTrue(job.isTerminated());
assertEquals(0, scheduler.getJobsWaiting().size());
assertEquals(0, scheduler.getJobsRunning().size());
intpA.close();
schedulerSvc.removeScheduler("test");
}
Aggregations