void initialize() throws ExecutorManagerException { if (this.initialized) { return; } this.initialized = true; this.setupExecutors(); this.loadRunningExecutions(); this.queuedFlows = new QueuedExecutions( this.azkProps.getLong(ConfigurationKeys.WEBSERVER_QUEUE_SIZE, 100000)); this.loadQueuedFlows(); this.cacheDir = new File(this.azkProps.getString("cache.directory", "cache")); // TODO extract QueueProcessor as a separate class, move all of this into it setupExecutotrComparatorWeightsMap(); setupExecutorFilterList(); this.queueProcessor = setupQueueProcessor(); }
@Test(expected = ExecutorManagerException.class) public void testSetupExecutorsException() throws Exception { this.props.put(Constants.ConfigurationKeys.USE_MULTIPLE_EXECUTORS, "true"); final Executor executor1 = this.loader.addExecutor("localhost", 12345); final ExecutorManager manager = createExecutorManager(); final Set<Executor> activeExecutors = new HashSet(manager.getAllActiveExecutors()); Assert.assertArrayEquals(activeExecutors.toArray(), new Executor[]{executor1}); // mark older executor as inactive executor1.setActive(false); this.loader.updateExecutor(executor1); manager.setupExecutors(); }
@Test public void testSetupExecutorsSucess() throws Exception { this.props.put(Constants.ConfigurationKeys.USE_MULTIPLE_EXECUTORS, "true"); final Executor executor1 = this.loader.addExecutor("localhost", 12345); final ExecutorManager manager = createExecutorManager(); Assert.assertArrayEquals(manager.getAllActiveExecutors().toArray(), new Executor[]{executor1}); // mark older executor as inactive executor1.setActive(false); this.loader.updateExecutor(executor1); final Executor executor2 = this.loader.addExecutor("localhost", 12346); final Executor executor3 = this.loader.addExecutor("localhost", 12347); manager.setupExecutors(); Assert.assertArrayEquals(manager.getAllActiveExecutors().toArray(), new Executor[]{executor2, executor3}); }
@Inject public ExecutorManager(final Props azkProps, final ExecutorLoader loader, final AlerterHolder alerterHolder, final CommonMetrics commonMetrics, final ExecutorApiGateway apiGateway) throws ExecutorManagerException { this.alerterHolder = alerterHolder; this.azkProps = azkProps; this.commonMetrics = commonMetrics; this.executorLoader = loader; this.apiGateway = apiGateway; this.setupExecutors(); this.loadRunningFlows(); this.queuedFlows = new QueuedExecutions( azkProps.getLong(Constants.ConfigurationKeys.WEBSERVER_QUEUE_SIZE, 100000)); // The default threshold is set to 30 for now, in case some users are affected. We may // decrease this number in future, to better prevent DDos attacks. this.maxConcurrentRunsOneFlow = azkProps .getInt(Constants.ConfigurationKeys.MAX_CONCURRENT_RUNS_ONEFLOW, DEFAULT_MAX_ONCURRENT_RUNS_ONEFLOW); this.loadQueuedFlows(); this.cacheDir = new File(azkProps.getString("cache.directory", "cache")); this.executingManager = new ExecutingManagerUpdaterThread(); if (isMultiExecutorMode()) { setupMultiExecutorMode(); } final long executionLogsRetentionMs = azkProps.getLong("execution.logs.retention.ms", DEFAULT_EXECUTION_LOGS_RETENTION_MS); this.cleanerThread = new CleanerThread(executionLogsRetentionMs); }