private static boolean clusterHas5xNodes(ClusterState state) { return state.nodes().getMinNodeVersion().before(Version.V_6_0_0_alpha1); }
private static boolean clusterHas5xIndices(ClusterState state) { final Iterator<IndexMetaData> indices = state.metaData().indices().valuesIt(); for(;indices.hasNext();) { final IndexMetaData indexMetaData = indices.next(); if(indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) { return true; } } return false; } }
private void checkVersion(Version version) { if (version.before(Version.V_5_2_0)) { throw new IllegalArgumentException("cannot explain shards in a mixed-cluster with pre-" + Version.V_5_2_0 + " nodes, node version [" + version + "]"); } } }
private static SimilarityProvider resolveSimilarity(Mapper.TypeParser.ParserContext parserContext, String name, String value) { if (parserContext.indexVersionCreated().before(Version.V_5_0_0_alpha1) && "default".equals(value)) { // "default" similarity has been renamed into "classic" in 3.x. value = "classic"; } SimilarityProvider similarityProvider = parserContext.getSimilarity(value); if (similarityProvider == null) { throw new MapperParsingException("Unknown Similarity type [" + value + "] for field [" + name + "]"); } return similarityProvider; } }
public SliceBuilder(StreamInput in) throws IOException { String field = in.readString(); if (UidFieldMapper.NAME.equals(field) && in.getVersion().before(Version.V_6_3_0)) { // This is safe because _id and _uid are handled the same way in #toFilter field = IdFieldMapper.NAME; } this.field = field; this.id = in.readVInt(); this.max = in.readVInt(); }
/** * BWC serialization for nested {@link InnerHitBuilder}. * Should only be used to send nested inner hits to nodes pre 5.5. */ protected void writeToNestedBWC(StreamOutput out, QueryBuilder query, String nestedPath) throws IOException { assert out.getVersion().before(Version.V_5_5_0) : "invalid output version, must be < " + Version.V_5_5_0.toString(); writeToBWC(out, query, nestedPath, null); }
@Override public void readFrom(StreamInput in) throws IOException { sizeInBytes = in.readVLong(); if (in.getVersion().before(Version.V_6_0_0_alpha1)) { in.readVLong(); // throttleTimeInNanos } }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeVLong(sizeInBytes); if (out.getVersion().before(Version.V_6_0_0_alpha1)) { out.writeVLong(0L); // throttleTimeInNanos } }
/** * BWC serialization for parent/child {@link InnerHitBuilder}. * Should only be used to send hasParent or hasChild inner hits to nodes pre 5.5. */ public void writeToParentChildBWC(StreamOutput out, QueryBuilder query, String parentChildPath) throws IOException { assert(out.getVersion().before(Version.V_5_5_0)) : "invalid output version, must be < " + Version.V_5_5_0.toString(); writeToBWC(out, query, null, parentChildPath); }
static void validateSplitIndex(ClusterState state, String sourceIndex, Set<String> targetIndexMappingsTypes, String targetIndexName, Settings targetIndexSettings) { IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings); IndexMetaData.selectSplitShard(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings)); if (sourceMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) { // ensure we have a single type since this would make the splitting code considerably more complex // and a 5.x index would not be splittable unless it has been shrunk before so rather opt out of the complexity // since in 5.x we don't have a setting to artificially set the number of routing shards throw new IllegalStateException("source index created version is too old to apply a split operation"); } }
@Override public Query termQuery(Object value, QueryShardContext context) { failIfNotIndexed(); TermQuery query = new TermQuery(new Term(name(), indexedValueForSearch(value))); if (boost() == 1f || (context != null && context.indexVersionCreated().before(Version.V_5_0_0_alpha1))) { return query; } return new BoostQuery(query, boost()); }
@Override public void writeTo(StreamOutput out) throws IOException { if (IdFieldMapper.NAME.equals(field) && out.getVersion().before(Version.V_6_3_0)) { out.writeString(UidFieldMapper.NAME); } else { out.writeString(field); } out.writeVInt(id); out.writeVInt(max); }
private boolean isTargetSameHistory() { final String targetHistoryUUID = request.metadataSnapshot().getHistoryUUID(); assert targetHistoryUUID != null || shard.indexSettings().getIndexVersionCreated().before(Version.V_6_0_0_rc1) : "incoming target history N/A but index was created after or on 6.0.0-rc1"; return targetHistoryUUID != null && targetHistoryUUID.equals(shard.getHistoryUUID()); }
/** * BWC serialization for collapsing {@link InnerHitBuilder}. * Should only be used to send collapsing inner hits to nodes pre 5.5. */ public void writeToCollapseBWC(StreamOutput out) throws IOException { assert out.getVersion().before(Version.V_5_5_0) : "invalid output version, must be < " + Version.V_5_5_0.toString(); writeToBWC(out, new MatchAllQueryBuilder(), null, null); }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.getVersion().before(Version.V_6_0_0_alpha2)) { in.readString(); // read lang from previous versions } id = in.readString(); }
@Override public void writeTo(StreamOutput out) throws IOException { if (out.getVersion().before(Version.V_6_2_0)) { out.writeVLong(getBytes()); } else { out.writeZLong(size); unit.writeTo(out); } }
public NodeAllocationResult(StreamInput in) throws IOException { node = new DiscoveryNode(in); shardStoreInfo = in.readOptionalWriteable(ShardStoreInfo::new); if (in.getVersion().before(Version.V_5_2_1)) { canAllocateDecision = Decision.readFrom(in); } else { canAllocateDecision = in.readOptionalWriteable(Decision::readFrom); } nodeDecision = AllocationDecision.readFrom(in); weightRanking = in.readVInt(); }
@Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(queryCache); out.writeBoolean(fieldDataCache); if (out.getVersion().before(Version.V_6_0_0_beta1)) { out.writeBoolean(false); // recycler } out.writeStringArrayNullable(fields); out.writeBoolean(requestCache); } }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(path); // total aggregates do not have a path out.writeOptionalString(mount); out.writeOptionalString(type); out.writeLong(total); out.writeLong(free); out.writeLong(available); if (out.getVersion().before(Version.V_6_0_0_alpha1)) { out.writeOptionalBoolean(null); } }
/*** Implementation of {@link RecoveryTargetHandler } */ @Override public void prepareForTranslogOperations(boolean fileBasedRecovery, int totalTranslogOps) throws IOException { if (fileBasedRecovery && indexShard.indexSettings().getIndexVersionCreated().before(Version.V_6_0_0)) { store.ensureIndexHas6xCommitTags(); } state().getTranslog().totalOperations(totalTranslogOps); indexShard().openEngineAndSkipTranslogRecovery(); }