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.impl.TestMultiQueueLlamaAM.java

License:Apache License

@Test
public void testMultiQueueDelegationWithoutThrottling() throws Exception {
    Configuration conf = new Configuration(false);
    conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class);
    conf.setBoolean(LlamaAM.THROTTLING_ENABLED_KEY, false);
    multiQueueTestImpl(conf);/*ww  w  . j ava2s. c o m*/
}

From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java

License:Apache License

@Test(expected = LlamaException.class)
public void testReleaseReservationForClientException() throws Exception {
    Configuration conf = new Configuration(false);
    conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class);
    conf.setBoolean("fail.release", true);
    LlamaAM am = LlamaAM.create(conf);/* w ww. ja v a 2s . c o m*/
    try {
        am.start();
        UUID cId = UUID.randomUUID();
        am.reserve(TestUtils.createReservation(cId, "q", 1, true));
        am.releaseReservationsForHandle(cId, false);
    } finally {
        am.stop();
    }
}

From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java

License:Apache License

@Test(expected = LlamaException.class)
public void testReleaseReservationForClientDiffQueuesException() throws Exception {
    Configuration conf = new Configuration(false);
    conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class);
    conf.setBoolean("fail.release", true);
    LlamaAM am = LlamaAM.create(conf);//from w ww .j  av a2  s  .  c o  m
    try {
        am.start();
        UUID cId = UUID.randomUUID();
        am.reserve(TestUtils.createReservation(cId, "q1", 1, true));
        am.reserve(TestUtils.createReservation(cId, "q2", 1, true));
        am.releaseReservationsForHandle(cId, false);
    } finally {
        am.stop();
    }
}

From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java

License:Apache License

@Test(expected = LlamaException.class)
public void testStartOfDelegatedLlamaAmFail() throws Exception {
    Configuration conf = new Configuration(false);
    conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class);
    conf.setBoolean("fail.start", true);
    conf.set(LlamaAM.CORE_QUEUES_KEY, "q");
    LlamaAM am = LlamaAM.create(conf);/*from   w  w  w.jav  a  2s  . com*/
    am.start();
}

From source file:com.cloudera.llama.am.impl.TestMultiQueueLlamaAM.java

License:Apache License

@Test(expected = LlamaException.class)
public void testRegisterOfDelegatedLlamaAmFail() throws Exception {
    Configuration conf = new Configuration(false);
    conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class);
    conf.setBoolean("fail.register", true);
    conf.set(LlamaAM.CORE_QUEUES_KEY, "q");
    LlamaAM am = LlamaAM.create(conf);/*from   www . jav  a 2 s.  co m*/
    am.start();
}

From source file:com.cloudera.llama.am.impl.TestSingleQueueLlamaAM.java

License:Apache License

public static SingleQueueLlamaAM createLlamaAM() {
    Configuration conf = new Configuration(false);
    conf.setClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, MyRMConnector.class, RMConnector.class);
    conf.setBoolean(LlamaAM.NORMALIZING_ENABLED_KEY, false);
    conf.setBoolean(LlamaAM.CACHING_ENABLED_KEY, false);
    SingleQueueLlamaAM am = new SingleQueueLlamaAM(conf, "queue", Executors.newScheduledThreadPool(4));
    return am;/*  ww w  .  j  av a2s . c  o  m*/
}

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

License:Apache License

public static int execute(String[] args) throws Exception {
    int exitCode = 1;
    CLIParser parser = createParser();//from   w  w w .ja v a  2  s.  c  o  m
    try {
        CLIParser.Command command = parser.parse(args);
        CommandLine cl = command.getCommandLine();

        Configuration conf = new Configuration(false);
        conf.addResource(LLAMAADMIN_CONFIG);
        if (cl.hasOption(SECURE)) {
            conf.setBoolean(LLAMAADMIN_SERVER_SECURE_KEY, true);
        }
        if (cl.hasOption(LLAMA)) {
            conf.set(LLAMAADMIN_SERVER_ADDRESS_KEY, cl.getOptionValue(LLAMA));
        }
        String llama = conf.get(LLAMAADMIN_SERVER_ADDRESS_KEY, LLAMAADMIN_SERVER_ADDRESS_DEFAULT);
        boolean secure = conf.getBoolean(LLAMAADMIN_SERVER_SECURE_KEY, LLAMAADMIN_SERVER_SECURE_DEFAULT);

        if (command.getName().equals(HELP_CMD)) {
            parser.showHelp(command.getCommandLine());
            exitCode = 0;
        } else if (command.getName().equals(RELEASE_CMD)) {
            boolean doNotCache = cl.hasOption(DO_NOT_CACHE);
            List<UUID> handles = optToHandles(cl.getOptionValue(HANDLES));
            List<UUID> reservations = optToHandles(cl.getOptionValue(RESERVATIONS));
            List<String> queues = optToStrings(cl.getOptionValue(QUEUES));

            if (handles.isEmpty() && reservations.isEmpty() && queues.isEmpty()) {
                System.err.print("At least one of the -queues, -handles or "
                        + "-reservations options must be specified");
                exitCode = 1;
            } else {
                release(secure, getHost(llama), getPort(llama, LLAMAADMIN_SERVER_PORT_DEFAULT), handles,
                        reservations, queues, doNotCache);
                exitCode = 0;
            }
        } else if (command.getName().equals(EMPTY_CACHE_CMD)) {
            boolean allQueues = cl.hasOption(ALL_QUEUES);
            List<String> queues = optToStrings(cl.getOptionValue(QUEUES));
            if ((!allQueues && queues.isEmpty()) || (allQueues && !queues.isEmpty())) {
                System.err.print("Either the -allqueues or the -queues option must " + "be specified");
                exitCode = 1;
            } else {
                emptyCache(secure, getHost(llama), getPort(llama, LLAMAADMIN_SERVER_PORT_DEFAULT), queues,
                        allQueues);
                exitCode = 0;
            }
        } else if (command.getName().equals(ERROR_CODES_CMD)) {
            System.out.println();
            System.out.println("Error codes for Llama version: " + VersionInfo.getVersion());
            System.out.println();
            for (String description : ErrorCode.ERROR_CODE_DESCRIPTIONS) {
                System.out.println("  " + description);
            }
            System.out.println();
        } else if (command.getName().equals(VERSION_CMD)) {
            System.out.println(VersionInfo.getVersion());
        } else {
            System.err.println("Sub-command missing");
            System.err.println();
            System.err.println(parser.shortHelp());
            exitCode = 1;
        }
    } catch (ParseException ex) {
        System.err.println("Invalid sub-command: " + ex.getMessage());
        System.err.println();
        System.err.println(parser.shortHelp());
        exitCode = 1;
    } catch (Throwable ex) {
        System.err.println("Error: " + ex.getMessage());
        ex.printStackTrace(System.err);
        exitCode = 2;
    }
    return exitCode;
}

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

License:Apache License

public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration(false);
    conf.addResource("llama-site.xml");

    CLIParser parser = createParser();/*ww  w  .j a v  a2 s .  c  o  m*/
    try {
        CLIParser.Command command = parser.parse(args);
        if (command.getName().equals(HELP_CMD)) {
            parser.showHelp(command.getCommandLine());
        } else {
            final MiniLlama llama;
            if (command.getName().equals(MINICLUSTER_CMD)) {
                CommandLine cl = command.getCommandLine();
                int nodes = Integer.parseInt(cl.getOptionValue(NODES, "1"));
                conf = createMiniLlamaConf(conf, nodes);
                llama = new MiniLlama(conf);
                llama.skipDfsFormat(cl.hasOption(HDFS_NO_FORMAT));
                if (cl.hasOption(HDFS_WRITE_CONF)) {
                    llama.setWriteHadoopConfig(cl.getOptionValue(HDFS_WRITE_CONF));
                }
            } else {
                conf.setBoolean(MINI_USE_EXTERNAL_HADOOP_KEY, true);
                conf = createMiniLlamaConf(conf, 1); //nodes is ignored
                llama = new MiniLlama(conf);
            }
            llama.start();
            String clusterType = (command.getName().equals(MINICLUSTER_CMD)) ? "embedded HDFS/Yarn mini-cluster"
                    : "external HDFS/Yarn cluster";
            LOG.info("**************************************************************"
                    + "*******************************************************");
            LOG.info("Mini Llama running with {} with {} nodes, " + "HDFS URI: {} Llama URI: {}", clusterType,
                    llama.getNodes(), llama.getHadoopConf().get("fs.defaultFS"),
                    llama.getAddressHost() + ":" + llama.getAddressPort());
            LOG.info("*************************************************************"
                    + "********************************************************");
            Runtime.getRuntime().addShutdownHook(new Thread("minillama-shutdownhoock") {
                @Override
                public void run() {
                    llama.stop();
                }
            });
            synchronized (MiniLlama.class) {
                MiniLlama.class.wait();
            }
        }
    } catch (ParseException ex) {
        System.err.println("Invalid sub-command: " + ex.getMessage());
        System.err.println();
        System.err.println(parser.shortHelp());
        System.exit(1);
    } catch (Throwable ex) {
        System.err.println("Error: " + ex.getMessage());
        ex.printStackTrace(System.err);
        System.exit(2);
    }

}

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

License:Apache License

public static Configuration createMiniLlamaConf(Configuration conf, int nodes) {
    ParamChecker.notNull(conf, "conf");
    ParamChecker.greaterThan(nodes, 0, "nodes");
    conf.set(ServerConfiguration.CONFIG_DIR_KEY, "");
    conf.setIfUnset(LlamaAM.RM_CONNECTOR_CLASS_KEY, YarnRMConnector.class.getName());
    conf.setInt(MINI_CLUSTER_NODES_KEY, nodes);
    conf.setIfUnset(S_CONF.getPropertyName(ServerConfiguration.SERVER_ADDRESS_KEY), "localhost:0");
    conf.setIfUnset(S_CONF.getPropertyName(ServerConfiguration.SERVER_ADMIN_ADDRESS_KEY), "localhost:0");
    conf.setIfUnset(S_CONF.getPropertyName(ServerConfiguration.HTTP_ADDRESS_KEY), "localhost:0");
    conf.setBoolean(YarnConfiguration.RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAME, true);
    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, 0);
    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 0);

    conf.set(YarnRMConnector.HADOOP_USER_NAME_KEY, System.getProperty("user.name"));
    return conf;/*from  w w w  . j a  va 2 s .c  o  m*/
}

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

License:Apache License

private Configuration startMiniHadoop() throws Exception {
    int clusterNodes = getConf().getInt(MINI_CLUSTER_NODES_KEY, 1);
    if (System.getProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA) == null) {
        String testBuildData = new File("target").getAbsolutePath();
        System.setProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA, testBuildData);
    }/*from  w  w  w . ja  v a 2 s . c o m*/
    //to trigger hdfs-site.xml registration as default resource
    new HdfsConfiguration();
    Configuration conf = new YarnConfiguration();
    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);

    int hdfsPort = 0;
    String fsUri = conf.get("fs.defaultFS");
    if (fsUri != null && !fsUri.equals("file:///")) {
        int i = fsUri.lastIndexOf(":");
        if (i > -1) {
            try {
                hdfsPort = Integer.parseInt(fsUri.substring(i + 1));
            } catch (Exception ex) {
                throw new RuntimeException(
                        "Could not parse port from Hadoop's " + "'fs.defaultFS property: " + fsUri);
            }
        }
    }
    miniHdfs = new MiniDFSCluster(hdfsPort, conf, clusterNodes, !skipDfsFormat, true, null, null);
    miniHdfs.waitActive();
    conf = miniHdfs.getConfiguration(0);
    miniYarn = new MiniYARNCluster("minillama", clusterNodes, 1, 1);
    conf.setBoolean(YarnConfiguration.RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAME, true);
    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, 0);
    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 0);

    miniYarn.init(conf);
    miniYarn.start();
    conf = miniYarn.getConfig();

    ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
    return conf;
}