Example usage for org.apache.commons.logging Log debug

List of usage examples for org.apache.commons.logging Log debug

Introduction

In this page you can find the example usage for org.apache.commons.logging Log debug.

Prototype

void debug(Object message);

Source Link

Document

Logs a message with debug log level.

Usage

From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java

public static void filterNonDataNodesIfNeeded(Settings settings, Log log) {
    if (!settings.getNodesDataOnly() || settings.getNodesClientOnly()) {
        return;/*from   www  . ja va  2s. c o  m*/
    }

    RestClient bootstrap = new RestClient(settings);
    try {
        String message = "No data nodes with HTTP-enabled available";
        List<String> dataNodes = bootstrap.getHttpDataNodes();
        if (dataNodes.isEmpty()) {
            throw new EsHadoopIllegalArgumentException(message);
        }
        if (log.isDebugEnabled()) {
            log.debug(String.format("Found data nodes %s", dataNodes));
        }

        List<String> ddNodes = SettingsUtils.discoveredOrDeclaredNodes(settings);
        // remove non-data nodes
        ddNodes.retainAll(dataNodes);
        if (log.isDebugEnabled()) {
            log.debug(String.format("Filtered discovered only nodes %s to data-only %s",
                    SettingsUtils.discoveredOrDeclaredNodes(settings), ddNodes));
        }

        if (ddNodes.isEmpty()) {
            if (settings.getNodesDiscovery()) {
                message += String.format(
                        "; looks like the data nodes discovered have been removed; is the cluster in a stable state? %s",
                        dataNodes);
            } else {
                message += String.format(
                        "; node discovery is disabled and none of nodes specified fits the criterion %s",
                        SettingsUtils.discoveredOrDeclaredNodes(settings));
            }
            throw new EsHadoopIllegalArgumentException(message);
        }

        SettingsUtils.setDiscoveredNodes(settings, dataNodes);
    } finally {
        bootstrap.close();
    }
}

From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java

public static String discoverEsVersion(Settings settings, Log log) {
    String version = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION);
    if (StringUtils.hasText(version)) {
        if (log.isDebugEnabled()) {
            log.debug(String.format(
                    "Elasticsearch version [%s] already present in configuration; skipping discovery",
                    version));/*from   w  ww . j  av a 2  s.com*/
        }

        return version;
    }

    RestClient bootstrap = new RestClient(settings);
    // first get ES version
    try {
        String esVersion = bootstrap.esVersion();
        if (log.isDebugEnabled()) {
            log.debug(String.format("Discovered Elasticsearch version [%s]", esVersion));
        }
        // validate version (make sure it's running against ES 1.x or 2.x)

        if (!(esVersion.startsWith("1.") || esVersion.startsWith("2."))) {
            throw new EsHadoopIllegalArgumentException(
                    "Unsupported/Unknown Elasticsearch version " + esVersion);
        }
        settings.setProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION, esVersion);
        return esVersion;
    } finally {
        bootstrap.close();
    }
}

From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java

public static boolean setFieldExtractorIfNotSet(Settings settings, Class<? extends FieldExtractor> clazz,
        Log log) {//from w w w .  ja  v  a 2  s .c  om
    if (!StringUtils.hasText(settings.getMappingIdExtractorClassName())) {
        Log logger = (log != null ? log : LogFactory.getLog(clazz));

        String name = clazz.getName();
        settings.setProperty(ConfigurationOptions.ES_MAPPING_DEFAULT_EXTRACTOR_CLASS, name);
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("Using pre-defined field extractor [%s] as default",
                    settings.getMappingIdExtractorClassName()));
        }
        return true;
    }

    return false;
}

From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java

public static <T> void saveSchemaIfNeeded(Object conf, ValueWriter<T> schemaWriter, T schema, Log log) {
    Settings settings = HadoopSettingsManager.loadFrom(conf);

    if (settings.getIndexAutoCreate()) {
        RestRepository client = new RestRepository(settings);
        if (!client.indexExists(false)) {
            if (schemaWriter == null) {
                log.warn(String.format(
                        "No mapping found [%s] and no schema found; letting Elasticsearch perform auto-mapping...",
                        settings.getResourceWrite()));
            } else {
                log.info(String.format("No mapping found [%s], creating one based on given schema",
                        settings.getResourceWrite()));
                ContentBuilder builder = ContentBuilder.generate(schemaWriter).value(schema).flush();
                BytesArray content = ((FastByteArrayOutputStream) builder.content()).bytes();
                builder.close();//from   www .  java 2s . c  o  m
                client.putMapping(content);
                if (log.isDebugEnabled()) {
                    log.debug(String.format("Creating ES mapping [%s] from schema [%s]", content.toString(),
                            schema));
                }
            }
        }
        client.close();
    }
}

From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java

public static boolean setValueWriterIfNotSet(Settings settings, Class<? extends ValueWriter<?>> clazz,
        Log log) {/*from  w ww . j a v  a2  s  .  c o m*/
    if (!StringUtils.hasText(settings.getSerializerValueWriterClassName())) {
        Log logger = (log != null ? log : LogFactory.getLog(clazz));

        String name = clazz.getName();
        if (settings.getInputAsJson()) {
            name = NoOpValueWriter.class.getName();
            if (logger.isDebugEnabled()) {
                logger.debug(String.format(
                        "Elasticsearch input marked as JSON; bypassing serialization through [%s] instead of [%s]",
                        name, clazz));
            }
        }
        settings.setProperty(ConfigurationOptions.ES_SERIALIZATION_WRITER_VALUE_CLASS, name);
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("Using pre-defined writer serializer [%s] as default",
                    settings.getSerializerValueWriterClassName()));
        }
        return true;
    }

    return false;
}

From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java

public static boolean setBytesConverterIfNeeded(Settings settings, Class<? extends BytesConverter> clazz,
        Log log) {// w ww . jav  a 2s.co  m
    if (settings.getInputAsJson() && !StringUtils.hasText(settings.getSerializerBytesConverterClassName())) {
        settings.setProperty(ConfigurationOptions.ES_SERIALIZATION_WRITER_BYTES_CLASS, clazz.getName());
        Log logger = (log != null ? log : LogFactory.getLog(clazz));
        if (logger.isDebugEnabled()) {
            logger.debug(String.format(
                    "JSON input specified; using pre-defined bytes/json converter [%s] as default",
                    settings.getSerializerBytesConverterClassName()));
        }
        return true;
    }

    return false;
}

From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java

public static boolean setValueReaderIfNotSet(Settings settings, Class<? extends ValueReader> clazz, Log log) {

    if (!StringUtils.hasText(settings.getSerializerValueReaderClassName())) {
        settings.setProperty(ConfigurationOptions.ES_SERIALIZATION_READER_VALUE_CLASS, clazz.getName());
        Log logger = (log != null ? log : LogFactory.getLog(clazz));
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("Using pre-defined reader serializer [%s] as default",
                    settings.getSerializerValueReaderClassName()));
        }//www  . j  a  v  a  2  s. co m
        return true;
    }

    return false;
}

From source file:org.elasticsearch.hadoop.serialization.SerializationUtils.java

public static boolean setValueWriterIfNotSet(Settings settings, Class<? extends ValueWriter<?>> clazz,
        Log log) {/* w  ww.  j av a  2 s.c o  m*/

    if (!StringUtils.hasText(settings.getSerializerValueWriterClassName())) {
        settings.setProperty(ConfigurationOptions.ES_SERIALIZATION_WRITER_CLASS, clazz.getName());
        Log logger = (log != null ? log : LogFactory.getLog(clazz));
        logger.debug(String.format("Using pre-defined writer serializer [%s] as default",
                settings.getSerializerValueWriterClassName()));
        return true;
    }

    return false;
}

From source file:org.elasticsearch.hadoop.serialization.SerializationUtils.java

public static boolean setValueReaderIfNotSet(Settings settings, Class<? extends ValueReader> clazz, Log log) {

    if (!StringUtils.hasText(settings.getSerializerValueReaderClassName())) {
        settings.setProperty(ConfigurationOptions.ES_SERIALIZATION_READER_CLASS, clazz.getName());
        Log logger = (log != null ? log : LogFactory.getLog(clazz));
        logger.debug(String.format("Using pre-defined reader serializer [%s] as default",
                settings.getSerializerValueReaderClassName()));
        return true;
    }//  ww  w  . j a v  a  2 s.c o m

    return false;
}

From source file:org.eurekastreams.commons.search.analysis.SynonymMapFactory.java

/**
 * Initialize the synonym map./*from ww w .j av a  2 s. co m*/
 *
 * @param thesaurusInputStream
 *            InputStream of the WordNet synonyms file
 * @return true
 */
public static boolean inform(final InputStream thesaurusInputStream) {
    if (synonyms == null) {
        synchronized (SynonymMapFactory.class) {
            Log initLog = LogFactory.getLog(SynonymMapFactory.class);
            initLog.debug("Initializing SynonymMap.");
            try {
                // NOTE: the synonym stream is closed inside SynonymMap
                synonyms = new SynonymMap(thesaurusInputStream);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            initLog.info("Testing SynonymMap.");
            if (initLog.isInfoEnabled()) {
                initLog.info("Synonyms for 'success': " + Arrays.toString(synonyms.getSynonyms("success")));
            }
            initLog.info("SynonymMap initializing complete.");
        }
    }
    return true;
}