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);
}
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);
}
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();
}
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);
}
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);
}
Aggregations