当前位置: 首页>>代码示例>>Java>>正文


Java MetaData.index方法代码示例

本文整理汇总了Java中org.elasticsearch.cluster.metadata.MetaData.index方法的典型用法代码示例。如果您正苦于以下问题:Java MetaData.index方法的具体用法?Java MetaData.index怎么用?Java MetaData.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.cluster.metadata.MetaData的用法示例。


在下文中一共展示了MetaData.index方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveStatesToBeWritten

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:GatewayMetaState.java

示例2: buildShardLevelInfo

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
static void buildShardLevelInfo(Logger logger, ShardStats[] stats, ImmutableOpenMap.Builder<String, Long> newShardSizes,
                                ImmutableOpenMap.Builder<ShardRouting, String> newShardRoutingToDataPath, ClusterState state) {
    MetaData meta = state.getMetaData();
    for (ShardStats s : stats) {
        IndexMetaData indexMeta = meta.index(s.getShardRouting().index());
        newShardRoutingToDataPath.put(s.getShardRouting(), s.getDataPath());
        long size = s.getStats().getStore().sizeInBytes();
        String sid = ClusterInfo.shardIdentifierFromRouting(s.getShardRouting());
        if (logger.isTraceEnabled()) {
            logger.trace("shard: {} size: {}", sid, size);
        }
        if (indexMeta != null && indexMeta.isIndexUsingShadowReplicas()) {
            // Shards on a shared filesystem should be considered of size 0
            if (logger.isTraceEnabled()) {
                logger.trace("shard: {} is using shadow replicas and will be treated as size 0", sid);
            }
            size = 0;
        }
        newShardSizes.put(sid, size);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:InternalClusterInfoService.java

示例3: initializeSnapshot

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void initializeSnapshot(SnapshotId snapshotId, List<String> indices, MetaData metaData) {
    if (readOnly()) {
        throw new RepositoryException(this.repositoryName, "cannot create snapshot in a readonly repository");
    }
    try {
        if (snapshotFormat.exists(snapshotsBlobContainer, snapshotId.getSnapshot()) ||
                snapshotLegacyFormat.exists(snapshotsBlobContainer, snapshotId.getSnapshot())) {
            throw new InvalidSnapshotNameException(snapshotId, "snapshot with such name already exists");
        }
        // Write Global MetaData
        globalMetaDataFormat.write(metaData, snapshotsBlobContainer, snapshotId.getSnapshot());
        for (String index : indices) {
            final IndexMetaData indexMetaData = metaData.index(index);
            final BlobPath indexPath = basePath().add("indices").add(index);
            final BlobContainer indexMetaDataBlobContainer = blobStore().blobContainer(indexPath);
            indexMetaDataFormat.write(indexMetaData, indexMetaDataBlobContainer, snapshotId.getSnapshot());
        }
    } catch (IOException ex) {
        throw new SnapshotCreationException(snapshotId, ex);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:BlobStoreRepository.java

示例4: resolveStatesToBeWritten

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:GatewayMetaState.java

示例5: buildShardLevelInfo

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
static void buildShardLevelInfo(ESLogger logger, ShardStats[] stats, HashMap<String, Long> newShardSizes, HashMap<ShardRouting, String> newShardRoutingToDataPath, ClusterState state) {
    MetaData meta = state.getMetaData();
    for (ShardStats s : stats) {
        IndexMetaData indexMeta = meta.index(s.getShardRouting().index());
        Settings indexSettings = indexMeta == null ? null : indexMeta.getSettings();
        newShardRoutingToDataPath.put(s.getShardRouting(), s.getDataPath());
        long size = s.getStats().getStore().sizeInBytes();
        String sid = ClusterInfo.shardIdentifierFromRouting(s.getShardRouting());
        if (logger.isTraceEnabled()) {
            logger.trace("shard: {} size: {}", sid, size);
        }
        if (indexSettings != null && IndexMetaData.isIndexUsingShadowReplicas(indexSettings)) {
            // Shards on a shared filesystem should be considered of size 0
            if (logger.isTraceEnabled()) {
                logger.trace("shard: {} is using shadow replicas and will be treated as size 0", sid);
            }
            size = 0;
        }
        newShardSizes.put(sid, size);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:InternalClusterInfoService.java

示例6: shardOperationOnPrimary

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
@Override
protected Tuple<IndexResponse, IndexRequest> shardOperationOnPrimary(MetaData metaData, IndexRequest request) throws Throwable {

    // validate, if routing is required, that we got routing
    IndexMetaData indexMetaData = metaData.index(request.shardId().getIndex());
    MappingMetaData mappingMd = indexMetaData.mappingOrDefault(request.type());
    if (mappingMd != null && mappingMd.routing().required()) {
        if (request.routing() == null) {
            throw new RoutingMissingException(request.shardId().getIndex(), request.type(), request.id());
        }
    }

    IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex());
    IndexShard indexShard = indexService.shardSafe(request.shardId().id());
    indexShard.checkDiskSpace(fsService);
    final WriteResult<IndexResponse> result = executeIndexRequestOnPrimary(null, request, indexShard, mappingUpdatedAction);
    final IndexResponse response = result.response;
    final Translog.Location location = result.location;
    processAfterWrite(request.refresh(), indexShard, location);
    return new Tuple<>(response, request);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:TransportIndexAction.java

示例7: initializeSnapshot

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
@Override
public void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, MetaData clusterMetaData) {
    if (isReadOnly()) {
        throw new RepositoryException(metadata.name(), "cannot create snapshot in a readonly repository");
    }
    try {
        final String snapshotName = snapshotId.getName();
        // check if the snapshot name already exists in the repository
        final RepositoryData repositoryData = getRepositoryData();
        if (repositoryData.getAllSnapshotIds().stream().anyMatch(s -> s.getName().equals(snapshotName))) {
            throw new InvalidSnapshotNameException(metadata.name(), snapshotId.getName(), "snapshot with the same name already exists");
        }
        if (snapshotFormat.exists(snapshotsBlobContainer, snapshotId.getUUID())) {
            throw new InvalidSnapshotNameException(metadata.name(), snapshotId.getName(), "snapshot with the same name already exists");
        }

        // Write Global MetaData
        globalMetaDataFormat.write(clusterMetaData, snapshotsBlobContainer, snapshotId.getUUID());

        // write the index metadata for each index in the snapshot
        for (IndexId index : indices) {
            final IndexMetaData indexMetaData = clusterMetaData.index(index.getName());
            final BlobPath indexPath = basePath().add("indices").add(index.getId());
            final BlobContainer indexMetaDataBlobContainer = blobStore().blobContainer(indexPath);
            indexMetaDataFormat.write(indexMetaData, indexMetaDataBlobContainer, snapshotId.getUUID());
        }
    } catch (IOException ex) {
        throw new SnapshotCreationException(metadata.name(), snapshotId, ex);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:BlobStoreRepository.java

示例8: 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 (Index index : danglingIndices.keySet()) {
        final IndexMetaData indexMetaData = metaData.index(index);
        if (indexMetaData != null && indexMetaData.getIndex().getName().equals(index.getName())) {
            if (indexMetaData.getIndex().getUUID().equals(index.getUUID()) == false) {
                logger.warn("[{}] can not be imported as a dangling index, as there is already another index " +
                    "with the same name but a different uuid. local index will be ignored (but not deleted)", index);
            } else {
                logger.debug("[{}] no longer dangling (created), removing from dangling list", index);
            }
            danglingIndices.remove(index);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:DanglingIndicesState.java

示例9: getShardsToPurge

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
/**
 * Returns the shards to purge, i.e. the local started primary shards that have ttl enabled and disable_purge to false
 */
private List<IndexShard> getShardsToPurge() {
    List<IndexShard> shardsToPurge = new ArrayList<>();
    MetaData metaData = clusterService.state().metaData();
    for (IndexService indexService : indicesService) {
        // check the value of disable_purge for this index
        IndexMetaData indexMetaData = metaData.index(indexService.index().name());
        if (indexMetaData == null) {
            continue;
        }
        boolean disablePurge = indexMetaData.getSettings().getAsBoolean(INDEX_TTL_DISABLE_PURGE, false);
        if (disablePurge) {
            continue;
        }

        // check if ttl is enabled for at least one type of this index
        boolean hasTTLEnabled = false;
        for (String type : indexService.mapperService().types()) {
            DocumentMapper documentType = indexService.mapperService().documentMapper(type);
            if (documentType.TTLFieldMapper().enabled()) {
                hasTTLEnabled = true;
                break;
            }
        }
        if (hasTTLEnabled) {
            for (IndexShard indexShard : indexService) {
                if (indexShard.state() == IndexShardState.STARTED && indexShard.routingEntry().primary() && indexShard.routingEntry().started()) {
                    shardsToPurge.add(indexShard);
                }
            }
        }
    }
    return shardsToPurge;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:37,代码来源:IndicesTTLService.java

示例10: 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

示例11: updateLeftDelayOfUnassignedShards

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
public static void updateLeftDelayOfUnassignedShards(RoutingAllocation allocation, Settings settings) {
    for (ShardRouting shardRouting : allocation.routingNodes().unassigned()) {
        final MetaData metaData = allocation.metaData();
        final IndexMetaData indexMetaData = metaData.index(shardRouting.index());
        shardRouting.unassignedInfo().updateDelay(allocation.getCurrentNanoTime(), settings, indexMetaData.getSettings());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:AllocationService.java

示例12: indexMetaDataChanged

import org.elasticsearch.cluster.metadata.MetaData; //导入方法依赖的package包/类
/**
 * Returns <code>true</code> iff the {@link IndexMetaData} for a given index
 * has changed between the previous cluster state and the new cluster state.
 * Note that this is an object reference equality test, not an equals test.
 */
public boolean indexMetaDataChanged(IndexMetaData current) {
    MetaData previousMetaData = previousState.metaData();
    if (previousMetaData == null) {
        return true;
    }
    IndexMetaData previousIndexMetaData = previousMetaData.index(current.getIndex());
    // no need to check on version, since disco modules will make sure to use the
    // same instance if its a version match
    if (previousIndexMetaData == current) {
        return false;
    }
    return true;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:ClusterChangedEvent.java


注:本文中的org.elasticsearch.cluster.metadata.MetaData.index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。