@Inject public SqlQueryQueueManager(QueryManagerConfig config, ObjectMapper mapper, MBeanExporter mbeanExporter) { requireNonNull(config, "config is null"); this.mbeanExporter = requireNonNull(mbeanExporter, "mbeanExporter is null"); ImmutableList.Builder<QueryQueueRule> rules = ImmutableList.builder(); if (config.getQueueConfigFile() == null) { QueryQueueDefinition global = new QueryQueueDefinition("global", config.getMaxConcurrentQueries(), config.getMaxQueuedQueries()); rules.add(new QueryQueueRule(null, null, ImmutableMap.of(), ImmutableList.of(global))); } else { File file = new File(config.getQueueConfigFile()); ManagerSpec managerSpec; try { managerSpec = mapper.readValue(file, ManagerSpec.class); } catch (IOException e) { throw Throwables.propagate(e); } Map<String, QueryQueueDefinition> definitions = new HashMap<>(); for (Map.Entry<String, QueueSpec> queue : managerSpec.getQueues().entrySet()) { definitions.put(queue.getKey(), new QueryQueueDefinition(queue.getKey(), queue.getValue().getMaxConcurrent(), queue.getValue().getMaxQueued())); } for (RuleSpec rule : managerSpec.getRules()) { rules.add(QueryQueueRule.createRule(rule.getUserRegex(), rule.getSourceRegex(), rule.getSessionPropertyRegexes(), rule.getQueues(), definitions)); } } this.rules = rules.build(); checkIsDAG(this.rules); }