Repository: zeppelin Updated Branches: refs/heads/master ba5a2d825 -> 4f6a0e34f
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/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 9ad6d4c..0b21f8d 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 @@ -89,7 +89,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>()); @@ -98,13 +98,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; @@ -112,7 +112,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(); @@ -121,10 +121,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())); } @@ -144,7 +144,7 @@ public class Notebook implements NoteEventListener { } else { note = createNote(null, subject); } - notebookIndex.addIndexDoc(note); + noteSearchService.addIndexDoc(note); return note; } @@ -156,7 +156,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); } @@ -169,7 +170,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; @@ -198,7 +199,7 @@ public class Notebook implements NoteEventListener { * * @param sourceJson - the note JSON to import * @param noteName - the name of the new note - * @return notebook ID + * @return note ID * @throws IOException */ public Note importNote(String sourceJson, String noteName, AuthenticationInfo subject) @@ -235,17 +236,17 @@ public class Notebook implements NoteEventListener { /** * Clone existing note. * - * @param sourceNoteID - the note ID to clone + * @param sourceNoteId - the note ID to clone * @param newNoteName - the name of the new note * @return noteId * @throws IOException, CloneNotSupportedException, IllegalArgumentException */ - public Note cloneNote(String sourceNoteID, String newNoteName, AuthenticationInfo subject) + public Note cloneNote(String sourceNoteId, String newNoteName, AuthenticationInfo subject) throws IOException, CloneNotSupportedException, IllegalArgumentException { - Note sourceNote = getNote(sourceNoteID); + Note sourceNote = getNote(sourceNoteId); if (sourceNote == null) { - throw new IllegalArgumentException(sourceNoteID + "not found"); + throw new IllegalArgumentException(sourceNoteId + "not found"); } Note newNote = createNote(subject); if (newNoteName != null) { @@ -262,7 +263,7 @@ public class Notebook implements NoteEventListener { newNote.addCloneParagraph(p); } - notebookIndex.addIndexDoc(newNote); + noteSearchService.addIndexDoc(newNote); newNote.persist(subject); return newNote; } @@ -317,7 +318,7 @@ public class Notebook implements NoteEventListener { note = notes.remove(id); } replFactory.removeNoteInterpreterSettingBinding(subject.getUser(), id); - notebookIndex.deleteIndexDocs(note); + noteSearchService.deleteIndexDocs(note); notebookAuthorization.removeNote(id); // remove from all interpreter instance's angular object registry @@ -338,7 +339,7 @@ public class Notebook implements NoteEventListener { } } } - // remove notebook scope object + // remove note scope object ((RemoteAngularObjectRegistry) registry).removeAllAndNotifyRemoteProcess(id, null); } else { // remove paragraph scope object @@ -353,7 +354,7 @@ public class Notebook implements NoteEventListener { } } } - // remove notebook scope object + // remove note scope object registry.removeAll(id, null); } } @@ -397,7 +398,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); @@ -471,7 +472,7 @@ public class Notebook implements NoteEventListener { /** * Reload all notes from repository after clearing `notes` - * to reflect the changes of added/deleted/modified notebooks on file system level. + * to reflect the changes of added/deleted/modified notes on file system level. * * @throws IOException */ @@ -618,23 +619,23 @@ public class Notebook implements NoteEventListener { return lastRunningUnixTime; } - public List<Map<String, Object>> getJobListByParagraphId(String paragraphID) { + public List<Map<String, Object>> getJobListByParagraphId(String paragraphId) { String gotNoteId = null; List<Note> notes = getAllNotes(); for (Note note : notes) { - Paragraph p = note.getParagraph(paragraphID); + Paragraph p = note.getParagraph(paragraphId); if (p != null) { gotNoteId = note.getId(); } } - return getJobListBymNotebookId(gotNoteId); + return getJobListByNoteId(gotNoteId); } - public List<Map<String, Object>> getJobListBymNotebookId(String notebookID) { - final String CRON_TYPE_NOTEBOOK_KEYWORD = "cron"; + public List<Map<String, Object>> getJobListByNoteId(String noteId) { + final String CRON_TYPE_NOTE_KEYWORD = "cron"; long lastRunningUnixTime = 0; - boolean isNotebookRunning = false; - Note jobNote = getNote(notebookID); + boolean isNoteRunning = false; + Note jobNote = getNote(noteId); List<Map<String, Object>> notesInfo = new LinkedList<>(); if (jobNote == null) { return notesInfo; @@ -642,19 +643,19 @@ public class Notebook implements NoteEventListener { Map<String, Object> info = new HashMap<>(); - info.put("notebookId", jobNote.getId()); - String notebookName = jobNote.getName(); - if (notebookName != null && !notebookName.equals("")) { - info.put("notebookName", jobNote.getName()); + info.put("noteId", jobNote.getId()); + String noteName = jobNote.getName(); + if (noteName != null && !noteName.equals("")) { + info.put("noteName", jobNote.getName()); } else { - info.put("notebookName", "Note " + jobNote.getId()); + info.put("noteName", "Note " + jobNote.getId()); } - // set notebook type ( cron or normal ) - if (jobNote.getConfig().containsKey(CRON_TYPE_NOTEBOOK_KEYWORD) && !jobNote.getConfig() - .get(CRON_TYPE_NOTEBOOK_KEYWORD).equals("")) { - info.put("notebookType", "cron"); + // set note type ( cron or normal ) + if (jobNote.getConfig().containsKey(CRON_TYPE_NOTE_KEYWORD) && !jobNote.getConfig() + .get(CRON_TYPE_NOTE_KEYWORD).equals("")) { + info.put("noteType", "cron"); } else { - info.put("notebookType", "normal"); + info.put("noteType", "normal"); } // set paragraphs @@ -662,7 +663,7 @@ public class Notebook implements NoteEventListener { for (Paragraph paragraph : jobNote.getParagraphs()) { // check paragraph's status. if (paragraph.getStatus().isRunning()) { - isNotebookRunning = true; + isNoteRunning = true; } // get data for the job manager. @@ -679,9 +680,9 @@ public class Notebook implements NoteEventListener { interpreterGroupName = replFactory.getInterpreterSettings(jobNote.getId()).get(0).getName(); } - // notebook json object root information. + // note json object root information. info.put("interpreter", interpreterGroupName); - info.put("isRunningJob", isNotebookRunning); + info.put("isRunningJob", isNoteRunning); info.put("unixTimeLastRun", lastRunningUnixTime); info.put("paragraphs", paragraphsInfo); notesInfo.add(info); @@ -691,7 +692,7 @@ public class Notebook implements NoteEventListener { public List<Map<String, Object>> getJobListByUnixTime(boolean needsReload, long lastUpdateServerUnixTime, AuthenticationInfo subject) { - final String CRON_TYPE_NOTEBOOK_KEYWORD = "cron"; + final String CRON_TYPE_NOTE_KEYWORD = "cron"; if (needsReload) { try { @@ -704,28 +705,28 @@ public class Notebook implements NoteEventListener { List<Note> notes = getAllNotes(); List<Map<String, Object>> notesInfo = new LinkedList<>(); for (Note note : notes) { - boolean isNotebookRunning = false; - boolean isUpdateNotebook = false; + boolean isNoteRunning = false; + boolean isUpdateNote = false; long lastRunningUnixTime = 0; Map<String, Object> info = new HashMap<>(); - // set notebook ID - info.put("notebookId", note.getId()); + // set note ID + info.put("noteId", note.getId()); - // set notebook Name - String notebookName = note.getName(); - if (notebookName != null && !notebookName.equals("")) { - info.put("notebookName", note.getName()); + // set note Name + String noteName = note.getName(); + if (noteName != null && !noteName.equals("")) { + info.put("noteName", note.getName()); } else { - info.put("notebookName", "Note " + note.getId()); + info.put("noteName", "Note " + note.getId()); } - // set notebook type ( cron or normal ) - if (note.getConfig().containsKey(CRON_TYPE_NOTEBOOK_KEYWORD) && !note.getConfig() - .get(CRON_TYPE_NOTEBOOK_KEYWORD).equals("")) { - info.put("notebookType", "cron"); + // set note type ( cron or normal ) + if (note.getConfig().containsKey(CRON_TYPE_NOTE_KEYWORD) && !note.getConfig() + .get(CRON_TYPE_NOTE_KEYWORD).equals("")) { + info.put("noteType", "cron"); } else { - info.put("notebookType", "normal"); + info.put("noteType", "normal"); } // set paragraphs @@ -733,17 +734,17 @@ public class Notebook implements NoteEventListener { for (Paragraph paragraph : note.getParagraphs()) { // check paragraph's status. if (paragraph.getStatus().isRunning()) { - isNotebookRunning = true; - isUpdateNotebook = true; + isNoteRunning = true; + isUpdateNote = true; } // get data for the job manager. Map<String, Object> paragraphItem = getParagraphForJobManagerItem(paragraph); lastRunningUnixTime = getUnixTimeLastRunParagraph(paragraph); - // is update notebook for last server update time. + // is update note for last server update time. if (lastRunningUnixTime > lastUpdateServerUnixTime) { - isUpdateNotebook = true; + isUpdateNote = true; } paragraphsInfo.add(paragraphItem); } @@ -756,13 +757,13 @@ public class Notebook implements NoteEventListener { } // not update and not running -> pass - if (!isUpdateNotebook && !isNotebookRunning) { + if (!isUpdateNote && !isNoteRunning) { continue; } - // notebook json object root information. + // note json object root information. info.put("interpreter", interpreterGroupName); - info.put("isRunningJob", isNotebookRunning); + info.put("isRunningJob", isNoteRunning); info.put("unixTimeLastRun", lastRunningUnixTime); info.put("paragraphs", paragraphsInfo); notesInfo.add(info); @@ -879,7 +880,7 @@ public class Notebook implements NoteEventListener { public void close() { this.notebookRepo.close(); - this.notebookIndex.close(); + this.noteSearchService.close(); } public void addNotebookEventListener(NotebookEventListener listener) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java index aff684f..d1bf1d5 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepo.java @@ -39,7 +39,7 @@ public interface NotebookRepo { /** * Get the notebook with the given id. - * @param noteId is notebook id. + * @param noteId is note id. * @param subject contains user information. * @return * @throws IOException http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/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 635d6f2..0265eff 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 @@ -45,9 +45,9 @@ import org.slf4j.LoggerFactory; public class NotebookRepoSync implements NotebookRepo { private static final Logger LOG = LoggerFactory.getLogger(NotebookRepoSync.class); private static final int maxRepoNum = 2; - private static final String pushKey = "pushNoteIDs"; - private static final String pullKey = "pullNoteIDs"; - private static final String delDstKey = "delDstNoteIDs"; + private static final String pushKey = "pushNoteIds"; + private static final String pullKey = "pullNoteIds"; + private static final String delDstKey = "delDstNoteIds"; private static ZeppelinConfiguration config; private static final String defaultStorage = "org.apache.zeppelin.notebook.repo.VFSNotebookRepo"; @@ -56,9 +56,7 @@ public class NotebookRepoSync implements NotebookRepo { private final boolean oneWaySync; /** - * @param noteIndex - * @param (conf) - * @throws - Exception + * @param conf */ @SuppressWarnings("static-access") public NotebookRepoSync(ZeppelinConfiguration conf) { @@ -72,7 +70,7 @@ public class NotebookRepoSync implements NotebookRepo { String[] storageClassNames = allStorageClassNames.split(","); if (storageClassNames.length > getMaxRepoNum()) { LOG.warn("Unsupported number {} of storage classes in ZEPPELIN_NOTEBOOK_STORAGE : {}\n" + - "first {} will be used", storageClassNames.length, allStorageClassNames, getMaxRepoNum()); + "first {} will be used", storageClassNames.length, allStorageClassNames, getMaxRepoNum()); } for (int i = 0; i < Math.min(storageClassNames.length, getMaxRepoNum()); i++) { @@ -81,7 +79,7 @@ public class NotebookRepoSync implements NotebookRepo { try { notebookStorageClass = getClass().forName(storageClassNames[i].trim()); Constructor<?> constructor = notebookStorageClass.getConstructor( - ZeppelinConfiguration.class); + ZeppelinConfiguration.class); repos.add((NotebookRepo) constructor.newInstance(conf)); } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | @@ -91,7 +89,7 @@ public class NotebookRepoSync implements NotebookRepo { } // couldn't initialize any storage, use default if (getRepoCount() == 0) { - LOG.info("No storages could be initialized, using default {} storage", defaultStorage); + LOG.info("No storage could be initialized, using default {} storage", defaultStorage); initializeDefaultStorage(conf); } } @@ -184,38 +182,38 @@ public class NotebookRepoSync implements NotebookRepo { List <NoteInfo> srcNotes = auth.filterByUser(allSrcNotes, subject); List <NoteInfo> dstNotes = dstRepo.list(subject); - Map<String, List<String>> noteIDs = notesCheckDiff(srcNotes, srcRepo, dstNotes, dstRepo, + Map<String, List<String>> noteIds = notesCheckDiff(srcNotes, srcRepo, dstNotes, dstRepo, subject); - List<String> pushNoteIDs = noteIDs.get(pushKey); - List<String> pullNoteIDs = noteIDs.get(pullKey); - List<String> delDstNoteIDs = noteIDs.get(delDstKey); + List<String> pushNoteIds = noteIds.get(pushKey); + List<String> pullNoteIds = noteIds.get(pullKey); + List<String> delDstNoteIds = noteIds.get(delDstKey); - if (!pushNoteIDs.isEmpty()) { + if (!pushNoteIds.isEmpty()) { LOG.info("Notes with the following IDs will be pushed"); - for (String id : pushNoteIDs) { + for (String id : pushNoteIds) { LOG.info("ID : " + id); } - pushNotes(subject, pushNoteIDs, srcRepo, dstRepo, false); + pushNotes(subject, pushNoteIds, srcRepo, dstRepo, false); } else { LOG.info("Nothing to push"); } - if (!pullNoteIDs.isEmpty()) { + if (!pullNoteIds.isEmpty()) { LOG.info("Notes with the following IDs will be pulled"); - for (String id : pullNoteIDs) { + for (String id : pullNoteIds) { LOG.info("ID : " + id); } - pushNotes(subject, pullNoteIDs, dstRepo, srcRepo, true); + pushNotes(subject, pullNoteIds, dstRepo, srcRepo, true); } else { LOG.info("Nothing to pull"); } - if (!delDstNoteIDs.isEmpty()) { + if (!delDstNoteIds.isEmpty()) { LOG.info("Notes with the following IDs will be deleted from dest"); - for (String id : delDstNoteIDs) { + for (String id : delDstNoteIds) { LOG.info("ID : " + id); } - deleteNotes(subject, delDstNoteIDs, dstRepo); + deleteNotes(subject, delDstNoteIds, dstRepo); } else { LOG.info("Nothing to delete from dest"); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java index 2aded60..b78203c 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java @@ -34,7 +34,7 @@ public class Message { // @param id note id NOTE, // [s-c] note info - // @param note serlialized Note object + // @param note serialized Note object PARAGRAPH, // [s-c] paragraph info // @param paragraph serialized paragraph object @@ -115,7 +115,7 @@ public class Message { CONFIGURATIONS_INFO, // [s-c] all key/value pairs of configurations // @param settings serialized Map<String, String> object - CHECKPOINT_NOTEBOOK, // [c-s] checkpoint notebook to storage repository + CHECKPOINT_NOTE, // [c-s] checkpoint note to storage repository // @param noteId // @param checkpointName @@ -130,14 +130,14 @@ public class Message { APP_LOAD, // [s-c] on app load APP_STATUS_CHANGE, // [s-c] on app status change - LIST_NOTEBOOK_JOBS, // [c-s] get notebook job management infomations - LIST_UPDATE_NOTEBOOK_JOBS, // [c-s] get job management informations for until unixtime - UNSUBSCRIBE_UPDATE_NOTEBOOK_JOBS, // [c-s] unsubscribe job information for job management + LIST_NOTE_JOBS, // [c-s] get note job management information + LIST_UPDATE_NOTE_JOBS, // [c-s] get job management information for until unixtime + UNSUBSCRIBE_UPDATE_NOTE_JOBS, // [c-s] unsubscribe job information for job management // @param unixTime GET_INTERPRETER_BINDINGS, // [c-s] get interpreter bindings - // @param noteID + // @param noteId SAVE_INTERPRETER_BINDINGS, // [c-s] save interpreter bindings - // @param noteID + // @param noteId // @param selectedSettingIds INTERPRETER_BINDINGS, // [s-c] interpreter bindings ERROR_INFO // [s-c] error information to be sent http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java index 64f2b75..0b86ac6 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java @@ -25,7 +25,7 @@ import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.Paragraph; /** - * Search (both, indexing and query) the notebooks. + * Search (both, indexing and query) the notes. * * Intended to have multiple implementation, i.e: * - local Lucene (in-memory, on-disk) @@ -34,7 +34,7 @@ import org.apache.zeppelin.notebook.Paragraph; public interface SearchService { /** - * Full-text search in all the notebooks + * Full-text search in all the notes * * @param queryStr a query * @return A list of matching paragraphs (id, text, snippet w/ highlight) @@ -59,7 +59,7 @@ public interface SearchService { public void addIndexDocs(Collection<Note> collection); /** - * Indexes the given notebook. + * Indexes the given note. * * @throws IOException If there is a low-level I/O error */ http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/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 87e2415..2bb6112 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 @@ -428,7 +428,7 @@ public class NotebookTest implements JobListenerFactory{ Paragraph cp = cloneNote.paragraphs.get(0); assertEquals(cp.getStatus(), Status.READY); - // Keep same ParagraphID + // Keep same ParagraphId assertEquals(cp.getId(), p.getId()); assertEquals(cp.text, p.text); assertEquals(cp.getResult().message(), p.getResult().message()); @@ -476,7 +476,7 @@ public class NotebookTest implements JobListenerFactory{ Note cloneNote = notebook.cloneNote(note.getId(), "clone note with Exception result", anonymous); Paragraph cp = cloneNote.paragraphs.get(0); - // Keep same ParagraphID + // Keep same ParagraphId assertEquals(cp.getId(), p.getId()); assertEquals(cp.text, p.text); assertNull(cp.getResult()); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java index bf4d9aa..2b13fed 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java @@ -41,7 +41,8 @@ public class LuceneSearchTest { private static NotebookRepo notebookRepoMock; private static InterpreterFactory interpreterFactory; - private SearchService notebookIndex; + + private SearchService noteSearchService; private AuthenticationInfo anonymous; @BeforeClass @@ -55,13 +56,13 @@ public class LuceneSearchTest { @Before public void startUp() { - notebookIndex = new LuceneSearch(); + noteSearchService = new LuceneSearch(); anonymous = new AuthenticationInfo("anonymous"); } @After public void shutDown() { - notebookIndex.close(); + noteSearchService.close(); } @Test public void canIndexNotebook() { @@ -71,17 +72,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(); @@ -94,10 +95,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(); @@ -110,10 +111,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(); @@ -131,7 +132,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); @@ -141,9 +142,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 @@ -154,18 +155,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(); } @@ -173,21 +174,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"); @@ -199,7 +200,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 @@ -224,7 +225,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 @@ -238,7 +239,7 @@ public class LuceneSearchTest { } private List<Map<String, String>> resultForQuery(String q) { - return notebookIndex.query(q); + return noteSearchService.query(q); } /** @@ -287,7 +288,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; }
