Search in sources :

Example 1 with AuthorizationService

use of org.apache.zeppelin.notebook.AuthorizationService 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 AuthorizationService

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

the class NotebookRepoSyncTest method setUp.

@Before
public void setUp() throws Exception {
    System.setProperty("zeppelin.isTest", "true");
    ZEPPELIN_HOME = Files.createTempDir();
    new File(ZEPPELIN_HOME, "conf").mkdirs();
    String mainNotePath = ZEPPELIN_HOME.getAbsolutePath() + "/notebook";
    String secNotePath = ZEPPELIN_HOME.getAbsolutePath() + "/notebook_secondary";
    mainNotebookDir = new File(mainNotePath);
    secNotebookDir = new File(secNotePath);
    mainNotebookDir.mkdirs();
    secNotebookDir.mkdirs();
    System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), ZEPPELIN_HOME.getAbsolutePath());
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), "org.apache.zeppelin.notebook.repo.VFSNotebookRepo,org.apache.zeppelin.notebook.repo.mock.VFSNotebookRepoMock");
    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC.getVarName(), "false");
    System.setProperty(ConfVars.ZEPPELIN_CONFIG_FS_DIR.getVarName(), ZEPPELIN_HOME.getAbsolutePath() + "/conf");
    System.setProperty(ConfVars.ZEPPELIN_PLUGINS_DIR.getVarName(), new File("../../../plugins").getAbsolutePath());
    LOG.info("main Note dir : " + mainNotePath);
    LOG.info("secondary note dir : " + secNotePath);
    conf = ZeppelinConfiguration.create();
    ConfigStorage.reset();
    interpreterSettingManager = new InterpreterSettingManager(conf, mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
    factory = new InterpreterFactory(interpreterSettingManager);
    notebookRepoSync = new NotebookRepoSync(conf);
    noteManager = new NoteManager(notebookRepoSync, conf);
    authorizationService = new AuthorizationService(noteManager, conf);
    credentials = new Credentials(conf);
    notebook = new Notebook(conf, authorizationService, notebookRepoSync, noteManager, factory, interpreterSettingManager, credentials, null);
    anonymous = new AuthenticationInfo("anonymous");
}
Also used : Notebook(org.apache.zeppelin.notebook.Notebook) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) NoteManager(org.apache.zeppelin.notebook.NoteManager) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager) File(java.io.File) InterpreterFactory(org.apache.zeppelin.interpreter.InterpreterFactory) Credentials(org.apache.zeppelin.user.Credentials) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) Before(org.junit.Before)

Example 3 with AuthorizationService

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

the class AbstractInterpreterTest method setUp.

@Before
public void setUp() throws Exception {
    // copy the resources files to a temp folder
    zeppelinHome = new File("..");
    LOGGER.info("ZEPPELIN_HOME: " + zeppelinHome.getAbsolutePath());
    interpreterDir = new File(zeppelinHome, "interpreter_" + getClass().getSimpleName());
    confDir = new File(zeppelinHome, "conf_" + getClass().getSimpleName());
    notebookDir = new File(zeppelinHome, "notebook_" + getClass().getSimpleName());
    FileUtils.deleteDirectory(notebookDir);
    interpreterDir.mkdirs();
    confDir.mkdirs();
    notebookDir.mkdirs();
    FileUtils.copyDirectory(new File("src/test/resources/interpreter"), interpreterDir);
    FileUtils.copyDirectory(new File("src/test/resources/conf"), confDir);
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), zeppelinHome.getAbsolutePath());
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), confDir.getAbsolutePath());
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_DIR.getVarName(), interpreterDir.getAbsolutePath());
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_GROUP_DEFAULT.getVarName(), "test");
    conf = ZeppelinConfiguration.create();
    NotebookRepo notebookRepo = new InMemoryNotebookRepo();
    NoteManager noteManager = new NoteManager(notebookRepo, conf);
    AuthorizationService authorizationService = new AuthorizationService(noteManager, conf);
    interpreterSettingManager = new InterpreterSettingManager(conf, mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
    interpreterFactory = new InterpreterFactory(interpreterSettingManager);
    Credentials credentials = new Credentials(conf);
    notebook = new Notebook(conf, authorizationService, notebookRepo, noteManager, interpreterFactory, interpreterSettingManager, credentials);
    interpreterSettingManager.setNotebook(notebook);
}
Also used : NotebookRepo(org.apache.zeppelin.notebook.repo.NotebookRepo) InMemoryNotebookRepo(org.apache.zeppelin.notebook.repo.InMemoryNotebookRepo) Notebook(org.apache.zeppelin.notebook.Notebook) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) NoteManager(org.apache.zeppelin.notebook.NoteManager) File(java.io.File) InMemoryNotebookRepo(org.apache.zeppelin.notebook.repo.InMemoryNotebookRepo) Credentials(org.apache.zeppelin.user.Credentials) Before(org.junit.Before)

Example 4 with AuthorizationService

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

the class ZeppelinServer method setupClusterManagerServer.

private static void setupClusterManagerServer(ServiceLocator serviceLocator) {
    if (conf.isClusterMode()) {
        LOG.info("Cluster mode is enabled, starting ClusterManagerServer");
        ClusterManagerServer clusterManagerServer = ClusterManagerServer.getInstance(conf);
        NotebookServer notebookServer = serviceLocator.getService(NotebookServer.class);
        clusterManagerServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_NOTE_EVENT_TOPIC, notebookServer);
        AuthorizationService authorizationService = serviceLocator.getService(AuthorizationService.class);
        clusterManagerServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_AUTH_EVENT_TOPIC, authorizationService);
        InterpreterSettingManager interpreterSettingManager = serviceLocator.getService(InterpreterSettingManager.class);
        clusterManagerServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_INTP_SETTING_EVENT_TOPIC, interpreterSettingManager);
        // This allows the ClusterInterpreterLauncher to listen for cluster events.
        try {
            InterpreterSettingManager intpSettingManager = sharedServiceLocator.getService(InterpreterSettingManager.class);
            RecoveryStorage recoveryStorage = ReflectionUtils.createClazzInstance(conf.getRecoveryStorageClass(), new Class[] { ZeppelinConfiguration.class, InterpreterSettingManager.class }, new Object[] { conf, intpSettingManager });
            recoveryStorage.init();
            PluginManager.get().loadInterpreterLauncher(InterpreterSetting.CLUSTER_INTERPRETER_LAUNCHER_NAME, recoveryStorage);
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }
        clusterManagerServer.start();
    } else {
        LOG.info("Cluster mode is disabled");
    }
}
Also used : ClusterManagerServer(org.apache.zeppelin.cluster.ClusterManagerServer) NotebookServer(org.apache.zeppelin.socket.NotebookServer) AuthorizationService(org.apache.zeppelin.notebook.AuthorizationService) RecoveryStorage(org.apache.zeppelin.interpreter.recovery.RecoveryStorage) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager) IOException(java.io.IOException)

Example 5 with AuthorizationService

use of org.apache.zeppelin.notebook.AuthorizationService 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)

Aggregations

AuthorizationService (org.apache.zeppelin.notebook.AuthorizationService)7 Notebook (org.apache.zeppelin.notebook.Notebook)6 NoteManager (org.apache.zeppelin.notebook.NoteManager)4 Credentials (org.apache.zeppelin.user.Credentials)4 Before (org.junit.Before)4 InterpreterSettingManager (org.apache.zeppelin.interpreter.InterpreterSettingManager)3 NotebookRepo (org.apache.zeppelin.notebook.repo.NotebookRepo)3 File (java.io.File)2 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)2 InterpreterFactory (org.apache.zeppelin.interpreter.InterpreterFactory)2 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)2 QuartzSchedulerService (org.apache.zeppelin.notebook.scheduler.QuartzSchedulerService)2 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)2 TypeToken (com.google.gson.reflect.TypeToken)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1