Search in sources :

Example 6 with NoteManager

use of org.apache.zeppelin.notebook.NoteManager in project zeppelin by apache.

the class NotebookRepoSyncTest method testOneWaySyncOnReloadedList.

@Test
public void testOneWaySyncOnReloadedList() throws IOException, SchedulerException {
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC.getVarName(), "true");
    conf = ZeppelinConfiguration.create();
    notebookRepoSync = new NotebookRepoSync(conf);
    notebook = new Notebook(conf, mock(AuthorizationService.class), notebookRepoSync, new NoteManager(notebookRepoSync, conf), factory, interpreterSettingManager, credentials, null);
    // check that both storage repos are empty
    assertTrue(notebookRepoSync.getRepoCount() > 1);
    assertEquals(0, notebookRepoSync.list(0, null).size());
    assertEquals(0, notebookRepoSync.list(1, null).size());
    File srcDir = new File("src/test/resources/notebook");
    File destDir = secNotebookDir;
    /* copy manually new notebook into secondary storage repo and check repos */
    try {
        FileUtils.copyDirectory(srcDir, destDir);
    } catch (IOException e) {
        LOG.error(e.toString(), e);
    }
    assertEquals(0, notebookRepoSync.list(0, null).size());
    assertEquals(2, notebookRepoSync.list(1, null).size());
    // after reloading the notebook should be wiped from secondary storage
    notebook.reloadAllNotes(null);
    assertEquals(0, notebookRepoSync.list(0, null).size());
    assertEquals(0, notebookRepoSync.list(1, null).size());
    destDir = mainNotebookDir;
    // copy manually new notebook into primary storage repo and check repos
    try {
        FileUtils.copyDirectory(srcDir, destDir);
    } catch (IOException e) {
        LOG.error(e.toString(), e);
    }
    assertEquals(2, notebookRepoSync.list(0, null).size());
    assertEquals(0, notebookRepoSync.list(1, null).size());
    // after reloading notebooks repos should be synchronized
    notebook.reloadAllNotes(null);
    assertEquals(2, notebookRepoSync.list(0, null).size());
    assertEquals(2, notebookRepoSync.list(1, null).size());
}
Also used : Notebook(org.apache.zeppelin.notebook.Notebook) NoteManager(org.apache.zeppelin.notebook.NoteManager) IOException(java.io.IOException) File(java.io.File) Test(org.junit.Test)

Example 7 with NoteManager

use of org.apache.zeppelin.notebook.NoteManager in project zeppelin by apache.

the class HeliumApplicationFactoryTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    // set AppEventListener properly
    for (InterpreterSetting interpreterSetting : interpreterSettingManager.get()) {
        interpreterSetting.setAppEventListener(heliumAppFactory);
    }
    AuthorizationService authorizationService = mock(AuthorizationService.class);
    notebookRepo = mock(NotebookRepo.class);
    notebook = new Notebook(conf, authorizationService, notebookRepo, new NoteManager(notebookRepo, ZeppelinConfiguration.create()), interpreterFactory, interpreterSettingManager, new Credentials());
    heliumAppFactory = new HeliumApplicationFactory(notebook, null);
    notebook.addNotebookEventListener(heliumAppFactory);
    anonymous = new AuthenticationInfo("anonymous");
}
Also used : NotebookRepo(org.apache.zeppelin.notebook.repo.NotebookRepo) Notebook(org.apache.zeppelin.notebook.Notebook) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) NoteManager(org.apache.zeppelin.notebook.NoteManager) Credentials(org.apache.zeppelin.user.Credentials) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) Before(org.junit.Before)

Aggregations

NoteManager (org.apache.zeppelin.notebook.NoteManager)7 Notebook (org.apache.zeppelin.notebook.Notebook)7 AuthorizationService (org.apache.zeppelin.notebook.AuthorizationService)5 Before (org.junit.Before)5 Credentials (org.apache.zeppelin.user.Credentials)4 File (java.io.File)3 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)3 InterpreterFactory (org.apache.zeppelin.interpreter.InterpreterFactory)3 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)3 InterpreterSettingManager (org.apache.zeppelin.interpreter.InterpreterSettingManager)3 NotebookRepo (org.apache.zeppelin.notebook.repo.NotebookRepo)3 InMemoryNotebookRepo (org.apache.zeppelin.notebook.repo.InMemoryNotebookRepo)2 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Interpreter (org.apache.zeppelin.interpreter.Interpreter)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1 ManagedInterpreterGroup (org.apache.zeppelin.interpreter.ManagedInterpreterGroup)1 Note (org.apache.zeppelin.notebook.Note)1 NoteInfo (org.apache.zeppelin.notebook.NoteInfo)1