}
if(jobDirs.size() < 1)
throw new IllegalArgumentException("No job directory given.");
Props defaultProps = PropsUtils.loadPropsInDirs(_jobDirs, ".properties", ".schema");
_baseClassLoader = getBaseClassloader();
String defaultTimezoneID = defaultProps.getString(DEFAULT_TIMEZONE_ID, null);
if (defaultTimezoneID != null) {
DateTimeZone.setDefault(DateTimeZone.forID(defaultTimezoneID));
TimeZone.setDefault(TimeZone.getTimeZone(defaultTimezoneID));
}
NamedPermitManager permitManager = getNamedPermitManager(defaultProps);
JobWrappingFactory factory = new JobWrappingFactory(
permitManager,
new ReadWriteLockManager(),
_logsDir.getAbsolutePath(),
"java",
new ImmutableMap.Builder<String, Class<? extends Job>>()
.put("java", JavaJob.class)
.put("command", ProcessJob.class)
.put("javaprocess", JavaProcessJob.class)
.put("pig", PigProcessJob.class)
.put("propertyPusher", NoopJob.class)
.put("python", PythonJob.class)
.put("ruby", RubyJob.class)
.put("script", ScriptJob.class).build());
_hdfsUrl = defaultProps.getString("hdfs.instance.url", null);
_jobManager = new JobManager(factory,
_logsDir.getAbsolutePath(),
defaultProps,
_jobDirs,
_baseClassLoader);
_mailer = new Mailman(defaultProps.getString("mail.host", "localhost"),
defaultProps.getString("mail.user", ""),
defaultProps.getString("mail.password", ""));
String failureEmail = defaultProps.getString("job.failure.email", null);
String successEmail = defaultProps.getString("job.success.email", null);
int schedulerThreads = defaultProps.getInt("scheduler.threads", 50);
_instanceName = defaultProps.getString(INSTANCE_NAME, "");
final File initialJobDir = _jobDirs.get(0);
File schedule = getScheduleFile(defaultProps, initialJobDir);
File backup = getBackupFile(defaultProps, initialJobDir);
File executionsStorageDir = new File(
defaultProps.getString("azkaban.executions.storage.dir", initialJobDir.getAbsolutePath() + "/executions")
);
if (! executionsStorageDir.exists()) executionsStorageDir.mkdirs();
long lastExecutionId = getLastExecutionId(executionsStorageDir);
logger.info(String.format("Using path[%s] for storing executions.", executionsStorageDir));
logger.info(String.format("Last known execution id was [%s]", lastExecutionId));
final ExecutableFlowSerializer flowSerializer = new DefaultExecutableFlowSerializer();
final ExecutableFlowDeserializer flowDeserializer = new DefaultExecutableFlowDeserializer(_jobManager, factory);
FlowExecutionSerializer flowExecutionSerializer = new FlowExecutionSerializer(flowSerializer);
FlowExecutionDeserializer flowExecutionDeserializer = new FlowExecutionDeserializer(flowDeserializer);
_allFlows = new CachingFlowManager(
new RefreshableFlowManager(
_jobManager,
flowExecutionSerializer,
flowExecutionDeserializer,
executionsStorageDir,
lastExecutionId
),
defaultProps.getInt("azkaban.flow.cache.size", 1000)
);
_jobManager.setFlowManager(_allFlows);
_jobExecutorManager = new JobExecutorManager(
_allFlows,
_jobManager,
_mailer,
failureEmail,
successEmail,
schedulerThreads
);
this._schedulerManager = new ScheduleManager(_jobExecutorManager, new LocalFileScheduleLoader(schedule, backup));
/* set predefined log url prefix
*/
String server_url = defaultProps.getString("server.url", null) ;
if (server_url != null) {
if (server_url.endsWith("/"))
_jobExecutorManager.setRuntimeProperty(AppCommon.DEFAULT_LOG_URL_PREFIX, server_url + "logs?file=" );
else
_jobExecutorManager.setRuntimeProperty(AppCommon.DEFAULT_LOG_URL_PREFIX, server_url + "/logs?file=" );