List of usage examples for org.apache.lucene.util Constants JAVA_VERSION
String JAVA_VERSION
To view the source code for org.apache.lucene.util Constants JAVA_VERSION.
Click Source Link
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); }//www . j av a 2 s . c o 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()); }//from w ww . jav a 2 s . co m }
From source file:io.crate.operation.reference.sys.check.node.JvmVersionSysCheck.java
License:Apache License
@Override public boolean validate() { return validateJavaVersion(Constants.JAVA_VERSION); }
From source file:org.elasticsearch.bootstrap.JVMCheck.java
License:Apache License
/** * Returns java + jvm version, looks like this: * {@code Oracle Corporation 1.8.0_45 [Java HotSpot(TM) 64-Bit Server VM 25.45-b02]} *//* w ww. java 2 s . co m*/ static String fullVersion() { StringBuilder sb = new StringBuilder(); sb.append(Constants.JAVA_VENDOR); sb.append(" "); sb.append(Constants.JAVA_VERSION); sb.append(" ["); sb.append(Constants.JVM_NAME); sb.append(" "); sb.append(Constants.JVM_VERSION); sb.append("]"); return sb.toString(); }
From source file:org.elasticsearch.index.mapper.attachment.AttachmentMapper.java
License:Apache License
@Override public void parse(ParseContext context) throws IOException { byte[] content = null; String contentType = null;// ww w . j a v a 2 s . c o m int indexedChars = defaultIndexedChars; boolean langDetect = defaultLangDetect; String name = null; String language = null; XContentParser parser = context.parser(); XContentParser.Token token = parser.currentToken(); if (token == XContentParser.Token.VALUE_STRING) { content = parser.binaryValue(); } else { String currentFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.VALUE_STRING) { if ("_content".equals(currentFieldName)) { content = parser.binaryValue(); } else if ("_content_type".equals(currentFieldName)) { contentType = parser.text(); } else if ("_name".equals(currentFieldName)) { name = parser.text(); } else if ("_language".equals(currentFieldName)) { language = parser.text(); } } else if (token == XContentParser.Token.VALUE_NUMBER) { if ("_indexed_chars".equals(currentFieldName) || "_indexedChars".equals(currentFieldName)) { indexedChars = parser.intValue(); } } else if (token == XContentParser.Token.VALUE_BOOLEAN) { if ("_detect_language".equals(currentFieldName) || "_detectLanguage".equals(currentFieldName)) { langDetect = parser.booleanValue(); } } } } // Throw clean exception when no content is provided Fix #23 if (content == null) { throw new MapperParsingException("No content is provided."); } Metadata metadata = new Metadata(); if (contentType != null) { metadata.add(Metadata.CONTENT_TYPE, contentType); } if (name != null) { metadata.add(Metadata.RESOURCE_NAME_KEY, name); } String parsedContent; try { Tika tika = tika(); if (tika == null) { if (!ignoreErrors) { throw new MapperParsingException("Tika can not be initialized with the current Locale [" + Locale.getDefault().getLanguage() + "] on the current JVM [" + Constants.JAVA_VERSION + "]"); } else { logger.warn("Tika can not be initialized with the current Locale [{}] on the current JVM [{}]", Locale.getDefault().getLanguage(), Constants.JAVA_VERSION); return; } } // Set the maximum length of strings returned by the parseToString method, -1 sets no limit parsedContent = tika.parseToString(new BytesStreamInput(content, false), metadata, indexedChars); } catch (Throwable e) { // It could happen that Tika adds a System property `sun.font.fontmanager` which should not happen // TODO Remove when this will be fixed in Tika. See https://issues.apache.org/jira/browse/TIKA-1548 System.clearProperty("sun.font.fontmanager"); // #18: we could ignore errors when Tika does not parse data if (!ignoreErrors) { throw new MapperParsingException( "Failed to extract [" + indexedChars + "] characters of text for [" + name + "]", e); } else { logger.debug("Failed to extract [{}] characters of text for [{}]: [{}]", indexedChars, name, e.getMessage()); logger.trace("exception caught", e); } return; } context = context.createExternalValueContext(parsedContent); contentMapper.parse(context); if (langDetect) { try { if (language != null) { metadata.add(Metadata.CONTENT_LANGUAGE, language); } else { LanguageIdentifier identifier = new LanguageIdentifier(parsedContent); language = identifier.getLanguage(); } context = context.createExternalValueContext(language); languageMapper.parse(context); } catch (Throwable t) { logger.debug("Cannot detect language: [{}]", t.getMessage()); } } if (name != null) { try { context = context.createExternalValueContext(name); nameMapper.parse(context); } catch (MapperParsingException e) { if (!ignoreErrors) throw e; if (logger.isDebugEnabled()) logger.debug("Ignoring MapperParsingException catch while parsing name: [{}]", e.getMessage()); } } if (metadata.get(Metadata.DATE) != null) { try { context = context.createExternalValueContext(metadata.get(Metadata.DATE)); dateMapper.parse(context); } catch (MapperParsingException e) { if (!ignoreErrors) throw e; if (logger.isDebugEnabled()) logger.debug("Ignoring MapperParsingException catch while parsing date: [{}]: [{}]", e.getMessage(), context.externalValue()); } } if (metadata.get(Metadata.TITLE) != null) { try { context = context.createExternalValueContext(metadata.get(Metadata.TITLE)); titleMapper.parse(context); } catch (MapperParsingException e) { if (!ignoreErrors) throw e; if (logger.isDebugEnabled()) logger.debug("Ignoring MapperParsingException catch while parsing title: [{}]: [{}]", e.getMessage(), context.externalValue()); } } if (metadata.get(Metadata.AUTHOR) != null) { try { context = context.createExternalValueContext(metadata.get(Metadata.AUTHOR)); authorMapper.parse(context); } catch (MapperParsingException e) { if (!ignoreErrors) throw e; if (logger.isDebugEnabled()) logger.debug("Ignoring MapperParsingException catch while parsing author: [{}]: [{}]", e.getMessage(), context.externalValue()); } } if (metadata.get(Metadata.KEYWORDS) != null) { try { context = context.createExternalValueContext(metadata.get(Metadata.KEYWORDS)); keywordsMapper.parse(context); } catch (MapperParsingException e) { if (!ignoreErrors) throw e; if (logger.isDebugEnabled()) logger.debug("Ignoring MapperParsingException catch while parsing keywords: [{}]: [{}]", e.getMessage(), context.externalValue()); } } if (contentType == null) { contentType = metadata.get(Metadata.CONTENT_TYPE); } if (contentType != null) { try { context = context.createExternalValueContext(contentType); contentTypeMapper.parse(context); } catch (MapperParsingException e) { if (!ignoreErrors) throw e; if (logger.isDebugEnabled()) logger.debug("Ignoring MapperParsingException catch while parsing content_type: [{}]: [{}]", e.getMessage(), context.externalValue()); } } int length = content.length; // If we have CONTENT_LENGTH from Tika we use it if (metadata.get(Metadata.CONTENT_LENGTH) != null) { length = Integer.parseInt(metadata.get(Metadata.CONTENT_LENGTH)); } try { context = context.createExternalValueContext(length); contentLengthMapper.parse(context); } catch (MapperParsingException e) { if (!ignoreErrors) throw e; if (logger.isDebugEnabled()) logger.debug("Ignoring MapperParsingException catch while parsing content_length: [{}]: [{}]", e.getMessage(), context.externalValue()); } // multiFields.parse(this, context); if (copyTo != null) { copyTo.parse(context); } }
From source file:org.elasticsearch.index.mapper.attachment.test.MapperTestUtils.java
License:Apache License
/** * We can have issues with some JVMs and Locale * See https://github.com/elasticsearch/elasticsearch-mapper-attachments/issues/105 *//*from w ww . ja v a 2s.c o m*/ public static void assumeCorrectLocale() { assumeTrue("Current Locale language " + Locale.getDefault().getLanguage() + " could cause an error with Java " + Constants.JAVA_VERSION, isLocaleCompatible()); }
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 ww . j a va 2 s . com*/ // 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); } } }