Repository: zeppelin Updated Branches: refs/heads/branch-0.6 6b825cdca -> c1d0870ae
[ZEPPELIN-1426] User aware storage sync This is to make storage layer sync function aware of the user Improvement * [x] - change function and test [ZEPPELIN-1426](https://issues.apache.org/jira/browse/ZEPPELIN-1426) corresponding storage layer tests should pass * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Khalid Huseynov <[email protected]> Closes #1424 from khalidhuseynov/storage/sync-with-subject and squashes the following commits: 7cc8455 [Khalid Huseynov] propagate subject to sync() (cherry picked from commit 64190707f7ba1458e77fcf83a1b1e8004efa48ad) Signed-off-by: Lee moon soo <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/c1d0870a Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/c1d0870a Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/c1d0870a Branch: refs/heads/branch-0.6 Commit: c1d0870ae8b001c08dc5b6902ea25d34cf2ce049 Parents: 6b825cd Author: Khalid Huseynov <[email protected]> Authored: Mon Sep 12 14:41:01 2016 +0900 Committer: Lee moon soo <[email protected]> Committed: Thu Sep 15 16:24:00 2016 -0700 ---------------------------------------------------------------------- .../org/apache/zeppelin/notebook/Notebook.java | 2 +- .../notebook/repo/NotebookRepoSync.java | 21 ++++++++++---------- .../notebook/repo/NotebookRepoSyncTest.java | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c1d0870a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java index d5760c2..50505ed 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java @@ -431,7 +431,7 @@ public class Notebook { if (notebookRepo instanceof NotebookRepoSync) { NotebookRepoSync mainRepo = (NotebookRepoSync) notebookRepo; if (mainRepo.getRepoCount() > 1) { - mainRepo.sync(); + mainRepo.sync(subject); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c1d0870a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java index b396da0..b427040 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java @@ -89,7 +89,8 @@ public class NotebookRepoSync implements NotebookRepo { } if (getRepoCount() > 1) { try { - sync(0, 1); + AuthenticationInfo subject = new AuthenticationInfo("anonymous"); + sync(0, 1, subject); } catch (IOException e) { LOG.warn("Failed to sync with secondary storage on start {}", e); } @@ -171,12 +172,12 @@ public class NotebookRepoSync implements NotebookRepo { * * @throws IOException */ - void sync(int sourceRepoIndex, int destRepoIndex) throws IOException { + void sync(int sourceRepoIndex, int destRepoIndex, AuthenticationInfo subject) throws IOException { LOG.info("Sync started"); NotebookRepo srcRepo = getRepo(sourceRepoIndex); NotebookRepo dstRepo = getRepo(destRepoIndex); - List <NoteInfo> srcNotes = srcRepo.list(null); - List <NoteInfo> dstNotes = dstRepo.list(null); + List <NoteInfo> srcNotes = srcRepo.list(subject); + List <NoteInfo> dstNotes = dstRepo.list(subject); Map<String, List<String>> noteIDs = notesCheckDiff(srcNotes, srcRepo, dstNotes, dstRepo); List<String> pushNoteIDs = noteIDs.get(pushKey); @@ -186,7 +187,7 @@ public class NotebookRepoSync implements NotebookRepo { for (String id : pushNoteIDs) { LOG.info("ID : " + id); } - pushNotes(pushNoteIDs, srcRepo, dstRepo); + pushNotes(subject, pushNoteIDs, srcRepo, dstRepo); } else { LOG.info("Nothing to push"); } @@ -196,7 +197,7 @@ public class NotebookRepoSync implements NotebookRepo { for (String id : pullNoteIDs) { LOG.info("ID : " + id); } - pushNotes(pullNoteIDs, dstRepo, srcRepo); + pushNotes(subject, pullNoteIDs, dstRepo, srcRepo); } else { LOG.info("Nothing to pull"); } @@ -204,14 +205,14 @@ public class NotebookRepoSync implements NotebookRepo { LOG.info("Sync ended"); } - public void sync() throws IOException { - sync(0, 1); + public void sync(AuthenticationInfo subject) throws IOException { + sync(0, 1, subject); } - private void pushNotes(List<String> ids, NotebookRepo localRepo, + private void pushNotes(AuthenticationInfo subject, List<String> ids, NotebookRepo localRepo, NotebookRepo remoteRepo) throws IOException { for (String id : ids) { - remoteRepo.save(localRepo.get(id, null), null); + remoteRepo.save(localRepo.get(id, subject), subject); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c1d0870a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java index fe7e3fc..03e322e 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java @@ -184,7 +184,7 @@ public class NotebookRepoSyncTest implements JobListenerFactory { assertEquals(0, notebookRepoSync.get(1, notebookRepoSync.list(1, null).get(0).getId(), null).getParagraphs().size()); /* apply sync */ - notebookRepoSync.sync(); + notebookRepoSync.sync(null); /* check whether added to second storage */ assertEquals(1, notebookRepoSync.get(1, notebookRepoSync.list(1, null).get(0).getId(), null).getParagraphs().size());
