/** * Set a component option, creating the component if necessary * @param component component name * @param option option name * @param val value */ public void setComponentOpt(String component, String option, String val) { Map<String, String> roleopts = getOrAddComponent(component); roleopts.put(option, val); }
/** * Set a component option, creating the component if necessary * @param component component name * @param option option name * @param val value */ public void setComponentOpt(String component, String option, String val) { Map<String, String> roleopts = getOrAddComponent(component); roleopts.put(option, val); }
/** * Merge the map of a single component * @param component component name * @param map map to merge */ public void mergeSingleComponentMap(String component, Map<String, String> map) { MapOperations comp = getOrAddComponent(component); comp.putAll(map); } /**
/** * Merge the map of a single component * @param component component name * @param map map to merge */ public void mergeSingleComponentMap(String component, Map<String, String> map) { MapOperations comp = getOrAddComponent(component); comp.putAll(map); } /**
@BeforeClass public static void init() { resources.getOrAddComponent("A"); resources.getOrAddComponent("B"); resources.getOrAddComponent("C"); resources.getOrAddComponent("D"); resources.getOrAddComponent("E"); }
@BeforeClass public static void init() { resources.getOrAddComponent("A"); resources.getOrAddComponent("B"); resources.getOrAddComponent("C"); resources.getOrAddComponent("D"); resources.getOrAddComponent("E"); }
/** * Merge the map of a single component * @param component component name * @param map map to merge */ public void mergeSingleComponentMapPrefix(String component, Map<String, String> map, String prefix, boolean overwrite) { boolean needsMerge = false; for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { needsMerge = true; break; } } if (!needsMerge) { return; } MapOperations comp = getOrAddComponent(component); comp.mergeMapPrefixedKeys(map,prefix, overwrite); }
/** * Merge in another tree with overwrites * @param that the other tree */ public void merge(ConfTree that) { getGlobalOptions().putAll(that.global); confTree.metadata.putAll(that.metadata); confTree.credentials.putAll(that.credentials); for (Map.Entry<String, Map<String, String>> entry : that.components.entrySet()) { MapOperations comp = getOrAddComponent(entry.getKey()); comp.putAll(entry.getValue()); } }
/** * Merge in another tree -no overwrites of global or conf data * (note that metadata does a naive putAll merge/overwrite) * @param that the other tree */ public void mergeWithoutOverwrite(ConfTree that) { getGlobalOptions().mergeWithoutOverwrite(that.global); confTree.metadata.putAll(that.metadata); confTree.credentials.putAll(that.credentials); for (Map.Entry<String, Map<String, String>> entry : that.components.entrySet()) { MapOperations comp = getOrAddComponent(entry.getKey()); comp.mergeWithoutOverwrite(entry.getValue()); } }
/** * Merge the map of a single component * @param component component name * @param map map to merge */ public void mergeSingleComponentMapPrefix(String component, Map<String, String> map, String prefix, boolean overwrite) { boolean needsMerge = false; for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { needsMerge = true; break; } } if (!needsMerge) { return; } MapOperations comp = getOrAddComponent(component); comp.mergeMapPrefixedKeys(map,prefix, overwrite); }
/** * Merge in another tree -no overwrites of global or conf data * (note that metadata does a naive putAll merge/overwrite) * @param that the other tree */ public void mergeWithoutOverwrite(ConfTree that) { getGlobalOptions().mergeWithoutOverwrite(that.global); confTree.metadata.putAll(that.metadata); confTree.credentials.putAll(that.credentials); for (Map.Entry<String, Map<String, String>> entry : that.components.entrySet()) { MapOperations comp = getOrAddComponent(entry.getKey()); comp.mergeWithoutOverwrite(entry.getValue()); } }
/** * Merge in another tree with overwrites * @param that the other tree */ public void merge(ConfTree that) { getGlobalOptions().putAll(that.global); confTree.metadata.putAll(that.metadata); confTree.credentials.putAll(that.credentials); for (Map.Entry<String, Map<String, String>> entry : that.components.entrySet()) { MapOperations comp = getOrAddComponent(entry.getKey()); comp.putAll(entry.getValue()); } }
/** * Start an asychronous launch operation * @param assignment container assignment * @param clusterSpec cluster spec to use for template * @param credentials credentials to use */ public void launchRole(ContainerAssignment assignment, AggregateConf clusterSpec, Credentials credentials) { RoleStatus role = assignment.role; String roleName = role.getName(); String roleGroup = role.getGroup(); // prelaunch safety check Preconditions.checkArgument(provider.isSupportedRole(roleName)); RoleLaunchService.RoleLauncher launcher = new RoleLaunchService.RoleLauncher(assignment, clusterSpec, clusterSpec.getResourceOperations().getOrAddComponent(roleGroup), clusterSpec.getAppConfOperations().getOrAddComponent(roleGroup), credentials); execute(launcher); }
/** * Start an asychronous launch operation * @param assignment container assignment * @param clusterSpec cluster spec to use for template * @param credentials credentials to use */ public void launchRole(ContainerAssignment assignment, AggregateConf clusterSpec, Credentials credentials) { RoleStatus role = assignment.role; String roleName = role.getName(); String roleGroup = role.getGroup(); // prelaunch safety check Preconditions.checkArgument(provider.isSupportedRole(roleName)); RoleLaunchService.RoleLauncher launcher = new RoleLaunchService.RoleLauncher(assignment, clusterSpec, clusterSpec.getResourceOperations().getOrAddComponent(roleGroup), clusterSpec.getAppConfOperations().getOrAddComponent(roleGroup), credentials); execute(launcher); }
log.debug("Merging options for {} into {}", subComponent, prefix + subComponent); MapOperations subComponentOps = ops.getOrAddComponent( prefix + subComponent); if (priority == null) {
instanceDescription.getInternalOperations().getOrAddComponent( SliderKeys.COMPONENT_AM));
@Test public void testComponentCommandOrderBadComponent() throws Exception { ConfTreeOperations resourcesGood = new ConfTreeOperations(new ConfTree()); resourcesGood.getOrAddComponent("A"); resourcesGood.getOrAddComponent("Z"); ConfTreeOperations resourcesBad = new ConfTreeOperations(new ConfTree()); CommandOrder co1 = new CommandOrder(); co1.setCommand("A-START"); co1.setRequires("Z-STARTED"); CommandOrder co2 = new CommandOrder(); co2.setCommand("Z-START"); co2.setRequires("A-STARTED"); ComponentCommandOrder cco = new ComponentCommandOrder( Arrays.asList(co1), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co1), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } }
@Test public void testComponentCommandOrderBadComponent() throws Exception { ConfTreeOperations resourcesGood = new ConfTreeOperations(new ConfTree()); resourcesGood.getOrAddComponent("A"); resourcesGood.getOrAddComponent("Z"); ConfTreeOperations resourcesBad = new ConfTreeOperations(new ConfTree()); CommandOrder co1 = new CommandOrder(); co1.setCommand("A-START"); co1.setRequires("Z-STARTED"); CommandOrder co2 = new CommandOrder(); co2.setCommand("Z-START"); co2.setRequires("A-STARTED"); ComponentCommandOrder cco = new ComponentCommandOrder( Arrays.asList(co1), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co1), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } }
private AggregateConf prepareConfForAgentStateTests() { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); AggregateConf instanceDefinition = new AggregateConf(); instanceDefinition.setInternal(tree); instanceDefinition.setAppConf(tree); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.APP_DEF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_CONF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_VERSION, "."); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_MASTER"); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_REGIONSERVER"); return instanceDefinition; }
private AggregateConf prepareConfForAgentStateTests() { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); AggregateConf instanceDefinition = new AggregateConf(); instanceDefinition.setInternal(tree); instanceDefinition.setAppConf(tree); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.APP_DEF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_CONF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions() .put(AgentKeys.AGENT_VERSION, "."); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_MASTER"); instanceDefinition.getResourceOperations().getOrAddComponent( "HBASE_REGIONSERVER"); return instanceDefinition; }