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


Java SnapshotsInProgress.ShardSnapshotStatus方法代码示例

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


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

示例1: canMove

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的package包/类
private Decision canMove(ShardRouting shardRouting, RoutingAllocation allocation) {
    if (shardRouting.primary()) {
        // Only primary shards are snapshotted

        SnapshotsInProgress snapshotsInProgress = allocation.custom(SnapshotsInProgress.TYPE);
        if (snapshotsInProgress == null) {
            // Snapshots are not running
            return allocation.decision(Decision.YES, NAME, "no snapshots are currently running");
        }

        for (SnapshotsInProgress.Entry snapshot : snapshotsInProgress.entries()) {
            SnapshotsInProgress.ShardSnapshotStatus shardSnapshotStatus = snapshot.shards().get(shardRouting.shardId());
            if (shardSnapshotStatus != null && !shardSnapshotStatus.state().completed() && shardSnapshotStatus.nodeId() != null &&
                    shardSnapshotStatus.nodeId().equals(shardRouting.currentNodeId())) {
                if (logger.isTraceEnabled()) {
                    logger.trace("Preventing snapshotted shard [{}] from being moved away from node [{}]",
                            shardRouting.shardId(), shardSnapshotStatus.nodeId());
                }
                return allocation.decision(Decision.THROTTLE, NAME,
                    "waiting for snapshotting of shard [%s] to complete on this node [%s]",
                    shardRouting.shardId(), shardSnapshotStatus.nodeId());
            }
        }
    }
    return allocation.decision(Decision.YES, NAME, "the shard is not being snapshotted");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:SnapshotInProgressAllocationDecider.java

示例2: randomSnapshot

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的package包/类
private Entry randomSnapshot() {
    Snapshot snapshot = new Snapshot(randomAsciiOfLength(10), new SnapshotId(randomAsciiOfLength(10), randomAsciiOfLength(10)));
    boolean includeGlobalState = randomBoolean();
    boolean partial = randomBoolean();
    State state = randomFrom(State.values());
    int numberOfIndices = randomIntBetween(0, 10);
    List<IndexId> indices = new ArrayList<>();
    for (int i = 0; i < numberOfIndices; i++) {
        indices.add(new IndexId(randomAsciiOfLength(10), randomAsciiOfLength(10)));
    }
    long startTime = randomLong();
    long repositoryStateId = randomLong();
    ImmutableOpenMap.Builder<ShardId, SnapshotsInProgress.ShardSnapshotStatus> builder = ImmutableOpenMap.builder();
    int shardsCount = randomIntBetween(0, 10);
    for (int j = 0; j < shardsCount; j++) {
        ShardId shardId = new ShardId(new Index(randomAsciiOfLength(10), randomAsciiOfLength(10)), randomIntBetween(0, 10));
        String nodeId = randomAsciiOfLength(10);
        State shardState = randomFrom(State.values());
        builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(nodeId, shardState));
    }
    ImmutableOpenMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards = builder.build();
    return new Entry(snapshot, includeGlobalState, partial, state, indices, startTime, repositoryStateId, shards);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:SnapshotsInProgressSerializationTests.java

示例3: canMove

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的package包/类
private Decision canMove(ShardRouting shardRouting, RoutingAllocation allocation) {
    if (!enableRelocation && shardRouting.primary()) {
        // Only primary shards are snapshotted

        SnapshotsInProgress snapshotsInProgress = allocation.routingNodes().custom(SnapshotsInProgress.TYPE);
        if (snapshotsInProgress == null) {
            // Snapshots are not running
            return allocation.decision(Decision.YES, NAME, "no snapshots are currently running");
        }

        for (SnapshotsInProgress.Entry snapshot : snapshotsInProgress.entries()) {
            SnapshotsInProgress.ShardSnapshotStatus shardSnapshotStatus = snapshot.shards().get(shardRouting.shardId());
            if (shardSnapshotStatus != null && !shardSnapshotStatus.state().completed() && shardSnapshotStatus.nodeId() != null && shardSnapshotStatus.nodeId().equals(shardRouting.currentNodeId())) {
                logger.trace("Preventing snapshotted shard [{}] to be moved from node [{}]", shardRouting.shardId(), shardSnapshotStatus.nodeId());
                return allocation.decision(Decision.NO, NAME, "snapshot for shard [%s] is currently running on node [%s]",
                        shardRouting.shardId(), shardSnapshotStatus.nodeId());
            }
        }
    }
    return allocation.decision(Decision.YES, NAME, "shard not primary or relocation disabled");
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:SnapshotInProgressAllocationDecider.java

示例4: indicesWithMissingShards

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的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

示例5: indicesWithMissingShards

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的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

示例6: syncShardStatsOnNewMaster

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的package包/类
/**
 * Checks if any shards were processed that the new master doesn't know about
 */
private void syncShardStatsOnNewMaster(ClusterChangedEvent event) {
    SnapshotsInProgress snapshotsInProgress = event.state().custom(SnapshotsInProgress.TYPE);
    if (snapshotsInProgress == null) {
        return;
    }
    for (SnapshotsInProgress.Entry snapshot : snapshotsInProgress.entries()) {
        if (snapshot.state() == SnapshotsInProgress.State.STARTED || snapshot.state() == SnapshotsInProgress.State.ABORTED) {
            Map<ShardId, IndexShardSnapshotStatus> localShards = currentSnapshotShards(snapshot.snapshotId());
            if (localShards != null) {
                ImmutableMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> masterShards = snapshot.shards();
                for(Map.Entry<ShardId, IndexShardSnapshotStatus> localShard : localShards.entrySet()) {
                    ShardId shardId = localShard.getKey();
                    IndexShardSnapshotStatus localShardStatus = localShard.getValue();
                    SnapshotsInProgress.ShardSnapshotStatus masterShard = masterShards.get(shardId);
                    if (masterShard != null && masterShard.state().completed() == false) {
                        // Master knows about the shard and thinks it has not completed
                        if (localShardStatus.stage() == IndexShardSnapshotStatus.Stage.DONE) {
                            // but we think the shard is done - we need to make new master know that the shard is done
                            logger.debug("[{}] new master thinks the shard [{}] is not completed but the shard is done locally, updating status on the master", snapshot.snapshotId(), shardId);
                            updateIndexShardSnapshotStatus(snapshot.snapshotId(), shardId,
                                    new SnapshotsInProgress.ShardSnapshotStatus(event.state().nodes().localNodeId(), SnapshotsInProgress.State.SUCCESS));
                        } else if (localShard.getValue().stage() == IndexShardSnapshotStatus.Stage.FAILURE) {
                            // but we think the shard failed - we need to make new master know that the shard failed
                            logger.debug("[{}] new master thinks the shard [{}] is not completed but the shard failed locally, updating status on master", snapshot.snapshotId(), shardId);
                            updateIndexShardSnapshotStatus(snapshot.snapshotId(), shardId,
                                    new SnapshotsInProgress.ShardSnapshotStatus(event.state().nodes().localNodeId(), SnapshotsInProgress.State.FAILED, localShardStatus.failure()));

                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:38,代码来源:SnapshotShardsService.java

示例7: updateIndexShardSnapshotStatus

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的package包/类
/**
 * Updates the shard status
 */
public void updateIndexShardSnapshotStatus(SnapshotId snapshotId, ShardId shardId, SnapshotsInProgress.ShardSnapshotStatus status) {
    UpdateIndexShardSnapshotStatusRequest request = new UpdateIndexShardSnapshotStatusRequest(snapshotId, shardId, status);
    try {
        if (clusterService.state().nodes().localNodeMaster()) {
            innerUpdateSnapshotState(request);
        } else {
            transportService.sendRequest(clusterService.state().nodes().masterNode(),
                    UPDATE_SNAPSHOT_ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
        }
    } catch (Throwable t) {
        logger.warn("[{}] [{}] failed to update snapshot state", t, request.snapshotId(), request.status());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:SnapshotShardsService.java

示例8: UpdateIndexShardSnapshotStatusRequest

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的package包/类
public UpdateIndexShardSnapshotStatusRequest(SnapshotId snapshotId, ShardId shardId, SnapshotsInProgress.ShardSnapshotStatus status) {
    this.snapshotId = snapshotId;
    this.shardId = shardId;
    this.status = status;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:SnapshotShardsService.java

示例9: status

import org.elasticsearch.cluster.SnapshotsInProgress; //导入方法依赖的package包/类
public SnapshotsInProgress.ShardSnapshotStatus status() {
    return status;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:SnapshotShardsService.java


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