Search in sources :

Example 1 with ESLogger

use of org.elasticsearch.common.logging.ESLogger in project crate by crate.

the class BlobService method doStart.

@Override
protected void doStart() throws ElasticsearchException {
    logger.info("BlobService.doStart() {}", this);
    // suppress warning about replaced recovery handler
    ESLogger transportServiceLogger = Loggers.getLogger(TransportService.class);
    String previousLevel = transportServiceLogger.getLevel();
    transportServiceLogger.setLevel("ERROR");
    injector.getInstance(BlobRecoverySource.class).registerHandler();
    transportServiceLogger.setLevel(previousLevel);
    blobHeadRequestHandler.registerHandler();
    // can be added to DiscoveryNodes - this is required for the redirect logic.
    if (settings.getAsBoolean("http.enabled", true)) {
        injector.getInstance(HttpServer.class).start();
    } else {
        logger.warn("Http server should be enabled for blob support");
    }
}
Also used : HttpServer(org.elasticsearch.http.HttpServer) ESLogger(org.elasticsearch.common.logging.ESLogger) BlobRecoverySource(org.elasticsearch.indices.recovery.BlobRecoverySource)

Example 2 with ESLogger

use of org.elasticsearch.common.logging.ESLogger in project crate by crate.

the class BootstrapProxy method initializeNatives.

/**
     * initialize native resources
     */
public static void initializeNatives(Path tmpFile, boolean mlockAll, boolean seccomp, boolean ctrlHandler) {
    final ESLogger logger = Loggers.getLogger(Bootstrap.class);
    // check if the user is running as root, and bail
    if (Natives.definitelyRunningAsRoot()) {
        if (Boolean.parseBoolean(System.getProperty("es.insecure.allow.root"))) {
            logger.warn("running as ROOT user. this is a bad idea!");
        } else {
            throw new RuntimeException("don't run elasticsearch as root.");
        }
    }
    // enable secure computing mode
    if (seccomp) {
        Natives.trySeccomp(tmpFile);
    }
    // mlockall if requested
    if (mlockAll) {
        if (Constants.WINDOWS) {
            Natives.tryVirtualLock();
        } else {
            Natives.tryMlockall();
        }
    }
    // listener for windows close event
    if (ctrlHandler) {
        Natives.addConsoleCtrlHandler(new ConsoleCtrlHandler() {

            @Override
            public boolean handle(int code) {
                if (CTRL_CLOSE_EVENT == code) {
                    logger.info("running graceful exit on windows");
                    Bootstrap.stop();
                    return true;
                }
                return false;
            }
        });
    }
    // force remainder of JNA to be loaded (if available).
    try {
        JNAKernel32Library.getInstance();
    } catch (Throwable ignored) {
    // we've already logged this.
    }
    // init lucene random seed. it will use /dev/urandom where available:
    StringHelper.randomId();
}
Also used : ESLogger(org.elasticsearch.common.logging.ESLogger)

Example 3 with ESLogger

use of org.elasticsearch.common.logging.ESLogger in project crate by crate.

the class BootstrapProxy method checkUnsetAndMaybeExit.

private static void checkUnsetAndMaybeExit(String confFileSetting, String settingName) {
    if (confFileSetting != null && confFileSetting.isEmpty() == false) {
        ESLogger logger = Loggers.getLogger(Bootstrap.class);
        logger.info("{} is no longer supported. crate.yml must be placed in the config directory and cannot be renamed.", settingName);
        System.exit(1);
    }
}
Also used : ESLogger(org.elasticsearch.common.logging.ESLogger)

Example 4 with ESLogger

use of org.elasticsearch.common.logging.ESLogger in project crate by crate.

the class BootstrapProxy method init.

/**
     * This method is invoked by {@link Elasticsearch#main(String[])}
     * to startup elasticsearch.
     */
public static void init(String[] args) throws Throwable {
    // Set the system property before anything has a chance to trigger its use
    System.setProperty("es.logger.prefix", "");
    BootstrapCLIParser bootstrapCLIParser = new BootstrapCLIParser();
    CliTool.ExitStatus status = bootstrapCLIParser.execute(args);
    if (CliTool.ExitStatus.OK != status) {
        System.exit(status.status());
    }
    INSTANCE = new BootstrapProxy();
    boolean foreground = !"false".equals(System.getProperty("es.foreground", System.getProperty("es-foreground")));
    // handle the wrapper system property, if its a service, don't run as a service
    if (System.getProperty("wrapper.service", "XXX").equalsIgnoreCase("true")) {
        foreground = false;
    }
    Environment environment = initialSettings(foreground);
    Settings settings = environment.settings();
    setupLogging(settings, environment);
    checkForCustomConfFile();
    if (environment.pidFile() != null) {
        PidFile.create(environment.pidFile(), true);
    }
    if (System.getProperty("es.max-open-files", "false").equals("true")) {
        ESLogger logger = Loggers.getLogger(Bootstrap.class);
        logger.info("max_open_files [{}]", ProcessProbe.getInstance().getMaxFileDescriptorCount());
    }
    // warn if running using the client VM
    if (JvmInfo.jvmInfo().getVmName().toLowerCase(Locale.ROOT).contains("client")) {
        ESLogger logger = Loggers.getLogger(Bootstrap.class);
        logger.warn("jvm uses the client vm, make sure to run `java` with the server vm for best performance by adding `-server` to the command line");
    }
    try {
        if (!foreground) {
            Loggers.disableConsoleLogging();
            closeSystOut();
        }
        // fail if using broken version
        JVMCheck.check();
        INSTANCE.setup(true, settings, environment);
        INSTANCE.start();
        if (!foreground) {
            closeSysError();
        }
    } catch (Throwable e) {
        // disable console logging, so user does not see the exception twice (jvm will show it already)
        if (foreground) {
            Loggers.disableConsoleLogging();
        }
        ESLogger logger = Loggers.getLogger(Bootstrap.class);
        if (INSTANCE.node != null) {
            logger = Loggers.getLogger(Bootstrap.class, INSTANCE.node.settings().get("name"));
        }
        // HACK, it sucks to do this, but we will run users out of disk space otherwise
        if (e instanceof CreationException) {
            // guice: log the shortened exc to the log file
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            PrintStream ps = new PrintStream(os, false, "UTF-8");
            new StartupError(e).printStackTrace(ps);
            ps.flush();
            logger.error("Guice Exception: {}", os.toString("UTF-8"));
        } else {
            // full exception
            logger.error("Exception", e);
        }
        // re-enable it if appropriate, so they can see any logging during the shutdown process
        if (foreground) {
            Loggers.enableConsoleLogging();
        }
        throw e;
    }
}
Also used : PrintStream(java.io.PrintStream) CliTool(org.elasticsearch.common.cli.CliTool) CreationException(org.elasticsearch.common.inject.CreationException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ESLogger(org.elasticsearch.common.logging.ESLogger) Environment(org.elasticsearch.env.Environment) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

ESLogger (org.elasticsearch.common.logging.ESLogger)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 CliTool (org.elasticsearch.common.cli.CliTool)1 CreationException (org.elasticsearch.common.inject.CreationException)1 Settings (org.elasticsearch.common.settings.Settings)1 Environment (org.elasticsearch.env.Environment)1 HttpServer (org.elasticsearch.http.HttpServer)1 BlobRecoverySource (org.elasticsearch.indices.recovery.BlobRecoverySource)1