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


Java MetaData.hasIndex方法代碼示例

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


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

示例1: resolveAndValidateRouting

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
public static void resolveAndValidateRouting(final MetaData metaData, String concreteIndex, DeleteRequest request) {
    request.routing(metaData.resolveIndexRouting(request.routing(), request.index()));
    if (metaData.hasIndex(concreteIndex)) {
        // check if routing is required, if so, throw error if routing wasn't specified
        MappingMetaData mappingMd = metaData.index(concreteIndex).mappingOrDefault(request.type());
        if (mappingMd != null && mappingMd.routing().required()) {
            if (request.routing() == null) {
                if (request.versionType() != VersionType.INTERNAL) {
                    // TODO: implement this feature
                    throw new IllegalArgumentException("routing value is required for deleting documents of type [" + request.type()
                        + "] while using version_type [" + request.versionType() + "]");
                }
                throw new RoutingMissingException(concreteIndex, request.type(), request.id());
            }
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:18,代碼來源:TransportDeleteAction.java

示例2: findNewDanglingIndices

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
/**
 * Finds new dangling indices by iterating over the indices and trying to find indices
 * that have state on disk, but are not part of the provided meta data, or not detected
 * as dangled already.
 */
Map<Index, IndexMetaData> findNewDanglingIndices(final MetaData metaData) {
    final Set<String> excludeIndexPathIds = new HashSet<>(metaData.indices().size() + danglingIndices.size());
    for (ObjectCursor<IndexMetaData> cursor : metaData.indices().values()) {
        excludeIndexPathIds.add(cursor.value.getIndex().getUUID());
    }
    excludeIndexPathIds.addAll(danglingIndices.keySet().stream().map(Index::getUUID).collect(Collectors.toList()));
    try {
        final List<IndexMetaData> indexMetaDataList = metaStateService.loadIndicesStates(excludeIndexPathIds::contains);
        Map<Index, IndexMetaData> newIndices = new HashMap<>(indexMetaDataList.size());
        final IndexGraveyard graveyard = metaData.indexGraveyard();
        for (IndexMetaData indexMetaData : indexMetaDataList) {
            if (metaData.hasIndex(indexMetaData.getIndex().getName())) {
                logger.warn("[{}] can not be imported as a dangling index, as index with same name already exists in cluster metadata",
                    indexMetaData.getIndex());
            } else if (graveyard.containsIndex(indexMetaData.getIndex())) {
                logger.warn("[{}] can not be imported as a dangling index, as an index with the same name and UUID exist in the " +
                            "index tombstones.  This situation is likely caused by copying over the data directory for an index " +
                            "that was previously deleted.", indexMetaData.getIndex());
            } else {
                logger.info("[{}] dangling index exists on local file system, but not in cluster metadata, " +
                            "auto import to cluster state", indexMetaData.getIndex());
                newIndices.put(indexMetaData.getIndex(), indexMetaData);
            }
        }
        return newIndices;
    } catch (IOException e) {
        logger.warn("failed to list dangling indices", e);
        return emptyMap();
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:36,代碼來源:DanglingIndicesState.java

示例3: indicesWithMissingShards

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
/**
 * Returns list of indices with missing shards, and list of indices that are closed
 *
 * @param shards list of shard statuses
 * @return list of failed and closed indices
 */
private Tuple<Set<String>, Set<String>> indicesWithMissingShards(ImmutableOpenMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards, MetaData metaData) {
    Set<String> missing = new HashSet<>();
    Set<String> closed = new HashSet<>();
    for (ObjectObjectCursor<ShardId, SnapshotsInProgress.ShardSnapshotStatus> entry : shards) {
        if (entry.value.state() == State.MISSING) {
            if (metaData.hasIndex(entry.key.getIndex().getName()) && metaData.getIndexSafe(entry.key.getIndex()).getState() == IndexMetaData.State.CLOSE) {
                closed.add(entry.key.getIndex().getName());
            } else {
                missing.add(entry.key.getIndex().getName());
            }
        }
    }
    return new Tuple<>(missing, closed);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,代碼來源:SnapshotsService.java

示例4: removeIndexLocationsForDeletedIndices

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
private void removeIndexLocationsForDeletedIndices(ClusterChangedEvent event, MetaData currentMetaData) {
    MetaData newMetaData = event.state().metaData();
    for (IndexMetaData current : currentMetaData) {
        String index = current.getIndex();
        if (!newMetaData.hasIndex(index) && isBlobIndex(index)) {
            deleteBlobIndexLocation(current, index);
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:10,代碼來源:BlobIndices.java

示例5: cleanupAllocatedDangledIndices

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
/**
 * Cleans dangling indices if they are already allocated on the provided meta data.
 */
void cleanupAllocatedDangledIndices(MetaData metaData) {
    for (String danglingIndex : danglingIndices.keySet()) {
        if (metaData.hasIndex(danglingIndex)) {
            logger.debug("[{}] no longer dangling (created), removing from dangling list", danglingIndex);
            danglingIndices.remove(danglingIndex);
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:12,代碼來源:DanglingIndicesState.java

示例6: findNewDanglingIndices

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
/**
 * Finds new dangling indices by iterating over the indices and trying to find indices
 * that have state on disk, but are not part of the provided meta data, or not detected
 * as dangled already.
 */
Map<String, IndexMetaData> findNewDanglingIndices(MetaData metaData) {
    final Set<String> indices;
    try {
        indices = nodeEnv.findAllIndices();
    } catch (Throwable e) {
        logger.warn("failed to list dangling indices", e);
        return ImmutableMap.of();
    }

    Map<String, IndexMetaData>  newIndices = Maps.newHashMap();
    for (String indexName : indices) {
        if (metaData.hasIndex(indexName) == false && danglingIndices.containsKey(indexName) == false) {
            try {
                IndexMetaData indexMetaData = metaStateService.loadIndexState(indexName);
                if (indexMetaData != null) {
                    logger.info("[{}] dangling index, exists on local file system, but not in cluster metadata, auto import to cluster state", indexName);
                    if (!indexMetaData.getIndex().equals(indexName)) {
                        logger.info("dangled index directory name is [{}], state name is [{}], renaming to directory name", indexName, indexMetaData.getIndex());
                        indexMetaData = IndexMetaData.builder(indexMetaData).index(indexName).build();
                    }
                    newIndices.put(indexName, indexMetaData);
                } else {
                    logger.debug("[{}] dangling index directory detected, but no state found", indexName);
                }
            } catch (Throwable t) {
                logger.warn("[{}] failed to load index state for detected dangled index", t, indexName);
            }
        }
    }
    return newIndices;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:37,代碼來源:DanglingIndicesState.java

示例7: validate

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
public void validate(RoutingTableValidation validation, MetaData metaData) {
    if (!metaData.hasIndex(index())) {
        validation.addIndexFailure(index(), "Exists in routing does not exists in metadata");
        return;
    }
    IndexMetaData indexMetaData = metaData.index(index());
    for (String failure : validate(indexMetaData)) {
        validation.addIndexFailure(index, failure);
    }

}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:12,代碼來源:IndexRoutingTable.java

示例8: indicesWithMissingShards

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
/**
 * Returns list of indices with missing shards, and list of indices that are closed
 *
 * @param shards list of shard statuses
 * @return list of failed and closed indices
 */
private Tuple<Set<String>, Set<String>> indicesWithMissingShards(ImmutableMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards, MetaData metaData) {
    Set<String> missing = newHashSet();
    Set<String> closed = newHashSet();
    for (ImmutableMap.Entry<ShardId, SnapshotsInProgress.ShardSnapshotStatus> entry : shards.entrySet()) {
        if (entry.getValue().state() == State.MISSING) {
            if (metaData.hasIndex(entry.getKey().getIndex()) && metaData.index(entry.getKey().getIndex()).getState() == IndexMetaData.State.CLOSE) {
                closed.add(entry.getKey().getIndex());
            } else {
                missing.add(entry.getKey().getIndex());
            }
        }
    }
    return new Tuple<>(missing, closed);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:21,代碼來源:SnapshotsService.java

示例9: resolveRequest

import org.elasticsearch.cluster.metadata.MetaData; //導入方法依賴的package包/類
@Override
protected void resolveRequest(MetaData metaData, String concreteIndex, IndexRequest request) {
    MappingMetaData mappingMd = null;
    if (metaData.hasIndex(concreteIndex)) {
        mappingMd = metaData.index(concreteIndex).mappingOrDefault(request.type());
    }
    request.process(metaData, mappingMd, allowIdGeneration, concreteIndex);
    ShardId shardId = clusterService.operationRouting().shardId(clusterService.state(), concreteIndex, request.type(), request.id(), request.routing());
    request.setShardId(shardId);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:11,代碼來源:TransportIndexAction.java


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