use of org.apache.zeppelin.display.AngularObjectWatcher in project zeppelin by apache.
the class ZeppelinContext method angularWatch.
private void angularWatch(String name, String noteId, final scala.Function3<Object, Object, InterpreterContext, Unit> func) {
AngularObjectWatcher w = new AngularObjectWatcher(getInterpreterContext()) {
@Override
public void watch(Object oldObject, Object newObject, InterpreterContext context) {
func.apply(oldObject, newObject, context);
}
};
angularWatch(name, noteId, w);
}
use of org.apache.zeppelin.display.AngularObjectWatcher 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);
}
use of org.apache.zeppelin.display.AngularObjectWatcher in project zeppelin by apache.
the class ZeppelinContext method angularWatch.
private void angularWatch(String name, String noteId, final scala.Function2<Object, Object, Unit> func) {
AngularObjectWatcher w = new AngularObjectWatcher(getInterpreterContext()) {
@Override
public void watch(Object oldObject, Object newObject, InterpreterContext context) {
func.apply(newObject, newObject);
}
};
angularWatch(name, noteId, w);
}
Aggregations