private static AllocationConfigurationException createConfigException( String value, String message, Throwable t) { String msg = INVALID_RESOURCE_DEFINITION_PREFIX + value + ". " + message; if (t != null) { return new AllocationConfigurationException(msg, t); } else { return new AllocationConfigurationException(msg); } }
@Test public void testParentWithReservation() throws Exception { Configuration conf = new Configuration(); conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); out.println("<?xml version=\"1.0\"?>"); out.println("<allocations>"); out.println("<queue name=\"parent\">"); out.println("<reservation>"); out.println("</reservation>"); out.println(" <queue name=\"child\">"); out.println(" </queue>"); out.println("</queue>"); out.println("</allocations>"); out.close(); AllocationFileLoaderService allocLoader = new AllocationFileLoaderService(); allocLoader.init(conf); ReloadListener confHolder = new ReloadListener(); allocLoader.setReloadListener(confHolder); try { allocLoader.reloadAllocations(); } catch (AllocationConfigurationException ex) { assertEquals(ex.getMessage(), "The configuration settings for root.parent" + " are invalid. A queue element that contains child queue elements" + " or that has the type='parent' attribute cannot also include a" + " reservation element."); } }
@Test public void testParentTagWithReservation() throws Exception { Configuration conf = new Configuration(); conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); out.println("<?xml version=\"1.0\"?>"); out.println("<allocations>"); out.println("<queue name=\"parent\" type=\"parent\">"); out.println("<reservation>"); out.println("</reservation>"); out.println("</queue>"); out.println("</allocations>"); out.close(); AllocationFileLoaderService allocLoader = new AllocationFileLoaderService(); allocLoader.init(conf); ReloadListener confHolder = new ReloadListener(); allocLoader.setReloadListener(confHolder); try { allocLoader.reloadAllocations(); } catch (AllocationConfigurationException ex) { assertEquals(ex.getMessage(), "The configuration settings for root.parent" + " are invalid. A queue element that contains child queue elements" + " or that has the type='parent' attribute cannot also include a" + " reservation element."); } }
private static int findResource(String val, String units) throws AllocationConfigurationException { final Pattern pattern = Pattern.compile("(\\d+)(\\.\\d*)?\\s*" + units); Matcher matcher = pattern.matcher(val); if (!matcher.find()) { throw new AllocationConfigurationException("Missing resource: " + units); } return Integer.parseInt(matcher.group(1)); } }
private static int findResource(String val, String units) throws AllocationConfigurationException { Pattern pattern = Pattern.compile("(\\d+)\\s*" + units); Matcher matcher = pattern.matcher(val); if (!matcher.find()) { throw new AllocationConfigurationException("Missing resource: " + units); } return Integer.parseInt(matcher.group(1)); } }
private static int findResource(String val, String units) throws AllocationConfigurationException { Pattern pattern = Pattern.compile("(\\d+)\\s*" + units); Matcher matcher = pattern.matcher(val); if (!matcher.find()) { throw new AllocationConfigurationException("Missing resource: " + units); } return Integer.parseInt(matcher.group(1)); } }
private static double findPercentage(String val, String units) throws AllocationConfigurationException { final Pattern pattern = Pattern.compile("((\\d+)(\\.\\d*)?)\\s*%\\s*" + units); Matcher matcher = pattern.matcher(val); if (!matcher.find()) { if (units.equals("")) { throw new AllocationConfigurationException("Invalid percentage: " + val); } else { throw new AllocationConfigurationException("Missing resource: " + units); } } return Double.parseDouble(matcher.group(1)) / 100.0; }
protected void throwPolicyDoesnotApplyException(SchedulingPolicy policy) throws AllocationConfigurationException { throw new AllocationConfigurationException("SchedulingPolicy " + policy + " does not apply to queue " + getName()); }
protected void throwPolicyDoesnotApplyException(SchedulingPolicy policy) throws AllocationConfigurationException { throw new AllocationConfigurationException("SchedulingPolicy " + policy + " does not apply to queue " + getName()); }
/** * Create and initialize a rule given a xml node * @param node * @return QueuePlacementPolicy * @throws AllocationConfigurationException */ public static QueuePlacementRule createAndInitializeRule(Node node) throws AllocationConfigurationException { Element element = (Element) node; String ruleName = element.getAttribute("name"); if ("".equals(ruleName)) { throw new AllocationConfigurationException("No name provided for a " + "rule element"); } Class<? extends QueuePlacementRule> clazz = ruleClasses.get(ruleName); if (clazz == null) { throw new AllocationConfigurationException("No rule class found for " + ruleName); } QueuePlacementRule rule = ReflectionUtils.newInstance(clazz, null); rule.initializeFromXml(element); return rule; }
/** * Create and initialize a rule given a xml node * @param node * @return QueuePlacementPolicy * @throws AllocationConfigurationException */ public static QueuePlacementRule createAndInitializeRule(Node node) throws AllocationConfigurationException { Element element = (Element) node; String ruleName = element.getAttribute("name"); if ("".equals(ruleName)) { throw new AllocationConfigurationException("No name provided for a " + "rule element"); } Class<? extends QueuePlacementRule> clazz = ruleClasses.get(ruleName); if (clazz == null) { throw new AllocationConfigurationException("No rule class found for " + ruleName); } QueuePlacementRule rule = ReflectionUtils.newInstance(clazz, null); rule.initializeFromXml(element); return rule; }
/** * Create and initialize a rule given a xml node * @param node * @return QueuePlacementPolicy * @throws AllocationConfigurationException */ public static QueuePlacementRule createAndInitializeRule(Node node) throws AllocationConfigurationException { Element element = (Element) node; String ruleName = element.getAttribute("name"); if ("".equals(ruleName)) { throw new AllocationConfigurationException("No name provided for a " + "rule element"); } Class<? extends QueuePlacementRule> clazz = ruleClasses.get(ruleName); if (clazz == null) { throw new AllocationConfigurationException("No rule class found for " + ruleName); } QueuePlacementRule rule = ReflectionUtils.newInstance(clazz, null); rule.initializeFromXml(element); return rule; }
public QueuePlacementPolicy(List<QueuePlacementRule> rules, Map<FSQueueType, Set<String>> configuredQueues, Configuration conf) throws AllocationConfigurationException { for (int i = 0; i < rules.size()-1; i++) { if (rules.get(i).isTerminal()) { throw new AllocationConfigurationException("Rules after rule " + i + " in queue placement policy can never be reached"); } } if (!rules.get(rules.size()-1).isTerminal()) { throw new AllocationConfigurationException( "Could get past last queue placement rule without assigning"); } this.rules = rules; this.configuredQueues = configuredQueues; groups = new Groups(conf); }
private SchedulingPolicy extractSchedulingPolicy(Element element) throws AllocationConfigurationException { String text = getTrimmedTextData(element); if (text.equalsIgnoreCase(FifoPolicy.NAME)) { throw new AllocationConfigurationException("Bad fair scheduler " + "config file: defaultQueueSchedulingPolicy or " + "defaultQueueSchedulingMode can't be FIFO."); } return SchedulingPolicy.parse(text); }
public QueuePlacementPolicy(List<QueuePlacementRule> rules, Map<FSQueueType, Set<String>> configuredQueues, Configuration conf) throws AllocationConfigurationException { for (int i = 0; i < rules.size()-1; i++) { if (rules.get(i).isTerminal()) { throw new AllocationConfigurationException("Rules after rule " + i + " in queue placement policy can never be reached"); } } if (!rules.get(rules.size()-1).isTerminal()) { throw new AllocationConfigurationException( "Could get past last queue placement rule without assigning"); } this.rules = rules; this.configuredQueues = configuredQueues; groups = new Groups(conf); }
public QueuePlacementPolicy(List<QueuePlacementRule> rules, Map<FSQueueType, Set<String>> configuredQueues, Configuration conf) throws AllocationConfigurationException { for (int i = 0; i < rules.size()-1; i++) { if (rules.get(i).isTerminal()) { throw new AllocationConfigurationException("Rules after rule " + i + " in queue placement policy can never be reached"); } } if (!rules.get(rules.size()-1).isTerminal()) { throw new AllocationConfigurationException( "Could get past last queue placement rule without assigning"); } this.rules = rules; this.configuredQueues = configuredQueues; groups = new Groups(conf); }
.createAndInitializeRule(node); if (rule == null) { throw new AllocationConfigurationException( "Unable to create nested rule in nestedUserQueue rule"); throw new AllocationConfigurationException( "No nested rule specified in <nestedUserQueue> rule");
.createAndInitializeRule(node); if (rule == null) { throw new AllocationConfigurationException( "Unable to create nested rule in nestedUserQueue rule"); throw new AllocationConfigurationException( "No nested rule specified in <nestedUserQueue> rule");
.createAndInitializeRule(node); if (rule == null) { throw new AllocationConfigurationException( "Unable to create nested rule in nestedUserQueue rule"); throw new AllocationConfigurationException( "No nested rule specified in <nestedUserQueue> rule");
clazz = Class.forName(policy); } catch (ClassNotFoundException cnfe) { throw new AllocationConfigurationException(policy + " SchedulingPolicy class not found!"); throw new AllocationConfigurationException(policy + " does not extend SchedulingPolicy");