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


Java ImmutableMap.Entry方法代码示例

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


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

示例1: writeTo

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    if (status != null) {
        out.writeVInt(status.size());
        for (ImmutableMap.Entry<SnapshotId, ImmutableMap<ShardId, SnapshotIndexShardStatus>> entry : status.entrySet()) {
            entry.getKey().writeTo(out);
            out.writeVInt(entry.getValue().size());
            for (ImmutableMap.Entry<ShardId, SnapshotIndexShardStatus> shardEntry : entry.getValue().entrySet()) {
                shardEntry.getKey().writeTo(out);
                shardEntry.getValue().writeTo(out);
            }
        }
    } else {
        out.writeVInt(0);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:TransportNodesSnapshotsStatus.java

示例2: processWaitingShards

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private ImmutableMap<ShardId, ShardSnapshotStatus> processWaitingShards(ImmutableMap<ShardId, ShardSnapshotStatus> snapshotShards, RoutingTable routingTable) {
    boolean snapshotChanged = false;
    ImmutableMap.Builder<ShardId, ShardSnapshotStatus> shards = ImmutableMap.builder();
    for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> shardEntry : snapshotShards.entrySet()) {
        ShardSnapshotStatus shardStatus = shardEntry.getValue();
        if (shardStatus.state() == State.WAITING) {
            ShardId shardId = shardEntry.getKey();
            IndexRoutingTable indexShardRoutingTable = routingTable.index(shardId.getIndex());
            if (indexShardRoutingTable != null) {
                IndexShardRoutingTable shardRouting = indexShardRoutingTable.shard(shardId.id());
                if (shardRouting != null && shardRouting.primaryShard() != null) {
                    if (shardRouting.primaryShard().started()) {
                        // Shard that we were waiting for has started on a node, let's process it
                        snapshotChanged = true;
                        logger.trace("starting shard that we were waiting for [{}] on node [{}]", shardEntry.getKey(), shardStatus.nodeId());
                        shards.put(shardEntry.getKey(), new ShardSnapshotStatus(shardRouting.primaryShard().currentNodeId()));
                        continue;
                    } else if (shardRouting.primaryShard().initializing() || shardRouting.primaryShard().relocating()) {
                        // Shard that we were waiting for hasn't started yet or still relocating - will continue to wait
                        shards.put(shardEntry);
                        continue;
                    }
                }
            }
            // Shard that we were waiting for went into unassigned state or disappeared - giving up
            snapshotChanged = true;
            logger.warn("failing snapshot of shard [{}] on unassigned shard [{}]", shardEntry.getKey(), shardStatus.nodeId());
            shards.put(shardEntry.getKey(), new ShardSnapshotStatus(shardStatus.nodeId(), State.FAILED, "shard is unassigned"));
        } else {
            shards.put(shardEntry);
        }
    }
    if (snapshotChanged) {
        return shards.build();
    } else {
        return null;
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:39,代码来源:SnapshotsService.java

示例3: indicesWithMissingShards

import com.google.common.collect.ImmutableMap; //导入方法依赖的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

示例4: processDeletedIndices

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
 * Checks if any of the deleted indices are still recovering and fails recovery on the shards of these indices
 *
 * @param event cluster changed event
 */
private void processDeletedIndices(ClusterChangedEvent event) {
    RestoreInProgress restore = event.state().custom(RestoreInProgress.TYPE);
    if (restore == null) {
        // Not restoring - nothing to do
        return;
    }

    if (!event.indicesDeleted().isEmpty()) {
        // Some indices were deleted, let's make sure all indices that we are restoring still exist
        for (RestoreInProgress.Entry entry : restore.entries()) {
            List<ShardId> shardsToFail = null;
            for (ImmutableMap.Entry<ShardId, ShardRestoreStatus> shard : entry.shards().entrySet()) {
                if (!shard.getValue().state().completed()) {
                    if (!event.state().metaData().hasIndex(shard.getKey().getIndex())) {
                        if (shardsToFail == null) {
                            shardsToFail = new ArrayList<>();
                        }
                        shardsToFail.add(shard.getKey());
                    }
                }
            }
            if (shardsToFail != null) {
                for (ShardId shardId : shardsToFail) {
                    logger.trace("[{}] failing running shard restore [{}]", entry.snapshotId(), shardId);
                    updateRestoreStateOnMaster(new UpdateIndexShardRestoreStatusRequest(entry.snapshotId(), shardId, new ShardRestoreStatus(null, RestoreInProgress.State.FAILURE, "index was deleted")));
                }
            }
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:36,代码来源:RestoreService.java

示例5: checkFilters

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
 * Checks if the string currently in the given matcher
 * passes all of the filters. The matcher must already
 * matching state.
 */
private boolean checkFilters(Matcher matcher)
{
    boolean passing = true;
    for (ImmutableMap.Entry<String, Predicate<String>> f
            : namedGroupFilters.entrySet()) {
        passing = passing && f.getValue().test(matcher.group(f.getKey()));
    }
    return passing;
}
 
开发者ID:prestodb,项目名称:presto-manager,代码行数:15,代码来源:LogFilter.java


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