Search in sources :

Example 1 with GUI

use of org.apache.zeppelin.display.GUI in project zeppelin by apache.

the class DepInterpreterTest method setUp.

@Before
public void setUp() throws Exception {
    Properties p = getTestProperties();
    dep = new DepInterpreter(p);
    dep.open();
    InterpreterGroup intpGroup = new InterpreterGroup();
    intpGroup.put("note", new LinkedList<Interpreter>());
    intpGroup.get("note").add(new SparkInterpreter(p));
    intpGroup.get("note").add(dep);
    dep.setInterpreterGroup(intpGroup);
    context = new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), null, new LinkedList<InterpreterContextRunner>(), null);
}
Also used : HashMap(java.util.HashMap) GUI(org.apache.zeppelin.display.GUI) Properties(java.util.Properties) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Example 2 with GUI

use of org.apache.zeppelin.display.GUI in project zeppelin by apache.

the class SparkInterpreterTest method testParagraphUrls.

@Test
public void testParagraphUrls() {
    String paraId = "test_para_job_url";
    InterpreterContext intpCtx = new InterpreterContext("note", paraId, null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("id"), new LinkedList<InterpreterContextRunner>(), new InterpreterOutput(null));
    repl.interpret("sc.parallelize(1 to 10).map(x => {x}).collect", intpCtx);
    Map<String, String> paraInfos = paraIdToInfosMap.get(intpCtx.getParagraphId());
    String jobUrl = null;
    if (paraInfos != null) {
        jobUrl = paraInfos.get("jobUrl");
    }
    String sparkUIUrl = repl.getSparkUIUrl();
    assertNotNull(jobUrl);
    assertTrue(jobUrl.startsWith(sparkUIUrl + "/jobs/job?id="));
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) GUI(org.apache.zeppelin.display.GUI) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry)

Example 3 with GUI

use of org.apache.zeppelin.display.GUI in project zeppelin by apache.

the class RemoteInterpreterTest method testRemoteInterperterCall.

@Test
public void testRemoteInterperterCall() throws TTransportException, IOException {
    Properties p = new Properties();
    intpGroup.put("note", new LinkedList<Interpreter>());
    RemoteInterpreter intpA = createMockInterpreterA(p);
    intpGroup.get("note").add(intpA);
    intpA.setInterpreterGroup(intpGroup);
    RemoteInterpreter intpB = createMockInterpreterB(p);
    intpGroup.get("note").add(intpB);
    intpB.setInterpreterGroup(intpGroup);
    RemoteInterpreterProcess process = intpA.getInterpreterProcess();
    process.equals(intpB.getInterpreterProcess());
    assertFalse(process.isRunning());
    assertEquals(0, process.getNumIdleClient());
    assertEquals(0, process.referenceCount());
    // initializa all interpreters in the same group
    intpA.open();
    assertTrue(process.isRunning());
    assertEquals(1, process.getNumIdleClient());
    assertEquals(2, process.referenceCount());
    intpA.interpret("1", new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("pool1"), new LinkedList<InterpreterContextRunner>(), null));
    intpB.open();
    assertEquals(2, process.referenceCount());
    intpA.close();
    assertEquals(1, process.referenceCount());
    intpB.close();
    assertEquals(0, process.referenceCount());
    assertFalse(process.isRunning());
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) HashMap(java.util.HashMap) GUI(org.apache.zeppelin.display.GUI) Properties(java.util.Properties) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with GUI

use of org.apache.zeppelin.display.GUI in project zeppelin by apache.

the class RemoteInterpreterTest method testInterpreterGroupResetDuringProcessRunning.

@Test
public void testInterpreterGroupResetDuringProcessRunning() throws InterruptedException {
    Properties p = new Properties();
    intpGroup.put("note", new LinkedList<Interpreter>());
    final RemoteInterpreter intpA = createMockInterpreterA(p);
    intpGroup.get("note").add(intpA);
    intpA.setInterpreterGroup(intpGroup);
    intpA.open();
    Job jobA = new Job("jobA", null) {

        private Object r;

        @Override
        public Object getReturn() {
            return r;
        }

        @Override
        public void setResult(Object results) {
            this.r = results;
        }

        @Override
        public int progress() {
            return 0;
        }

        @Override
        public Map<String, Object> info() {
            return null;
        }

        @Override
        protected Object jobRun() throws Throwable {
            return intpA.interpret("2000", new InterpreterContext("note", "jobA", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("pool1"), new LinkedList<InterpreterContextRunner>(), null));
        }

        @Override
        protected boolean jobAbort() {
            return false;
        }
    };
    intpA.getScheduler().submit(jobA);
    // wait for job started
    while (intpA.getScheduler().getJobsRunning().size() == 0) {
        Thread.sleep(100);
    }
    // restart interpreter
    RemoteInterpreterProcess processA = intpA.getInterpreterProcess();
    intpA.close();
    InterpreterGroup newInterpreterGroup = new InterpreterGroup(intpA.getInterpreterGroup().getId());
    newInterpreterGroup.put("note", new LinkedList<Interpreter>());
    intpA.setInterpreterGroup(newInterpreterGroup);
    intpA.open();
    RemoteInterpreterProcess processB = intpA.getInterpreterProcess();
    assertNotSame(processA.hashCode(), processB.hashCode());
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) HashMap(java.util.HashMap) Properties(java.util.Properties) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) LinkedList(java.util.LinkedList) AngularObject(org.apache.zeppelin.display.AngularObject) GUI(org.apache.zeppelin.display.GUI) Job(org.apache.zeppelin.scheduler.Job) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) Test(org.junit.Test)

Example 5 with GUI

use of org.apache.zeppelin.display.GUI in project zeppelin by apache.

the class RemoteInterpreterTest method testRunParallel.

@Test
public void testRunParallel() throws InterruptedException {
    Properties p = new Properties();
    p.put("parallel", "true");
    intpGroup.put("note", new LinkedList<Interpreter>());
    final RemoteInterpreter intpA = createMockInterpreterA(p);
    intpGroup.get("note").add(intpA);
    intpA.setInterpreterGroup(intpGroup);
    intpA.open();
    int concurrency = 4;
    final int timeToSleep = 1000;
    final List<InterpreterResultMessage> results = new LinkedList<>();
    long start = System.currentTimeMillis();
    Scheduler scheduler = intpA.getScheduler();
    for (int i = 0; i < concurrency; i++) {
        final String jobId = Integer.toString(i);
        scheduler.submit(new Job(jobId, Integer.toString(i), null, 300) {

            private Object r;

            @Override
            public Object getReturn() {
                return r;
            }

            @Override
            public void setResult(Object results) {
                this.r = results;
            }

            @Override
            public int progress() {
                return 0;
            }

            @Override
            public Map<String, Object> info() {
                return null;
            }

            @Override
            protected Object jobRun() throws Throwable {
                String stmt = Integer.toString(timeToSleep);
                InterpreterResult ret = intpA.interpret(stmt, 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));
                synchronized (results) {
                    results.addAll(ret.message());
                    results.notify();
                }
                return stmt;
            }

            @Override
            protected boolean jobAbort() {
                return false;
            }
        });
    }
    // wait for job finished
    synchronized (results) {
        while (results.size() != concurrency) {
            results.wait(300);
        }
    }
    long end = System.currentTimeMillis();
    assertTrue(end - start < timeToSleep * concurrency);
    intpA.close();
}
Also used : LocalResourcePool(org.apache.zeppelin.resource.LocalResourcePool) Scheduler(org.apache.zeppelin.scheduler.Scheduler) Properties(java.util.Properties) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) GUI(org.apache.zeppelin.display.GUI) Job(org.apache.zeppelin.scheduler.Job) RemoteInterpreterResultMessage(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterResultMessage) LinkedList(java.util.LinkedList) AngularObject(org.apache.zeppelin.display.AngularObject) HashMap(java.util.HashMap) Map(java.util.Map) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) Test(org.junit.Test)

Aggregations

GUI (org.apache.zeppelin.display.GUI)30 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)22 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)22 LocalResourcePool (org.apache.zeppelin.resource.LocalResourcePool)20 Test (org.junit.Test)20 HashMap (java.util.HashMap)19 LinkedList (java.util.LinkedList)19 Properties (java.util.Properties)19 AngularObject (org.apache.zeppelin.display.AngularObject)14 Job (org.apache.zeppelin.scheduler.Job)8 File (java.io.File)7 Map (java.util.Map)6 MockInterpreterA (org.apache.zeppelin.interpreter.remote.mock.MockInterpreterA)4 RemoteInterpreterResultMessage (org.apache.zeppelin.interpreter.thrift.RemoteInterpreterResultMessage)4 Scheduler (org.apache.zeppelin.scheduler.Scheduler)4 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)3 RemoteInterpreter (org.apache.zeppelin.interpreter.remote.RemoteInterpreter)3 Before (org.junit.Before)3 Message (org.apache.zeppelin.common.Message)2 Interpreter (org.apache.zeppelin.interpreter.Interpreter)2