本文整理汇总了Java中com.carrotsearch.hppc.cursors.ObjectCursor类的典型用法代码示例。如果您正苦于以下问题:Java ObjectCursor类的具体用法?Java ObjectCursor怎么用?Java ObjectCursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectCursor类属于com.carrotsearch.hppc.cursors包,在下文中一共展示了ObjectCursor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadExistingMappingIntoIndexInfo
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的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: internalMerge
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private synchronized Map<String, DocumentMapper> internalMerge(IndexMetaData indexMetaData, MergeReason reason, boolean updateAllTypes,
boolean onlyUpdateIfNeeded) {
Map<String, CompressedXContent> map = new LinkedHashMap<>();
for (ObjectCursor<MappingMetaData> cursor : indexMetaData.getMappings().values()) {
MappingMetaData mappingMetaData = cursor.value;
if (onlyUpdateIfNeeded) {
DocumentMapper existingMapper = documentMapper(mappingMetaData.type());
if (existingMapper == null || mappingMetaData.source().equals(existingMapper.mappingSource()) == false) {
map.put(mappingMetaData.type(), mappingMetaData.source());
}
} else {
map.put(mappingMetaData.type(), mappingMetaData.source());
}
}
return internalMerge(map, reason, updateAllTypes);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:MapperService.java
示例3: validateAdd
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
/**
* Checks that a node can be safely added to this node collection.
*
* @return null if all is OK or an error message explaining why a node can not be added.
*
* Note: if this method returns a non-null value, calling {@link #add(DiscoveryNode)} will fail with an
* exception
*/
private String validateAdd(DiscoveryNode node) {
for (ObjectCursor<DiscoveryNode> cursor : nodes.values()) {
final DiscoveryNode existingNode = cursor.value;
if (node.getAddress().equals(existingNode.getAddress()) &&
node.getId().equals(existingNode.getId()) == false) {
return "can't add node " + node + ", found existing node " + existingNode + " with same address";
}
if (node.getId().equals(existingNode.getId()) &&
node.equals(existingNode) == false) {
return "can't add node " + node + ", found existing node " + existingNode
+ " with the same id but is a different node instance";
}
}
return null;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:DiscoveryNodes.java
示例4: indicesCreated
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
/**
* Returns the indices created in this event
*/
public List<String> indicesCreated() {
if (!metaDataChanged()) {
return Collections.emptyList();
}
List<String> created = null;
for (ObjectCursor<String> cursor : state.metaData().indices().keys()) {
String index = cursor.value;
if (!previousState.metaData().hasIndex(index)) {
if (created == null) {
created = new ArrayList<>();
}
created.add(index);
}
}
return created == null ? Collections.<String>emptyList() : created;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:ClusterChangedEvent.java
示例5: indicesDeletedFromClusterState
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private List<Index> indicesDeletedFromClusterState() {
// If the new cluster state has a new cluster UUID, the likely scenario is that a node was elected
// master that has had its data directory wiped out, in which case we don't want to delete the indices and lose data;
// rather we want to import them as dangling indices instead. So we check here if the cluster UUID differs from the previous
// cluster UUID, in which case, we don't want to delete indices that the master erroneously believes shouldn't exist.
// See test DiscoveryWithServiceDisruptionsIT.testIndicesDeleted()
// See discussion on https://github.com/elastic/elasticsearch/pull/9952 and
// https://github.com/elastic/elasticsearch/issues/11665
if (metaDataChanged() == false || isNewCluster()) {
return Collections.emptyList();
}
List<Index> deleted = null;
for (ObjectCursor<IndexMetaData> cursor : previousState.metaData().indices().values()) {
IndexMetaData index = cursor.value;
IndexMetaData current = state.metaData().index(index.getIndex());
if (current == null) {
if (deleted == null) {
deleted = new ArrayList<>();
}
deleted.add(index.getIndex());
}
}
return deleted == null ? Collections.<Index>emptyList() : deleted;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ClusterChangedEvent.java
示例6: valuesIt
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
/**
* Returns a direct iterator over the keys.
*/
public Iterator<VType> valuesIt() {
final Iterator<ObjectCursor<VType>> iterator = map.values().iterator();
return new Iterator<VType>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public VType next() {
return iterator.next().value;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ImmutableOpenIntMap.java
示例7: keysIt
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
/**
* Returns a direct iterator over the keys.
*/
public Iterator<KType> keysIt() {
final Iterator<ObjectCursor<KType>> iterator = map.keys().iterator();
return new Iterator<KType>() {
@Override
public boolean hasNext() { return iterator.hasNext(); }
@Override
public KType next() {
return iterator.next().value;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ImmutableOpenMap.java
示例8: valuesIt
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
/**
* Returns a direct iterator over the keys.
*/
public Iterator<VType> valuesIt() {
final Iterator<ObjectCursor<VType>> iterator = map.values().iterator();
return new Iterator<VType>() {
@Override
public boolean hasNext() { return iterator.hasNext(); }
@Override
public VType next() {
return iterator.next().value;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ImmutableOpenMap.java
示例9: waitingShardsStartedOrUnassigned
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private boolean waitingShardsStartedOrUnassigned(ClusterChangedEvent event) {
SnapshotsInProgress curr = event.state().custom(SnapshotsInProgress.TYPE);
if (curr != null) {
for (SnapshotsInProgress.Entry entry : curr.entries()) {
if (entry.state() == State.STARTED && !entry.waitingIndices().isEmpty()) {
for (ObjectCursor<String> index : entry.waitingIndices().keys()) {
if (event.indexRoutingTableChanged(index.value)) {
IndexRoutingTable indexShardRoutingTable = event.state().getRoutingTable().index(index.value);
for (ShardId shardId : entry.waitingIndices().get(index.value)) {
ShardRouting shardRouting = indexShardRoutingTable.shard(shardId.id()).primaryShard();
if (shardRouting != null && (shardRouting.started() || shardRouting.unassigned())) {
return true;
}
}
}
}
}
}
}
return false;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SnapshotsService.java
示例10: removedNodesCleanupNeeded
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private boolean removedNodesCleanupNeeded(ClusterChangedEvent event) {
SnapshotsInProgress snapshotsInProgress = event.state().custom(SnapshotsInProgress.TYPE);
if (snapshotsInProgress == null) {
return false;
}
// Check if we just became the master
boolean newMaster = !event.previousState().nodes().isLocalNodeElectedMaster();
for (SnapshotsInProgress.Entry snapshot : snapshotsInProgress.entries()) {
if (newMaster && (snapshot.state() == State.SUCCESS || snapshot.state() == State.INIT)) {
// We just replaced old master and snapshots in intermediate states needs to be cleaned
return true;
}
for (DiscoveryNode node : event.nodesDelta().removedNodes()) {
for (ObjectCursor<ShardSnapshotStatus> shardStatus : snapshot.shards().values()) {
if (!shardStatus.value.state().completed() && node.getId().equals(shardStatus.value.nodeId())) {
// At least one shard was running on the removed node - we need to fail it
return true;
}
}
}
}
return false;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:SnapshotsService.java
示例11: overallState
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
public static RestoreInProgress.State overallState(RestoreInProgress.State nonCompletedState,
ImmutableOpenMap<ShardId, RestoreInProgress.ShardRestoreStatus> shards) {
boolean hasFailed = false;
for (ObjectCursor<RestoreInProgress.ShardRestoreStatus> status : shards.values()) {
if (!status.value.state().completed()) {
return nonCompletedState;
}
if (status.value.state() == RestoreInProgress.State.FAILURE) {
hasFailed = true;
}
}
if (hasFailed) {
return RestoreInProgress.State.FAILURE;
} else {
return RestoreInProgress.State.SUCCESS;
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestoreService.java
示例12: concreteAliases
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
public String[] concreteAliases(MetaData metaData, String concreteIndex) {
if (expandAliasesWildcards()) {
//for DELETE we expand the aliases
String[] indexAsArray = {concreteIndex};
ImmutableOpenMap<String, List<AliasMetaData>> aliasMetaData = metaData.findAliases(aliases, indexAsArray);
List<String> finalAliases = new ArrayList<>();
for (ObjectCursor<List<AliasMetaData>> curAliases : aliasMetaData.values()) {
for (AliasMetaData aliasMeta: curAliases.value) {
finalAliases.add(aliasMeta.alias());
}
}
return finalAliases.toArray(new String[finalAliases.size()]);
} else {
//for add we just return the current aliases
return aliases;
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:IndicesAliasesRequest.java
示例13: assertAndCapturePrimaryTerms
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private Map<String, long[]> assertAndCapturePrimaryTerms(Map<String, long[]> previousTerms) {
if (previousTerms == null) {
previousTerms = new HashMap<>();
}
final Map<String, long[]> result = new HashMap<>();
final ClusterState state = client().admin().cluster().prepareState().get().getState();
for (ObjectCursor<IndexMetaData> cursor : state.metaData().indices().values()) {
final IndexMetaData indexMetaData = cursor.value;
final String index = indexMetaData.getIndex().getName();
final long[] previous = previousTerms.get(index);
final long[] current = IntStream.range(0, indexMetaData.getNumberOfShards()).mapToLong(indexMetaData::primaryTerm).toArray();
if (previous == null) {
result.put(index, current);
} else {
assertThat("number of terms changed for index [" + index + "]", current.length, equalTo(previous.length));
for (int shard = 0; shard < current.length; shard++) {
assertThat("primary term didn't increase for [" + index + "][" + shard + "]", current[shard], greaterThan(previous[shard]));
}
result.put(index, current);
}
}
return result;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:RecoveryFromGatewayIT.java
示例14: createNonExistentShards
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private List<ShardStateAction.ShardEntry> createNonExistentShards(ClusterState currentState, String reason) {
// add shards from a non-existent index
String nonExistentIndexUUID = "non-existent";
Index index = new Index("non-existent", nonExistentIndexUUID);
List<String> nodeIds = new ArrayList<>();
for (ObjectCursor<String> nodeId : currentState.nodes().getNodes().keys()) {
nodeIds.add(nodeId.toString());
}
List<ShardRouting> nonExistentShards = new ArrayList<>();
nonExistentShards.add(nonExistentShardRouting(index, nodeIds, true));
for (int i = 0; i < numberOfReplicas; i++) {
nonExistentShards.add(nonExistentShardRouting(index, nodeIds, false));
}
List<ShardStateAction.ShardEntry> existingShards = createExistingShards(currentState, reason);
List<ShardStateAction.ShardEntry> shardsWithMismatchedAllocationIds = new ArrayList<>();
for (ShardStateAction.ShardEntry existingShard : existingShards) {
shardsWithMismatchedAllocationIds.add(new ShardStateAction.ShardEntry(existingShard.shardId, UUIDs.randomBase64UUID(), 0L, existingShard.message, existingShard.failure));
}
List<ShardStateAction.ShardEntry> tasks = new ArrayList<>();
nonExistentShards.forEach(shard -> tasks.add(new ShardStateAction.ShardEntry(shard.shardId(), shard.allocationId().getId(), 0L, reason, new CorruptIndexException("simulated", nonExistentIndexUUID))));
tasks.addAll(shardsWithMismatchedAllocationIds);
return tasks;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:ShardFailedClusterStateTaskExecutorTests.java
示例15: startPrimaries
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private ClusterState startPrimaries(final ClusterState clusterState, final String indexName) {
RoutingTable routingTable = clusterState.routingTable();
IndexRoutingTable indexRoutingTable = routingTable.index(indexName);
IndexRoutingTable.Builder newIndexRoutingTable = IndexRoutingTable.builder(indexRoutingTable.getIndex());
for (final ObjectCursor<IndexShardRoutingTable> shardEntry : indexRoutingTable.getShards().values()) {
final IndexShardRoutingTable shardRoutingTable = shardEntry.value;
for (ShardRouting shardRouting : shardRoutingTable.getShards()) {
if (shardRouting.primary()) {
shardRouting = shardRouting.initialize(randomAsciiOfLength(8), null, shardRouting.getExpectedShardSize())
.moveToStarted();
}
newIndexRoutingTable.addShard(shardRouting);
}
}
routingTable = RoutingTable.builder(routingTable).add(newIndexRoutingTable).build();
return ClusterState.builder(clusterState).routingTable(routingTable).build();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ActiveShardCountTests.java
示例16: startAllShards
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private ClusterState startAllShards(final ClusterState clusterState, final String indexName) {
RoutingTable routingTable = clusterState.routingTable();
IndexRoutingTable indexRoutingTable = routingTable.index(indexName);
IndexRoutingTable.Builder newIndexRoutingTable = IndexRoutingTable.builder(indexRoutingTable.getIndex());
for (final ObjectCursor<IndexShardRoutingTable> shardEntry : indexRoutingTable.getShards().values()) {
final IndexShardRoutingTable shardRoutingTable = shardEntry.value;
for (ShardRouting shardRouting : shardRoutingTable.getShards()) {
if (shardRouting.primary()) {
assertTrue(shardRouting.active());
} else {
if (shardRouting.active() == false) {
shardRouting = shardRouting.initialize(randomAsciiOfLength(8), null, shardRouting.getExpectedShardSize())
.moveToStarted();
}
}
newIndexRoutingTable.addShard(shardRouting);
}
}
routingTable = RoutingTable.builder(routingTable).add(newIndexRoutingTable).build();
return ClusterState.builder(clusterState).routingTable(routingTable).build();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ActiveShardCountTests.java
示例17: findTemplates
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private List<IndexTemplateMetaData> findTemplates(BulkCreateIndicesRequest request,
ClusterState state,
IndexTemplateFilter indexTemplateFilter) {
List<IndexTemplateMetaData> templates = new ArrayList<>();
CreateIndexClusterStateUpdateRequest dummyRequest =
new CreateIndexClusterStateUpdateRequest(request, "bulk-create", request.indices().iterator().next(), false);
// note: only use the first index name to see if template matches.
// this means
for (ObjectCursor<IndexTemplateMetaData> cursor : state.metaData().templates().values()) {
IndexTemplateMetaData template = cursor.value;
if (indexTemplateFilter.apply(dummyRequest, template)) {
templates.add(template);
}
}
CollectionUtil.timSort(templates, new Comparator<IndexTemplateMetaData>() {
@Override
public int compare(IndexTemplateMetaData o1, IndexTemplateMetaData o2) {
return o2.order() - o1.order();
}
});
return templates;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:TransportBulkCreateIndicesAction.java
示例18: parse
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
public void parse(FieldMapper mainField, ParseContext context) throws IOException {
// TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part of the mappings
if (mappers.isEmpty()) {
return;
}
context = context.createMultiFieldContext();
ContentPath.Type origPathType = context.path().pathType();
context.path().pathType(pathType);
context.path().add(mainField.simpleName());
for (ObjectCursor<FieldMapper> cursor : mappers.values()) {
cursor.value.parse(context);
}
context.path().remove();
context.path().pathType(origPathType);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:FieldMapper.java
示例19: canBeAllocatedToAtLeastOneNode
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
/**
* Can the shard be allocated on at least one node based on the allocation deciders.
*/
private boolean canBeAllocatedToAtLeastOneNode(ShardRouting shard, RoutingAllocation allocation) {
for (ObjectCursor<DiscoveryNode> cursor : allocation.nodes().dataNodes().values()) {
RoutingNode node = allocation.routingNodes().node(cursor.value.id());
if (node == null) {
continue;
}
// if we can't allocate it on a node, ignore it, for example, this handles
// cases for only allocating a replica after a primary
Decision decision = allocation.deciders().canAllocate(shard, node, allocation);
if (decision.type() == Decision.Type.YES) {
return true;
}
}
return false;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:ReplicaShardAllocator.java
示例20: findTemplates
import com.carrotsearch.hppc.cursors.ObjectCursor; //导入依赖的package包/类
private List<IndexTemplateMetaData> findTemplates(CreateIndexClusterStateUpdateRequest request, ClusterState state, IndexTemplateFilter indexTemplateFilter) throws IOException {
List<IndexTemplateMetaData> templates = new ArrayList<>();
for (ObjectCursor<IndexTemplateMetaData> cursor : state.metaData().templates().values()) {
IndexTemplateMetaData template = cursor.value;
if (indexTemplateFilter.apply(request, template)) {
templates.add(template);
}
}
CollectionUtil.timSort(templates, new Comparator<IndexTemplateMetaData>() {
@Override
public int compare(IndexTemplateMetaData o1, IndexTemplateMetaData o2) {
return o2.order() - o1.order();
}
});
return templates;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:MetaDataCreateIndexService.java
注:本文中的com.carrotsearch.hppc.cursors.ObjectCursor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论