Search in sources :

Example 11 with InterpreterContext

use of org.apache.zeppelin.interpreter.InterpreterContext in project zeppelin by apache.

the class PigInterpreterTest method setUpLocal.

private void setUpLocal(boolean includeJobStats) {
    Properties properties = new Properties();
    properties.put("zeppelin.pig.execType", "local");
    properties.put("zeppelin.pig.includeJobStats", includeJobStats + "");
    pigInterpreter = new PigInterpreter(properties);
    pigInterpreter.open();
    context = new InterpreterContext(null, "paragraph_id", null, null, null, null, null, null, null, null, null, null);
}
Also used : Properties(java.util.Properties) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext)

Example 12 with InterpreterContext

use of org.apache.zeppelin.interpreter.InterpreterContext in project zeppelin by apache.

the class PigInterpreterTezTest method setUpTez.

public void setUpTez(boolean includeJobStats) {
    Properties properties = new Properties();
    properties.put("zeppelin.pig.execType", "tez_local");
    properties.put("zeppelin.pig.includeJobStats", includeJobStats + "");
    properties.put("tez.queue.name", "test");
    pigInterpreter = new PigInterpreter(properties);
    pigInterpreter.open();
    context = new InterpreterContext(null, "paragraph_id", null, null, null, null, null, null, null, null, null, null);
}
Also used : Properties(java.util.Properties) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext)

Example 13 with InterpreterContext

use of org.apache.zeppelin.interpreter.InterpreterContext in project zeppelin by apache.

the class JDBCInterpreterTest method testMultiTenant.

@Test
public void testMultiTenant() throws SQLException, IOException {
    /**
     * assume that the database user is 'dbuser' and password is 'dbpassword'
     * 'jdbc1' interpreter has user('dbuser')/password('dbpassword') property
     * 'jdbc2' interpreter doesn't have user/password property
     * 'user1' doesn't have Credential information.
     * 'user2' has 'jdbc2' Credential information that is same with database account.
     */
    JDBCInterpreter jdbc1 = new JDBCInterpreter(getDBProperty("dbuser", "dbpassword"));
    JDBCInterpreter jdbc2 = new JDBCInterpreter(getDBProperty(null, null));
    AuthenticationInfo user1Credential = getUserAuth("user1", null, null, null);
    AuthenticationInfo user2Credential = getUserAuth("user2", "jdbc.jdbc2", "dbuser", "dbpassword");
    // user1 runs jdbc1
    jdbc1.open();
    InterpreterContext ctx1 = new InterpreterContext("", "1", "jdbc.jdbc1", "", "", user1Credential, null, null, null, null, null, null);
    jdbc1.interpret("", ctx1);
    JDBCUserConfigurations user1JDBC1Conf = jdbc1.getJDBCConfiguration("user1");
    assertEquals("dbuser", user1JDBC1Conf.getPropertyMap("default").get("user"));
    assertEquals("dbpassword", user1JDBC1Conf.getPropertyMap("default").get("password"));
    jdbc1.close();
    // user1 runs jdbc2
    jdbc2.open();
    InterpreterContext ctx2 = new InterpreterContext("", "1", "jdbc.jdbc2", "", "", user1Credential, null, null, null, null, null, null);
    jdbc2.interpret("", ctx2);
    JDBCUserConfigurations user1JDBC2Conf = jdbc2.getJDBCConfiguration("user1");
    assertNull(user1JDBC2Conf.getPropertyMap("default").get("user"));
    assertNull(user1JDBC2Conf.getPropertyMap("default").get("password"));
    jdbc2.close();
    // user2 runs jdbc1
    jdbc1.open();
    InterpreterContext ctx3 = new InterpreterContext("", "1", "jdbc.jdbc1", "", "", user2Credential, null, null, null, null, null, null);
    jdbc1.interpret("", ctx3);
    JDBCUserConfigurations user2JDBC1Conf = jdbc1.getJDBCConfiguration("user2");
    assertEquals("dbuser", user2JDBC1Conf.getPropertyMap("default").get("user"));
    assertEquals("dbpassword", user2JDBC1Conf.getPropertyMap("default").get("password"));
    jdbc1.close();
    // user2 runs jdbc2
    jdbc2.open();
    InterpreterContext ctx4 = new InterpreterContext("", "1", "jdbc.jdbc2", "", "", user2Credential, null, null, null, null, null, null);
    jdbc2.interpret("", ctx4);
    JDBCUserConfigurations user2JDBC2Conf = jdbc2.getJDBCConfiguration("user2");
    assertNull(user2JDBC2Conf.getPropertyMap("default").get("user"));
    assertNull(user2JDBC2Conf.getPropertyMap("default").get("password"));
    jdbc2.close();
}
Also used : InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) Test(org.junit.Test)

Example 14 with InterpreterContext

use of org.apache.zeppelin.interpreter.InterpreterContext in project zeppelin by apache.

the class FlinkInterpreterTest method setUp.

@BeforeClass
public static void setUp() {
    Properties p = new Properties();
    flink = new FlinkInterpreter(p);
    flink.open();
    context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null, null);
}
Also used : Properties(java.util.Properties) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) BeforeClass(org.junit.BeforeClass)

Example 15 with InterpreterContext

use of org.apache.zeppelin.interpreter.InterpreterContext in project zeppelin by apache.

the class MockInterpreterAngular method interpret.

@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
    String[] stmt = st.split(" ");
    String cmd = stmt[0];
    String name = null;
    if (stmt.length >= 2) {
        name = stmt[1];
    }
    String value = null;
    if (stmt.length == 3) {
        value = stmt[2];
    }
    AngularObjectRegistry registry = context.getAngularObjectRegistry();
    if (cmd.equals("add")) {
        registry.add(name, value, context.getNoteId(), null);
        registry.get(name, context.getNoteId(), null).addWatcher(new AngularObjectWatcher(null) {

            @Override
            public void watch(Object oldObject, Object newObject, InterpreterContext context) {
                numWatch.incrementAndGet();
            }
        });
    } else if (cmd.equalsIgnoreCase("update")) {
        registry.get(name, context.getNoteId(), null).set(value);
    } else if (cmd.equals("remove")) {
        registry.remove(name, context.getNoteId(), null);
    }
    try {
        // wait for watcher executed
        Thread.sleep(500);
    } catch (InterruptedException e) {
        logger.error("Exception in MockInterpreterAngular while interpret Thread.sleep", e);
    }
    String msg = registry.getAll(context.getNoteId(), null).size() + " " + Integer.toString(numWatch.get());
    return new InterpreterResult(Code.SUCCESS, msg);
}
Also used : AngularObjectWatcher(org.apache.zeppelin.display.AngularObjectWatcher) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry)

Aggregations

InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)21 Properties (java.util.Properties)9 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 Before (org.junit.Before)7 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)6 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)5 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)5 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 GUI (org.apache.zeppelin.display.GUI)4 Theory (org.junit.experimental.theories.Theory)4 AngularObjectWatcher (org.apache.zeppelin.display.AngularObjectWatcher)3 Interpreter (org.apache.zeppelin.interpreter.Interpreter)3 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)3 LocalResourcePool (org.apache.zeppelin.resource.LocalResourcePool)3 AngularObject (org.apache.zeppelin.display.AngularObject)2 BeforeClass (org.junit.BeforeClass)2 Test (org.junit.Test)2 File (java.io.File)1 IOException (java.io.IOException)1