Rework sync with secondary storage when reload notebooks

- Address @khalidhuseynov comment
This commit is contained in:
Mina Lee 2015-12-28 21:00:49 -08:00
parent 5423e3c160
commit 64e1a28c04
2 changed files with 10 additions and 1 deletions

View file

@ -38,6 +38,7 @@ import org.apache.zeppelin.interpreter.InterpreterGroup;
import org.apache.zeppelin.interpreter.InterpreterSetting;
import org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry;
import org.apache.zeppelin.notebook.repo.NotebookRepo;
import org.apache.zeppelin.notebook.repo.NotebookRepoSync;
import org.apache.zeppelin.scheduler.SchedulerFactory;
import org.apache.zeppelin.search.SearchService;
import org.quartz.CronScheduleBuilder;
@ -334,6 +335,14 @@ public class Notebook {
synchronized (notes) {
notes.clear();
}
if (notebookRepo instanceof NotebookRepoSync) {
NotebookRepoSync mainRepo = (NotebookRepoSync) notebookRepo;
if (mainRepo.getRepoCount() > 1) {
mainRepo.sync();
}
}
List<NoteInfo> noteInfos = notebookRepo.list();
for (NoteInfo info : noteInfos) {
loadNoteFromRepo(info.getId());

View file

@ -176,7 +176,7 @@ public class NotebookRepoSync implements NotebookRepo {
}
}
int getRepoCount() {
public int getRepoCount() {
return repos.size();
}