You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2018/09/18 00:46:12 UTC
zeppelin git commit: [ZEPPELIN-3691] Scheduled note continues to work
in the trash
Repository: zeppelin
Updated Branches:
refs/heads/master 86dabd77b -> 76ac96142
[ZEPPELIN-3691] Scheduled note continues to work in the trash
### What is this PR for?
Fix bug with scheduled note working in the trash.
How to repeat bug:
1. Make scheduled note with cron;
2. Move it to trash;
3. Restart zeppelin.
### What type of PR is it?
Bug Fix
### What is the Jira issue?
[ZEPPELIN-3691](https://issues.apache.org/jira/browse/ZEPPELIN-3691)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: oxygen311 <al...@mail.ru>
Closes #3117 from oxygen311/DW-17950 and squashes the following commits:
074613701 [oxygen311] Merge branch 'master' of https://github.com/apache/zeppelin into DW-17950-cronTrash
27f92e29f [oxygen311] Add test for cron note in trash
b3e7d0c99 [oxygen311] Check is note in trash in `refreshCron`
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/76ac9614
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/76ac9614
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/76ac9614
Branch: refs/heads/master
Commit: 76ac9614234ac0ed9107a3bac9f1c2bf2aa2c349
Parents: 86dabd7
Author: oxygen311 <al...@mail.ru>
Authored: Mon Aug 20 13:12:14 2018 +0200
Committer: Jeff Zhang <zj...@apache.org>
Committed: Tue Sep 18 08:46:08 2018 +0800
----------------------------------------------------------------------
.../org/apache/zeppelin/notebook/Notebook.java | 4 ++--
.../apache/zeppelin/notebook/NotebookTest.java | 23 ++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/76ac9614/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 bb7ad1f..7c849d2 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
@@ -83,7 +83,7 @@ public class Notebook implements NoteEventListener {
private final FolderView folders = new FolderView();
private ZeppelinConfiguration conf;
private StdSchedulerFactory quertzSchedFact;
- private org.quartz.Scheduler quartzSched;
+ org.quartz.Scheduler quartzSched;
private ParagraphJobListener paragraphJobListener;
private NotebookRepo notebookRepo;
private SearchService noteSearchService;
@@ -676,7 +676,7 @@ public class Notebook implements NoteEventListener {
synchronized (notes) {
Note note = notes.get(id);
- if (note == null) {
+ if (note == null || note.isTrash()) {
return;
}
Map<String, Object> config = note.getConfig();
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/76ac9614/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
index 6de2822..5b30211 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
@@ -44,6 +44,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.quartz.SchedulerException;
+import org.quartz.impl.matchers.GroupMatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.RepositoryException;
@@ -781,6 +782,28 @@ public class NotebookTest extends AbstractInterpreterTest implements ParagraphJo
}
@Test
+ public void testCronNoteInTrash() throws InterruptedException, IOException, SchedulerException {
+ Note note = notebook.createNote(anonymous);
+ note.setName("~Trash/NotCron");
+
+ Map<String, Object> config = note.getConfig();
+ config.put("enabled", true);
+ config.put("cron", "* * * * * ?");
+ note.setConfig(config);
+
+ final int jobsBeforeRefresh = notebook.quartzSched.getJobKeys(GroupMatcher.anyGroup()).size();
+ notebook.refreshCron(note.getId());
+ final int jobsAfterRefresh = notebook.quartzSched.getJobKeys(GroupMatcher.anyGroup()).size();
+
+ assertEquals(jobsBeforeRefresh, jobsAfterRefresh);
+
+ // remove cron scheduler.
+ config.remove("cron");
+ notebook.refreshCron(note.getId());
+ notebook.removeNote(note.getId(), anonymous);
+ }
+
+ @Test
public void testExportAndImportNote() throws IOException, CloneNotSupportedException,
InterruptedException, InterpreterException, SchedulerException, RepositoryException {
Note note = notebook.createNote(anonymous);