當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。