@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(); } }
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(); }
public Builder updateSettings(Settings settings, String... indices) { if (indices == null || indices.length == 0) { indices = this.indices.keys().toArray(String.class); } for (String index : indices) { IndexMetaData indexMetaData = this.indices.get(index); if (indexMetaData == null) { throw new IndexNotFoundException(index); } put(IndexMetaData.builder(indexMetaData) .settings(Settings.builder().put(indexMetaData.getSettings()).put(settings))); } return this; }
/** * Get a node by its id * * @param nodeId id of the wanted node * @return wanted node if it exists. Otherwise <code>null</code> */ @Nullable public DiscoveryNode get(String nodeId) { return nodes.get(nodeId); }
public Builder remove(DiscoveryNode node) { if (node.equals(nodes.get(node.getId()))) { nodes.remove(node.getId()); } return this; }
/** * Get a node by its id * * @param nodeId id of the wanted node * @return wanted node if it exists. Otherwise <code>null</code> */ @Nullable public DiscoveryNode get(String nodeId) { return nodes.get(nodeId); }
public IndexMetaData build() { ImmutableOpenMap.Builder<String, AliasMetaData> tmpAliases = aliases; Settings tmpSettings = settings; // update default mapping on the MappingMetaData if (mappings.containsKey(MapperService.DEFAULT_MAPPING)) { MappingMetaData defaultMapping = mappings.get(MapperService.DEFAULT_MAPPING); for (ObjectCursor<MappingMetaData> cursor : mappings.values()) { cursor.value.updateDefaultMapping(defaultMapping); } } return new IndexMetaData(index, version, state, tmpSettings, mappings.build(), tmpAliases.build(), customs.build()); }
/** * Get a node by its id * * @param nodeId id of the wanted node * @return wanted node if it exists. Otherwise <code>null</code> */ @Nullable public DiscoveryNode get(String nodeId) { return nodes.get(nodeId); }
public Builder remove(DiscoveryNode node) { if (node.equals(nodes.get(node.getId()))) { nodes.remove(node.getId()); } return this; }
MappingMetaData defaultMapping = mappings.get(MapperService.DEFAULT_MAPPING); for (ObjectCursor<MappingMetaData> cursor : mappings.values()) { cursor.value.updateDefaultMapping(defaultMapping);
for (Response fetchResponse : fetchResponses) { ImmutableOpenIntMap<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexStoreStatuses = indicesStoreStatusesBuilder.get(fetchResponse.shardId.getIndexName()); final ImmutableOpenIntMap.Builder<java.util.List<IndicesShardStoresResponse.StoreStatus>> indexShardsBuilder; if (indexStoreStatuses == null) {
IndexRoutingTable indexRoutingTable = indicesRouting.get(index); if (indexRoutingTable == null) {
/** * Update the number of replicas for the specified indices. * * @param numberOfReplicas the number of replicas * @param indices the indices to update the number of replicas for * @return the builder */ public Builder updateNumberOfReplicas(final int numberOfReplicas, final String[] indices) { for (String index : indices) { IndexMetaData indexMetaData = this.indices.get(index); if (indexMetaData == null) { throw new IndexNotFoundException(index); } put(IndexMetaData.builder(indexMetaData).numberOfReplicas(numberOfReplicas)); } return this; }
public Custom getCustom(String type) { return customs.get(type); }
public RolloverInfo getRolloverInfo(String alias) { return rolloverInfos.get(alias); }
public MappingMetaData mapping(String type) { return mappings.get(type); }
public IndexMetaData get(String index) { return indices.get(index); }
public Builder remove(DiscoveryNode node) { if (node.equals(nodes.get(node.getId()))) { nodes.remove(node.getId()); } return this; }
/** * Get a node by its id * * @param nodeId id of the wanted node * @return wanted node if it exists. Otherwise <code>null</code> */ @Nullable public DiscoveryNode get(String nodeId) { return nodes.get(nodeId); }
public Builder put(IndexMetaData indexMetaData, boolean incrementVersion) { if (indices.get(indexMetaData.getIndex().getName()) == indexMetaData) { return this; } // if we put a new index metadata, increment its version if (incrementVersion) { indexMetaData = IndexMetaData.builder(indexMetaData).version(indexMetaData.getVersion() + 1).build(); } indices.put(indexMetaData.getIndex().getName(), indexMetaData); return this; }