indicesToWrite.add(new GatewayMetaState.IndexMetaWriteInfo(newIndexMetaData, previousIndexMetaData, writeReason));
/** * Loads the current meta state for each index in the new cluster state and checks if it has to be persisted. * Each index state that should be written to disk will be returned. This is only run for data only nodes. * It will return only the states for indices that actually have a shard allocated on the current node. * * @param previouslyWrittenIndices A list of indices for which the state was already written before * @param potentiallyUnwrittenIndices The list of indices for which state should potentially be written * @param previousMetaData The last meta data we know of. meta data for all indices in previouslyWrittenIndices list is persisted now * @param newMetaData The new metadata * @return iterable over all indices states that should be written to disk */ public static Iterable<GatewayMetaState.IndexMetaWriteInfo> resolveStatesToBeWritten(ImmutableSet<String> previouslyWrittenIndices, Set<String> potentiallyUnwrittenIndices, MetaData previousMetaData, MetaData newMetaData) { List<GatewayMetaState.IndexMetaWriteInfo> indicesToWrite = new ArrayList<>(); for (String index : potentiallyUnwrittenIndices) { IndexMetaData newIndexMetaData = newMetaData.index(index); IndexMetaData previousIndexMetaData = previousMetaData == null ? null : previousMetaData.index(index); String writeReason = null; if (previouslyWrittenIndices.contains(index) == false || previousIndexMetaData == null) { writeReason = "freshly created"; } else if (previousIndexMetaData.getVersion() != newIndexMetaData.getVersion()) { writeReason = "version changed from [" + previousIndexMetaData.getVersion() + "] to [" + newIndexMetaData.getVersion() + "]"; } if (writeReason != null) { indicesToWrite.add(new GatewayMetaState.IndexMetaWriteInfo(newIndexMetaData, previousIndexMetaData, writeReason)); } } return indicesToWrite; }
/** * Loads the current meta state for each index in the new cluster state and checks if it has to be persisted. * Each index state that should be written to disk will be returned. This is only run for data only nodes. * It will return only the states for indices that actually have a shard allocated on the current node. * * @param previouslyWrittenIndices A list of indices for which the state was already written before * @param potentiallyUnwrittenIndices The list of indices for which state should potentially be written * @param previousMetaData The last meta data we know of. meta data for all indices in previouslyWrittenIndices list is persisted now * @param newMetaData The new metadata * @return iterable over all indices states that should be written to disk */ public static Iterable<GatewayMetaState.IndexMetaWriteInfo> resolveStatesToBeWritten(Set<Index> previouslyWrittenIndices, Set<Index> potentiallyUnwrittenIndices, MetaData previousMetaData, MetaData newMetaData) { List<GatewayMetaState.IndexMetaWriteInfo> indicesToWrite = new ArrayList<>(); for (Index index : potentiallyUnwrittenIndices) { IndexMetaData newIndexMetaData = newMetaData.getIndexSafe(index); IndexMetaData previousIndexMetaData = previousMetaData == null ? null : previousMetaData.index(index); String writeReason = null; if (previouslyWrittenIndices.contains(index) == false || previousIndexMetaData == null) { writeReason = "freshly created"; } else if (previousIndexMetaData.getVersion() != newIndexMetaData.getVersion()) { writeReason = "version changed from [" + previousIndexMetaData.getVersion() + "] to [" + newIndexMetaData.getVersion() + "]"; } if (writeReason != null) { indicesToWrite.add(new GatewayMetaState.IndexMetaWriteInfo(newIndexMetaData, previousIndexMetaData, writeReason)); } } return indicesToWrite; }
/** * Loads the current meta state for each index in the new cluster state and checks if it has to be persisted. * Each index state that should be written to disk will be returned. This is only run for data only nodes. * It will return only the states for indices that actually have a shard allocated on the current node. * * @param previouslyWrittenIndices A list of indices for which the state was already written before * @param potentiallyUnwrittenIndices The list of indices for which state should potentially be written * @param previousMetaData The last meta data we know of. meta data for all indices in previouslyWrittenIndices list is persisted now * @param newMetaData The new metadata * @return iterable over all indices states that should be written to disk */ public static Iterable<GatewayMetaState.IndexMetaWriteInfo> resolveStatesToBeWritten(Set<Index> previouslyWrittenIndices, Set<Index> potentiallyUnwrittenIndices, MetaData previousMetaData, MetaData newMetaData) { List<GatewayMetaState.IndexMetaWriteInfo> indicesToWrite = new ArrayList<>(); for (Index index : potentiallyUnwrittenIndices) { IndexMetaData newIndexMetaData = newMetaData.getIndexSafe(index); IndexMetaData previousIndexMetaData = previousMetaData == null ? null : previousMetaData.index(index); String writeReason = null; if (previouslyWrittenIndices.contains(index) == false || previousIndexMetaData == null) { writeReason = "freshly created"; } else if (previousIndexMetaData.getVersion() != newIndexMetaData.getVersion()) { writeReason = "version changed from [" + previousIndexMetaData.getVersion() + "] to [" + newIndexMetaData.getVersion() + "]"; } if (writeReason != null) { indicesToWrite.add(new GatewayMetaState.IndexMetaWriteInfo(newIndexMetaData, previousIndexMetaData, writeReason)); } } return indicesToWrite; }
/** * Loads the current meta state for each index in the new cluster state and checks if it has to be persisted. * Each index state that should be written to disk will be returned. This is only run for data only nodes. * It will return only the states for indices that actually have a shard allocated on the current node. * * @param previouslyWrittenIndices A list of indices for which the state was already written before * @param potentiallyUnwrittenIndices The list of indices for which state should potentially be written * @param previousMetaData The last meta data we know of. meta data for all indices in previouslyWrittenIndices list is persisted now * @param newMetaData The new metadata * @return iterable over all indices states that should be written to disk */ public static Iterable<GatewayMetaState.IndexMetaWriteInfo> resolveStatesToBeWritten(Set<Index> previouslyWrittenIndices, Set<Index> potentiallyUnwrittenIndices, MetaData previousMetaData, MetaData newMetaData) { List<GatewayMetaState.IndexMetaWriteInfo> indicesToWrite = new ArrayList<>(); for (Index index : potentiallyUnwrittenIndices) { IndexMetaData newIndexMetaData = newMetaData.getIndexSafe(index); IndexMetaData previousIndexMetaData = previousMetaData == null ? null : previousMetaData.index(index); String writeReason = null; if (previouslyWrittenIndices.contains(index) == false || previousIndexMetaData == null) { writeReason = "freshly created"; } else if (previousIndexMetaData.getVersion() != newIndexMetaData.getVersion()) { writeReason = "version changed from [" + previousIndexMetaData.getVersion() + "] to [" + newIndexMetaData.getVersion() + "]"; } if (writeReason != null) { indicesToWrite.add(new GatewayMetaState.IndexMetaWriteInfo(newIndexMetaData, previousIndexMetaData, writeReason)); } } return indicesToWrite; }