Example usage for org.apache.hadoop.conf Configuration setBoolean

List of usage examples for org.apache.hadoop.conf Configuration setBoolean

Introduction

In this page you can find the example usage for org.apache.hadoop.conf Configuration setBoolean.

Prototype

public void setBoolean(String name, boolean value) 

Source Link

Document

Set the value of the name property to a boolean.

Usage

From source file:com.cloudera.llama.am.TestLlamaHAServer.java

License:Apache License

@Before
public void setup() {
    Configuration conf = new Configuration(false);
    conf.set(ServerConfiguration.CONFIG_DIR_KEY, TestAbstractMain.createTestDir());
    conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MockRMConnector.class, RMConnector.class);
    conf.set(LlamaAM.CORE_QUEUES_KEY, "root.q1,root.q2");
    conf.set(MockRMConnector.QUEUES_KEY, "root.q1,root.q2");
    String nodesKey = "" + MockLlamaAMFlags.ALLOCATE + "n1";
    conf.set(MockRMConnector.NODES_KEY, nodesKey);
    conf.setInt(MockRMConnector.EVENTS_MIN_WAIT_KEY, 5);
    conf.setInt(MockRMConnector.EVENTS_MAX_WAIT_KEY, 10);

    ServerConfiguration sConf = new AMServerConfiguration(conf);
    conf.set(sConf.getPropertyName(ServerConfiguration.SERVER_ADDRESS_KEY), "localhost:0");
    conf.set(sConf.getPropertyName(ServerConfiguration.SERVER_ADMIN_ADDRESS_KEY), "localhost:0");
    conf.set(sConf.getPropertyName(ServerConfiguration.HTTP_ADDRESS_KEY), "localhost:0");

    conf.setBoolean(HAServerConfiguration.HA_ENABLED, true);
    server = new LlamaHAServer();
    server.setConf(conf);//from ww  w. java 2s .c om
}

From source file:com.cloudera.llama.am.TestSecureLlamaAMThriftServer.java

License:Apache License

@Override
protected Configuration createCallbackConfiguration() throws Exception {
    ServerConfiguration cConf = new NotificationServerConfiguration();
    Configuration conf = super.createCallbackConfiguration();
    String confDir = conf.get(ServerConfiguration.CONFIG_DIR_KEY);
    ParamChecker.notEmpty(confDir, "missing confDir");

    conf.setBoolean(cConf.getPropertyName(ServerConfiguration.SECURITY_ENABLED_KEY), true);
    File keytab = new File(confDir, "notification.keytab");
    miniKdc.createPrincipal(keytab, "notification/localhost");
    conf.set(cConf.getPropertyName(ServerConfiguration.KEYTAB_FILE_KEY), keytab.getAbsolutePath());
    conf.set(cConf.getPropertyName(ServerConfiguration.SERVER_PRINCIPAL_NAME_KEY), "notification/localhost");
    conf.set(cConf.getPropertyName(ServerConfiguration.SERVER_ADDRESS_KEY), "localhost:0");
    return conf;//from   w ww  .  ja v a2  s. co  m
}

From source file:com.cloudera.llama.am.TestSecureLlamaAMThriftServer.java

License:Apache License

@Override
protected Configuration createLlamaConfiguration() throws Exception {
    Configuration conf = super.createLlamaConfiguration();
    String confDir = conf.get(ServerConfiguration.CONFIG_DIR_KEY);
    ParamChecker.notEmpty(confDir, "missing confDir");
    conf.setBoolean(amConf.getPropertyName(ServerConfiguration.SECURITY_ENABLED_KEY), true);
    File keytab = new File(confDir, "llama.keytab");
    miniKdc.createPrincipal(keytab, "llama/localhost");
    conf.set(amConf.getPropertyName(ServerConfiguration.KEYTAB_FILE_KEY), keytab.getAbsolutePath());
    conf.set(amConf.getPropertyName(ServerConfiguration.SERVER_PRINCIPAL_NAME_KEY), "llama/localhost");
    conf.set(amConf.getPropertyName(ServerConfiguration.SERVER_ADDRESS_KEY), "localhost:0");
    conf.set(amConf.getPropertyName(ServerConfiguration.NOTIFICATION_PRINCIPAL_NAME_KEY), "notification");
    return conf;// w w w  .j a  v a 2  s.  c om
}

From source file:com.cloudera.llama.am.yarn.TestLlamaAMWithYarn.java

License:Apache License

private Configuration createMiniYarnConfig(boolean usePortInName) throws Exception {
    Configuration conf = new YarnConfiguration();
    conf.set("yarn.scheduler.fair.allocation.file", "test-fair-scheduler.xml");
    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 0);
    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, 0);
    conf.setClass(YarnConfiguration.RM_SCHEDULER, FairScheduler.class, FairScheduler.class);

    //proxy user config
    String llamaProxyUser = System.getProperty("user.name");
    conf.set("hadoop.security.authentication", "simple");
    conf.set("hadoop.proxyuser." + llamaProxyUser + ".hosts", "*");
    conf.set("hadoop.proxyuser." + llamaProxyUser + ".groups", "*");
    String[] userGroups = new String[] { "g" };
    UserGroupInformation.createUserForTesting(llamaProxyUser, userGroups);
    conf.setBoolean(YarnConfiguration.RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAME, usePortInName);
    return conf;/* w ww . java2  s.co  m*/
}

From source file:com.cloudera.llama.am.yarn.TestLlamaAMWithYarn.java

License:Apache License

private void restartMiniYarn() throws Exception {
    Configuration conf = miniYarn.getConfig();
    conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true);
    stopYarn();/*from   w  ww  . java  2s  .  co m*/
    startYarn(conf);
}

From source file:com.cloudera.llama.am.yarn.TestLlamaAMWithYarn.java

License:Apache License

@Test
public void testResourceRejections() throws Exception {
    try {//  w w  w  .j  a  va 2s. co m
        Configuration conf = createMiniYarnConfig(true);
        conf.setInt(YarnConfiguration.NM_VCORES, 1);
        conf.setInt(YarnConfiguration.NM_PMEM_MB, 4096);
        conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, 2);
        conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 5020);
        startYarn(conf, 1);
        Configuration llamaConf = getLlamaConfiguration();
        llamaConf.setBoolean(LlamaAM.NORMALIZING_ENABLED_KEY, false);
        LlamaAM llama = LlamaAM.create(llamaConf);
        try {
            llama.start();
            List<NodeInfo> nodes = llama.getNodes();

            //invalid node
            try {
                Resource r = TestUtils.createResource("xyz:-1", Resource.Locality.MUST, 1, 4096);
                llama.reserve(TestUtils.createReservation(UUID.randomUUID(), "u", "root.queue1",
                        Arrays.asList(r), true));
                Assert.fail();
            } catch (LlamaException ex) {
                //NOP
            }

            //over max cpus
            try {
                Resource r = TestUtils.createResource(nodes.get(0).getLocation(), Resource.Locality.MUST, 3,
                        4096);
                llama.reserve(TestUtils.createReservation(UUID.randomUUID(), "u", "root.queue1",
                        Arrays.asList(r), true));
                Assert.fail();
            } catch (LlamaException ex) {
                //NOP
            }

            //over max memory
            try {
                Resource r = TestUtils.createResource(nodes.get(0).getLocation(), Resource.Locality.MUST, 1,
                        4097);
                llama.reserve(TestUtils.createReservation(UUID.randomUUID(), "u", "root.queue1",
                        Arrays.asList(r), true));
                Assert.fail();
            } catch (LlamaException ex) {
                //NOP
            }

            //over node cpus
            try {
                Resource r = TestUtils.createResource(nodes.get(0).getLocation(), Resource.Locality.MUST, 2,
                        4096);
                llama.reserve(TestUtils.createReservation(UUID.randomUUID(), "u", "root.queue1",
                        Arrays.asList(r), true));
                Assert.fail();
            } catch (LlamaException ex) {
                //NOP
            }

            //over node memory
            try {
                Resource r = TestUtils.createResource(nodes.get(0).getLocation(), Resource.Locality.MUST, 1,
                        5021);
                llama.reserve(TestUtils.createReservation(UUID.randomUUID(), "u", "root.queue1",
                        Arrays.asList(r), true));
                Assert.fail();
            } catch (LlamaException ex) {
                //NOP
            }

        } finally {
            llama.stop();
        }
    } finally {
        stopYarn();
    }
}

From source file:com.cloudera.llama.nm.TestSecureLlamaNMAuxiliaryService.java

License:Apache License

@Override
protected void injectLlamaNMConfiguration(Configuration conf) throws Exception {
    super.injectLlamaNMConfiguration(conf);
    String confDir = TestAbstractMain.createTestDir();
    conf.set(ServerConfiguration.CONFIG_DIR_KEY, confDir);
    conf.setBoolean(sConf.getPropertyName(ServerConfiguration.SECURITY_ENABLED_KEY), true);
    File keytab = new File(confDir, "llama.keytab");
    miniKdc.createPrincipal(keytab, "llama/localhost");
    conf.set(sConf.getPropertyName(ServerConfiguration.KEYTAB_FILE_KEY), keytab.getAbsolutePath());
    conf.set(sConf.getPropertyName(ServerConfiguration.SERVER_PRINCIPAL_NAME_KEY), "llama/localhost");
    conf.set(sConf.getPropertyName(ServerConfiguration.SERVER_ADDRESS_KEY), "localhost:0");
    conf.set(sConf.getPropertyName(ServerConfiguration.NOTIFICATION_PRINCIPAL_NAME_KEY), "notification");
}

From source file:com.cloudera.llama.server.TestAbstractServer.java

License:Apache License

@Test
public void testStartStopStepsOK() throws Exception {
    MyServer server = new MyServer();
    Configuration conf = new Configuration(false);
    server.setConf(conf);//from w  w w  .j av a  2  s  .  co  m
    server.start();
    for (String step : STEPS) {
        Assert.assertTrue(conf.getBoolean("start." + step + ".trace", false));
        Assert.assertFalse(conf.getBoolean("stop." + step + ".trace", false));
    }
    for (String step : STEPS) {
        conf.setBoolean("start." + step + ".trace", false);
    }
    server.stop();
    for (String step : STEPS) {
        Assert.assertFalse(conf.getBoolean("start." + step + ".trace", false));
        Assert.assertTrue(conf.getBoolean("stop." + step + ".trace", false));
    }
}

From source file:com.cloudera.llama.server.TestAbstractServer.java

License:Apache License

@Test
public void testStartStepsFailures() throws Exception {
    for (String step : STEPS) {
        MyServer server = new MyServer();
        Configuration conf = new Configuration(false);
        conf.setBoolean("start." + step + ".fail", true);
        server.setConf(conf);//from w  ww . j  a  v  a 2 s . c  om
        try {
            server.start();
            Assert.fail();
        } catch (RuntimeException ex) {
            //NOP        
        } catch (Exception ex) {
            Assert.fail();
        } finally {
            server.stop();
        }
    }
}

From source file:com.cloudera.llama.server.TestAbstractServer.java

License:Apache License

@Test
public void testStopStepsFailures() throws Exception {
    for (String step : STEPS) {
        MyServer server = new MyServer();
        Configuration conf = new Configuration(false);
        conf.setBoolean("stop." + step + ".fail", true);
        server.setConf(conf);//from ww w  . j a v a 2 s .c o m
        server.start();
        server.stop();
        for (String step2 : STEPS) {
            Assert.assertTrue(conf.getBoolean("start." + step2 + ".trace", false));
            Assert.assertTrue(conf.getBoolean("stop." + step2 + ".trace", false));
        }
    }
}