Example usage for org.apache.lucene.util Constants OS_NAME

List of usage examples for org.apache.lucene.util Constants OS_NAME

Introduction

In this page you can find the example usage for org.apache.lucene.util Constants OS_NAME.

Prototype

String OS_NAME

To view the source code for org.apache.lucene.util Constants OS_NAME.

Click Source Link

Document

The value of System.getProperty("os.name").

Usage

From source file:com.clearclouds.driver.monitor.os.OsProbe.java

License:Apache License

public OsInfo osInfo() {
    OsInfo info = new OsInfo();
    info.availableProcessors = Runtime.getRuntime().availableProcessors();
    info.name = Constants.OS_NAME;
    info.arch = Constants.OS_ARCH;/*from  ww w  .  j ava2s .c  o  m*/
    info.version = Constants.OS_VERSION;
    return info;
}

From source file:io.crate.expression.reference.sys.node.NodeStatsContext.java

License:Apache License

public NodeStatsContext(boolean complete) {
    this.complete = complete;
    if (complete) {
        osName = BytesRefs.toBytesRef(Constants.OS_NAME);
        osArch = BytesRefs.toBytesRef(Constants.OS_ARCH);
        osVersion = BytesRefs.toBytesRef(Constants.OS_VERSION);
        javaVersion = BytesRefs.toBytesRef(Constants.JAVA_VERSION);
        jvmName = BytesRefs.toBytesRef(Constants.JVM_NAME);
        jvmVendor = BytesRefs.toBytesRef(Constants.JVM_VENDOR);
        jvmVersion = BytesRefs.toBytesRef(Constants.JVM_VERSION);
    }/* w  w  w.  j  a  va 2  s  . co  m*/
}

From source file:io.crate.integrationtests.NodeStatsTest.java

License:Apache License

@Test
public void testSysNodsOsInfo() throws Exception {
    SQLResponse response = execute("select os_info from sys.nodes limit 1");
    Map results = (Map) response.rows()[0][0];
    assertThat(response.rowCount(), is(1L));

    assertThat((Integer) results.get("available_processors"), greaterThan(0));
    assertEquals(Constants.OS_NAME, results.get("name"));
    assertEquals(Constants.OS_ARCH, results.get("arch"));
    assertEquals(Constants.OS_VERSION, results.get("version"));

    Map<String, Object> jvmObj = new HashMap<>(4);
    jvmObj.put("version", Constants.JAVA_VERSION);
    jvmObj.put("vm_name", Constants.JVM_NAME);
    jvmObj.put("vm_vendor", Constants.JVM_VENDOR);
    jvmObj.put("vm_version", Constants.JVM_VERSION);
    assertEquals(jvmObj, results.get("jvm"));
}

From source file:io.crate.node.CrateNode.java

License:Apache License

@Override
protected void startUpLogging(Logger logger, Settings tmpSettings, boolean hadPredefinedNodeName) {
    final JvmInfo jvmInfo = JvmInfo.jvmInfo();
    logger.info("CrateDB version[{}], pid[{}], build[{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", Version.CURRENT,
            jvmInfo.pid(), Build.CURRENT.hashShort(), Build.CURRENT.timestamp(), Constants.OS_NAME,
            Constants.OS_VERSION, Constants.OS_ARCH, Constants.JVM_VENDOR, Constants.JVM_NAME,
            Constants.JAVA_VERSION, Constants.JVM_VERSION);

    if (logger.isDebugEnabled()) {
        Environment environment = getEnvironment();
        logger.debug("using config [{}], data [{}], logs [{}], plugins [{}]", environment.configFile(),
                Arrays.toString(environment.dataFiles()), environment.logsFile(), environment.pluginsFile());
    }//www.  j  a v  a  2s  . co m
}

From source file:org.elasticsearch.bootstrap.Seccomp.java

License:Apache License

/**
 * Attempt to drop the capability to execute for the process.
 * <p>//from  www.j a  v a2  s .com
 * This is best effort and OS and architecture dependent. It may throw any Throwable.
 * @return 0 if we can do this for application threads, 1 for the entire process
 */
static int init(Path tmpFile) throws Throwable {
    if (Constants.LINUX) {
        return linuxImpl();
    } else if (Constants.MAC_OS_X) {
        // try to enable both mechanisms if possible
        bsdImpl();
        macImpl(tmpFile);
        return 1;
    } else if (Constants.SUN_OS) {
        solarisImpl();
        return 1;
    } else if (Constants.FREE_BSD || OPENBSD) {
        bsdImpl();
        return 1;
    } else if (Constants.WINDOWS) {
        windowsImpl();
        return 1;
    } else {
        throw new UnsupportedOperationException(
                "syscall filtering not supported for OS: '" + Constants.OS_NAME + "'");
    }
}

From source file:org.elasticsearch.bootstrap.SpawnerTests.java

License:Apache License

public void testMakePlatformName() {
    String platformName = Spawner.makePlatformName(Constants.OS_NAME, Constants.OS_ARCH);

    assertFalse(platformName, platformName.isEmpty());
    assertTrue(platformName, platformName.equals(platformName.toLowerCase(Locale.ROOT)));
    assertTrue(platformName, platformName.indexOf("-") > 0);
    assertTrue(platformName, platformName.indexOf("-") < platformName.length() - 1);
    assertFalse(platformName, platformName.contains(" "));
}

From source file:org.elasticsearch.bootstrap.SystemCallFilter.java

License:Apache License

/**
 * Attempt to drop the capability to execute for the process.
 * <p>/*  w w  w  .  java  2  s . c  o  m*/
 * This is best effort and OS and architecture dependent. It may throw any Throwable.
 * @return 0 if we can do this for application threads, 1 for the entire process
 */
static int init(Path tmpFile) throws Exception {
    if (Constants.LINUX) {
        return linuxImpl();
    } else if (Constants.MAC_OS_X) {
        // try to enable both mechanisms if possible
        bsdImpl();
        macImpl(tmpFile);
        return 1;
    } else if (Constants.SUN_OS) {
        solarisImpl();
        return 1;
    } else if (Constants.FREE_BSD || OPENBSD) {
        bsdImpl();
        return 1;
    } else if (Constants.WINDOWS) {
        windowsImpl();
        return 1;
    } else {
        throw new UnsupportedOperationException(
                "syscall filtering not supported for OS: '" + Constants.OS_NAME + "'");
    }
}

From source file:org.elasticsearch.monitor.os.OsProbeTests.java

License:Apache License

@Test
public void testOsInfo() {
    OsInfo info = probe.osInfo();//from  w  w  w  . ja  v a 2s .  co  m
    assertNotNull(info);
    assertThat(info.getRefreshInterval(), anyOf(equalTo(-1L), greaterThanOrEqualTo(0L)));
    assertThat(info.getName(), equalTo(Constants.OS_NAME));
    assertThat(info.getArch(), equalTo(Constants.OS_ARCH));
    assertThat(info.getVersion(), equalTo(Constants.OS_VERSION));
    assertThat(info.getAvailableProcessors(), equalTo(Runtime.getRuntime().availableProcessors()));
}

From source file:org.elasticsearch.monitor.os.OsService.java

License:Apache License

@Inject
public OsService(Settings settings, OsProbe probe) {
    super(settings);
    this.probe = probe;

    TimeValue refreshInterval = settings.getAsTime("monitor.os.refresh_interval",
            TimeValue.timeValueSeconds(1));

    this.info = probe.osInfo();
    this.info.refreshInterval = refreshInterval.millis();
    this.info.availableProcessors = Runtime.getRuntime().availableProcessors();
    this.info.name = Constants.OS_NAME;
    osStatsCache = new OsStatsCache(refreshInterval, probe.osStats());
    logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
}

From source file:org.elasticsearch.node.Node.java

License:Apache License

protected Node(final Environment environment, Collection<Class<? extends Plugin>> classpathPlugins) {
    final List<Closeable> resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
    boolean success = false;
    {/*w  w  w  . j a va2s .c o m*/
        // use temp logger just to say we are starting. we can't use it later on because the node name might not be set
        Logger logger = Loggers.getLogger(Node.class, NODE_NAME_SETTING.get(environment.settings()));
        logger.info("initializing ...");

    }
    try {
        Settings tmpSettings = Settings.builder().put(environment.settings())
                .put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();

        tmpSettings = TribeService.processSettings(tmpSettings);

        // create the node environment as soon as possible, to recover the node id and enable logging
        try {
            nodeEnvironment = new NodeEnvironment(tmpSettings, environment);
            resourcesToClose.add(nodeEnvironment);
        } catch (IOException ex) {
            throw new IllegalStateException("Failed to created node environment", ex);
        }

        final boolean hadPredefinedNodeName = NODE_NAME_SETTING.exists(tmpSettings);
        tmpSettings = addNodeNameIfNeeded(tmpSettings, nodeEnvironment.nodeId());
        Logger logger = Loggers.getLogger(Node.class, tmpSettings);
        if (hadPredefinedNodeName == false) {
            logger.info("node name [{}] derived from node ID; set [{}] to override",
                    NODE_NAME_SETTING.get(tmpSettings), NODE_NAME_SETTING.getKey());
        }

        final String displayVersion = Version.CURRENT + (Build.CURRENT.isSnapshot() ? "-SNAPSHOT" : "");
        final JvmInfo jvmInfo = JvmInfo.jvmInfo();
        logger.info("version[{}], pid[{}], build[{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", displayVersion,
                jvmInfo.pid(), Build.CURRENT.shortHash(), Build.CURRENT.date(), Constants.OS_NAME,
                Constants.OS_VERSION, Constants.OS_ARCH, Constants.JVM_VENDOR, Constants.JVM_NAME,
                Constants.JAVA_VERSION, Constants.JVM_VERSION);

        if (logger.isDebugEnabled()) {
            logger.debug("using config [{}], data [{}], logs [{}], plugins [{}]", environment.configFile(),
                    Arrays.toString(environment.dataFiles()), environment.logsFile(),
                    environment.pluginsFile());
        }
        // TODO: Remove this in Elasticsearch 6.0.0
        if (JsonXContent.unquotedFieldNamesSet) {
            DeprecationLogger dLogger = new DeprecationLogger(logger);
            dLogger.deprecated("[{}] has been set, but will be removed in Elasticsearch 6.0.0",
                    JsonXContent.JSON_ALLOW_UNQUOTED_FIELD_NAMES);
        }

        this.pluginsService = new PluginsService(tmpSettings, environment.modulesFile(),
                environment.pluginsFile(), classpathPlugins);
        this.settings = pluginsService.updatedSettings();
        // create the environment based on the finalized (processed) view of the settings
        // this is just to makes sure that people get the same settings, no matter where they ask them from
        this.environment = new Environment(this.settings);
        Environment.assertEquivalent(environment, this.environment);

        final List<ExecutorBuilder<?>> executorBuilders = pluginsService.getExecutorBuilders(settings);

        final ThreadPool threadPool = new ThreadPool(settings,
                executorBuilders.toArray(new ExecutorBuilder[0]));
        resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
        // adds the context to the DeprecationLogger so that it does not need to be injected everywhere
        DeprecationLogger.setThreadContext(threadPool.getThreadContext());
        resourcesToClose.add(() -> DeprecationLogger.removeThreadContext(threadPool.getThreadContext()));

        final List<Setting<?>> additionalSettings = new ArrayList<>();
        final List<String> additionalSettingsFilter = new ArrayList<>();
        additionalSettings.addAll(pluginsService.getPluginSettings());
        additionalSettingsFilter.addAll(pluginsService.getPluginSettingsFilter());
        for (final ExecutorBuilder<?> builder : threadPool.builders()) {
            additionalSettings.addAll(builder.getRegisteredSettings());
        }
        final ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, threadPool);
        final ScriptModule scriptModule = ScriptModule.create(settings, this.environment,
                resourceWatcherService, pluginsService.filterPlugins(ScriptPlugin.class));
        AnalysisModule analysisModule = new AnalysisModule(this.environment,
                pluginsService.filterPlugins(AnalysisPlugin.class));
        additionalSettings.addAll(scriptModule.getSettings());
        // this is as early as we can validate settings at this point. we already pass them to ScriptModule as well as ThreadPool
        // so we might be late here already
        final SettingsModule settingsModule = new SettingsModule(this.settings, additionalSettings,
                additionalSettingsFilter);
        scriptModule.registerClusterSettingsListeners(settingsModule.getClusterSettings());
        resourcesToClose.add(resourceWatcherService);
        final NetworkService networkService = new NetworkService(settings,
                getCustomNameResolvers(pluginsService.filterPlugins(DiscoveryPlugin.class)));
        final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(),
                threadPool);
        clusterService.add(scriptModule.getScriptService());
        resourcesToClose.add(clusterService);
        final TribeService tribeService = new TribeService(settings, clusterService, nodeEnvironment.nodeId());
        resourcesToClose.add(tribeService);
        final IngestService ingestService = new IngestService(settings, threadPool, this.environment,
                scriptModule.getScriptService(), analysisModule.getAnalysisRegistry(),
                pluginsService.filterPlugins(IngestPlugin.class));
        final UsageService usageService = new UsageService(clusterService::localNode, settings);

        ModulesBuilder modules = new ModulesBuilder();
        // plugin modules must be added here, before others or we can get crazy injection errors...
        for (Module pluginModule : pluginsService.createGuiceModules()) {
            modules.add(pluginModule);
        }
        final MonitorService monitorService = new MonitorService(settings, nodeEnvironment, threadPool);
        modules.add(new NodeModule(this, monitorService));
        NetworkModule networkModule = new NetworkModule(networkService, settings, false);
        modules.add(networkModule);
        modules.add(new DiscoveryModule(this.settings));
        ClusterModule clusterModule = new ClusterModule(settings, clusterService,
                pluginsService.filterPlugins(ClusterPlugin.class));
        modules.add(clusterModule);
        IndicesModule indicesModule = new IndicesModule(pluginsService.filterPlugins(MapperPlugin.class));
        modules.add(indicesModule);
        SearchModule searchModule = new SearchModule(settings, false,
                pluginsService.filterPlugins(SearchPlugin.class));
        modules.add(searchModule);
        if (config.getisUsageStatisticsActivated()) {
            modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false, settings,
                    clusterModule.getIndexNameExpressionResolver(), settingsModule.getClusterSettings(),
                    pluginsService.filterPlugins(ActionPlugin.class), usageService));
        } else {
            modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false, settings,
                    clusterModule.getIndexNameExpressionResolver(), settingsModule.getClusterSettings(),
                    pluginsService.filterPlugins(ActionPlugin.class), null));
        }
        modules.add(new GatewayModule());
        modules.add(
                new RepositoriesModule(this.environment, pluginsService.filterPlugins(RepositoryPlugin.class)));
        pluginsService.processModules(modules);
        CircuitBreakerService circuitBreakerService = createCircuitBreakerService(settingsModule.getSettings(),
                settingsModule.getClusterSettings());
        resourcesToClose.add(circuitBreakerService);
        BigArrays bigArrays = createBigArrays(settings, circuitBreakerService);
        resourcesToClose.add(bigArrays);
        modules.add(settingsModule);
        List<NamedWriteableRegistry.Entry> namedWriteables = Stream
                .of(networkModule.getNamedWriteables().stream(), indicesModule.getNamedWriteables().stream(),
                        searchModule.getNamedWriteables().stream(),
                        pluginsService.filterPlugins(Plugin.class).stream()
                                .flatMap(p -> p.getNamedWriteables().stream()))
                .flatMap(Function.identity()).collect(Collectors.toList());
        final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(namedWriteables);
        final MetaStateService metaStateService = new MetaStateService(settings, nodeEnvironment);
        final IndicesService indicesService = new IndicesService(settings, pluginsService, nodeEnvironment,
                settingsModule.getClusterSettings(), analysisModule.getAnalysisRegistry(),
                searchModule.getQueryParserRegistry(), clusterModule.getIndexNameExpressionResolver(),
                indicesModule.getMapperRegistry(), namedWriteableRegistry, threadPool,
                settingsModule.getIndexScopedSettings(), circuitBreakerService, metaStateService);
        client = new NodeClient(settings, threadPool);
        Collection<Object> pluginComponents = pluginsService.filterPlugins(Plugin.class).stream()
                .flatMap(p -> p
                        .createComponents(client, clusterService, threadPool, resourceWatcherService,
                                scriptModule.getScriptService(), searchModule.getSearchRequestParsers())
                        .stream())
                .collect(Collectors.toList());
        Collection<UnaryOperator<Map<String, MetaData.Custom>>> customMetaDataUpgraders = pluginsService
                .filterPlugins(Plugin.class).stream().map(Plugin::getCustomMetaDataUpgrader)
                .collect(Collectors.toList());
        final MetaDataUpgrader metaDataUpgrader = new MetaDataUpgrader(customMetaDataUpgraders);
        modules.add(b -> {
            b.bind(PluginsService.class).toInstance(pluginsService);
            b.bind(Client.class).toInstance(client);
            b.bind(NodeClient.class).toInstance(client);
            b.bind(Environment.class).toInstance(this.environment);
            b.bind(ThreadPool.class).toInstance(threadPool);
            b.bind(NodeEnvironment.class).toInstance(nodeEnvironment);
            b.bind(TribeService.class).toInstance(tribeService);
            b.bind(ResourceWatcherService.class).toInstance(resourceWatcherService);
            b.bind(CircuitBreakerService.class).toInstance(circuitBreakerService);
            b.bind(BigArrays.class).toInstance(bigArrays);
            b.bind(ScriptService.class).toInstance(scriptModule.getScriptService());
            b.bind(AnalysisRegistry.class).toInstance(analysisModule.getAnalysisRegistry());
            b.bind(IngestService.class).toInstance(ingestService);
            b.bind(NamedWriteableRegistry.class).toInstance(namedWriteableRegistry);
            b.bind(UsageService.class).toInstance(usageService);
            b.bind(MetaDataUpgrader.class).toInstance(metaDataUpgrader);
            b.bind(MetaStateService.class).toInstance(metaStateService);
            b.bind(IndicesService.class).toInstance(indicesService);
            Class<? extends SearchService> searchServiceImpl = pickSearchServiceImplementation();
            if (searchServiceImpl == SearchService.class) {
                b.bind(SearchService.class).asEagerSingleton();
            } else {
                b.bind(SearchService.class).to(searchServiceImpl).asEagerSingleton();
            }
            pluginComponents.stream().forEach(p -> b.bind((Class) p.getClass()).toInstance(p));

        });
        injector = modules.createInjector();

        List<LifecycleComponent> pluginLifecycleComponents = pluginComponents.stream()
                .filter(p -> p instanceof LifecycleComponent).map(p -> (LifecycleComponent) p)
                .collect(Collectors.toList());
        pluginLifecycleComponents.addAll(pluginsService.getGuiceServiceClasses().stream()
                .map(injector::getInstance).collect(Collectors.toList()));
        resourcesToClose.addAll(pluginLifecycleComponents);
        this.pluginLifecycleComponents = Collections.unmodifiableList(pluginLifecycleComponents);

        client.intialize(injector.getInstance(new Key<Map<GenericAction, TransportAction>>() {
        }));

        logger.info("initialized");

        success = true;
    } catch (IOException ex) {
        throw new ElasticsearchException("failed to bind service", ex);
    } finally {
        if (!success) {
            IOUtils.closeWhileHandlingException(resourcesToClose);
        }
    }
}