Skip to content

Commit

Permalink
[ZEPPELIN-680] Cron job will run cells that have had their run disabled
Browse files Browse the repository at this point in the history
### What is this PR for?
When I run a cron job, cells that I have selected the "disable run" option will still run.
This PR fixes the problem.

### What type of PR is it?
Bug Fix

### Todos
* [x] - exclude disabled paragraph from runAll

### Is there a relevant Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-680?jql=project%20%3D%20ZEPPELIN

### How should this be tested?
Create paragraph and disable it.
Then enable cron scheduling a notebook.
The paragraph supposed to not run.

### Screenshots (if appropriate)
N/A

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Lee moon soo <[email protected]>

Closes apache#730 from Leemoonsoo/ZEPPELIN-680 and squashes the following commits:

ced9aee [Lee moon soo] Exclude disabled paragraph from runAll
  • Loading branch information
Leemoonsoo committed Feb 23, 2016
1 parent 7a1f921 commit e0fa386
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ public List<Map<String, String>> generateParagraphsInfo (){
public void runAll() {
synchronized (paragraphs) {
for (Paragraph p : paragraphs) {
if (!p.isEnabled()) {
continue;
}
p.setNoteReplLoader(replLoader);
p.setListener(jobListenerFactory.getParagraphJobListener(this));
Interpreter intp = replLoader.get(p.getRequiredReplName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public Note getNote() {
return note;
}

public boolean isEnabled() {
Boolean enabled = (Boolean) config.get("enabled");
return enabled == null || enabled.booleanValue();
}

public String getRequiredReplName() {
return getRequiredReplName(text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,38 @@ public void testClearParagraphOutput() throws IOException, SchedulerException{
public void testRunAll() throws IOException {
Note note = notebook.createNote();
note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList());

// p1
Paragraph p1 = note.addParagraph();
Map config = p1.getConfig();
config.put("enabled", true);
p1.setConfig(config);
Map config1 = p1.getConfig();
config1.put("enabled", true);
p1.setConfig(config1);
p1.setText("p1");

// p2
Paragraph p2 = note.addParagraph();
Map config1 = p2.getConfig();
p2.setConfig(config1);
Map config2 = p2.getConfig();
config2.put("enabled", false);
p2.setConfig(config2);
p2.setText("p2");
assertEquals(null, p2.getResult());

// p3
Paragraph p3 = note.addParagraph();
p3.setText("p3");

// when
note.runAll();

while(p2.isTerminated()==false || p2.getResult()==null) Thread.yield();
assertEquals("repl1: p2", p2.getResult().message());
// wait for finish
while(p3.isTerminated()==false) {
Thread.yield();
}

assertEquals("repl1: p1", p1.getResult().message());
assertNull(p2.getResult());
assertEquals("repl1: p3", p3.getResult().message());

notebook.removeNote(note.getId());
}

@Test
Expand Down

0 comments on commit e0fa386

Please sign in to comment.