當前位置: 首頁>>代碼示例>>Java>>正文


Java Settings.getAsVersion方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.settings.Settings.getAsVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java Settings.getAsVersion方法的具體用法?Java Settings.getAsVersion怎麽用?Java Settings.getAsVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.settings.Settings的用法示例。


在下文中一共展示了Settings.getAsVersion方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addHumanReadableSettings

import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:IndexMetaData.java

示例2: indexCreated

import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,代碼來源:Version.java

示例3: indexCreated

import org.elasticsearch.common.settings.Settings; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:13,代碼來源:Version.java


注:本文中的org.elasticsearch.common.settings.Settings.getAsVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。