Search in sources :

Example 16 with SchedulerConfigurationData

use of com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData in project dr-elephant by linkedin.

the class AzkabanJobStatusUtil method doLogin.

public WorkflowClient doLogin(AzkabanWorkflowClient workflowClient) {
    Long _currentTime = System.currentTimeMillis();
    if (_currentTime - workflowClient.getSessionUpdatedTime() > TOKEN_UPDATE_INTERVAL) {
        logger.info("Creating a new session with Azkaban");
        SchedulerConfigurationData schedulerData = InfoExtractor.getSchedulerData(scheduler);
        if (schedulerData == null) {
            throw new RuntimeException(String.format("Cannot find scheduler %s for url %s", scheduler));
        }
        if (!schedulerData.getParamMap().containsKey(USERNAME)) {
            throw new RuntimeException(String.format("Cannot find username for login"));
        }
        String username = schedulerData.getParamMap().get(USERNAME);
        if (schedulerData.getParamMap().containsKey(PRIVATE_KEY)) {
            workflowClient.login(username, new File(schedulerData.getParamMap().get(PRIVATE_KEY)));
        } else if (schedulerData.getParamMap().containsKey(PASSWORD)) {
            workflowClient.login(username, schedulerData.getParamMap().get(PASSWORD));
        } else {
            throw new RuntimeException("Neither private key nor password was specified");
        }
        workflowClient.setSessionUpdatedTime(_currentTime);
    }
    return workflowClient;
}
Also used : File(java.io.File) SchedulerConfigurationData(com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData)

Aggregations

SchedulerConfigurationData (com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData)16 Test (org.junit.Test)12 Matchers.anyString (org.mockito.Matchers.anyString)6 Scheduler (com.linkedin.drelephant.schedulers.Scheduler)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 ApplicationType (com.linkedin.drelephant.analysis.ApplicationType)1 HadoopApplicationData (com.linkedin.drelephant.analysis.HadoopApplicationData)1 WorkflowClient (com.linkedin.drelephant.clients.WorkflowClient)1 SchedulerConfiguration (com.linkedin.drelephant.configurations.scheduler.SchedulerConfiguration)1 AirflowScheduler (com.linkedin.drelephant.schedulers.AirflowScheduler)1 AzkabanScheduler (com.linkedin.drelephant.schedulers.AzkabanScheduler)1 OozieScheduler (com.linkedin.drelephant.schedulers.OozieScheduler)1 File (java.io.File)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 AppResult (models.AppResult)1