Java Code Examples for org.elasticsearch.common.collect.ImmutableOpenMap#values()

The following examples show how to use org.elasticsearch.common.collect.ImmutableOpenMap#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetaData.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
MetaData(String clusterUUID, long version, Settings transientSettings, Settings persistentSettings, ImmutableOpenMap<String, IndexMetaData> indices, ImmutableOpenMap<String, IndexTemplateMetaData> templates, UserMetadata userMetadata, TenantMetadata tenantMetadata, ImmutableOpenMap<String, Custom> customs, String[] allIndices, String[] allOpenIndices, String[] allClosedIndices, SortedMap<String, AliasOrIndex> aliasAndIndexLookup) {
    this.clusterUUID = clusterUUID;
    this.version = version;
    this.transientSettings = transientSettings;
    this.persistentSettings = persistentSettings;
    this.settings = Settings.settingsBuilder().put(persistentSettings).put(transientSettings).build();
    this.indices = indices;
    this.customs = customs;
    this.templates = templates;
    this.userMetadata = userMetadata;
    this.tenantMetadata = tenantMetadata;
    int totalNumberOfShards = 0;
    int numberOfShards = 0;
    for (ObjectCursor<IndexMetaData> cursor : indices.values()) {
        totalNumberOfShards += cursor.value.getTotalNumberOfShards();
        numberOfShards += cursor.value.getNumberOfShards();
    }
    this.totalNumberOfShards = totalNumberOfShards;
    this.numberOfShards = numberOfShards;

    this.allIndices = allIndices;
    this.allOpenIndices = allOpenIndices;
    this.allClosedIndices = allClosedIndices;
    this.aliasAndIndexLookup = aliasAndIndexLookup;
}
 
Example 2
Source File: IndicesAliasesRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example 3
Source File: RestoreService.java    From crate with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example 4
Source File: ParentChildAtomicFieldData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: AbstractElasticSearchTest.java    From camunda-bpm-elasticsearch with Apache License 2.0 5 votes vote down vote up
protected void printMapping(ImmutableOpenMap<String, MappingMetaData> mappedMetaData) {
  for (ObjectCursor<MappingMetaData> metaDataEntry : mappedMetaData.values()) {
    try {
      Map<String, Object> sourceAsMap = metaDataEntry.value.getSourceAsMap();
      logger.info(mapper.writeValueAsString(sourceAsMap));
    } catch (IOException e) {
      // nop
    }
  }
}
 
Example 6
Source File: DiskThresholdDecider.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a {@link DiskUsage} for the {@link RoutingNode} using the
 * average usage of other nodes in the disk usage map.
 * @param node Node to return an averaged DiskUsage object for
 * @param usages Map of nodeId to DiskUsage for all known nodes
 * @return DiskUsage representing given node using the average disk usage
 */
DiskUsage averageUsage(RoutingNode node, ImmutableOpenMap<String, DiskUsage> usages) {
    if (usages.size() == 0) {
        return new DiskUsage(node.nodeId(), node.node().getName(), "_na_", 0, 0);
    }
    long totalBytes = 0;
    long freeBytes = 0;
    for (ObjectCursor<DiskUsage> du : usages.values()) {
        totalBytes += du.value.getTotalBytes();
        freeBytes += du.value.getFreeBytes();
    }
    return new DiskUsage(node.nodeId(), node.node().getName(), "_na_", totalBytes / usages.size(), freeBytes / usages.size());
}
 
Example 7
Source File: RestoreService.java    From crate with Apache License 2.0 5 votes vote down vote up
public static boolean completed(ImmutableOpenMap<ShardId, RestoreInProgress.ShardRestoreStatus> shards) {
    for (ObjectCursor<RestoreInProgress.ShardRestoreStatus> status : shards.values()) {
        if (!status.value.state().completed()) {
            return false;
        }
    }
    return true;
}
 
Example 8
Source File: MetaData.java    From crate with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
MetaData(String clusterUUID,
         boolean clusterUUIDCommitted,
         long version,
         CoordinationMetaData coordinationMetaData,
         Settings transientSettings,
         Settings persistentSettings,
         ImmutableOpenMap<String, IndexMetaData> indices,
         ImmutableOpenMap<String, IndexTemplateMetaData> templates,
         ImmutableOpenMap<String, Custom> customs,
         String[] allIndices,
         String[] allOpenIndices,
         String[] allClosedIndices,
         SortedMap<String, AliasOrIndex> aliasAndIndexLookup) {
    this.clusterUUID = clusterUUID;
    this.clusterUUIDCommitted = clusterUUIDCommitted;
    this.version = version;
    this.coordinationMetaData = coordinationMetaData;
    this.transientSettings = transientSettings;
    this.persistentSettings = persistentSettings;
    this.settings = Settings.builder().put(persistentSettings).put(transientSettings).build();
    this.indices = indices;
    this.customs = customs;
    this.templates = templates;
    int totalNumberOfShards = 0;
    int totalOpenIndexShards = 0;
    int numberOfShards = 0;
    for (ObjectCursor<IndexMetaData> cursor : indices.values()) {
        totalNumberOfShards += cursor.value.getTotalNumberOfShards();
        numberOfShards += cursor.value.getNumberOfShards();
        if (IndexMetaData.State.OPEN.equals(cursor.value.getState())) {
            totalOpenIndexShards += cursor.value.getTotalNumberOfShards();
        }
    }
    this.totalNumberOfShards = totalNumberOfShards;
    this.totalOpenIndexShards = totalOpenIndexShards;
    this.numberOfShards = numberOfShards;

    this.allIndices = allIndices;
    this.allOpenIndices = allOpenIndices;
    this.allClosedIndices = allClosedIndices;
    this.aliasAndIndexLookup = aliasAndIndexLookup;

    indicesByUUID = buildIndicesByUUIDMap();
}