use of org.apache.zeppelin.interpreter.remote.RemoteAngularObject in project zeppelin by apache.
the class RemoteInterpreterEventServer method updateAngularObject.
@Override
public void updateAngularObject(String intpGroupId, String json) throws InterpreterRPCException, TException {
AngularObject<?> angularObject = AngularObject.fromJson(json);
InterpreterGroup interpreterGroup = interpreterSettingManager.getInterpreterGroupById(intpGroupId);
if (interpreterGroup == null) {
throw new InterpreterRPCException("Invalid InterpreterGroupId: " + intpGroupId);
}
AngularObject localAngularObject = interpreterGroup.getAngularObjectRegistry().get(angularObject.getName(), angularObject.getNoteId(), angularObject.getParagraphId());
if (localAngularObject instanceof RemoteAngularObject) {
// to avoid ping-pong loop
((RemoteAngularObject) localAngularObject).set(angularObject.get(), true, false);
} else {
localAngularObject.set(angularObject.get());
}
if (angularObject.getNoteId() != null) {
try {
interpreterSettingManager.getNotebook().processNote(angularObject.getNoteId(), note -> {
if (note != null) {
note.addOrUpdateAngularObject(intpGroupId, angularObject);
interpreterSettingManager.getNotebook().saveNote(note, AuthenticationInfo.ANONYMOUS);
}
return null;
});
} catch (IOException e) {
LOGGER.error("Fail to get note: {}", angularObject.getNoteId());
}
}
}
use of org.apache.zeppelin.interpreter.remote.RemoteAngularObject in project zeppelin by apache.
the class Note method deleteAngularObject.
/**
* Delete the note AngularObject.
*/
public void deleteAngularObject(String intpGroupId, String noteId, String paragraphId, String name) {
if (angularObjects.containsKey(intpGroupId)) {
// Delete existing AngularObject
Iterator<AngularObject> iter = angularObjects.get(intpGroupId).iterator();
while (iter.hasNext()) {
String noteIdCandidate = "";
String paragraphIdCandidate = "";
String nameCandidate = "";
Object object = iter.next();
if (object instanceof AngularObject) {
AngularObject ao = (AngularObject) object;
noteIdCandidate = ao.getNoteId();
paragraphIdCandidate = ao.getParagraphId();
nameCandidate = ao.getName();
} else if (object instanceof RemoteAngularObject) {
RemoteAngularObject rao = (RemoteAngularObject) object;
noteIdCandidate = rao.getNoteId();
paragraphIdCandidate = rao.getParagraphId();
nameCandidate = rao.getName();
} else {
continue;
}
if (StringUtils.equals(noteId, noteIdCandidate) && StringUtils.equals(paragraphId, paragraphIdCandidate) && StringUtils.equals(name, nameCandidate)) {
iter.remove();
}
}
}
}
use of org.apache.zeppelin.interpreter.remote.RemoteAngularObject in project zeppelin by apache.
the class Note method addOrUpdateAngularObject.
/**
* Add or update the note AngularObject.
*/
public void addOrUpdateAngularObject(String intpGroupId, AngularObject angularObject) {
List<AngularObject> angularObjectList;
if (!angularObjects.containsKey(intpGroupId)) {
angularObjectList = new ArrayList<>();
angularObjects.put(intpGroupId, angularObjectList);
} else {
angularObjectList = angularObjects.get(intpGroupId);
// Delete existing AngularObject
Iterator<AngularObject> iter = angularObjectList.iterator();
while (iter.hasNext()) {
String noteId = "";
String paragraphId = "";
String name = "";
Object object = iter.next();
if (object instanceof AngularObject) {
AngularObject ao = (AngularObject) object;
noteId = ao.getNoteId();
paragraphId = ao.getParagraphId();
name = ao.getName();
} else if (object instanceof RemoteAngularObject) {
RemoteAngularObject rao = (RemoteAngularObject) object;
noteId = rao.getNoteId();
paragraphId = rao.getParagraphId();
name = rao.getName();
} else {
continue;
}
if (StringUtils.equals(noteId, angularObject.getNoteId()) && StringUtils.equals(paragraphId, angularObject.getParagraphId()) && StringUtils.equals(name, angularObject.getName())) {
iter.remove();
}
}
}
angularObjectList.add(angularObject);
}
Aggregations