/** * Set a global option, converting it to a string as needed * @param key key * @param value non null value */ public void set(String key, Object value) { globalOptions.put(key, value.toString()); } /**
/** * Set a global option, converting it to a string as needed * @param key key * @param value non null value */ public void set(String key, Object value) { globalOptions.put(key, value.toString()); } /**
public void set(String key, Object value) { assert value != null; put(key, value.toString()); }
public void set(String key, Object value) { assert value != null; put(key, value.toString()); }
/** * This is critical for an insecure cluster -it passes * down the username to YARN, and so gives the code running * in containers the rights it needs to work with * data. * @throws IOException problems working with current user */ protected void propagateUsernameInInsecureCluster() throws IOException { //insecure cluster: propagate user name via env variable String userName = UserGroupInformation.getCurrentUser().getUserName(); env.put(SliderKeys.HADOOP_USER_NAME, userName); }
/** * Set an environment variable in the launch context * @param var variable name * @param value value (must be non null) */ public void setEnv(String var, String value) { Preconditions.checkArgument(var != null, "null variable name"); Preconditions.checkArgument(value != null, "null value"); env.put(var, value); }
/** * This is critical for an insecure cluster -it passes * down the username to YARN, and so gives the code running * in containers the rights it needs to work with * data. * @throws IOException problems working with current user */ protected void propagateUsernameInInsecureCluster() throws IOException { //insecure cluster: propagate user name via env variable String userName = UserGroupInformation.getCurrentUser().getUserName(); env.put(SliderKeys.HADOOP_USER_NAME, userName); }
/** * Set an environment variable in the launch context * @param var variable name * @param value value (must be non null) */ public void setEnv(String var, String value) { Preconditions.checkArgument(var != null, "null variable name"); Preconditions.checkArgument(value != null, "null value"); env.put(var, value); }
/** * Set a property if it is not already set * @param key key * @param value value */ public void putIfUnset(String key, String value) { if (get(key) == null) { put(key, value); } }
/** * Set a property if it is not already set * @param key key * @param value value */ public void putIfUnset(String key, String value) { if (get(key) == null) { put(key, value); } }
/** * Add the ZK paths to the application options. * * @param zkBinding ZK binding */ public void addZKBinding(ZKPathBuilder zkBinding) throws BadConfigException { String quorum = zkBinding.getAppQuorum(); if (SliderUtils.isSet(quorum)) { MapOperations globalAppOptions = instanceDescription.getAppConfOperations().getGlobalOptions(); globalAppOptions.put(ZOOKEEPER_PATH, zkBinding.getAppPath()); globalAppOptions.put(ZOOKEEPER_QUORUM, quorum); globalAppOptions.put(ZOOKEEPER_HOSTS, ZookeeperUtils.convertToHostsOnlyList(quorum)); } }
/** * Add the ZK paths to the application options. * * @param zkBinding ZK binding */ public void addZKBinding(ZKPathBuilder zkBinding) throws BadConfigException { String quorum = zkBinding.getAppQuorum(); if (SliderUtils.isSet(quorum)) { MapOperations globalAppOptions = instanceDescription.getAppConfOperations().getGlobalOptions(); globalAppOptions.put(ZOOKEEPER_PATH, zkBinding.getAppPath()); globalAppOptions.put(ZOOKEEPER_QUORUM, quorum); globalAppOptions.put(ZOOKEEPER_HOSTS, ZookeeperUtils.convertToHostsOnlyList(quorum)); } }
/** * append to a global option * @param key key * @return value * */ public String append(String key, String value) { if (SliderUtils.isUnset(value)) { return null; } if (globalOptions.containsKey(key)) { globalOptions.put(key, globalOptions.get(key) + "," + value); } else { globalOptions.put(key, value); } return globalOptions.get(key); }
@Before public void setup() throws Exception { certMan = new CertificateManager(); MapOperations compOperations = new MapOperations(); secDir = new File(workDir.getRoot(), SliderKeys.SECURITY_DIR); File keystoreFile = new File(secDir, SliderKeys.KEYSTORE_FILE_NAME); compOperations.put(SliderXmlConfKeys.KEY_KEYSTORE_LOCATION, keystoreFile.getAbsolutePath()); certMan.initialize(compOperations, "cahost", null, null); }
@Before public void setup() throws Exception { certMan = new CertificateManager(); MapOperations compOperations = new MapOperations(); secDir = new File(workDir.getRoot(), SliderKeys.SECURITY_DIR); File keystoreFile = new File(secDir, SliderKeys.KEYSTORE_FILE_NAME); compOperations.put(SliderXmlConfKeys.KEY_KEYSTORE_LOCATION, keystoreFile.getAbsolutePath()); certMan.initialize(compOperations, "cahost", null, null); }
@Test public void testParameterParsing() throws IOException { AgentProviderService aps = createAgentProviderService(new Configuration()); AggregateConf aggConf = new AggregateConf(); ConfTreeOperations treeOps = aggConf.getAppConfOperations(); treeOps.getGlobalOptions().put(AgentKeys.SYSTEM_CONFIGS, "core-site,yarn-site, core-site "); List<String> configs = aps.getSystemConfigurationsRequested(treeOps); Assert.assertEquals(2, configs.size()); Assert.assertTrue(configs.contains("core-site")); Assert.assertFalse(configs.contains("bore-site")); }
@Test public void testParameterParsing() throws IOException { AgentProviderService aps = createAgentProviderService(new Configuration()); AggregateConf aggConf = new AggregateConf(); ConfTreeOperations treeOps = aggConf.getAppConfOperations(); treeOps.getGlobalOptions().put(AgentKeys.SYSTEM_CONFIGS, "core-site,yarn-site, core-site "); List<String> configs = aps.getSystemConfigurationsRequested(treeOps); Assert.assertEquals(2, configs.size()); Assert.assertTrue(configs.contains("core-site")); Assert.assertFalse(configs.contains("bore-site")); }
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; }
@Test public void testContainerStoresGenerationMisconfiguration() throws Exception { AggregateConf instanceDefinition = new AggregateConf(); MapOperations compOps = new MapOperations(); compOps.put(SliderKeys.COMP_STORES_REQUIRED_KEY, "true"); setupCredentials(instanceDefinition, "cant.be.found", null); try { StoresGenerator.generateSecurityStores("testhost", "container1", "component1", instanceDefinition, compOps); Assert.fail("SliderException should have been generated"); } catch (SliderException e) { // ignore - should be thrown } }
@Test public void testContainerStoresGenerationMisconfiguration() throws Exception { AggregateConf instanceDefinition = new AggregateConf(); MapOperations compOps = new MapOperations(); compOps.put(SliderKeys.COMP_STORES_REQUIRED_KEY, "true"); setupCredentials(instanceDefinition, "cant.be.found", null); try { StoresGenerator.generateSecurityStores("testhost", "container1", "component1", instanceDefinition, compOps); Assert.fail("SliderException should have been generated"); } catch (SliderException e) { // ignore - should be thrown } }