mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Fix more code not changed (notebookIndex to noteSearchService)
This commit is contained in:
parent
4b4e1e8e5b
commit
24822a3253
3 changed files with 44 additions and 42 deletions
|
|
@ -74,7 +74,7 @@ public class ZeppelinServer extends Application {
|
|||
private SchedulerFactory schedulerFactory;
|
||||
private InterpreterFactory replFactory;
|
||||
private NotebookRepo notebookRepo;
|
||||
private SearchService notebookIndex;
|
||||
private SearchService noteSearchService;
|
||||
private NotebookAuthorization notebookAuthorization;
|
||||
private Credentials credentials;
|
||||
private DependencyResolver depResolver;
|
||||
|
|
@ -91,12 +91,12 @@ public class ZeppelinServer extends Application {
|
|||
this.replFactory = new InterpreterFactory(conf, notebookWsServer,
|
||||
notebookWsServer, heliumApplicationFactory, depResolver);
|
||||
this.notebookRepo = new NotebookRepoSync(conf);
|
||||
this.notebookIndex = new LuceneSearch();
|
||||
this.noteSearchService = new LuceneSearch();
|
||||
this.notebookAuthorization = NotebookAuthorization.init(conf);
|
||||
this.credentials = new Credentials(conf.credentialsPersist(), conf.getCredentialsPath());
|
||||
notebook = new Notebook(conf,
|
||||
notebookRepo, schedulerFactory, replFactory, notebookWsServer,
|
||||
notebookIndex, notebookAuthorization, credentials);
|
||||
noteSearchService, notebookAuthorization, credentials);
|
||||
|
||||
// to update notebook from application event from remote process.
|
||||
heliumApplicationFactory.setNotebook(notebook);
|
||||
|
|
@ -304,7 +304,8 @@ public class ZeppelinServer extends Application {
|
|||
ZeppelinRestApi root = new ZeppelinRestApi();
|
||||
singletons.add(root);
|
||||
|
||||
NotebookRestApi notebookApi = new NotebookRestApi(notebook, notebookWsServer, notebookIndex);
|
||||
NotebookRestApi notebookApi
|
||||
= new NotebookRestApi(notebook, notebookWsServer, noteSearchService);
|
||||
singletons.add(notebookApi);
|
||||
|
||||
HeliumRestApi heliumApi = new HeliumRestApi(helium, heliumApplicationFactory, notebook);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public class Notebook implements NoteEventListener {
|
|||
private org.quartz.Scheduler quartzSched;
|
||||
private JobListenerFactory jobListenerFactory;
|
||||
private NotebookRepo notebookRepo;
|
||||
private SearchService notebookIndex;
|
||||
private SearchService noteSearchService;
|
||||
private NotebookAuthorization notebookAuthorization;
|
||||
private final List<NotebookEventListener> notebookEventListeners =
|
||||
Collections.synchronizedList(new LinkedList<NotebookEventListener>());
|
||||
|
|
@ -96,13 +96,13 @@ public class Notebook implements NoteEventListener {
|
|||
/**
|
||||
* Main constructor \w manual Dependency Injection
|
||||
*
|
||||
* @param notebookIndex - (nullable) for indexing all notebooks on creating.
|
||||
* @param noteSearchService - (nullable) for indexing all notebooks on creating.
|
||||
* @throws IOException
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
public Notebook(ZeppelinConfiguration conf, NotebookRepo notebookRepo,
|
||||
SchedulerFactory schedulerFactory, InterpreterFactory replFactory,
|
||||
JobListenerFactory jobListenerFactory, SearchService notebookIndex,
|
||||
JobListenerFactory jobListenerFactory, SearchService noteSearchService,
|
||||
NotebookAuthorization notebookAuthorization, Credentials credentials)
|
||||
throws IOException, SchedulerException {
|
||||
this.conf = conf;
|
||||
|
|
@ -110,7 +110,7 @@ public class Notebook implements NoteEventListener {
|
|||
this.schedulerFactory = schedulerFactory;
|
||||
this.replFactory = replFactory;
|
||||
this.jobListenerFactory = jobListenerFactory;
|
||||
this.notebookIndex = notebookIndex;
|
||||
this.noteSearchService = noteSearchService;
|
||||
this.notebookAuthorization = notebookAuthorization;
|
||||
this.credentials = credentials;
|
||||
quertzSchedFact = new org.quartz.impl.StdSchedulerFactory();
|
||||
|
|
@ -119,10 +119,10 @@ public class Notebook implements NoteEventListener {
|
|||
CronJob.notebook = this;
|
||||
|
||||
loadAllNotes();
|
||||
if (this.notebookIndex != null) {
|
||||
if (this.noteSearchService != null) {
|
||||
long start = System.nanoTime();
|
||||
logger.info("Notebook indexing started...");
|
||||
notebookIndex.addIndexDocs(notes.values());
|
||||
noteSearchService.addIndexDocs(notes.values());
|
||||
logger.info("Notebook indexing finished: {} indexed in {}s", notes.size(),
|
||||
TimeUnit.NANOSECONDS.toSeconds(start - System.nanoTime()));
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ public class Notebook implements NoteEventListener {
|
|||
} else {
|
||||
note = createNote(null, subject);
|
||||
}
|
||||
notebookIndex.addIndexDoc(note);
|
||||
noteSearchService.addIndexDoc(note);
|
||||
return note;
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,8 @@ public class Notebook implements NoteEventListener {
|
|||
public Note createNote(List<String> interpreterIds, AuthenticationInfo subject)
|
||||
throws IOException {
|
||||
Note note =
|
||||
new Note(notebookRepo, replFactory, jobListenerFactory, notebookIndex, credentials, this);
|
||||
new Note(notebookRepo, replFactory, jobListenerFactory,
|
||||
noteSearchService, credentials, this);
|
||||
synchronized (notes) {
|
||||
notes.put(note.getId(), note);
|
||||
}
|
||||
|
|
@ -166,7 +167,7 @@ public class Notebook implements NoteEventListener {
|
|||
owners.add(subject.getUser());
|
||||
notebookAuthorization.setOwners(note.getId(), owners);
|
||||
}
|
||||
notebookIndex.addIndexDoc(note);
|
||||
noteSearchService.addIndexDoc(note);
|
||||
note.persist(subject);
|
||||
fireNoteCreateEvent(note);
|
||||
return note;
|
||||
|
|
@ -259,7 +260,7 @@ public class Notebook implements NoteEventListener {
|
|||
newNote.addCloneParagraph(p);
|
||||
}
|
||||
|
||||
notebookIndex.addIndexDoc(newNote);
|
||||
noteSearchService.addIndexDoc(newNote);
|
||||
newNote.persist(subject);
|
||||
return newNote;
|
||||
}
|
||||
|
|
@ -312,7 +313,7 @@ public class Notebook implements NoteEventListener {
|
|||
note = notes.remove(id);
|
||||
}
|
||||
replFactory.removeNoteInterpreterSettingBinding(id);
|
||||
notebookIndex.deleteIndexDocs(note);
|
||||
noteSearchService.deleteIndexDocs(note);
|
||||
notebookAuthorization.removeNote(id);
|
||||
|
||||
// remove from all interpreter instance's angular object registry
|
||||
|
|
@ -391,7 +392,7 @@ public class Notebook implements NoteEventListener {
|
|||
}
|
||||
|
||||
//Manually inject ALL dependencies, as DI constructor was NOT used
|
||||
note.setIndex(this.notebookIndex);
|
||||
note.setIndex(this.noteSearchService);
|
||||
note.setCredentials(this.credentials);
|
||||
|
||||
note.setInterpreterFactory(replFactory);
|
||||
|
|
@ -873,7 +874,7 @@ public class Notebook implements NoteEventListener {
|
|||
|
||||
public void close() {
|
||||
this.notebookRepo.close();
|
||||
this.notebookIndex.close();
|
||||
this.noteSearchService.close();
|
||||
}
|
||||
|
||||
public void addNotebookEventListener(NotebookEventListener listener) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class LuceneSearchTest {
|
|||
|
||||
private static NotebookRepo notebookRepoMock;
|
||||
private static InterpreterFactory interpreterFactory;
|
||||
private SearchService notebookIndex;
|
||||
private SearchService noteSearchService;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeStartUp() {
|
||||
|
|
@ -53,12 +53,12 @@ public class LuceneSearchTest {
|
|||
|
||||
@Before
|
||||
public void startUp() {
|
||||
notebookIndex = new LuceneSearch();
|
||||
noteSearchService = new LuceneSearch();
|
||||
}
|
||||
|
||||
@After
|
||||
public void shutDown() {
|
||||
notebookIndex.close();
|
||||
noteSearchService.close();
|
||||
}
|
||||
|
||||
@Test public void canIndexNotebook() {
|
||||
|
|
@ -68,17 +68,17 @@ public class LuceneSearchTest {
|
|||
List<Note> notebook = Arrays.asList(note1, note2);
|
||||
|
||||
//when
|
||||
notebookIndex.addIndexDocs(notebook);
|
||||
noteSearchService.addIndexDocs(notebook);
|
||||
}
|
||||
|
||||
@Test public void canIndexAndQuery() {
|
||||
//given
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test");
|
||||
Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at all");
|
||||
notebookIndex.addIndexDocs(Arrays.asList(note1, note2));
|
||||
noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
|
||||
|
||||
//when
|
||||
List<Map<String, String>> results = notebookIndex.query("all");
|
||||
List<Map<String, String>> results = noteSearchService.query("all");
|
||||
|
||||
//then
|
||||
assertThat(results).isNotEmpty();
|
||||
|
|
@ -91,10 +91,10 @@ public class LuceneSearchTest {
|
|||
//given
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test");
|
||||
Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at all");
|
||||
notebookIndex.addIndexDocs(Arrays.asList(note1, note2));
|
||||
noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
|
||||
|
||||
//when
|
||||
List<Map<String, String>> results = notebookIndex.query("Notebook1");
|
||||
List<Map<String, String>> results = noteSearchService.query("Notebook1");
|
||||
|
||||
//then
|
||||
assertThat(results).isNotEmpty();
|
||||
|
|
@ -107,10 +107,10 @@ public class LuceneSearchTest {
|
|||
//given
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test", "testingTitleSearch");
|
||||
Note note2 = newNoteWithParagraph("Notebook2", "not test", "notTestingTitleSearch");
|
||||
notebookIndex.addIndexDocs(Arrays.asList(note1, note2));
|
||||
noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
|
||||
|
||||
//when
|
||||
List<Map<String, String>> results = notebookIndex.query("testingTitleSearch");
|
||||
List<Map<String, String>> results = noteSearchService.query("testingTitleSearch");
|
||||
|
||||
//then
|
||||
assertThat(results).isNotEmpty();
|
||||
|
|
@ -128,7 +128,7 @@ public class LuceneSearchTest {
|
|||
//give
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test");
|
||||
//when
|
||||
notebookIndex.addIndexDoc(note1);
|
||||
noteSearchService.addIndexDoc(note1);
|
||||
//then
|
||||
String id = resultForQuery("test").get(0).get(LuceneSearch.ID_FIELD);
|
||||
|
||||
|
|
@ -138,9 +138,9 @@ public class LuceneSearchTest {
|
|||
|
||||
@Test //(expected=IllegalStateException.class)
|
||||
public void canNotSearchBeforeIndexing() {
|
||||
//given NO notebookIndex.index() was called
|
||||
//given NO noteSearchService.index() was called
|
||||
//when
|
||||
List<Map<String, String>> result = notebookIndex.query("anything");
|
||||
List<Map<String, String>> result = noteSearchService.query("anything");
|
||||
//then
|
||||
assertThat(result).isEmpty();
|
||||
//assert logs were printed
|
||||
|
|
@ -151,18 +151,18 @@ public class LuceneSearchTest {
|
|||
//given
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test");
|
||||
Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at all");
|
||||
notebookIndex.addIndexDocs(Arrays.asList(note1, note2));
|
||||
noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
|
||||
|
||||
//when
|
||||
Paragraph p2 = note2.getLastParagraph();
|
||||
p2.setText("test indeed");
|
||||
notebookIndex.updateIndexDoc(note2);
|
||||
noteSearchService.updateIndexDoc(note2);
|
||||
|
||||
//then
|
||||
List<Map<String, String>> results = notebookIndex.query("all");
|
||||
List<Map<String, String>> results = noteSearchService.query("all");
|
||||
assertThat(results).isEmpty();
|
||||
|
||||
results = notebookIndex.query("indeed");
|
||||
results = noteSearchService.query("indeed");
|
||||
assertThat(results).isNotEmpty();
|
||||
}
|
||||
|
||||
|
|
@ -170,21 +170,21 @@ public class LuceneSearchTest {
|
|||
//give
|
||||
// looks like a bug in web UI: it tries to delete a note twice (after it has just been deleted)
|
||||
//when
|
||||
notebookIndex.deleteIndexDocs(null);
|
||||
noteSearchService.deleteIndexDocs(null);
|
||||
}
|
||||
|
||||
@Test public void canDeleteFromIndex() throws IOException {
|
||||
//given
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test");
|
||||
Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at all");
|
||||
notebookIndex.addIndexDocs(Arrays.asList(note1, note2));
|
||||
noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
|
||||
assertThat(resultForQuery("Notebook2")).isNotEmpty();
|
||||
|
||||
//when
|
||||
notebookIndex.deleteIndexDocs(note2);
|
||||
noteSearchService.deleteIndexDocs(note2);
|
||||
|
||||
//then
|
||||
assertThat(notebookIndex.query("all")).isEmpty();
|
||||
assertThat(noteSearchService.query("all")).isEmpty();
|
||||
assertThat(resultForQuery("Notebook2")).isEmpty();
|
||||
|
||||
List<Map<String, String>> results = resultForQuery("test");
|
||||
|
|
@ -196,7 +196,7 @@ public class LuceneSearchTest {
|
|||
//given: total 2 notebooks, 3 paragraphs
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test");
|
||||
Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at all");
|
||||
notebookIndex.addIndexDocs(Arrays.asList(note1, note2));
|
||||
noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
|
||||
assertThat(resultForQuery("test").size()).isEqualTo(3);
|
||||
|
||||
//when
|
||||
|
|
@ -221,7 +221,7 @@ public class LuceneSearchTest {
|
|||
//given: total 2 notebooks, 3 paragraphs
|
||||
Note note1 = newNoteWithParagraph("Notebook1", "test");
|
||||
Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at all");
|
||||
notebookIndex.addIndexDocs(Arrays.asList(note1, note2));
|
||||
noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
|
||||
assertThat(resultForQuery("test").size()).isEqualTo(3);
|
||||
|
||||
//when
|
||||
|
|
@ -235,7 +235,7 @@ public class LuceneSearchTest {
|
|||
}
|
||||
|
||||
private List<Map<String, String>> resultForQuery(String q) {
|
||||
return notebookIndex.query(q);
|
||||
return noteSearchService.query(q);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -284,7 +284,7 @@ public class LuceneSearchTest {
|
|||
}
|
||||
|
||||
private Note newNote(String name) {
|
||||
Note note = new Note(notebookRepoMock, interpreterFactory, null, notebookIndex, null, null);
|
||||
Note note = new Note(notebookRepoMock, interpreterFactory, null, noteSearchService, null, null);
|
||||
note.setName(name);
|
||||
return note;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue