public void clearIndexes() { Loggers.get(getClass()).info("Truncate Elasticsearch indices"); try { esClient.prepareClearCache().get(); for (String index : esClient.prepareState().get().getState().getMetaData().getConcreteAllIndices()) { clearIndex(new IndexType(index, index)); } } catch (Exception e) { throw new IllegalStateException("Unable to clear indexes", e); } }
/** * Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and all indices in the cluster. * * @param clusterState The current cluster state. Must not be null. */ public ClusterStateHealth(final ClusterState clusterState) { this(clusterState, clusterState.metaData().getConcreteAllIndices()); }
/** * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices * * @param indicesOrAliases the array containing index names * @param concreteIndices array containing the concrete indices that the first argument refers to * @return true if the first argument is a pattern that maps to all available indices, false otherwise */ boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) { // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure if (concreteIndices.length == metaData.getConcreteAllIndices().length && indicesOrAliases.length > 0) { //we might have something like /-test1,+test1 that would identify all indices //or something like /-test1 with test1 index missing and IndicesOptions.lenient() if (indicesOrAliases[0].charAt(0) == '-') { return true; } //otherwise we check if there's any simple regex for (String indexOrAlias : indicesOrAliases) { if (Regex.isSimpleMatchPattern(indexOrAlias)) { return true; } } } return false; }
/** * Sets the same routing for all indices */ public Map<String, Set<String>> resolveSearchRoutingAllIndices(MetaData metaData, String routing) { if (routing != null) { Set<String> r = Sets.newHashSet(Strings.splitStringByCommaToArray(routing)); Map<String, Set<String>> routings = new HashMap<>(); String[] concreteIndices = metaData.getConcreteAllIndices(); for (String index : concreteIndices) { routings.put(index, r); } return routings; } return null; }
private static List<String> resolveEmptyOrTrivialWildcard(IndicesOptions options, MetaData metaData) { if (options.expandWildcardsOpen() && options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllIndices()); } else if (options.expandWildcardsOpen()) { return Arrays.asList(metaData.getConcreteAllOpenIndices()); } else if (options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllClosedIndices()); } else { return Collections.emptyList(); } } }
/** * Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and all indices in the cluster. * * @param clusterState The current cluster state. Must not be null. */ public ClusterStateHealth(final ClusterState clusterState) { this(clusterState, clusterState.metaData().getConcreteAllIndices()); }
/** * Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and all indices in the cluster. * * @param clusterState The current cluster state. Must not be null. */ public ClusterStateHealth(final ClusterState clusterState) { this(clusterState, clusterState.metaData().getConcreteAllIndices()); }
/** * Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and all indices in the cluster. * * @param clusterState The current cluster state. Must not be null. */ public ClusterStateHealth(final ClusterState clusterState) { this(clusterState, clusterState.metaData().getConcreteAllIndices()); }
/** * Sets the same routing for all indices */ private Map<String, Set<String>> resolveSearchRoutingAllIndices(MetaData metaData, String routing) { if (routing != null) { Set<String> r = Strings.splitStringByCommaToSet(routing); Map<String, Set<String>> routings = new HashMap<>(); String[] concreteIndices = metaData.getConcreteAllIndices(); for (String index : concreteIndices) { routings.put(index, r); } return routings; } return null; }
/** * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices * * @param indicesOrAliases the array containing index names * @param concreteIndices array containing the concrete indices that the first argument refers to * @return true if the first argument is a pattern that maps to all available indices, false otherwise */ boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) { // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure if (concreteIndices.length == metaData.getConcreteAllIndices().length && indicesOrAliases.length > 0) { //we might have something like /-test1,+test1 that would identify all indices //or something like /-test1 with test1 index missing and IndicesOptions.lenient() if (indicesOrAliases[0].charAt(0) == '-') { return true; } //otherwise we check if there's any simple regex for (String indexOrAlias : indicesOrAliases) { if (Regex.isSimpleMatchPattern(indexOrAlias)) { return true; } } } return false; }
/** * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices * * @param indicesOrAliases the array containing index names * @param concreteIndices array containing the concrete indices that the first argument refers to * @return true if the first argument is a pattern that maps to all available indices, false otherwise */ boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) { // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure if (concreteIndices.length == metaData.getConcreteAllIndices().length && indicesOrAliases.length > 0) { //we might have something like /-test1,+test1 that would identify all indices //or something like /-test1 with test1 index missing and IndicesOptions.lenient() if (indicesOrAliases[0].charAt(0) == '-') { return true; } //otherwise we check if there's any simple regex for (String indexOrAlias : indicesOrAliases) { if (Regex.isSimpleMatchPattern(indexOrAlias)) { return true; } } } return false; }
/** * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices * * @param indicesOrAliases the array containing index names * @param concreteIndices array containing the concrete indices that the first argument refers to * @return true if the first argument is a pattern that maps to all available indices, false otherwise */ boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) { // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure if (concreteIndices.length == metaData.getConcreteAllIndices().length && indicesOrAliases.length > 0) { //we might have something like /-test1,+test1 that would identify all indices //or something like /-test1 with test1 index missing and IndicesOptions.lenient() if (indicesOrAliases[0].charAt(0) == '-') { return true; } //otherwise we check if there's any simple regex for (String indexOrAlias : indicesOrAliases) { if (Regex.isSimpleMatchPattern(indexOrAlias)) { return true; } } } return false; }
/** * Sets the same routing for all indices */ public Map<String, Set<String>> resolveSearchRoutingAllIndices(MetaData metaData, String routing) { if (routing != null) { Set<String> r = Sets.newHashSet(Strings.splitStringByCommaToArray(routing)); Map<String, Set<String>> routings = new HashMap<>(); String[] concreteIndices = metaData.getConcreteAllIndices(); for (String index : concreteIndices) { routings.put(index, r); } return routings; } return null; }
/** * Sets the same routing for all indices */ public Map<String, Set<String>> resolveSearchRoutingAllIndices(MetaData metaData, String routing) { if (routing != null) { Set<String> r = Sets.newHashSet(Strings.splitStringByCommaToArray(routing)); Map<String, Set<String>> routings = new HashMap<>(); String[] concreteIndices = metaData.getConcreteAllIndices(); for (String index : concreteIndices) { routings.put(index, r); } return routings; } return null; }
private static List<String> resolveEmptyOrTrivialWildcard(IndicesOptions options, MetaData metaData) { if (options.expandWildcardsOpen() && options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllIndices()); } else if (options.expandWildcardsOpen()) { return Arrays.asList(metaData.getConcreteAllOpenIndices()); } else if (options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllClosedIndices()); } else { return Collections.emptyList(); } } }
private void cleanOrphanIndex() { String[] indices = client.admin().cluster().prepareState().execute().actionGet().getState() .getMetaData().getConcreteAllIndices(); List<String> orphans = Stream.of(indices) .filter(i -> i.startsWith(this.configuration.getAlias())) .filter(i -> 0 == client.admin().indices().getAliases(new GetAliasesRequest().indices(i)) .actionGet().getAliases().size()) .collect(Collectors.toList()); for (String orphan : orphans) { client.admin().indices().delete(new DeleteIndexRequest(orphan)).actionGet(); } }
private static List<String> resolveEmptyOrTrivialWildcard(IndicesOptions options, MetaData metaData) { if (options.expandWildcardsOpen() && options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllIndices()); } else if (options.expandWildcardsOpen()) { return Arrays.asList(metaData.getConcreteAllOpenIndices()); } else if (options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllClosedIndices()); } else { return Collections.emptyList(); } } }
private List<String> resolveEmptyOrTrivialWildcard(IndicesOptions options, MetaData metaData, boolean assertEmpty) { if (options.expandWildcardsOpen() && options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllIndices()); } else if (options.expandWildcardsOpen()) { return Arrays.asList(metaData.getConcreteAllOpenIndices()); } else if (options.expandWildcardsClosed()) { return Arrays.asList(metaData.getConcreteAllClosedIndices()); } else { assert assertEmpty : "Shouldn't end up here"; return Collections.emptyList(); } } }
public void clearIndexes() { Loggers.get(getClass()).info("Truncate Elasticsearch indices"); try { esClient.prepareClearCache().get(); for (String index : esClient.prepareState().get().getState().getMetaData().getConcreteAllIndices()) { clearIndex(new IndexType(index, index)); } } catch (Exception e) { throw new IllegalStateException("Unable to clear indexes", e); } }
metaData.getTemplates(), metaData.getCustoms(), metaData.getConcreteAllIndices(), metaData.getConcreteAllOpenIndices(), metaData.getConcreteAllClosedIndices(),