use of com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData in project dr-elephant by linkedin.
the class InfoExtractor method getWorkflowClientInstance.
/**
* Returns the workflow client instance based on the scheduler name and the workflow url
* @param scheduler The name of the scheduler
* @param url The url of the workflow
* @return The Workflow cient based on the workflow url
*/
public static WorkflowClient getWorkflowClientInstance(String scheduler, String url) {
for (SchedulerConfigurationData data : _configuredSchedulers) {
if (data.getSchedulerName().equals(scheduler)) {
try {
String workflowClass = data.getParamMap().get("exception_class");
Class<?> schedulerClass = Class.forName(workflowClass);
Object instance = schedulerClass.getConstructor(String.class).newInstance(url);
if (!(instance instanceof WorkflowClient)) {
throw new IllegalArgumentException("Class " + schedulerClass.getName() + " is not an implementation of " + WorkflowClient.class.getName());
}
WorkflowClient workflowClient = (WorkflowClient) instance;
return workflowClient;
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not find class " + data.getClassName(), e);
} catch (InstantiationException e) {
throw new RuntimeException("Could not instantiate class " + data.getClassName(), e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Could not access constructor for class" + data.getClassName(), e);
} catch (RuntimeException e) {
throw new RuntimeException(data.getClassName() + " is not a valid Scheduler class.", e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Could not invoke class " + data.getClassName(), e);
} catch (NoSuchMethodException e) {
throw new RuntimeException("Could not find constructor for class " + data.getClassName(), e);
}
}
}
return null;
}
use of com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData in project dr-elephant by linkedin.
the class InfoExtractor method getSchedulerInstance.
/**
* Find the scheduler which scheduled the job.
*
* @param appId The application id
* @param properties The application properties
* @return the corresponding Scheduler which scheduled the job.
*/
public static Scheduler getSchedulerInstance(String appId, Properties properties) {
if (properties != null) {
for (SchedulerConfigurationData data : _configuredSchedulers) {
try {
Class<?> schedulerClass = Class.forName(data.getClassName());
Object instance = schedulerClass.getConstructor(String.class, Properties.class, SchedulerConfigurationData.class).newInstance(appId, properties, data);
if (!(instance instanceof Scheduler)) {
throw new IllegalArgumentException("Class " + schedulerClass.getName() + " is not an implementation of " + Scheduler.class.getName());
}
Scheduler scheduler = (Scheduler) instance;
if (!scheduler.isEmpty()) {
return scheduler;
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not find class " + data.getClassName(), e);
} catch (InstantiationException e) {
throw new RuntimeException("Could not instantiate class " + data.getClassName(), e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Could not access constructor for class" + data.getClassName(), e);
} catch (RuntimeException e) {
throw new RuntimeException(data.getClassName() + " is not a valid Scheduler class.", e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Could not invoke class " + data.getClassName(), e);
} catch (NoSuchMethodException e) {
throw new RuntimeException("Could not find constructor for class " + data.getClassName(), e);
}
}
}
return null;
}
use of com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData in project dr-elephant by linkedin.
the class OozieSchedulerTest method testOozieLoadInfoWithOozieClientException.
@Test
public void testOozieLoadInfoWithOozieClientException() throws Exception {
thrown.expect(RuntimeException.class);
thrown.expectMessage("Failed fetching Oozie workflow " + jobInfo + " info");
doThrow(new OozieClientException("500 Internal server error", "BOOM")).when(oozieClient).getJobInfo(anyString());
SchedulerConfigurationData schedulerConfig = makeConfig("oozie", getDefaultSchedulerParams());
new OozieScheduler("id", getOozieProperties(), schedulerConfig, oozieClient);
}
use of com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData in project dr-elephant by linkedin.
the class OozieSchedulerTest method testUserGivenTemplateArePreferredUrl.
@Test
public void testUserGivenTemplateArePreferredUrl() throws Exception {
Map<String, String> params = getDefaultSchedulerParams();
SchedulerConfigurationData schedulerConfig = makeConfig("oozie", params);
OozieScheduler scheduler = new OozieScheduler("id", getOozieProperties(), schedulerConfig, manualCommittedJobClient);
assertEquals("http://oozie/search?workflow=" + jobInfo, scheduler.getJobDefUrl());
assertEquals("http://oozie/workflows/" + jobInfo, scheduler.getJobExecUrl());
assertEquals("http://oozie/search?workflow=" + parentJobInfo, scheduler.getFlowDefUrl());
assertEquals("http://oozie/workflows/" + parentJobInfo, scheduler.getFlowExecUrl());
}
use of com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData in project dr-elephant by linkedin.
the class OozieSchedulerTest method testOozieLoadsNameFromConfData.
@Test
public void testOozieLoadsNameFromConfData() {
SchedulerConfigurationData schedulerConfig = makeConfig("othername", getDefaultSchedulerParams());
OozieScheduler scheduler = new OozieScheduler("id", null, schedulerConfig);
assertEquals("othername", scheduler.getSchedulerName());
}
Aggregations