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

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

Introduction

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

Prototype

public boolean getBoolean(String name, boolean defaultValue) 

Source Link

Document

Get the value of the name property as a boolean.

Usage

From source file:org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.java

License:Apache License

/**
 * Determines whether this feature is enabled.
 *
 * @param implementingClass//from   w  w  w.j  a v  a 2  s .c o m
 *          the class whose name will be used as a prefix for the property configuration key
 * @param conf
 *          the Hadoop configuration object to configure
 * @return true if the feature is enabled, false otherwise
 * @since 1.6.0
 * @see #setSimulationMode(Class, Configuration, boolean)
 */
public static Boolean getSimulationMode(Class<?> implementingClass, Configuration conf) {
    return conf.getBoolean(enumToConfKey(implementingClass, Features.SIMULATION_MODE), false);
}

From source file:org.apache.accumulo.examples.wikisearch.ingest.WikipediaConfiguration.java

License:Apache License

public static boolean runPartitioner(Configuration conf) {
    return conf.getBoolean(RUN_PARTITIONER, false);
}

From source file:org.apache.accumulo.examples.wikisearch.ingest.WikipediaConfiguration.java

License:Apache License

public static boolean runIngest(Configuration conf) {
    return conf.getBoolean(RUN_INGEST, true);
}

From source file:org.apache.accumulo.examples.wikisearch.ingest.WikipediaConfiguration.java

License:Apache License

public static boolean bulkIngest(Configuration conf) {
    return conf.getBoolean(BULK_INGEST, true);
}

From source file:org.apache.accumulo.hadoopImpl.mapreduce.lib.ConfiguratorBase.java

License:Apache License

/**
 * Determines if the connector info has already been set for this instance.
 *
 * @param implementingClass// w  w w . j a v  a 2  s .  c  o  m
 *          the class whose name will be used as a prefix for the property configuration key
 * @param conf
 *          the Hadoop configuration object to configure
 * @return true if the connector info has already been set, false otherwise
 * @since 1.6.0
 */
public static Boolean isClientConfigured(Class<?> implementingClass, Configuration conf) {
    return conf.getBoolean(enumToConfKey(implementingClass, ClientOpts.IS_CONFIGURED), false);
}

From source file:org.apache.accumulo.hadoopImpl.mapreduce.lib.ConfiguratorBase.java

License:Apache License

/**
 * Checks if the job store method was called. If not throw exception.
 *
 * @since 2.0.0// w w w  . ja va 2s. c  o m
 */
public static void checkJobStored(Class<?> implementingClass, Configuration conf) {
    if (!conf.getBoolean(enumToConfKey(implementingClass, ClientOpts.STORE_JOB_CALLED), false)) {
        throw new IllegalStateException("Bad configuration: the store method was not called.");
    }
}

From source file:org.apache.ambari.servicemonitor.Monitor.java

License:Apache License

/**
 * Execute the monitor. This method does not exit except by throwing exceptions or by calling System.exit().
 * @throws IOException problems//from   www . j  a v a  2s .c  o  m
 * @throws ExitMainException an explicit exit exception
 */
public void execMonitor(Reporter reporter) throws IOException {

    Configuration conf = getConf();
    int probeInterval = conf.getInt(MONITOR_PROBE_INTERVAL, PROBE_INTERVAL_DEFAULT);
    int reportInterval = conf.getInt(MONITOR_REPORT_INTERVAL, REPORT_INTERVAL_DEFAULT);
    int probeTimeout = conf.getInt(MONITOR_PROBE_TIMEOUT, PROBE_TIMEOUT_DEFAULT);
    int bootstrapTimeout = conf.getInt(MONITOR_BOOTSTRAP_TIMEOUT, BOOTSTRAP_TIMEOUT_DEFAULT);

    boolean krb5Enabled = conf.getBoolean(MONITOR_KRB5_ENABLED, MONITOR_DEFAULT_KRB5_ENABLED);
    String krb5Principal = conf.get(MONITOR_KRB5_PRINCIPAL, MONITOR_DEFAULT_KRB5_PRINCIPAL);
    String krb5Keytab = conf.get(MONITOR_KRB5_KEYTAB, MONITOR_DEFAULT_KRB5_KEYTAB);

    if (LOG.isInfoEnabled()) {
        LOG.info("krb5Enabled = " + krb5Enabled + ", krb5Principal = " + krb5Principal + ", krb5Keyab = "
                + krb5Keytab);
    }
    if (krb5Enabled) {
        UserGroupInformation.loginUserFromKeytab(krb5Principal, krb5Keytab);
        UserGroupInformation.getLoginUser();
    }

    List<Probe> probes = new ArrayList<Probe>();
    if (conf.getBoolean(PORT_PROBE_ENABLED, false)) {

        String probeHost = conf.get(PORT_PROBE_HOST, DEFAULT_PROBE_HOST);

        int probePort = conf.getInt(PORT_PROBE_PORT, DEFAULT_PROBE_PORT);

        if (probePort == -1) {
            URI fsURI = FileSystem.getDefaultUri(conf);
            probePort = fsURI.getPort();
            validateParam(probePort == -1, "No port value in " + fsURI);
        }

        PortProbe portProbe = PortProbe.createPortProbe(new Configuration(conf), probeHost, probePort);
        probes.add(portProbe);
    } else {
        LOG.debug("port probe disabled");
    }

    if (conf.getBoolean(PID_PROBE_ENABLED, false)) {
        Probe probe = PidLiveProbe.createProbe(new Configuration(conf));
        probes.add(probe);
        LOG.debug("Pid probe enabled: " + probe.toString());
    } else {
        LOG.debug("Pid probe disabled");
    }

    if (conf.getBoolean(WEB_PROBE_ENABLED, false)) {
        HttpProbe httpProbe = HttpProbe.createHttpProbe(new Configuration(conf));
        probes.add(httpProbe);
    } else {
        LOG.debug("HTTP probe disabled");
    }

    if (conf.getBoolean(LS_PROBE_ENABLED, false)) {
        String path = conf.get(LS_PROBE_PATH, LS_PROBE_DEFAULT);
        DfsListProbe lsProbe = new DfsListProbe(new Configuration(conf), path);
        probes.add(lsProbe);
    } else {
        LOG.debug("ls probe disabled");
    }

    if (conf.getBoolean(JT_PROBE_ENABLED, false)) {
        Probe jtProbe = new JTClusterStatusProbe(new Configuration(conf));
        probes.add(jtProbe);
    } else {
        LOG.debug("JT probe disabled");
    }

    List<Probe> dependencyProbes = new ArrayList<Probe>(1);

    if (conf.getBoolean(MONITOR_DEPENDENCY_DFSLIVE, false)) {
        //there's a dependency on DFS
        //add a monitor for it
        LOG.info("Adding a dependency on HDFS being live");
        dependencyProbes.add(new DfsSafeModeProbe(new Configuration(conf), true));
    }

    reportingLoop = new ReportingLoop(name, reporter, probes, dependencyProbes, probeInterval, reportInterval,
            probeTimeout, bootstrapTimeout);

    if (!reportingLoop.startReporting()) {
        throw new ExitMainException(name + ": failed to start monitoring with reporter " + reporter);
    }
    //start reporting, either in a background thread
    //or here, directly in the main thread
    reportingLoop.run();
}

From source file:org.apache.apex.benchmark.state.ManagedStateBenchmarkApp.java

License:Apache License

@Override
public void populateDAG(DAG dag, Configuration conf) {
    TestStatsListener sl = new TestStatsListener();
    sl.adjustRate = conf.getBoolean("dt.ManagedStateBenchmark.adjustRate", false);
    TestGenerator gen = dag.addOperator("Generator", new TestGenerator());
    gen.setRange(timeRange);//from  www.  j a  va 2  s . c o m
    dag.setAttribute(gen, OperatorContext.STATS_LISTENERS, Lists.newArrayList((StatsListener) sl));

    storeOperator = new StoreOperator();
    storeOperator.setStore(createStore(conf));
    storeOperator.setTimeRange(timeRange);
    storeOperator = dag.addOperator("Store", storeOperator);

    dag.setAttribute(storeOperator, OperatorContext.STATS_LISTENERS, Lists.newArrayList((StatsListener) sl));

    dag.addStream("Events", gen.data, storeOperator.input).setLocality(Locality.CONTAINER_LOCAL);
}

From source file:org.apache.apex.engine.security.ACLManager.java

License:Apache License

public static boolean areACLsRequired(Configuration conf) {
    logger.debug("Check ACLs required");
    if (conf.getBoolean(YarnConfiguration.YARN_ACL_ENABLE, YarnConfiguration.DEFAULT_YARN_ACL_ENABLE)) {
        logger.debug("Admin ACL {}", conf.get(YarnConfiguration.YARN_ADMIN_ACL));
        if (!YarnConfiguration.DEFAULT_YARN_ADMIN_ACL.equals(conf.get(YarnConfiguration.YARN_ADMIN_ACL))) {
            logger.debug("Non default admin ACL");
            return true;
        }//from w w w.ja v  a 2  s .c  o m
    }
    return false;
}

From source file:org.apache.atlas.security.SecureClientUtils.java

License:Apache License

public static void persistSSLClientConfiguration(org.apache.commons.configuration.Configuration clientConfig)
        throws AtlasException, IOException {
    //trust settings
    Configuration configuration = new Configuration(false);
    File sslClientFile = getSSLClientFile();
    if (!sslClientFile.exists()) {
        configuration.set("ssl.client.truststore.type", "jks");
        configuration.set("ssl.client.truststore.location", clientConfig.getString(TRUSTSTORE_FILE_KEY));
        if (clientConfig.getBoolean(CLIENT_AUTH_KEY, false)) {
            // need to get client key properties
            configuration.set("ssl.client.keystore.location", clientConfig.getString(KEYSTORE_FILE_KEY));
            configuration.set("ssl.client.keystore.type", "jks");
        }/*from   w  ww .  j  ava2  s. com*/
        // add the configured credential provider
        configuration.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
                clientConfig.getString(CERT_STORES_CREDENTIAL_PROVIDER_PATH));
        String hostnameVerifier = clientConfig.getString(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY);
        if (hostnameVerifier != null) {
            configuration.set(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY, hostnameVerifier);
        }

        configuration.writeXml(new FileWriter(sslClientFile));
    }
}