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


Java ImmutableOpenMap.Builder方法代码示例

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


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

示例1: readFrom

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    count = in.readVLong();
    memoryInBytes = in.readLong();
    termsMemoryInBytes = in.readLong();
    storedFieldsMemoryInBytes = in.readLong();
    termVectorsMemoryInBytes = in.readLong();
    normsMemoryInBytes = in.readLong();
    pointsMemoryInBytes = in.readLong();
    docValuesMemoryInBytes = in.readLong();
    indexWriterMemoryInBytes = in.readLong();
    versionMapMemoryInBytes = in.readLong();
    bitsetMemoryInBytes = in.readLong();
    maxUnsafeAutoIdTimestamp = in.readLong();

    int size = in.readVInt();
    ImmutableOpenMap.Builder<String, Long> map = ImmutableOpenMap.builder(size);
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        Long value = in.readLong();
        map.put(key, value);
    }
    fileSizes = map.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:SegmentsStats.java

示例2: buildShardLevelInfo

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的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: readFrom

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesBuilder = ImmutableOpenMap.builder();
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        int valueSize = in.readVInt();
        List<AliasMetaData> value = new ArrayList<>(valueSize);
        for (int j = 0; j < valueSize; j++) {
            value.add(AliasMetaData.Builder.readFrom(in));
        }
        aliasesBuilder.put(key, Collections.unmodifiableList(value));
    }
    aliases = aliasesBuilder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:GetAliasesResponse.java

示例4: randomSnapshot

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

示例5: build

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
public DiscoveryNodes build() {
    ImmutableOpenMap.Builder<String, DiscoveryNode> dataNodesBuilder = ImmutableOpenMap.builder();
    ImmutableOpenMap.Builder<String, DiscoveryNode> masterNodesBuilder = ImmutableOpenMap.builder();
    Version minNodeVersion = Version.CURRENT;
    Version minNonClientNodeVersion = Version.CURRENT;
    for (ObjectObjectCursor<String, DiscoveryNode> nodeEntry : nodes) {
        if (nodeEntry.value.dataNode()) {
            dataNodesBuilder.put(nodeEntry.key, nodeEntry.value);
            minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version());
        }
        if (nodeEntry.value.masterNode()) {
            masterNodesBuilder.put(nodeEntry.key, nodeEntry.value);
            minNonClientNodeVersion = Version.smallest(minNonClientNodeVersion, nodeEntry.value.version());
        }
        minNodeVersion = Version.smallest(minNodeVersion, nodeEntry.value.version());
    }

    return new DiscoveryNodes(nodes.build(), dataNodesBuilder.build(), masterNodesBuilder.build(), deadNodes.build(), masterNodeId, localNodeId, minNodeVersion, minNonClientNodeVersion);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:DiscoveryNodes.java

示例6: RestoreInProgress

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
public RestoreInProgress(StreamInput in) throws IOException {
    Entry[] entries = new Entry[in.readVInt()];
    for (int i = 0; i < entries.length; i++) {
        Snapshot snapshot = new Snapshot(in);
        State state = State.fromValue(in.readByte());
        int indices = in.readVInt();
        List<String> indexBuilder = new ArrayList<>();
        for (int j = 0; j < indices; j++) {
            indexBuilder.add(in.readString());
        }
        ImmutableOpenMap.Builder<ShardId, ShardRestoreStatus> builder = ImmutableOpenMap.builder();
        int shards = in.readVInt();
        for (int j = 0; j < shards; j++) {
            ShardId shardId = ShardId.readShardId(in);
            ShardRestoreStatus shardState = ShardRestoreStatus.readShardRestoreStatus(in);
            builder.put(shardId, shardState);
        }
        entries[i] = new Entry(snapshot, state, Collections.unmodifiableList(indexBuilder), builder.build());
    }
    this.entries = Arrays.asList(entries);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestoreInProgress.java

示例7: readFrom

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesBuilder = ImmutableOpenMap.builder();
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        int valueSize = in.readVInt();
        List<AliasMetaData> value = new ArrayList<>(valueSize);
        for (int j = 0; j < valueSize; j++) {
            value.add(new AliasMetaData(in));
        }
        aliasesBuilder.put(key, Collections.unmodifiableList(value));
    }
    aliases = aliasesBuilder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:GetAliasesResponse.java

示例8: readFrom

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    ImmutableOpenMap.Builder<String, Settings> builder = ImmutableOpenMap.builder();
    for (int i = 0; i < size; i++) {
        builder.put(in.readString(), Settings.readSettingsFromStream(in));
    }
    indexToSettings = builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:GetSettingsResponse.java

示例9: masterOperation

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Override
protected void masterOperation(GetSettingsRequest request, ClusterState state, ActionListener<GetSettingsResponse> listener) {
    String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
    ImmutableOpenMap.Builder<String, Settings> indexToSettingsBuilder = ImmutableOpenMap.builder();
    for (String concreteIndex : concreteIndices) {
        IndexMetaData indexMetaData = state.getMetaData().index(concreteIndex);
        if (indexMetaData == null) {
            continue;
        }

        Settings settings = SettingsFilter.filterSettings(settingsFilter.getPatterns(), indexMetaData.getSettings());
        if (request.humanReadable()) {
            settings = IndexMetaData.addHumanReadableSettings(settings);
        }
        if (!CollectionUtils.isEmpty(request.names())) {
            Settings.Builder settingsBuilder = Settings.builder();
            for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
                if (Regex.simpleMatch(request.names(), entry.getKey())) {
                    settingsBuilder.put(entry.getKey(), entry.getValue());
                }
            }
            settings = settingsBuilder.build();
        }
        indexToSettingsBuilder.put(concreteIndex, settings);
    }
    listener.onResponse(new GetSettingsResponse(indexToSettingsBuilder.build()));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:TransportGetSettingsAction.java

示例10: randomShardSizes

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private static ImmutableOpenMap<String, Long> randomShardSizes() {
    int numEntries = randomIntBetween(0, 128);
    ImmutableOpenMap.Builder<String, Long> builder = ImmutableOpenMap.builder(numEntries);
    for (int i = 0; i < numEntries; i++) {
        String key = randomAsciiOfLength(32);
        long shardSize = randomIntBetween(0, Integer.MAX_VALUE);
        builder.put(key, shardSize);
    }
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ClusterInfoTests.java

示例11: buildMetaDataForVersion

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private MetaData buildMetaDataForVersion(MetaData metaData, long version) {
    ImmutableOpenMap.Builder<String, IndexMetaData> indices = ImmutableOpenMap.builder(metaData.indices());
    indices.put("test" + version, IndexMetaData.builder("test" + version)
            .settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT))
            .numberOfShards((int) version).numberOfReplicas(0).build());
    return MetaData.builder(metaData)
            .transientSettings(Settings.builder().put("test", version).build())
            .indices(indices.build())
            .build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:PublishClusterStateActionTests.java

示例12: testFillDiskUsageSomeInvalidValues

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
public void testFillDiskUsageSomeInvalidValues() {
    ImmutableOpenMap.Builder<String, DiskUsage> newLeastAvailableUsages = ImmutableOpenMap.builder();
    ImmutableOpenMap.Builder<String, DiskUsage> newMostAvailableUsages = ImmutableOpenMap.builder();
    FsInfo.Path[] node1FSInfo =  new FsInfo.Path[] {
            new FsInfo.Path("/middle", "/dev/sda", 100, 90, 80),
            new FsInfo.Path("/least", "/dev/sdb", -1, -1, -1),
            new FsInfo.Path("/most", "/dev/sdc", 300, 290, 280),
    };
    FsInfo.Path[] node2FSInfo = new FsInfo.Path[] {
            new FsInfo.Path("/least_most", "/dev/sda", -2, -1, -1),
    };

    FsInfo.Path[] node3FSInfo =  new FsInfo.Path[] {
            new FsInfo.Path("/most", "/dev/sda", 100, 90, 70),
            new FsInfo.Path("/least", "/dev/sda", 10, -8, 0),
    };
    List<NodeStats> nodeStats = Arrays.asList(
            new NodeStats(new DiscoveryNode("node_1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
                    null,null,null,null,null,new FsInfo(0, null, node1FSInfo), null,null,null,null,null, null),
            new NodeStats(new DiscoveryNode("node_2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
                    null,null,null,null,null, new FsInfo(0, null, node2FSInfo), null,null,null,null,null, null),
            new NodeStats(new DiscoveryNode("node_3", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
                    null,null,null,null,null, new FsInfo(0, null, node3FSInfo), null,null,null,null,null, null)
    );
    InternalClusterInfoService.fillDiskUsagePerNode(logger, nodeStats, newLeastAvailableUsages, newMostAvailableUsages);
    DiskUsage leastNode_1 = newLeastAvailableUsages.get("node_1");
    DiskUsage mostNode_1 = newMostAvailableUsages.get("node_1");
    assertNull("node1 should have been skipped", leastNode_1);
    assertDiskUsage(mostNode_1, node1FSInfo[2]);

    DiskUsage leastNode_2 = newLeastAvailableUsages.get("node_2");
    DiskUsage mostNode_2 = newMostAvailableUsages.get("node_2");
    assertNull("node2 should have been skipped", leastNode_2);
    assertNull("node2 should have been skipped", mostNode_2);

    DiskUsage leastNode_3 = newLeastAvailableUsages.get("node_3");
    DiskUsage mostNode_3 = newMostAvailableUsages.get("node_3");
    assertDiskUsage(leastNode_3, node3FSInfo[1]);
    assertDiskUsage(mostNode_3, node3FSInfo[0]);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:DiskUsageTests.java

示例13: ClusterInfo

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
public ClusterInfo(StreamInput in) throws IOException {
    Map<String, DiskUsage> leastMap = in.readMap(StreamInput::readString, DiskUsage::new);
    Map<String, DiskUsage> mostMap = in.readMap(StreamInput::readString, DiskUsage::new);
    Map<String, Long> sizeMap = in.readMap(StreamInput::readString, StreamInput::readLong);
    Map<ShardRouting, String> routingMap = in.readMap(ShardRouting::new, StreamInput::readString);

    ImmutableOpenMap.Builder<String, DiskUsage> leastBuilder = ImmutableOpenMap.builder();
    this.leastAvailableSpaceUsage = leastBuilder.putAll(leastMap).build();
    ImmutableOpenMap.Builder<String, DiskUsage> mostBuilder = ImmutableOpenMap.builder();
    this.mostAvailableSpaceUsage = mostBuilder.putAll(mostMap).build();
    ImmutableOpenMap.Builder<String, Long> sizeBuilder = ImmutableOpenMap.builder();
    this.shardSizes = sizeBuilder.putAll(sizeMap).build();
    ImmutableOpenMap.Builder<ShardRouting, String> routingBuilder = ImmutableOpenMap.builder();
    this.routingToDataPath = routingBuilder.putAll(routingMap).build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ClusterInfo.java

示例14: updateTemplates

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Nullable
private static ImmutableOpenMap<String, IndexTemplateMetaData> updateTemplates(
        ESLogger logger, ImmutableOpenMap<String, IndexTemplateMetaData> templates) {

    ImmutableOpenMap.Builder<String, IndexTemplateMetaData> builder = null;
    for (ObjectObjectCursor<String, IndexTemplateMetaData> cursor : templates) {
        IndexTemplateMetaData templateMetaData = cursor.value;
        Settings currentSettings = templateMetaData.getSettings();
        Settings newSettings = addDefaultUnitsIfNeeded(
                MetaDataIndexUpgradeService.INDEX_TIME_SETTINGS,
                MetaDataIndexUpgradeService.INDEX_BYTES_SIZE_SETTINGS,
                logger,
                currentSettings);


        if (newSettings != currentSettings) {
            if (builder == null) {
                builder = ImmutableOpenMap.builder();
                builder.putAll(templates);
            }
            builder.put(cursor.key, new IndexTemplateMetaData(
                    templateMetaData.name(),
                    templateMetaData.order(),
                    templateMetaData.template(),
                    newSettings,
                    templateMetaData.mappings(),
                    templateMetaData.aliases(),
                    templateMetaData.customs(),
                    templateMetaData.templateOwnerTenantId()
            ));
        }
    }
    if (builder == null) {
        return null;
    }
    return builder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:38,代码来源:MetaData.java

示例15: finish

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
void finish() {
    ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<java.util.List<IndicesShardStoresResponse.StoreStatus>>> indicesStoreStatusesBuilder = ImmutableOpenMap.builder();
    java.util.List<IndicesShardStoresResponse.Failure> failureBuilder = new ArrayList<>();
    for (Response fetchResponse : fetchResponses) {
        ImmutableOpenIntMap<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexStoreStatuses = indicesStoreStatusesBuilder.get(fetchResponse.shardId.getIndex());
        final ImmutableOpenIntMap.Builder<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexShardsBuilder;
        if (indexStoreStatuses == null) {
            indexShardsBuilder = ImmutableOpenIntMap.builder();
        } else {
            indexShardsBuilder = ImmutableOpenIntMap.builder(indexStoreStatuses);
        }
        java.util.List<IndicesShardStoresResponse.StoreStatus> storeStatuses = indexShardsBuilder.get(fetchResponse.shardId.id());
        if (storeStatuses == null) {
            storeStatuses = new ArrayList<>();
        }
        for (NodeGatewayStartedShards response : fetchResponse.responses) {
            if (shardExistsInNode(response)) {
                IndicesShardStoresResponse.StoreStatus.Allocation allocation = getAllocation(fetchResponse.shardId.getIndex(), fetchResponse.shardId.id(), response.getNode());
                storeStatuses.add(new IndicesShardStoresResponse.StoreStatus(response.getNode(), response.version(), allocation, response.storeException()));
            }
        }
        CollectionUtil.timSort(storeStatuses);
        indexShardsBuilder.put(fetchResponse.shardId.id(), storeStatuses);
        indicesStoreStatusesBuilder.put(fetchResponse.shardId.getIndex(), indexShardsBuilder.build());
        for (FailedNodeException failure : fetchResponse.failures) {
            failureBuilder.add(new IndicesShardStoresResponse.Failure(failure.nodeId(), fetchResponse.shardId.getIndex(), fetchResponse.shardId.id(), failure.getCause()));
        }
    }
    listener.onResponse(new IndicesShardStoresResponse(indicesStoreStatusesBuilder.build(), Collections.unmodifiableList(failureBuilder)));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:TransportIndicesShardStoresAction.java


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