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


Java ImmutableOpenMap类代码示例

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


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

示例1: assertMappingOnMaster

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
/**
 * Waits for the given mapping type to exists on the master node.
 */
public void assertMappingOnMaster(final String index, final String type, final String... fieldNames) throws Exception {
    GetMappingsResponse response = client().admin().indices().prepareGetMappings(index).setTypes(type).get();
    ImmutableOpenMap<String, MappingMetaData> mappings = response.getMappings().get(index);
    assertThat(mappings, notNullValue());
    MappingMetaData mappingMetaData = mappings.get(type);
    assertThat(mappingMetaData, notNullValue());

    Map<String, Object> mappingSource = mappingMetaData.getSourceAsMap();
    assertFalse(mappingSource.isEmpty());
    assertTrue(mappingSource.containsKey("properties"));

    for (String fieldName : fieldNames) {
        Map<String, Object> mappingProperties = (Map<String, Object>) mappingSource.get("properties");
        if (fieldName.indexOf('.') != -1) {
            fieldName = fieldName.replace(".", ".properties.");
        }
        assertThat("field " + fieldName + " doesn't exists in mapping " + mappingMetaData.source().string(), XContentMapValues.extractValue(fieldName, mappingProperties), notNullValue());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ESIntegTestCase.java

示例2: 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, ImmutableOpenMap<String, MappingMetaData>> indexMapBuilder = ImmutableOpenMap.builder();
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        int valueSize = in.readVInt();
        ImmutableOpenMap.Builder<String, MappingMetaData> typeMapBuilder = ImmutableOpenMap.builder();
        for (int j = 0; j < valueSize; j++) {
            typeMapBuilder.put(in.readString(), MappingMetaData.PROTO.readFrom(in));
        }
        indexMapBuilder.put(key, typeMapBuilder.build());
    }
    mappings = indexMapBuilder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:GetMappingsResponse.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<IndexWarmersMetaData.Entry>> indexMapBuilder = ImmutableOpenMap.builder();
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        int valueSize = in.readVInt();
        List<IndexWarmersMetaData.Entry> warmerEntryBuilder = new ArrayList<>();
        for (int j = 0; j < valueSize; j++) {
            String name = in.readString();
            String[] types = in.readStringArray();
            BytesReference source = in.readBytesReference();
            Boolean queryCache = null;
            queryCache = in.readOptionalBoolean();
            warmerEntryBuilder.add(new IndexWarmersMetaData.Entry(
                            name,
                            types,
                            queryCache,
                            source)
            );
        }
        indexMapBuilder.put(key, Collections.unmodifiableList(warmerEntryBuilder));
    }
    warmers = indexMapBuilder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:GetWarmersResponse.java

示例4: copyContextFrom

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
@Override
public synchronized void copyContextFrom(HasContext other) {
    if (other == null) {
        return;
    }

    synchronized (other) {
        ImmutableOpenMap<Object, Object> otherContext = other.getContext();
        if (otherContext == null) {
            return;
        }
        if (context == null) {
            ObjectObjectHashMap<Object, Object> map = new ObjectObjectHashMap<>(other.getContext().size());
            map.putAll(otherContext);
            this.context = map;
        } else {
            context.putAll(otherContext);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:ContextAndHeaderHolder.java

示例5: getDiskUsage

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
private DiskUsage getDiskUsage(RoutingNode node, RoutingAllocation allocation,
                               ImmutableOpenMap<String, DiskUsage> usages, boolean subtractLeavingShards) {
    DiskUsage usage = usages.get(node.nodeId());
    if (usage == null) {
        // If there is no usage, and we have other nodes in the cluster,
        // use the average usage for all nodes as the usage for this node
        usage = averageUsage(node, usages);
        if (logger.isDebugEnabled()) {
            logger.debug("unable to determine disk usage for {}, defaulting to average across nodes [{} total] [{} free] [{}% free]",
                    node.nodeId(), usage.getTotalBytes(), usage.getFreeBytes(), usage.getFreeDiskAsPercentage());
        }
    }

    if (diskThresholdSettings.includeRelocations()) {
        long relocatingShardsSize = sizeOfRelocatingShards(node, allocation, subtractLeavingShards, usage.getPath());
        DiskUsage usageIncludingRelocations = new DiskUsage(node.nodeId(), node.node().getName(), usage.getPath(),
                usage.getTotalBytes(), usage.getFreeBytes() - relocatingShardsSize);
        if (logger.isTraceEnabled()) {
            logger.trace("usage without relocations: {}", usage);
            logger.trace("usage with relocations: [{} bytes] {}", relocatingShardsSize, usageIncludingRelocations);
        }
        usage = usageIncludingRelocations;
    }
    return usage;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:DiskThresholdDecider.java

示例6: getTypeListWithPrefix

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
public List<String> getTypeListWithPrefix(Object object, Object object2) {
  ArrayList<String> typeList = new ArrayList<>();
  GetMappingsResponse res;
  try {
    res = getClient().admin().indices().getMappings(new GetMappingsRequest().indices(object.toString())).get();
    ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get(object.toString());
    for (ObjectObjectCursor<String, MappingMetaData> c : mapping) {
      if (c.key.startsWith(object2.toString())) {
        typeList.add(c.key);
      }
    }
  } catch (InterruptedException | ExecutionException e) {
    LOG.error("Error whilst obtaining type list from Elasticsearch mappings.", e);
  }
  return typeList;
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:17,代码来源:ESDriver.java

示例7: apply

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
@Override
public ImmutableOpenMap<K, T> apply(ImmutableOpenMap<K, T> map) {
    ImmutableOpenMap.Builder<K, T> builder = ImmutableOpenMap.builder();
    builder.putAll(map);

    for (K part : deletes) {
        builder.remove(part);
    }

    for (Map.Entry<K, Diff<T>> diff : diffs.entrySet()) {
        builder.put(diff.getKey(), diff.getValue().apply(builder.get(diff.getKey())));
    }

    for (Map.Entry<K, T> upsert : upserts.entrySet()) {
        builder.put(upsert.getKey(), upsert.getValue());
    }
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:DiffableUtils.java

示例8: Entry

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
public Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, State state, List<IndexId> indices,
             long startTime, long repositoryStateId, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
    this.state = state;
    this.snapshot = snapshot;
    this.includeGlobalState = includeGlobalState;
    this.partial = partial;
    this.indices = indices;
    this.startTime = startTime;
    if (shards == null) {
        this.shards = ImmutableOpenMap.of();
        this.waitingIndices = ImmutableOpenMap.of();
    } else {
        this.shards = shards;
        this.waitingIndices = findWaitingIndices(shards);
    }
    this.repositoryStateId = repositoryStateId;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:SnapshotsInProgress.java

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

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

示例11: testFillDiskUsage

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
public void testFillDiskUsage() {
    ImmutableOpenMap.Builder<String, DiskUsage> newLeastAvaiableUsages = ImmutableOpenMap.builder();
    ImmutableOpenMap.Builder<String, DiskUsage> newMostAvaiableUsages = ImmutableOpenMap.builder();
    FsInfo.Path[] node1FSInfo =  new FsInfo.Path[] {
            new FsInfo.Path("/middle", "/dev/sda", 100, 90, 80),
            new FsInfo.Path("/least", "/dev/sdb", 200, 190, 70),
            new FsInfo.Path("/most", "/dev/sdc", 300, 290, 280),
    };
    FsInfo.Path[] node2FSInfo = new FsInfo.Path[] {
            new FsInfo.Path("/least_most", "/dev/sda", 100, 90, 80),
    };

    FsInfo.Path[] node3FSInfo =  new FsInfo.Path[] {
            new FsInfo.Path("/least", "/dev/sda", 100, 90, 70),
            new FsInfo.Path("/most", "/dev/sda", 100, 90, 80),
    };
    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, newLeastAvaiableUsages, newMostAvaiableUsages);
    DiskUsage leastNode_1 = newLeastAvaiableUsages.get("node_1");
    DiskUsage mostNode_1 = newMostAvaiableUsages.get("node_1");
    assertDiskUsage(mostNode_1, node1FSInfo[2]);
    assertDiskUsage(leastNode_1, node1FSInfo[1]);

    DiskUsage leastNode_2 = newLeastAvaiableUsages.get("node_2");
    DiskUsage mostNode_2 = newMostAvaiableUsages.get("node_2");
    assertDiskUsage(leastNode_2, node2FSInfo[0]);
    assertDiskUsage(mostNode_2, node2FSInfo[0]);

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

示例12: describeMismatchSafely

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
@Override
public void describeMismatchSafely(final ImmutableOpenMap map, final Description mismatchDescription) {
    if (map.size() == 0) {
        mismatchDescription.appendText("was empty");
    } else {
        mismatchDescription.appendText(" was ").appendValue(map);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:CollectionMatchers.java

示例13: addFileSizes

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
public void addFileSizes(ImmutableOpenMap<String, Long> fileSizes) {
    ImmutableOpenMap.Builder<String, Long> map = ImmutableOpenMap.builder(this.fileSizes);

    for (Iterator<ObjectObjectCursor<String, Long>> it = fileSizes.iterator(); it.hasNext();) {
        ObjectObjectCursor<String, Long> entry = it.next();
        if (map.containsKey(entry.key)) {
            Long oldValue = map.get(entry.key);
            map.put(entry.key, oldValue + entry.value);
        } else {
            map.put(entry.key, entry.value);
        }
    }

    this.fileSizes = map.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:SegmentsStats.java

示例14: ParentChildAtomicFieldData

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
public ParentChildAtomicFieldData(ImmutableOpenMap<String, AtomicOrdinalsFieldData> typeToIds) {
    this.typeToIds = typeToIds;
    long size = 0;
    for (ObjectCursor<AtomicOrdinalsFieldData> cursor : typeToIds.values()) {
        size += cursor.value.ramBytesUsed();
    }
    this.memorySizeInBytes = size;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:ParentChildAtomicFieldData.java

示例15: doMasterOperation

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入依赖的package包/类
@Override
protected void doMasterOperation(final GetWarmersRequest request, String[] concreteIndices, final ClusterState state, final ActionListener<GetWarmersResponse> listener) {
    ImmutableOpenMap<String, List<IndexWarmersMetaData.Entry>> result = state.metaData().findWarmers(
            concreteIndices, request.types(), request.warmers()
    );
    listener.onResponse(new GetWarmersResponse(result));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:TransportGetWarmersAction.java


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