Java Code Examples for org.elasticsearch.common.settings.Settings#getAsVersion()
The following examples show how to use
org.elasticsearch.common.settings.Settings#getAsVersion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexMetaData.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** * Adds human readable version and creation date settings. * This method is used to display the settings in a human readable format in REST API */ public static Settings addHumanReadableSettings(Settings settings) { Settings.Builder builder = Settings.builder().put(settings); Version version = settings.getAsVersion(SETTING_VERSION_CREATED, null); if (version != null) { builder.put(SETTING_VERSION_CREATED_STRING, version.toString()); } Version versionUpgraded = settings.getAsVersion(SETTING_VERSION_UPGRADED, null); if (versionUpgraded != null) { builder.put(SETTING_VERSION_UPGRADED_STRING, versionUpgraded.toString()); } Long creationDate = settings.getAsLong(SETTING_CREATION_DATE, null); if (creationDate != null) { DateTime creationDateTime = new DateTime(creationDate, DateTimeZone.UTC); builder.put(SETTING_CREATION_DATE_STRING, creationDateTime.toString()); } return builder.build(); }
Example 2
Source File: IndexMetaData.java From crate with Apache License 2.0 | 6 votes |
/** * Adds human readable version and creation date settings. * This method is used to display the settings in a human readable format in REST API */ public static Settings addHumanReadableSettings(Settings settings) { Settings.Builder builder = Settings.builder().put(settings); Version version = SETTING_INDEX_VERSION_CREATED.get(settings); if (version != Version.V_EMPTY) { builder.put(SETTING_VERSION_CREATED_STRING, version.toString()); } Version versionUpgraded = settings.getAsVersion(SETTING_VERSION_UPGRADED, null); if (versionUpgraded != null) { builder.put(SETTING_VERSION_UPGRADED_STRING, versionUpgraded.toString()); } Long creationDate = settings.getAsLong(SETTING_CREATION_DATE, null); if (creationDate != null) { ZonedDateTime creationDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(creationDate), ZoneOffset.UTC); builder.put(SETTING_CREATION_DATE_STRING, creationDateTime.toString()); } return builder.build(); }
Example 3
Source File: PartitionInfos.java From crate with Apache License 2.0 | 6 votes |
private static PartitionInfo createPartitionInfo(ObjectObjectCursor<String, IndexMetaData> indexMetaDataEntry) { PartitionName partitionName = PartitionName.fromIndexOrTemplate(indexMetaDataEntry.key); try { IndexMetaData indexMetaData = indexMetaDataEntry.value; MappingMetaData mappingMetaData = indexMetaData.mapping(Constants.DEFAULT_MAPPING_TYPE); Map<String, Object> mappingMap = mappingMetaData.sourceAsMap(); Map<String, Object> valuesMap = buildValuesMap(partitionName, mappingMetaData); Settings settings = indexMetaData.getSettings(); String numberOfReplicas = NumberOfReplicas.fromSettings(settings); return new PartitionInfo( partitionName, indexMetaData.getNumberOfShards(), numberOfReplicas, IndexMetaData.SETTING_INDEX_VERSION_CREATED.get(settings), settings.getAsVersion(IndexMetaData.SETTING_VERSION_UPGRADED, null), DocIndexMetaData.isClosed(indexMetaData, mappingMap, false), valuesMap, indexMetaData.getSettings()); } catch (Exception e) { LOGGER.trace("error extracting partition infos from index {}", e, indexMetaDataEntry.key); return null; // must filter on null } }
Example 4
Source File: Version.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Return the {@link Version} of Elasticsearch that has been used to create an index given its settings. * * @throws IllegalStateException if the given index settings doesn't contain a value for the key {@value IndexMetaData#SETTING_VERSION_CREATED} */ public static Version indexCreated(Settings indexSettings) { final Version indexVersion = indexSettings.getAsVersion(IndexMetaData.SETTING_VERSION_CREATED, null); if (indexVersion == null) { throw new IllegalStateException("[" + IndexMetaData.SETTING_VERSION_CREATED + "] is not present in the index settings for index with uuid: [" + indexSettings.get(IndexMetaData.SETTING_INDEX_UUID) + "]"); } return indexVersion; }
Example 5
Source File: InternalBlobTableInfoFactory.java From crate with Apache License 2.0 | 5 votes |
@Override public BlobTableInfo create(RelationName ident, ClusterState clusterState) { IndexMetaData indexMetaData = resolveIndexMetaData(ident.name(), clusterState); Settings settings = indexMetaData.getSettings(); return new BlobTableInfo( ident, indexMetaData.getIndex().getName(), indexMetaData.getNumberOfShards(), NumberOfReplicas.fromSettings(settings), settings, blobsPath(settings), IndexMetaData.SETTING_INDEX_VERSION_CREATED.get(settings), settings.getAsVersion(IndexMetaData.SETTING_VERSION_UPGRADED, null), indexMetaData.getState() == IndexMetaData.State.CLOSE); }
Example 6
Source File: DocIndexMetaData.java From crate with Apache License 2.0 | 5 votes |
DocIndexMetaData(Functions functions, IndexMetaData metaData, RelationName ident) throws IOException { this.functions = functions; this.ident = ident; this.numberOfShards = metaData.getNumberOfShards(); Settings settings = metaData.getSettings(); this.numberOfReplicas = NumberOfReplicas.fromSettings(settings); this.mappingMap = getMappingMap(metaData); this.tableParameters = metaData.getSettings(); Map<String, Object> metaMap = Maps.get(mappingMap, "_meta"); indicesMap = Maps.getOrDefault(metaMap, "indices", ImmutableMap.of()); List<List<String>> partitionedByList = Maps.getOrDefault(metaMap, "partitioned_by", List.of()); this.partitionedBy = getPartitionedBy(partitionedByList); generatedColumns = Maps.getOrDefault(metaMap, "generated_columns", ImmutableMap.of()); IndexMetaData.State state = isClosed(metaData, mappingMap, !partitionedByList.isEmpty()) ? IndexMetaData.State.CLOSE : IndexMetaData.State.OPEN; supportedOperations = Operation.buildFromIndexSettingsAndState(metaData.getSettings(), state); versionCreated = IndexMetaData.SETTING_INDEX_VERSION_CREATED.get(settings); versionUpgraded = settings.getAsVersion(IndexMetaData.SETTING_VERSION_UPGRADED, null); closed = state == IndexMetaData.State.CLOSE; this.expressionAnalyzer = new ExpressionAnalyzer( functions, CoordinatorTxnCtx.systemTransactionContext(), ParamTypeHints.EMPTY, FieldProvider.UNSUPPORTED, null); }