Search in sources :

Example 1 with QuartzSchedulerService

use of org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService in project zeppelin by apache.

the class ClusterEventTest method init.

@BeforeClass
public static void init() throws Exception {
    ZeppelinConfiguration zconf = genZeppelinConf();
    ZeppelinServerMock.startUp("ClusterEventTest", zconf);
    notebook = TestUtils.getInstance(Notebook.class);
    authorizationService = TestUtils.getInstance(AuthorizationService.class);
    schedulerService = new QuartzSchedulerService(zconf, notebook);
    schedulerService.waitForFinishInit();
    notebookServer = spy(NotebookServer.getInstance());
    notebookService = new NotebookService(notebook, authorizationService, zconf, schedulerService);
    ConfigurationService configurationService = new ConfigurationService(notebook.getConf());
    when(notebookServer.getNotebookService()).thenReturn(notebookService);
    when(notebookServer.getConfigurationService()).thenReturn(configurationService);
    startOtherZeppelinClusterNode(zconf);
    // wait zeppelin cluster startup
    Thread.sleep(10000);
    // mock cluster manager client
    clusterClient = ClusterManagerClient.getInstance(zconf);
    clusterClient.start(metaKey);
    // Waiting for cluster startup
    int wait = 0;
    while (wait++ < 100) {
        if (clusterIsStartup() && clusterClient.raftInitialized()) {
            LOGGER.info("wait {}(ms) found cluster leader", wait * 500);
            break;
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
    Thread.sleep(3000);
    assertEquals(true, clusterIsStartup());
    getClusterServerMeta();
}
Also used : Notebook(org.apache.zeppelin.notebook.Notebook) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) QuartzSchedulerService(org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) ConfigurationService(org.apache.zeppelin.service.ConfigurationService) NotebookService(org.apache.zeppelin.service.NotebookService) BeforeClass(org.junit.BeforeClass)

Example 2 with QuartzSchedulerService

use of org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService in project zeppelin by apache.

the class NotebookServiceTest method setUp.

@Before
public void setUp() throws Exception {
    notebookDir = Files.createTempDirectory("notebookDir").toAbsolutePath().toFile();
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
    ZeppelinConfiguration zeppelinConfiguration = ZeppelinConfiguration.create();
    NotebookRepo notebookRepo = new VFSNotebookRepo();
    notebookRepo.init(zeppelinConfiguration);
    InterpreterSettingManager mockInterpreterSettingManager = mock(InterpreterSettingManager.class);
    InterpreterFactory mockInterpreterFactory = mock(InterpreterFactory.class);
    Interpreter mockInterpreter = mock(Interpreter.class);
    when(mockInterpreterFactory.getInterpreter(any(), any())).thenReturn(mockInterpreter);
    when(mockInterpreter.interpret(eq("invalid_code"), any())).thenReturn(new InterpreterResult(Code.ERROR, "failed"));
    when(mockInterpreter.interpret(eq("1+1"), any())).thenReturn(new InterpreterResult(Code.SUCCESS, "succeed"));
    doCallRealMethod().when(mockInterpreter).getScheduler();
    when(mockInterpreter.getFormType()).thenReturn(FormType.NATIVE);
    ManagedInterpreterGroup mockInterpreterGroup = mock(ManagedInterpreterGroup.class);
    when(mockInterpreter.getInterpreterGroup()).thenReturn(mockInterpreterGroup);
    InterpreterSetting mockInterpreterSetting = mock(InterpreterSetting.class);
    when(mockInterpreterSetting.isUserAuthorized(any())).thenReturn(true);
    when(mockInterpreterGroup.getInterpreterSetting()).thenReturn(mockInterpreterSetting);
    when(mockInterpreterSetting.getStatus()).thenReturn(InterpreterSetting.Status.READY);
    Credentials credentials = new Credentials();
    NoteManager noteManager = new NoteManager(notebookRepo, zeppelinConfiguration);
    AuthorizationService authorizationService = new AuthorizationService(noteManager, zeppelinConfiguration);
    notebook = new Notebook(zeppelinConfiguration, authorizationService, notebookRepo, noteManager, mockInterpreterFactory, mockInterpreterSettingManager, credentials, null);
    searchService = new LuceneSearch(zeppelinConfiguration, notebook);
    QuartzSchedulerService schedulerService = new QuartzSchedulerService(zeppelinConfiguration, notebook);
    schedulerService.waitForFinishInit();
    notebookService = new NotebookService(notebook, authorizationService, zeppelinConfiguration, schedulerService);
    String interpreterName = "test";
    when(mockInterpreterSetting.getName()).thenReturn(interpreterName);
    when(mockInterpreterSettingManager.getDefaultInterpreterSetting()).thenReturn(mockInterpreterSetting);
}
Also used : NotebookRepo(org.apache.zeppelin.notebook.repo.NotebookRepo) VFSNotebookRepo(org.apache.zeppelin.notebook.repo.VFSNotebookRepo) Interpreter(org.apache.zeppelin.interpreter.Interpreter) Notebook(org.apache.zeppelin.notebook.Notebook) QuartzSchedulerService(org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager) InterpreterFactory(org.apache.zeppelin.interpreter.InterpreterFactory) ManagedInterpreterGroup(org.apache.zeppelin.interpreter.ManagedInterpreterGroup) VFSNotebookRepo(org.apache.zeppelin.notebook.repo.VFSNotebookRepo) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) LuceneSearch(org.apache.zeppelin.search.LuceneSearch) ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) NoteManager(org.apache.zeppelin.notebook.NoteManager) Credentials(org.apache.zeppelin.user.Credentials) Before(org.junit.Before)

Example 3 with QuartzSchedulerService

use of org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService in project zeppelin by apache.

the class NotebookTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_PUBLIC.getVarName(), "true");
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_CRON_ENABLE.getVarName(), "true");
    super.setUp();
    notebookRepo = new VFSNotebookRepo();
    notebookRepo.init(conf);
    noteManager = new NoteManager(notebookRepo, conf);
    authorizationService = new AuthorizationService(noteManager, conf);
    credentials = new Credentials(conf);
    notebook = new Notebook(conf, authorizationService, notebookRepo, noteManager, interpreterFactory, interpreterSettingManager, credentials, null);
    notebook.setParagraphJobListener(this);
    schedulerService = new QuartzSchedulerService(conf, notebook);
    schedulerService.waitForFinishInit();
}
Also used : VFSNotebookRepo(org.apache.zeppelin.notebook.repo.VFSNotebookRepo) QuartzSchedulerService(org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService) Credentials(org.apache.zeppelin.user.Credentials) Before(org.junit.Before)

Aggregations

QuartzSchedulerService (org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService)3 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)2 AuthorizationService (org.apache.zeppelin.notebook.AuthorizationService)2 Notebook (org.apache.zeppelin.notebook.Notebook)2 VFSNotebookRepo (org.apache.zeppelin.notebook.repo.VFSNotebookRepo)2 Credentials (org.apache.zeppelin.user.Credentials)2 Before (org.junit.Before)2 Interpreter (org.apache.zeppelin.interpreter.Interpreter)1 InterpreterFactory (org.apache.zeppelin.interpreter.InterpreterFactory)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)1 InterpreterSettingManager (org.apache.zeppelin.interpreter.InterpreterSettingManager)1 ManagedInterpreterGroup (org.apache.zeppelin.interpreter.ManagedInterpreterGroup)1 NoteManager (org.apache.zeppelin.notebook.NoteManager)1 NotebookRepo (org.apache.zeppelin.notebook.repo.NotebookRepo)1 LuceneSearch (org.apache.zeppelin.search.LuceneSearch)1 ConfigurationService (org.apache.zeppelin.service.ConfigurationService)1 NotebookService (org.apache.zeppelin.service.NotebookService)1 BeforeClass (org.junit.BeforeClass)1