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


Java ImmutableOpenMap.get方法代码示例

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


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

示例1: loadExistingMappingIntoIndexInfo

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private void loadExistingMappingIntoIndexInfo(Graph graph, IndexInfo indexInfo, String indexName) {
    try {
        GetMappingsResponse mapping = client.admin().indices().prepareGetMappings(indexName).get();
        for (ObjectCursor<String> mappingIndexName : mapping.getMappings().keys()) {
            ImmutableOpenMap<String, MappingMetaData> typeMappings = mapping.getMappings().get(mappingIndexName.value);
            for (ObjectCursor<String> typeName : typeMappings.keys()) {
                MappingMetaData typeMapping = typeMappings.get(typeName.value);
                Map<String, Map<String, String>> properties = getPropertiesFromTypeMapping(typeMapping);
                if (properties == null) {
                    continue;
                }

                for (Map.Entry<String, Map<String, String>> propertyEntry : properties.entrySet()) {
                    String rawPropertyName = propertyEntry.getKey().replace(FIELDNAME_DOT_REPLACEMENT, ".");
                    loadExistingPropertyMappingIntoIndexInfo(graph, indexInfo, rawPropertyName);
                }
            }
        }
    } catch (IOException ex) {
        throw new MemgraphException("Could not load type mappings", ex);
    }
}
 
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:23,代码来源:Elasticsearch5SearchIndex.java

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

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

示例4: testCreationDateGenerated

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
public void testCreationDateGenerated() {
    long timeBeforeRequest = System.currentTimeMillis();
    prepareCreate("test").get();
    long timeAfterRequest = System.currentTimeMillis();
    ClusterStateResponse response = client().admin().cluster().prepareState().get();
    ClusterState state = response.getState();
    assertThat(state, notNullValue());
    MetaData metadata = state.getMetaData();
    assertThat(metadata, notNullValue());
    ImmutableOpenMap<String, IndexMetaData> indices = metadata.getIndices();
    assertThat(indices, notNullValue());
    assertThat(indices.size(), equalTo(1));
    IndexMetaData index = indices.get("test");
    assertThat(index, notNullValue());
    assertThat(index.getCreationDate(), allOf(lessThanOrEqualTo(timeAfterRequest), greaterThanOrEqualTo(timeBeforeRequest)));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:CreateIndexIT.java

示例5: execute

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Override
public ClusterState execute(ClusterState currentState) {
    DiscoveryNodes.Builder nodesBuilder;
    nodesBuilder = DiscoveryNodes.builder(currentState.nodes());
    if (currentState.nodes().nodeExists(node.id())) {
        logger.debug("received a join request for an existing node [{}]", node);
        return currentState;
    } 
    // If this node is not in dead node list, then ignore this request
    ImmutableOpenMap<String, DiscoveryNode> deadNodes = clusterService.state().nodes().deadNodes();
    if (deadNodes.get(node.getIpPortAddress()) == null) {
        logger.warn("failed to find node [{}] in node list, ignore the join request", node);
        throw new IllegalStateException("could not find this node " + node + " from active node list and dead node list");
    }
    nodesBuilder.put(node);
    nodesBuilder.removeDeadNodeByIpPort(node);
    final ClusterState.Builder newStateBuilder = ClusterState.builder(currentState);
    newStateBuilder.nodes(nodesBuilder);
    ClusterState newState = newStateBuilder.build();
    return newState;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:JoinClusterAction.java

示例6: syncShardStatsOnNewMaster

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的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;
    }
    final String localNodeId = event.state().nodes().getLocalNodeId();
    final DiscoveryNode masterNode = event.state().nodes().getMasterNode();
    for (SnapshotsInProgress.Entry snapshot : snapshotsInProgress.entries()) {
        if (snapshot.state() == State.STARTED || snapshot.state() == State.ABORTED) {
            Map<ShardId, IndexShardSnapshotStatus> localShards = currentSnapshotShards(snapshot.snapshot());
            if (localShards != null) {
                ImmutableOpenMap<ShardId, ShardSnapshotStatus> masterShards = snapshot.shards();
                for(Map.Entry<ShardId, IndexShardSnapshotStatus> localShard : localShards.entrySet()) {
                    ShardId shardId = localShard.getKey();
                    IndexShardSnapshotStatus localShardStatus = localShard.getValue();
                    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() == 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.snapshot(), shardId);
                            updateIndexShardSnapshotStatus(snapshot.snapshot(), shardId,
                                    new ShardSnapshotStatus(localNodeId, State.SUCCESS), masterNode);
                        } else if (localShard.getValue().stage() == 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.snapshot(), shardId);
                            updateIndexShardSnapshotStatus(snapshot.snapshot(), shardId,
                                    new ShardSnapshotStatus(localNodeId, State.FAILED, localShardStatus.failure()), masterNode);

                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:SnapshotShardsService.java

示例7: assertMappingsHaveField

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private static void assertMappingsHaveField(GetMappingsResponse mappings, String index, String type, String field) throws IOException {
    ImmutableOpenMap<String, MappingMetaData> indexMappings = mappings.getMappings().get("index");
    assertNotNull(indexMappings);
    MappingMetaData typeMappings = indexMappings.get(type);
    assertNotNull(typeMappings);
    Map<String, Object> typeMappingsMap = typeMappings.getSourceAsMap();
    Map<String, Object> properties = (Map<String, Object>) typeMappingsMap.get("properties");
    assertTrue("Could not find [" + field + "] in " + typeMappingsMap.toString(), properties.containsKey(field));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:DynamicMappingIT.java

示例8: assertSettings

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private void assertSettings(GetIndexResponse response, String indexName) {
    ImmutableOpenMap<String, Settings> settings = response.settings();
    assertThat(settings, notNullValue());
    assertThat(settings.size(), equalTo(1));
    Settings indexSettings = settings.get(indexName);
    assertThat(indexSettings, notNullValue());
    assertThat(indexSettings.get("index.number_of_shards"), equalTo("1"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:GetIndexIT.java

示例9: assertNonEmptySettings

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private void assertNonEmptySettings(GetIndexResponse response, String indexName) {
    ImmutableOpenMap<String, Settings> settings = response.settings();
    assertThat(settings, notNullValue());
    assertThat(settings.size(), equalTo(1));
    Settings indexSettings = settings.get(indexName);
    assertThat(indexSettings, notNullValue());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:GetIndexIT.java

示例10: assertEmptyOrOnlyDefaultMappings

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private void assertEmptyOrOnlyDefaultMappings(GetIndexResponse response, String indexName) {
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = response.mappings();
    assertThat(mappings, notNullValue());
    assertThat(mappings.size(), equalTo(1));
    ImmutableOpenMap<String, MappingMetaData> indexMappings = mappings.get(indexName);
    assertThat(indexMappings, notNullValue());
    assertThat(indexMappings.size(), anyOf(equalTo(0), equalTo(1)));
    if (indexMappings.size() == 1) {
        MappingMetaData mapping = indexMappings.get("_default_");
        assertThat(mapping, notNullValue());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:GetIndexIT.java

示例11: assertAliases

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
private void assertAliases(GetIndexResponse response, String indexName) {
    ImmutableOpenMap<String, List<AliasMetaData>> aliases = response.aliases();
    assertThat(aliases, notNullValue());
    assertThat(aliases.size(), equalTo(1));
    List<AliasMetaData> indexAliases = aliases.get(indexName);
    assertThat(indexAliases, notNullValue());
    assertThat(indexAliases.size(), equalTo(1));
    AliasMetaData alias = indexAliases.get(0);
    assertThat(alias, notNullValue());
    assertThat(alias.alias(), equalTo("alias_idx"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:GetIndexIT.java

示例12: handleJoinRequest

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
void handleJoinRequest(final DiscoveryNode node, final ClusterState state, final JoinCallback callback) {
    if (!transportService.addressSupported(node.address().getClass())) {
        logger.warn("received a wrong address type from [{}], ignoring...", node);
    } else {
        transportService.connectToNode(node);
        try {
            // if the node already in active node list, then ignore this request
            if (clusterService.state().nodes().nodeExists(node.getId())) {
                callback.onSuccess();
                return;
            }
            // If this node is not in dead node list, then ignore this request
            ImmutableOpenMap<String, DiscoveryNode> deadNodes = clusterService.state().nodes().deadNodes();
            if (deadNodes.get(node.getIpPortAddress()) == null) {
                logger.warn("failed to find node [{}] in node list, ignore the join request", node);
                callback.onFailure(new IllegalStateException("could not find this node " + node + " from node list"));
                return;
            }
        } catch (Throwable e) {
            logger.warn("failed to validate incoming join request from node [{}]", node);
            callback.onFailure(new IllegalStateException("failure when sending a validation request to node", e));
            return;
        }
        // join task has to be immediate because if node is left then all shards is failed, this will generate a lot of tasks
        clusterService.submitStateUpdateTask("dl-disco-join(join from node[" + node + "])", new ProcessJoinsTask(Priority.IMMEDIATE, node, callback));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:JoinClusterAction.java

示例13: showIndex_onlyOneIndexReturWithMoreThanOneTypes

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Test
public void showIndex_onlyOneIndexReturWithMoreThanOneTypes() throws SqlParseException, SQLFeatureNotSupportedException, IOException {
    String query = "show "+ TEST_INDEX;
    GetIndexResponse getIndexResponse = runShowQuery(query);
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = getIndexResponse.getMappings();
    ImmutableOpenMap<String, MappingMetaData> typeToData = mappings.get(TEST_INDEX);
    Assert.assertTrue(typeToData.size()>1);
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:9,代码来源:ShowTest.java

示例14: showIndexType_onlyOneTypeReturn

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Test
public void showIndexType_onlyOneTypeReturn() throws SqlParseException, SQLFeatureNotSupportedException, IOException {
    String query = String.format("show %s/account", TEST_INDEX);
    GetIndexResponse getIndexResponse = runShowQuery(query);
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = getIndexResponse.getMappings();
    ImmutableOpenMap<String, MappingMetaData> typeToData = mappings.get(TEST_INDEX);
    Assert.assertEquals(1,typeToData.size());
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:9,代码来源:ShowTest.java

示例15: get

import org.elasticsearch.common.collect.ImmutableOpenMap; //导入方法依赖的package包/类
@Override
protected V get(ImmutableOpenMap<Integer, V> map, Integer key) {
    return map.get(key);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:DiffableTests.java


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