本文整理汇总了Java中org.elasticsearch.Version.before方法的典型用法代码示例。如果您正苦于以下问题:Java Version.before方法的具体用法?Java Version.before怎么用?Java Version.before使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.Version
的用法示例。
在下文中一共展示了Version.before方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsBooleanLenientForPreEs6Indices
import org.elasticsearch.Version; //导入方法依赖的package包/类
/**
* Returns the setting value (as boolean) associated with the setting key. If it does not exist, returns the default value provided.
* If the index was created on Elasticsearch below 6.0, booleans will be parsed leniently otherwise they are parsed strictly.
*
* See {@link Booleans#isBooleanLenient(char[], int, int)} for the definition of a "lenient boolean"
* and {@link Booleans#isBoolean(char[], int, int)} for the definition of a "strict boolean".
*
* @deprecated Only used to provide automatic upgrades for pre 6.0 indices.
*/
@Deprecated
public Boolean getAsBooleanLenientForPreEs6Indices(
final Version indexVersion,
final String setting,
final Boolean defaultValue,
final DeprecationLogger deprecationLogger) {
if (indexVersion.before(Version.V_6_0_0_alpha1_UNRELEASED)) {
//Only emit a warning if the setting's value is not a proper boolean
final String value = get(setting, "false");
if (Booleans.isBoolean(value) == false) {
@SuppressWarnings("deprecation")
boolean convertedValue = Booleans.parseBooleanLenient(get(setting), defaultValue);
deprecationLogger.deprecated("The value [{}] of setting [{}] is not coerced into boolean anymore. Please change " +
"this value to [{}].", value, setting, String.valueOf(convertedValue));
return convertedValue;
}
}
return getAsBoolean(setting, defaultValue);
}
示例2: testAllVersionsTested
import org.elasticsearch.Version; //导入方法依赖的package包/类
public void testAllVersionsTested() throws Exception {
SortedSet<String> expectedVersions = new TreeSet<>();
for (Version v : VersionUtils.allReleasedVersions()) {
if (VersionUtils.isSnapshot(v)) continue; // snapshots are unreleased, so there is no backcompat yet
if (v.isRelease() == false) continue; // no guarantees for prereleases
if (v.before(Version.CURRENT.minimumIndexCompatibilityVersion())) continue; // we can only support one major version backward
if (v.equals(Version.CURRENT)) continue; // the current version is always compatible with itself
expectedVersions.add("index-" + v.toString() + ".zip");
}
for (String index : indexes) {
if (expectedVersions.remove(index) == false) {
logger.warn("Old indexes tests contain extra index: {}", index);
}
}
if (expectedVersions.isEmpty() == false) {
StringBuilder msg = new StringBuilder("Old index tests are missing indexes:");
for (String expected : expectedVersions) {
msg.append("\n" + expected);
}
fail(msg.toString());
}
}
示例3: Mapping
import org.elasticsearch.Version; //导入方法依赖的package包/类
public Mapping(Version indexCreated, RootObjectMapper rootObjectMapper, MetadataFieldMapper[] metadataMappers, SourceTransform[] sourceTransforms, ImmutableMap<String, Object> meta) {
this.indexCreated = indexCreated;
this.metadataMappers = metadataMappers;
ImmutableMap.Builder<Class<? extends MetadataFieldMapper>, MetadataFieldMapper> builder = ImmutableMap.builder();
for (MetadataFieldMapper metadataMapper : metadataMappers) {
if (indexCreated.before(Version.V_2_0_0_beta1) && LEGACY_INCLUDE_IN_OBJECT.contains(metadataMapper.name())) {
rootObjectMapper = rootObjectMapper.copyAndPutMapper(metadataMapper);
}
builder.put(metadataMapper.getClass(), metadataMapper);
}
this.root = rootObjectMapper;
// keep root mappers sorted for consistent serialization
Arrays.sort(metadataMappers, new Comparator<Mapper>() {
@Override
public int compare(Mapper o1, Mapper o2) {
return o1.name().compareTo(o2.name());
}
});
this.metadataMappersMap = builder.build();
this.sourceTransforms = sourceTransforms;
this.meta = meta;
}
示例4: parseStringTimestamp
import org.elasticsearch.Version; //导入方法依赖的package包/类
public static String parseStringTimestamp(String timestampAsString, FormatDateTimeFormatter dateTimeFormatter,
Version version) throws TimestampParsingException {
try {
// no need for unix timestamp parsing in 2.x
FormatDateTimeFormatter formatter = version.onOrAfter(Version.V_2_0_0_beta1) ? dateTimeFormatter : EPOCH_MILLIS_PARSER;
return Long.toString(formatter.parser().parseMillis(timestampAsString));
} catch (RuntimeException e) {
if (version.before(Version.V_2_0_0_beta1)) {
try {
return Long.toString(dateTimeFormatter.parser().parseMillis(timestampAsString));
} catch (RuntimeException e1) {
throw new TimestampParsingException(timestampAsString, e1);
}
}
throw new TimestampParsingException(timestampAsString, e);
}
}
示例5: getIndexDir
import org.elasticsearch.Version; //导入方法依赖的package包/类
public static Path getIndexDir(
final Logger logger,
final String indexName,
final String indexFile,
final Path dataDir) throws IOException {
final Version version = Version.fromString(indexName.substring("index-".length()));
if (version.before(Version.V_5_0_0_alpha1)) {
// the bwc scripts packs the indices under this path
Path src = dataDir.resolve("nodes/0/indices/" + indexName);
assertTrue("[" + indexFile + "] missing index dir: " + src.toString(), Files.exists(src));
return src;
} else {
final List<Path> indexFolders = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dataDir.resolve("0/indices"),
(p) -> p.getFileName().toString().startsWith("extra") == false)) { // extra FS can break this...
for (final Path path : stream) {
indexFolders.add(path);
}
}
assertThat(indexFolders.toString(), indexFolders.size(), equalTo(1));
final IndexMetaData indexMetaData = IndexMetaData.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY,
indexFolders.get(0));
assertNotNull(indexMetaData);
assertThat(indexFolders.get(0).getFileName().toString(), equalTo(indexMetaData.getIndexUUID()));
assertThat(indexMetaData.getCreationVersion(), equalTo(version));
return indexFolders.get(0);
}
}
示例6: getNodeDir
import org.elasticsearch.Version; //导入方法依赖的package包/类
private Path getNodeDir(String indexFile) throws IOException {
Path unzipDir = createTempDir();
Path unzipDataDir = unzipDir.resolve("data");
// decompress the index
Path backwardsIndex = getBwcIndicesPath().resolve(indexFile);
try (InputStream stream = Files.newInputStream(backwardsIndex)) {
TestUtil.unzip(stream, unzipDir);
}
// check it is unique
assertTrue(Files.exists(unzipDataDir));
Path[] list = FileSystemUtils.files(unzipDataDir);
if (list.length != 1) {
throw new IllegalStateException("Backwards index must contain exactly one cluster");
}
int zipIndex = indexFile.indexOf(".zip");
final Version version = Version.fromString(indexFile.substring("index-".length(), zipIndex));
if (version.before(Version.V_5_0_0_alpha1)) {
// the bwc scripts packs the indices under this path
return list[0].resolve("nodes/0/");
} else {
// after 5.0.0, data folders do not include the cluster name
return list[0].resolve("0");
}
}
示例7: testRestoreOldSnapshots
import org.elasticsearch.Version; //导入方法依赖的package包/类
public void testRestoreOldSnapshots() throws Exception {
String repo = "test_repo";
String snapshot = "test_1";
List<String> repoVersions = repoVersions();
assertThat(repoVersions.size(), greaterThan(0));
for (String version : repoVersions) {
createRepo("repo", version, repo);
testOldSnapshot(version, repo, snapshot);
}
SortedSet<String> expectedVersions = new TreeSet<>();
for (Version v : VersionUtils.allReleasedVersions()) {
if (VersionUtils.isSnapshot(v)) continue; // snapshots are unreleased, so there is no backcompat yet
if (v.isRelease() == false) continue; // no guarantees for prereleases
if (v.before(Version.CURRENT.minimumIndexCompatibilityVersion())) continue; // we only support versions N and N-1
if (v.equals(Version.CURRENT)) continue; // the current version is always compatible with itself
expectedVersions.add(v.toString());
}
for (String repoVersion : repoVersions) {
if (expectedVersions.remove(repoVersion) == false) {
logger.warn("Old repositories tests contain extra repo: {}", repoVersion);
}
}
if (expectedVersions.isEmpty() == false) {
StringBuilder msg = new StringBuilder("Old repositories tests are missing versions:");
for (String expected : expectedVersions) {
msg.append("\n" + expected);
}
fail(msg.toString());
}
}
示例8: testFieldStatsBWC
import org.elasticsearch.Version; //导入方法依赖的package包/类
public void testFieldStatsBWC() throws Exception {
int size = randomIntBetween(5, 20);
Map<String, FieldStats<?> > stats = new HashMap<> ();
for (int i = 0; i < size; i++) {
stats.put(Integer.toString(i), FieldStatsTests.randomFieldStats(true));
}
FieldStatsShardResponse response = new FieldStatsShardResponse(new ShardId("test", "test", 0), stats);
for (int i = 0; i < 10; i++) {
Version version = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.CURRENT);
BytesStreamOutput output = new BytesStreamOutput();
output.setVersion(version);
response.writeTo(output);
output.flush();
StreamInput input = output.bytes().streamInput();
input.setVersion(version);
FieldStatsShardResponse deserialized = new FieldStatsShardResponse();
deserialized.readFrom(input);
final Map<String, FieldStats<?>> expected;
if (version.before(Version.V_5_2_0_UNRELEASED)) {
expected = deserialized.filterNullMinMax();
} else {
expected = deserialized.getFieldStats();
}
assertEquals(expected.size(), deserialized.getFieldStats().size());
assertThat(expected, equalTo(deserialized.getFieldStats()));
}
}
示例9: joinFieldTypeForParentType
import org.elasticsearch.Version; //导入方法依赖的package包/类
private static MappedFieldType joinFieldTypeForParentType(String parentType, Settings indexSettings) {
MappedFieldType parentJoinFieldType = Defaults.JOIN_FIELD_TYPE.clone();
parentJoinFieldType.setNames(new MappedFieldType.Names(joinField(parentType)));
Version indexCreated = Version.indexCreated(indexSettings);
if (indexCreated.before(Version.V_2_0_0_beta1)) {
parentJoinFieldType.setHasDocValues(false);
parentJoinFieldType.setDocValuesType(DocValuesType.NONE);
}
parentJoinFieldType.freeze();
return parentJoinFieldType;
}
示例10: positionIncrementGap
import org.elasticsearch.Version; //导入方法依赖的package包/类
/**
* The default position_increment_gap for a particular version of Elasticsearch.
*/
public static int positionIncrementGap(Version version) {
if (version.before(Version.V_2_0_0_beta1)) {
return POSITION_INCREMENT_GAP_PRE_2_0;
}
return POSITION_INCREMENT_GAP;
}
示例11: green
import org.elasticsearch.Version; //导入方法依赖的package包/类
/**
* Waits for cluster to attain green state.
*/
public void green() {
if(!USE_EXTERNAL_ES5){
TimeValue timeout = TimeValue.timeValueSeconds(30);
final org.elasticsearch.client.Client c = nodes[0].client();
ClusterHealthResponse actionGet = c.admin().cluster()
.health(Requests.clusterHealthRequest()
.timeout(timeout)
.waitForGreenStatus()
.waitForEvents(Priority.LANGUID)
.waitForRelocatingShards(0)).actionGet();
if (actionGet.isTimedOut()) {
logger.info("--> timed out waiting for cluster green state.\n{}\n{}",
c.admin().cluster().prepareState().get().getState().prettyPrint(),
c.admin().cluster().preparePendingClusterTasks().get().prettyPrint());
fail("timed out waiting for cluster green state");
}
Assert.assertTrue(actionGet.getStatus().compareTo(ClusterHealthStatus.GREEN) == 0);
NodesInfoResponse actionInfoGet = c.admin().cluster().nodesInfo(Requests.nodesInfoRequest().all()).actionGet();
for (NodeInfo node : actionInfoGet) {
Version nodeVersion = node.getVersion();
if (version == null) {
version = nodeVersion;
} else {
if (!nodeVersion.equals(version)) {
logger.debug("Nodes in elasticsearch cluster have inconsistent versions.");
}
}
if (nodeVersion.before(version)) {
version = nodeVersion;
}
}
}
}
示例12: checkVersion
import org.elasticsearch.Version; //导入方法依赖的package包/类
private void checkVersion(Version version) {
if (version.before(Version.V_5_2_0_UNRELEASED)) {
throw new IllegalArgumentException("cannot explain shards in a mixed-cluster with pre-" + Version.V_5_2_0_UNRELEASED +
" nodes, node version [" + version + "]");
}
}
示例13: legacyMetaData
import org.elasticsearch.Version; //导入方法依赖的package包/类
/**
* In v2.0.0 we changed the matadata file format
* @return true if legacy version should be used false otherwise
*/
public static boolean legacyMetaData(Version version) {
return version.before(Version.V_2_0_0_beta1);
}