Remove and ban ImmutableMap#entrySet
Banning `ImmutableSet` outright is too much to do all at once - this starts the process by banning `ImmutableMap#entrySet` - one of the more common ways that `ImmutableSet`s come up. It then starts to remove calls to `ImmutableMap#entrySet` by changing declarations from `ImmutableMap` to `Map`. Unfortunately this process is like pulling on a long, windy string and one declaration change requires another which requires 5 more which in turn require another few. So this change is rather large. As such, to keep the changes manageable they only remove `ImmutableMap` from the signatures that are needed for `entrySet` and make little effort to stop using `ImmutableMap` internally. Removing the usages of `ImmutableMap` complicates immutability guarantees and will be done separately.
This commit is contained in:
parent
a77c68ba0e
commit
52f3c89c3b
|
@ -42,9 +42,8 @@ import java.util.Map;
|
||||||
* Node information (static, does not change over time).
|
* Node information (static, does not change over time).
|
||||||
*/
|
*/
|
||||||
public class NodeInfo extends BaseNodeResponse {
|
public class NodeInfo extends BaseNodeResponse {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ImmutableMap<String, String> serviceAttributes;
|
private Map<String, String> serviceAttributes;
|
||||||
|
|
||||||
private Version version;
|
private Version version;
|
||||||
private Build build;
|
private Build build;
|
||||||
|
@ -119,7 +118,7 @@ public class NodeInfo extends BaseNodeResponse {
|
||||||
* The service attributes of the node.
|
* The service attributes of the node.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public ImmutableMap<String, String> getServiceAttributes() {
|
public Map<String, String> getServiceAttributes() {
|
||||||
return this.serviceAttributes;
|
return this.serviceAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.action.admin.cluster.snapshots.status;
|
package org.elasticsearch.action.admin.cluster.snapshots.status;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.action.ActionRequest;
|
||||||
import org.elasticsearch.action.FailedNodeException;
|
import org.elasticsearch.action.FailedNodeException;
|
||||||
|
@ -46,10 +47,13 @@ import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transport client that collects snapshot shard statuses from data nodes
|
* Transport client that collects snapshot shard statuses from data nodes
|
||||||
*/
|
*/
|
||||||
|
@ -104,7 +108,7 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NodeSnapshotStatus nodeOperation(NodeRequest request) {
|
protected NodeSnapshotStatus nodeOperation(NodeRequest request) {
|
||||||
ImmutableMap.Builder<SnapshotId, ImmutableMap<ShardId, SnapshotIndexShardStatus>> snapshotMapBuilder = ImmutableMap.builder();
|
Map<SnapshotId, Map<ShardId, SnapshotIndexShardStatus>> snapshotMapBuilder = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
String nodeId = clusterService.localNode().id();
|
String nodeId = clusterService.localNode().id();
|
||||||
for (SnapshotId snapshotId : request.snapshotIds) {
|
for (SnapshotId snapshotId : request.snapshotIds) {
|
||||||
|
@ -112,7 +116,7 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||||
if (shardsStatus == null) {
|
if (shardsStatus == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ImmutableMap.Builder<ShardId, SnapshotIndexShardStatus> shardMapBuilder = ImmutableMap.builder();
|
Map<ShardId, SnapshotIndexShardStatus> shardMapBuilder = new HashMap<>();
|
||||||
for (Map.Entry<ShardId, IndexShardSnapshotStatus> shardEntry : shardsStatus.entrySet()) {
|
for (Map.Entry<ShardId, IndexShardSnapshotStatus> shardEntry : shardsStatus.entrySet()) {
|
||||||
SnapshotIndexShardStatus shardStatus;
|
SnapshotIndexShardStatus shardStatus;
|
||||||
IndexShardSnapshotStatus.Stage stage = shardEntry.getValue().stage();
|
IndexShardSnapshotStatus.Stage stage = shardEntry.getValue().stage();
|
||||||
|
@ -124,9 +128,9 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||||
}
|
}
|
||||||
shardMapBuilder.put(shardEntry.getKey(), shardStatus);
|
shardMapBuilder.put(shardEntry.getKey(), shardStatus);
|
||||||
}
|
}
|
||||||
snapshotMapBuilder.put(snapshotId, shardMapBuilder.build());
|
snapshotMapBuilder.put(snapshotId, unmodifiableMap(shardMapBuilder));
|
||||||
}
|
}
|
||||||
return new NodeSnapshotStatus(clusterService.localNode(), snapshotMapBuilder.build());
|
return new NodeSnapshotStatus(clusterService.localNode(), unmodifiableMap(snapshotMapBuilder));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElasticsearchException("failed to load metadata", e);
|
throw new ElasticsearchException("failed to load metadata", e);
|
||||||
}
|
}
|
||||||
|
@ -241,17 +245,17 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||||
|
|
||||||
public static class NodeSnapshotStatus extends BaseNodeResponse {
|
public static class NodeSnapshotStatus extends BaseNodeResponse {
|
||||||
|
|
||||||
private ImmutableMap<SnapshotId, ImmutableMap<ShardId, SnapshotIndexShardStatus>> status;
|
private Map<SnapshotId, Map<ShardId, SnapshotIndexShardStatus>> status;
|
||||||
|
|
||||||
NodeSnapshotStatus() {
|
NodeSnapshotStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeSnapshotStatus(DiscoveryNode node, ImmutableMap<SnapshotId, ImmutableMap<ShardId, SnapshotIndexShardStatus>> status) {
|
public NodeSnapshotStatus(DiscoveryNode node, Map<SnapshotId, Map<ShardId, SnapshotIndexShardStatus>> status) {
|
||||||
super(node);
|
super(node);
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<SnapshotId, ImmutableMap<ShardId, SnapshotIndexShardStatus>> status() {
|
public Map<SnapshotId, Map<ShardId, SnapshotIndexShardStatus>> status() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,19 +263,19 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
int numberOfSnapshots = in.readVInt();
|
int numberOfSnapshots = in.readVInt();
|
||||||
ImmutableMap.Builder<SnapshotId, ImmutableMap<ShardId, SnapshotIndexShardStatus>> snapshotMapBuilder = ImmutableMap.builder();
|
Map<SnapshotId, Map<ShardId, SnapshotIndexShardStatus>> snapshotMapBuilder = new HashMap<>(numberOfSnapshots);
|
||||||
for (int i = 0; i < numberOfSnapshots; i++) {
|
for (int i = 0; i < numberOfSnapshots; i++) {
|
||||||
SnapshotId snapshotId = SnapshotId.readSnapshotId(in);
|
SnapshotId snapshotId = SnapshotId.readSnapshotId(in);
|
||||||
ImmutableMap.Builder<ShardId, SnapshotIndexShardStatus> shardMapBuilder = ImmutableMap.builder();
|
|
||||||
int numberOfShards = in.readVInt();
|
int numberOfShards = in.readVInt();
|
||||||
|
Map<ShardId, SnapshotIndexShardStatus> shardMapBuilder = new HashMap<>(numberOfShards);
|
||||||
for (int j = 0; j < numberOfShards; j++) {
|
for (int j = 0; j < numberOfShards; j++) {
|
||||||
ShardId shardId = ShardId.readShardId(in);
|
ShardId shardId = ShardId.readShardId(in);
|
||||||
SnapshotIndexShardStatus status = SnapshotIndexShardStatus.readShardSnapshotStatus(in);
|
SnapshotIndexShardStatus status = SnapshotIndexShardStatus.readShardSnapshotStatus(in);
|
||||||
shardMapBuilder.put(shardId, status);
|
shardMapBuilder.put(shardId, status);
|
||||||
}
|
}
|
||||||
snapshotMapBuilder.put(snapshotId, shardMapBuilder.build());
|
snapshotMapBuilder.put(snapshotId, unmodifiableMap(shardMapBuilder));
|
||||||
}
|
}
|
||||||
status = snapshotMapBuilder.build();
|
status = unmodifiableMap(snapshotMapBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -279,10 +283,10 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
out.writeVInt(status.size());
|
out.writeVInt(status.size());
|
||||||
for (ImmutableMap.Entry<SnapshotId, ImmutableMap<ShardId, SnapshotIndexShardStatus>> entry : status.entrySet()) {
|
for (Map.Entry<SnapshotId, Map<ShardId, SnapshotIndexShardStatus>> entry : status.entrySet()) {
|
||||||
entry.getKey().writeTo(out);
|
entry.getKey().writeTo(out);
|
||||||
out.writeVInt(entry.getValue().size());
|
out.writeVInt(entry.getValue().size());
|
||||||
for (ImmutableMap.Entry<ShardId, SnapshotIndexShardStatus> shardEntry : entry.getValue().entrySet()) {
|
for (Map.Entry<ShardId, SnapshotIndexShardStatus> shardEntry : entry.getValue().entrySet()) {
|
||||||
shardEntry.getKey().writeTo(out);
|
shardEntry.getKey().writeTo(out);
|
||||||
shardEntry.getValue().writeTo(out);
|
shardEntry.getValue().writeTo(out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
|
||||||
// We should have information about this shard from the shard:
|
// We should have information about this shard from the shard:
|
||||||
TransportNodesSnapshotsStatus.NodeSnapshotStatus nodeStatus = nodeSnapshotStatusMap.get(status.nodeId());
|
TransportNodesSnapshotsStatus.NodeSnapshotStatus nodeStatus = nodeSnapshotStatusMap.get(status.nodeId());
|
||||||
if (nodeStatus != null) {
|
if (nodeStatus != null) {
|
||||||
ImmutableMap<ShardId, SnapshotIndexShardStatus> shardStatues = nodeStatus.status().get(entry.snapshotId());
|
Map<ShardId, SnapshotIndexShardStatus> shardStatues = nodeStatus.status().get(entry.snapshotId());
|
||||||
if (shardStatues != null) {
|
if (shardStatues != null) {
|
||||||
SnapshotIndexShardStatus shardStatus = shardStatues.get(shardEntry.getKey());
|
SnapshotIndexShardStatus shardStatus = shardStatues.get(shardEntry.getKey());
|
||||||
if (shardStatus != null) {
|
if (shardStatus != null) {
|
||||||
|
@ -204,7 +204,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<Sn
|
||||||
Snapshot snapshot = snapshotsService.snapshot(snapshotId);
|
Snapshot snapshot = snapshotsService.snapshot(snapshotId);
|
||||||
List<SnapshotIndexShardStatus> shardStatusBuilder = new ArrayList<>();
|
List<SnapshotIndexShardStatus> shardStatusBuilder = new ArrayList<>();
|
||||||
if (snapshot.state().completed()) {
|
if (snapshot.state().completed()) {
|
||||||
ImmutableMap<ShardId, IndexShardSnapshotStatus> shardStatues = snapshotsService.snapshotShards(snapshotId);
|
Map<ShardId, IndexShardSnapshotStatus> shardStatues = snapshotsService.snapshotShards(snapshotId);
|
||||||
for (ImmutableMap.Entry<ShardId, IndexShardSnapshotStatus> shardStatus : shardStatues.entrySet()) {
|
for (ImmutableMap.Entry<ShardId, IndexShardSnapshotStatus> shardStatus : shardStatues.entrySet()) {
|
||||||
shardStatusBuilder.add(new SnapshotIndexShardStatus(shardStatus.getKey(), shardStatus.getValue()));
|
shardStatusBuilder.add(new SnapshotIndexShardStatus(shardStatus.getKey(), shardStatus.getValue()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.action.admin.indices.mapping.get;
|
package org.elasticsearch.action.admin.indices.mapping.get;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
@ -31,14 +32,17 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.index.mapper.Mapper;
|
import org.elasticsearch.index.mapper.Mapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
/** Response object for {@link GetFieldMappingsRequest} API */
|
/** Response object for {@link GetFieldMappingsRequest} API */
|
||||||
public class GetFieldMappingsResponse extends ActionResponse implements ToXContent {
|
public class GetFieldMappingsResponse extends ActionResponse implements ToXContent {
|
||||||
|
|
||||||
private ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappings = ImmutableMap.of();
|
private Map<String, Map<String, Map<String, FieldMappingMetaData>>> mappings = ImmutableMap.of();
|
||||||
|
|
||||||
GetFieldMappingsResponse(ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappings) {
|
GetFieldMappingsResponse(Map<String, Map<String, Map<String, FieldMappingMetaData>>> mappings) {
|
||||||
this.mappings = mappings;
|
this.mappings = mappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +50,7 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
|
||||||
}
|
}
|
||||||
|
|
||||||
/** returns the retrieved field mapping. The return map keys are index, type, field (as specified in the request). */
|
/** returns the retrieved field mapping. The return map keys are index, type, field (as specified in the request). */
|
||||||
public ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappings() {
|
public Map<String, Map<String, Map<String, FieldMappingMetaData>>> mappings() {
|
||||||
return mappings;
|
return mappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,11 +61,11 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
|
||||||
* @return FieldMappingMetaData for the requested field or null if not found.
|
* @return FieldMappingMetaData for the requested field or null if not found.
|
||||||
*/
|
*/
|
||||||
public FieldMappingMetaData fieldMappings(String index, String type, String field) {
|
public FieldMappingMetaData fieldMappings(String index, String type, String field) {
|
||||||
ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>> indexMapping = mappings.get(index);
|
Map<String, Map<String, FieldMappingMetaData>> indexMapping = mappings.get(index);
|
||||||
if (indexMapping == null) {
|
if (indexMapping == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ImmutableMap<String, FieldMappingMetaData> typeMapping = indexMapping.get(type);
|
Map<String, FieldMappingMetaData> typeMapping = indexMapping.get(type);
|
||||||
if (typeMapping == null) {
|
if (typeMapping == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -70,10 +74,10 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
for (Map.Entry<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> indexEntry : mappings.entrySet()) {
|
for (Map.Entry<String, Map<String, Map<String, FieldMappingMetaData>>> indexEntry : mappings.entrySet()) {
|
||||||
builder.startObject(indexEntry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(indexEntry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
||||||
builder.startObject("mappings");
|
builder.startObject("mappings");
|
||||||
for (Map.Entry<String, ImmutableMap<String, FieldMappingMetaData>> typeEntry : indexEntry.getValue().entrySet()) {
|
for (Map.Entry<String, Map<String, FieldMappingMetaData>> typeEntry : indexEntry.getValue().entrySet()) {
|
||||||
builder.startObject(typeEntry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
builder.startObject(typeEntry.getKey(), XContentBuilder.FieldCaseConversion.NONE);
|
||||||
for (Map.Entry<String, FieldMappingMetaData> fieldEntry : typeEntry.getValue().entrySet()) {
|
for (Map.Entry<String, FieldMappingMetaData> fieldEntry : typeEntry.getValue().entrySet()) {
|
||||||
builder.startObject(fieldEntry.getKey());
|
builder.startObject(fieldEntry.getKey());
|
||||||
|
@ -128,33 +132,33 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
int size = in.readVInt();
|
int size = in.readVInt();
|
||||||
ImmutableMap.Builder<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> indexMapBuilder = ImmutableMap.builder();
|
Map<String, Map<String, Map<String, FieldMappingMetaData>>> indexMapBuilder = new HashMap<>(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
String index = in.readString();
|
String index = in.readString();
|
||||||
int typesSize = in.readVInt();
|
int typesSize = in.readVInt();
|
||||||
ImmutableMap.Builder<String, ImmutableMap<String, FieldMappingMetaData>> typeMapBuilder = ImmutableMap.builder();
|
Map<String, Map<String, FieldMappingMetaData>> typeMapBuilder = new HashMap<>(typesSize);
|
||||||
for (int j = 0; j < typesSize; j++) {
|
for (int j = 0; j < typesSize; j++) {
|
||||||
String type = in.readString();
|
String type = in.readString();
|
||||||
ImmutableMap.Builder<String, FieldMappingMetaData> fieldMapBuilder = ImmutableMap.builder();
|
|
||||||
int fieldSize = in.readVInt();
|
int fieldSize = in.readVInt();
|
||||||
|
Map<String, FieldMappingMetaData> fieldMapBuilder = new HashMap<>(fieldSize);
|
||||||
for (int k = 0; k < fieldSize; k++) {
|
for (int k = 0; k < fieldSize; k++) {
|
||||||
fieldMapBuilder.put(in.readString(), new FieldMappingMetaData(in.readString(), in.readBytesReference()));
|
fieldMapBuilder.put(in.readString(), new FieldMappingMetaData(in.readString(), in.readBytesReference()));
|
||||||
}
|
}
|
||||||
typeMapBuilder.put(type, fieldMapBuilder.build());
|
typeMapBuilder.put(type, unmodifiableMap(fieldMapBuilder));
|
||||||
}
|
}
|
||||||
indexMapBuilder.put(index, typeMapBuilder.build());
|
indexMapBuilder.put(index, unmodifiableMap(typeMapBuilder));
|
||||||
}
|
}
|
||||||
mappings = indexMapBuilder.build();
|
mappings = unmodifiableMap(indexMapBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
out.writeVInt(mappings.size());
|
out.writeVInt(mappings.size());
|
||||||
for (Map.Entry<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> indexEntry : mappings.entrySet()) {
|
for (Map.Entry<String, Map<String, Map<String, FieldMappingMetaData>>> indexEntry : mappings.entrySet()) {
|
||||||
out.writeString(indexEntry.getKey());
|
out.writeString(indexEntry.getKey());
|
||||||
out.writeVInt(indexEntry.getValue().size());
|
out.writeVInt(indexEntry.getValue().size());
|
||||||
for (Map.Entry<String, ImmutableMap<String, FieldMappingMetaData>> typeEntry : indexEntry.getValue().entrySet()) {
|
for (Map.Entry<String, Map<String, FieldMappingMetaData>> typeEntry : indexEntry.getValue().entrySet()) {
|
||||||
out.writeString(typeEntry.getKey());
|
out.writeString(typeEntry.getKey());
|
||||||
out.writeVInt(typeEntry.getValue().size());
|
out.writeVInt(typeEntry.getValue().size());
|
||||||
for (Map.Entry<String, FieldMappingMetaData> fieldEntry : typeEntry.getValue().entrySet()) {
|
for (Map.Entry<String, FieldMappingMetaData> fieldEntry : typeEntry.getValue().entrySet()) {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.elasticsearch.action.admin.indices.mapping.get;
|
package org.elasticsearch.action.admin.indices.mapping.get;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
import org.elasticsearch.action.support.HandledTransportAction;
|
||||||
|
@ -32,6 +31,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction<GetF
|
||||||
}
|
}
|
||||||
|
|
||||||
private GetFieldMappingsResponse merge(AtomicReferenceArray<Object> indexResponses) {
|
private GetFieldMappingsResponse merge(AtomicReferenceArray<Object> indexResponses) {
|
||||||
MapBuilder<String, ImmutableMap<String, ImmutableMap<String, GetFieldMappingsResponse.FieldMappingMetaData>>> mergedResponses = MapBuilder.newMapBuilder();
|
MapBuilder<String, Map<String, Map<String, GetFieldMappingsResponse.FieldMappingMetaData>>> mergedResponses = MapBuilder.newMapBuilder();
|
||||||
for (int i = 0; i < indexResponses.length(); i++) {
|
for (int i = 0; i < indexResponses.length(); i++) {
|
||||||
Object element = indexResponses.get(i);
|
Object element = indexResponses.get(i);
|
||||||
if (element instanceof GetFieldMappingsResponse) {
|
if (element instanceof GetFieldMappingsResponse) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.action.admin.indices.mapping.get;
|
package org.elasticsearch.action.admin.indices.mapping.get;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData;
|
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
|
@ -52,6 +53,7 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.elasticsearch.common.util.CollectionUtils.newLinkedList;
|
import static org.elasticsearch.common.util.CollectionUtils.newLinkedList;
|
||||||
|
@ -105,7 +107,7 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleShardAc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MapBuilder<String, ImmutableMap<String, FieldMappingMetaData>> typeMappings = new MapBuilder<>();
|
MapBuilder<String, Map<String, FieldMappingMetaData>> typeMappings = new MapBuilder<>();
|
||||||
for (String type : typeIntersection) {
|
for (String type : typeIntersection) {
|
||||||
DocumentMapper documentMapper = indexService.mapperService().documentMapper(type);
|
DocumentMapper documentMapper = indexService.mapperService().documentMapper(type);
|
||||||
ImmutableMap<String, FieldMappingMetaData> fieldMapping = findFieldMappingsByType(documentMapper, request);
|
ImmutableMap<String, FieldMappingMetaData> fieldMapping = findFieldMappingsByType(documentMapper, request);
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.elasticsearch.cluster;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
|
@ -45,11 +45,11 @@ public final class DiffableUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates diff between two ImmutableMaps of Diffable objects
|
* Calculates diff between two Maps of Diffable objects.
|
||||||
*/
|
*/
|
||||||
public static <T extends Diffable<T>> Diff<ImmutableMap<String, T>> diff(ImmutableMap<String, T> before, ImmutableMap<String, T> after) {
|
public static <T extends Diffable<T>> Diff<Map<String, T>> diff(Map<String, T> before, Map<String, T> after) {
|
||||||
assert after != null && before != null;
|
assert after != null && before != null;
|
||||||
return new ImmutableMapDiff<>(before, after);
|
return new JdkMapDiff<>(before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,10 +60,10 @@ public final class DiffableUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an object that represents difference between two ImmutableMaps
|
* Loads an object that represents difference between two Maps.
|
||||||
*/
|
*/
|
||||||
public static <T extends Diffable<T>> Diff<ImmutableMap<String, T>> readImmutableMapDiff(StreamInput in, KeyedReader<T> keyedReader) throws IOException {
|
public static <T extends Diffable<T>> Diff<Map<String, T>> readJdkMapDiff(StreamInput in, KeyedReader<T> keyedReader) throws IOException {
|
||||||
return new ImmutableMapDiff<>(in, keyedReader);
|
return new JdkMapDiff<>(in, keyedReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,10 +74,10 @@ public final class DiffableUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an object that represents difference between two ImmutableMaps
|
* Loads an object that represents difference between two Maps.
|
||||||
*/
|
*/
|
||||||
public static <T extends Diffable<T>> Diff<ImmutableMap<String, T>> readImmutableMapDiff(StreamInput in, T proto) throws IOException {
|
public static <T extends Diffable<T>> Diff<Map<String, T>> readJdkMapDiff(StreamInput in, T proto) throws IOException {
|
||||||
return new ImmutableMapDiff<>(in, new PrototypeReader<>(proto));
|
return new JdkMapDiff<>(in, new PrototypeReader<>(proto));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,24 +121,24 @@ public final class DiffableUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents differences between two ImmutableMaps of diffable objects
|
* Represents differences between two Maps of Diffable objects.
|
||||||
*
|
*
|
||||||
* @param <T> the diffable object
|
* @param <T> the diffable object
|
||||||
*/
|
*/
|
||||||
private static class ImmutableMapDiff<T extends Diffable<T>> extends MapDiff<T, ImmutableMap<String, T>> {
|
private static class JdkMapDiff<T extends Diffable<T>> extends MapDiff<T, Map<String, T>> {
|
||||||
|
|
||||||
protected ImmutableMapDiff(StreamInput in, KeyedReader<T> reader) throws IOException {
|
protected JdkMapDiff(StreamInput in, KeyedReader<T> reader) throws IOException {
|
||||||
super(in, reader);
|
super(in, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMapDiff(ImmutableMap<String, T> before, ImmutableMap<String, T> after) {
|
public JdkMapDiff(Map<String, T> before, Map<String, T> after) {
|
||||||
assert after != null && before != null;
|
assert after != null && before != null;
|
||||||
for (String key : before.keySet()) {
|
for (String key : before.keySet()) {
|
||||||
if (!after.containsKey(key)) {
|
if (!after.containsKey(key)) {
|
||||||
deletes.add(key);
|
deletes.add(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ImmutableMap.Entry<String, T> partIter : after.entrySet()) {
|
for (Map.Entry<String, T> partIter : after.entrySet()) {
|
||||||
T beforePart = before.get(partIter.getKey());
|
T beforePart = before.get(partIter.getKey());
|
||||||
if (beforePart == null) {
|
if (beforePart == null) {
|
||||||
adds.put(partIter.getKey(), partIter.getValue());
|
adds.put(partIter.getKey(), partIter.getValue());
|
||||||
|
@ -149,8 +149,8 @@ public final class DiffableUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableMap<String, T> apply(ImmutableMap<String, T> map) {
|
public Map<String, T> apply(Map<String, T> map) {
|
||||||
HashMap<String, T> builder = new HashMap<>();
|
Map<String, T> builder = new HashMap<>();
|
||||||
builder.putAll(map);
|
builder.putAll(map);
|
||||||
|
|
||||||
for (String part : deletes) {
|
for (String part : deletes) {
|
||||||
|
@ -164,7 +164,7 @@ public final class DiffableUtils {
|
||||||
for (Map.Entry<String, T> additon : adds.entrySet()) {
|
for (Map.Entry<String, T> additon : adds.entrySet()) {
|
||||||
builder.put(additon.getKey(), additon.getValue());
|
builder.put(additon.getKey(), additon.getValue());
|
||||||
}
|
}
|
||||||
return ImmutableMap.copyOf(builder);
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
|
||||||
public static class Entry {
|
public static class Entry {
|
||||||
private final State state;
|
private final State state;
|
||||||
private final SnapshotId snapshotId;
|
private final SnapshotId snapshotId;
|
||||||
private final ImmutableMap<ShardId, ShardRestoreStatus> shards;
|
private final Map<ShardId, ShardRestoreStatus> shards;
|
||||||
private final List<String> indices;
|
private final List<String> indices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +148,7 @@ public class RestoreInProgress extends AbstractDiffable<Custom> implements Custo
|
||||||
*
|
*
|
||||||
* @return list of shards
|
* @return list of shards
|
||||||
*/
|
*/
|
||||||
public ImmutableMap<ShardId, ShardRestoreStatus> shards() {
|
public Map<ShardId, ShardRestoreStatus> shards() {
|
||||||
return this.shards;
|
return this.shards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta data about snapshots that are currently executing
|
* Meta data about snapshots that are currently executing
|
||||||
*/
|
*/
|
||||||
|
@ -67,12 +69,12 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
|
||||||
private final State state;
|
private final State state;
|
||||||
private final SnapshotId snapshotId;
|
private final SnapshotId snapshotId;
|
||||||
private final boolean includeGlobalState;
|
private final boolean includeGlobalState;
|
||||||
private final ImmutableMap<ShardId, ShardSnapshotStatus> shards;
|
private final Map<ShardId, ShardSnapshotStatus> shards;
|
||||||
private final List<String> indices;
|
private final List<String> indices;
|
||||||
private final ImmutableMap<String, List<ShardId>> waitingIndices;
|
private final Map<String, List<ShardId>> waitingIndices;
|
||||||
private final long startTime;
|
private final long startTime;
|
||||||
|
|
||||||
public Entry(SnapshotId snapshotId, boolean includeGlobalState, State state, List<String> indices, long startTime, ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
|
public Entry(SnapshotId snapshotId, boolean includeGlobalState, State state, List<String> indices, long startTime, Map<ShardId, ShardSnapshotStatus> shards) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.snapshotId = snapshotId;
|
this.snapshotId = snapshotId;
|
||||||
this.includeGlobalState = includeGlobalState;
|
this.includeGlobalState = includeGlobalState;
|
||||||
|
@ -82,16 +84,16 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
|
||||||
this.shards = ImmutableMap.of();
|
this.shards = ImmutableMap.of();
|
||||||
this.waitingIndices = ImmutableMap.of();
|
this.waitingIndices = ImmutableMap.of();
|
||||||
} else {
|
} else {
|
||||||
this.shards = shards;
|
this.shards = unmodifiableMap(shards);
|
||||||
this.waitingIndices = findWaitingIndices(shards);
|
this.waitingIndices = findWaitingIndices(shards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry(Entry entry, State state, ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
|
public Entry(Entry entry, State state, Map<ShardId, ShardSnapshotStatus> shards) {
|
||||||
this(entry.snapshotId, entry.includeGlobalState, state, entry.indices, entry.startTime, shards);
|
this(entry.snapshotId, entry.includeGlobalState, state, entry.indices, entry.startTime, shards);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry(Entry entry, ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
|
public Entry(Entry entry, Map<ShardId, ShardSnapshotStatus> shards) {
|
||||||
this(entry, entry.state, shards);
|
this(entry, entry.state, shards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +101,7 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
|
||||||
return this.snapshotId;
|
return this.snapshotId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<ShardId, ShardSnapshotStatus> shards() {
|
public Map<ShardId, ShardSnapshotStatus> shards() {
|
||||||
return this.shards;
|
return this.shards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +113,7 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
|
||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<String, List<ShardId>> waitingIndices() {
|
public Map<String, List<ShardId>> waitingIndices() {
|
||||||
return waitingIndices;
|
return waitingIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +155,7 @@ public class SnapshotsInProgress extends AbstractDiffable<Custom> implements Cus
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableMap<String, List<ShardId>> findWaitingIndices(ImmutableMap<ShardId, ShardSnapshotStatus> shards) {
|
private ImmutableMap<String, List<ShardId>> findWaitingIndices(Map<ShardId, ShardSnapshotStatus> shards) {
|
||||||
Map<String, List<ShardId>> waitingIndicesMap = new HashMap<>();
|
Map<String, List<ShardId>> waitingIndicesMap = new HashMap<>();
|
||||||
for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> entry : shards.entrySet()) {
|
for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> entry : shards.entrySet()) {
|
||||||
if (entry.getValue().state() == State.WAITING) {
|
if (entry.getValue().state() == State.WAITING) {
|
||||||
|
|
|
@ -45,11 +45,11 @@ public class ClusterBlocks extends AbstractDiffable<ClusterBlocks> {
|
||||||
|
|
||||||
private final ImmutableSet<ClusterBlock> global;
|
private final ImmutableSet<ClusterBlock> global;
|
||||||
|
|
||||||
private final ImmutableMap<String, ImmutableSet<ClusterBlock>> indicesBlocks;
|
private final Map<String, ImmutableSet<ClusterBlock>> indicesBlocks;
|
||||||
|
|
||||||
private final ImmutableLevelHolder[] levelHolders;
|
private final ImmutableLevelHolder[] levelHolders;
|
||||||
|
|
||||||
ClusterBlocks(ImmutableSet<ClusterBlock> global, ImmutableMap<String, ImmutableSet<ClusterBlock>> indicesBlocks) {
|
ClusterBlocks(ImmutableSet<ClusterBlock> global, Map<String, ImmutableSet<ClusterBlock>> indicesBlocks) {
|
||||||
this.global = global;
|
this.global = global;
|
||||||
this.indicesBlocks = indicesBlocks;
|
this.indicesBlocks = indicesBlocks;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class ClusterBlocks extends AbstractDiffable<ClusterBlocks> {
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<String, ImmutableSet<ClusterBlock>> indices() {
|
public Map<String, ImmutableSet<ClusterBlock>> indices() {
|
||||||
return indicesBlocks;
|
return indicesBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class ClusterBlocks extends AbstractDiffable<ClusterBlocks> {
|
||||||
return levelHolders[level.id()].global();
|
return levelHolders[level.id()].global();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<String, ImmutableSet<ClusterBlock>> indices(ClusterBlockLevel level) {
|
public Map<String, ImmutableSet<ClusterBlock>> indices(ClusterBlockLevel level) {
|
||||||
return levelHolders[level.id()].indices();
|
return levelHolders[level.id()].indices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class DiscoveryNode implements Streamable, ToXContent {
|
||||||
private String hostName;
|
private String hostName;
|
||||||
private String hostAddress;
|
private String hostAddress;
|
||||||
private TransportAddress address;
|
private TransportAddress address;
|
||||||
private ImmutableMap<String, String> attributes;
|
private Map<String, String> attributes;
|
||||||
private Version version = Version.CURRENT;
|
private Version version = Version.CURRENT;
|
||||||
|
|
||||||
DiscoveryNode() {
|
DiscoveryNode() {
|
||||||
|
@ -120,7 +120,7 @@ public class DiscoveryNode implements Streamable, ToXContent {
|
||||||
* @param version the version of the node.
|
* @param version the version of the node.
|
||||||
*/
|
*/
|
||||||
public DiscoveryNode(String nodeId, TransportAddress address, Version version) {
|
public DiscoveryNode(String nodeId, TransportAddress address, Version version) {
|
||||||
this("", nodeId, address, ImmutableMap.<String, String>of(), version);
|
this("", nodeId, address, Collections.emptyMap(), version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,14 +230,14 @@ public class DiscoveryNode implements Streamable, ToXContent {
|
||||||
/**
|
/**
|
||||||
* The node attributes.
|
* The node attributes.
|
||||||
*/
|
*/
|
||||||
public ImmutableMap<String, String> attributes() {
|
public Map<String, String> attributes() {
|
||||||
return this.attributes;
|
return this.attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The node attributes.
|
* The node attributes.
|
||||||
*/
|
*/
|
||||||
public ImmutableMap<String, String> getAttributes() {
|
public Map<String, String> getAttributes() {
|
||||||
return attributes();
|
return attributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.cluster.routing;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.IntSet;
|
import com.carrotsearch.hppc.IntSet;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.elasticsearch.cluster.Diff;
|
import org.elasticsearch.cluster.Diff;
|
||||||
import org.elasticsearch.cluster.Diffable;
|
import org.elasticsearch.cluster.Diffable;
|
||||||
import org.elasticsearch.cluster.DiffableUtils;
|
import org.elasticsearch.cluster.DiffableUtils;
|
||||||
|
@ -32,9 +33,16 @@ import org.elasticsearch.common.util.iterable.Iterables;
|
||||||
import org.elasticsearch.index.IndexNotFoundException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a global cluster-wide routing table for all indices including the
|
* Represents a global cluster-wide routing table for all indices including the
|
||||||
* version of the current routing state.
|
* version of the current routing state.
|
||||||
|
@ -50,11 +58,11 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
|
||||||
private final long version;
|
private final long version;
|
||||||
|
|
||||||
// index to IndexRoutingTable map
|
// index to IndexRoutingTable map
|
||||||
private final ImmutableMap<String, IndexRoutingTable> indicesRouting;
|
private final Map<String, IndexRoutingTable> indicesRouting;
|
||||||
|
|
||||||
RoutingTable(long version, Map<String, IndexRoutingTable> indicesRouting) {
|
RoutingTable(long version, Map<String, IndexRoutingTable> indicesRouting) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.indicesRouting = ImmutableMap.copyOf(indicesRouting);
|
this.indicesRouting = unmodifiableMap(indicesRouting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -304,7 +312,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
|
||||||
|
|
||||||
private final long version;
|
private final long version;
|
||||||
|
|
||||||
private final Diff<ImmutableMap<String, IndexRoutingTable>> indicesRouting;
|
private final Diff<Map<String, IndexRoutingTable>> indicesRouting;
|
||||||
|
|
||||||
public RoutingTableDiff(RoutingTable before, RoutingTable after) {
|
public RoutingTableDiff(RoutingTable before, RoutingTable after) {
|
||||||
version = after.version;
|
version = after.version;
|
||||||
|
@ -313,7 +321,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
|
||||||
|
|
||||||
public RoutingTableDiff(StreamInput in) throws IOException {
|
public RoutingTableDiff(StreamInput in) throws IOException {
|
||||||
version = in.readLong();
|
version = in.readLong();
|
||||||
indicesRouting = DiffableUtils.readImmutableMapDiff(in, IndexRoutingTable.PROTO);
|
indicesRouting = DiffableUtils.readJdkMapDiff(in, IndexRoutingTable.PROTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,7 +51,7 @@ public final class PrivateElementsImpl implements PrivateElements {
|
||||||
/**
|
/**
|
||||||
* lazily instantiated
|
* lazily instantiated
|
||||||
*/
|
*/
|
||||||
private ImmutableMap<Key<?>, Object> exposedKeysToSources;
|
private Map<Key<?>, Object> exposedKeysToSources;
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
||||||
public PrivateElementsImpl(Object source) {
|
public PrivateElementsImpl(Object source) {
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
|
||||||
public static final BlobStoreIndexShardSnapshots PROTO = new BlobStoreIndexShardSnapshots();
|
public static final BlobStoreIndexShardSnapshots PROTO = new BlobStoreIndexShardSnapshots();
|
||||||
|
|
||||||
private final List<SnapshotFiles> shardSnapshots;
|
private final List<SnapshotFiles> shardSnapshots;
|
||||||
private final ImmutableMap<String, FileInfo> files;
|
private final Map<String, FileInfo> files;
|
||||||
private final ImmutableMap<String, List<FileInfo>> physicalFiles;
|
private final Map<String, List<FileInfo>> physicalFiles;
|
||||||
|
|
||||||
public BlobStoreIndexShardSnapshots(List<SnapshotFiles> shardSnapshots) {
|
public BlobStoreIndexShardSnapshots(List<SnapshotFiles> shardSnapshots) {
|
||||||
this.shardSnapshots = Collections.unmodifiableList(new ArrayList<>(shardSnapshots));
|
this.shardSnapshots = Collections.unmodifiableList(new ArrayList<>(shardSnapshots));
|
||||||
|
@ -108,8 +108,8 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
|
||||||
|
|
||||||
private BlobStoreIndexShardSnapshots() {
|
private BlobStoreIndexShardSnapshots() {
|
||||||
shardSnapshots = Collections.emptyList();
|
shardSnapshots = Collections.emptyList();
|
||||||
files = ImmutableMap.of();
|
files = Collections.emptyMap();
|
||||||
physicalFiles = ImmutableMap.of();
|
physicalFiles = Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -737,7 +737,7 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref
|
||||||
|
|
||||||
public static final MetadataSnapshot EMPTY = new MetadataSnapshot();
|
public static final MetadataSnapshot EMPTY = new MetadataSnapshot();
|
||||||
|
|
||||||
private final ImmutableMap<String, String> commitUserData;
|
private final Map<String, String> commitUserData;
|
||||||
|
|
||||||
private final long numDocs;
|
private final long numDocs;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DeadlockAnalyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Set<LinkedHashSet<ThreadInfo>> calculateCycles(ImmutableMap<Long, ThreadInfo> threadInfoMap) {
|
private Set<LinkedHashSet<ThreadInfo>> calculateCycles(Map<Long, ThreadInfo> threadInfoMap) {
|
||||||
Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>();
|
Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>();
|
||||||
for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) {
|
for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) {
|
||||||
LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>();
|
LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.node.service;
|
package org.elasticsearch.node.service;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.elasticsearch.Build;
|
import org.elasticsearch.Build;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||||
|
@ -41,6 +42,7 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -101,7 +103,7 @@ public class NodeService extends AbstractComponent {
|
||||||
/**
|
/**
|
||||||
* Attributes different services in the node can add to be reported as part of the node info (for example).
|
* Attributes different services in the node can add to be reported as part of the node info (for example).
|
||||||
*/
|
*/
|
||||||
public ImmutableMap<String, String> attributes() {
|
public Map<String, String> attributes() {
|
||||||
return this.serviceAttributes;
|
return this.serviceAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class RepositoriesService extends AbstractComponent implements ClusterSta
|
||||||
|
|
||||||
private final VerifyNodeRepositoryAction verifyAction;
|
private final VerifyNodeRepositoryAction verifyAction;
|
||||||
|
|
||||||
private volatile ImmutableMap<String, RepositoryHolder> repositories = ImmutableMap.of();
|
private volatile Map<String, RepositoryHolder> repositories = ImmutableMap.of();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RepositoriesService(Settings settings, ClusterService clusterService, TransportService transportService, RepositoryTypesRegistry typesRegistry, Injector injector) {
|
public RepositoriesService(Settings settings, ClusterService clusterService, TransportService transportService, RepositoryTypesRegistry typesRegistry, Injector injector) {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.elasticsearch.rest.action.admin.indices.mapping.get;
|
package org.elasticsearch.rest.action.admin.indices.mapping.get;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
|
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
|
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData;
|
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData;
|
||||||
|
@ -29,7 +28,13 @@ import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.rest.*;
|
import org.elasticsearch.rest.BaseRestHandler;
|
||||||
|
import org.elasticsearch.rest.BytesRestResponse;
|
||||||
|
import org.elasticsearch.rest.RestChannel;
|
||||||
|
import org.elasticsearch.rest.RestController;
|
||||||
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
import org.elasticsearch.rest.RestResponse;
|
||||||
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.rest.action.support.RestBuilderListener;
|
import org.elasticsearch.rest.action.support.RestBuilderListener;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -64,11 +69,9 @@ public class RestGetFieldMappingAction extends BaseRestHandler {
|
||||||
getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
|
getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
|
||||||
getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
|
getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
|
||||||
client.admin().indices().getFieldMappings(getMappingsRequest, new RestBuilderListener<GetFieldMappingsResponse>(channel) {
|
client.admin().indices().getFieldMappings(getMappingsRequest, new RestBuilderListener<GetFieldMappingsResponse>(channel) {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public RestResponse buildResponse(GetFieldMappingsResponse response, XContentBuilder builder) throws Exception {
|
public RestResponse buildResponse(GetFieldMappingsResponse response, XContentBuilder builder) throws Exception {
|
||||||
ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappingsByIndex = response.mappings();
|
Map<String, Map<String, Map<String, FieldMappingMetaData>>> mappingsByIndex = response.mappings();
|
||||||
|
|
||||||
boolean isPossibleSingleFieldRequest = indices.length == 1 && types.length == 1 && fields.length == 1;
|
boolean isPossibleSingleFieldRequest = indices.length == 1 && types.length == 1 && fields.length == 1;
|
||||||
if (isPossibleSingleFieldRequest && isFieldMappingMissingField(mappingsByIndex)) {
|
if (isPossibleSingleFieldRequest && isFieldMappingMissingField(mappingsByIndex)) {
|
||||||
|
@ -91,13 +94,13 @@ public class RestGetFieldMappingAction extends BaseRestHandler {
|
||||||
* Helper method to find out if the only included fieldmapping metadata is typed NULL, which means
|
* Helper method to find out if the only included fieldmapping metadata is typed NULL, which means
|
||||||
* that type and index exist, but the field did not
|
* that type and index exist, but the field did not
|
||||||
*/
|
*/
|
||||||
private boolean isFieldMappingMissingField(ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappingsByIndex) throws IOException {
|
private boolean isFieldMappingMissingField(Map<String, Map<String, Map<String, FieldMappingMetaData>>> mappingsByIndex) throws IOException {
|
||||||
if (mappingsByIndex.size() != 1) {
|
if (mappingsByIndex.size() != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>> value : mappingsByIndex.values()) {
|
for (Map<String, Map<String, FieldMappingMetaData>> value : mappingsByIndex.values()) {
|
||||||
for (ImmutableMap<String, FieldMappingMetaData> fieldValue : value.values()) {
|
for (Map<String, FieldMappingMetaData> fieldValue : value.values()) {
|
||||||
for (Map.Entry<String, FieldMappingMetaData> fieldMappingMetaDataEntry : fieldValue.entrySet()) {
|
for (Map.Entry<String, FieldMappingMetaData> fieldMappingMetaDataEntry : fieldValue.entrySet()) {
|
||||||
if (fieldMappingMetaDataEntry.getValue().isNull()) {
|
if (fieldMappingMetaDataEntry.getValue().isNull()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.rest.action.cat;
|
package org.elasticsearch.rest.action.cat;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
|
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
|
||||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||||
|
@ -34,11 +33,16 @@ import org.elasticsearch.common.Table;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||||
import org.elasticsearch.rest.*;
|
import org.elasticsearch.rest.RestChannel;
|
||||||
|
import org.elasticsearch.rest.RestController;
|
||||||
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
import org.elasticsearch.rest.RestResponse;
|
||||||
import org.elasticsearch.rest.action.support.RestActionListener;
|
import org.elasticsearch.rest.action.support.RestActionListener;
|
||||||
import org.elasticsearch.rest.action.support.RestResponseListener;
|
import org.elasticsearch.rest.action.support.RestResponseListener;
|
||||||
import org.elasticsearch.rest.action.support.RestTable;
|
import org.elasticsearch.rest.action.support.RestTable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
||||||
|
|
||||||
public class RestNodeAttrsAction extends AbstractCatAction {
|
public class RestNodeAttrsAction extends AbstractCatAction {
|
||||||
|
@ -107,7 +111,7 @@ public class RestNodeAttrsAction extends AbstractCatAction {
|
||||||
|
|
||||||
for (DiscoveryNode node : nodes) {
|
for (DiscoveryNode node : nodes) {
|
||||||
NodeInfo info = nodesInfo.getNodesMap().get(node.id());
|
NodeInfo info = nodesInfo.getNodesMap().get(node.id());
|
||||||
ImmutableMap<String, String> attrs = node.getAttributes();
|
Map<String, String> attrs = node.getAttributes();
|
||||||
for(String att : attrs.keySet()) {
|
for(String att : attrs.keySet()) {
|
||||||
table.startRow();
|
table.startRow();
|
||||||
table.addCell(node.name());
|
table.addCell(node.name());
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class MatchedQueriesFetchSubPhase implements FetchSubPhase {
|
||||||
hitContext.hit().matchedQueries(matchedQueries.toArray(new String[matchedQueries.size()]));
|
hitContext.hit().matchedQueries(matchedQueries.toArray(new String[matchedQueries.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMatchedQueries(HitContext hitContext, ImmutableMap<String, Query> namedQueries, List<String> matchedQueries) throws IOException {
|
private void addMatchedQueries(HitContext hitContext, Map<String, Query> namedQueries, List<String> matchedQueries) throws IOException {
|
||||||
for (Map.Entry<String, Query> entry : namedQueries.entrySet()) {
|
for (Map.Entry<String, Query> entry : namedQueries.entrySet()) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
Query filter = entry.getValue();
|
Query filter = entry.getValue();
|
||||||
|
|
|
@ -19,12 +19,13 @@
|
||||||
|
|
||||||
package org.elasticsearch.search.lookup;
|
package org.elasticsearch.search.lookup;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
|
|
||||||
import org.apache.lucene.index.LeafReaderContext;
|
import org.apache.lucene.index.LeafReaderContext;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Per-segment version of {@link SearchLookup}.
|
* Per-segment version of {@link SearchLookup}.
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +36,7 @@ public class LeafSearchLookup {
|
||||||
final SourceLookup sourceLookup;
|
final SourceLookup sourceLookup;
|
||||||
final LeafFieldsLookup fieldsLookup;
|
final LeafFieldsLookup fieldsLookup;
|
||||||
final LeafIndexLookup indexLookup;
|
final LeafIndexLookup indexLookup;
|
||||||
final ImmutableMap<String, Object> asMap;
|
final Map<String, Object> asMap;
|
||||||
|
|
||||||
public LeafSearchLookup(LeafReaderContext ctx, LeafDocLookup docMap, SourceLookup sourceLookup,
|
public LeafSearchLookup(LeafReaderContext ctx, LeafDocLookup docMap, SourceLookup sourceLookup,
|
||||||
LeafFieldsLookup fieldsLookup, LeafIndexLookup indexLookup, Map<String, Object> topLevelMap) {
|
LeafFieldsLookup fieldsLookup, LeafIndexLookup indexLookup, Map<String, Object> topLevelMap) {
|
||||||
|
@ -45,17 +46,17 @@ public class LeafSearchLookup {
|
||||||
this.fieldsLookup = fieldsLookup;
|
this.fieldsLookup = fieldsLookup;
|
||||||
this.indexLookup = indexLookup;
|
this.indexLookup = indexLookup;
|
||||||
|
|
||||||
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
|
Map<String, Object> asMap = new HashMap<>(topLevelMap.size() + 5);
|
||||||
builder.putAll(topLevelMap);
|
asMap.putAll(topLevelMap);
|
||||||
builder.put("doc", docMap);
|
asMap.put("doc", docMap);
|
||||||
builder.put("_doc", docMap);
|
asMap.put("_doc", docMap);
|
||||||
builder.put("_source", sourceLookup);
|
asMap.put("_source", sourceLookup);
|
||||||
builder.put("_fields", fieldsLookup);
|
asMap.put("_fields", fieldsLookup);
|
||||||
builder.put("_index", indexLookup);
|
asMap.put("_index", indexLookup);
|
||||||
asMap = builder.build();
|
this.asMap = unmodifiableMap(asMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<String, Object> asMap() {
|
public Map<String, Object> asMap() {
|
||||||
return this.asMap;
|
return this.asMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent<SnapshotSh
|
||||||
|
|
||||||
private final Condition shutdownCondition = shutdownLock.newCondition();
|
private final Condition shutdownCondition = shutdownLock.newCondition();
|
||||||
|
|
||||||
private volatile ImmutableMap<SnapshotId, SnapshotShards> shardSnapshots = ImmutableMap.of();
|
private volatile Map<SnapshotId, SnapshotShards> shardSnapshots = ImmutableMap.of();
|
||||||
|
|
||||||
private final BlockingQueue<UpdateIndexShardSnapshotStatusRequest> updatedSnapshotStateQueue = ConcurrentCollections.newBlockingQueue();
|
private final BlockingQueue<UpdateIndexShardSnapshotStatusRequest> updatedSnapshotStateQueue = ConcurrentCollections.newBlockingQueue();
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent<SnapshotSh
|
||||||
if (snapshot.state() == SnapshotsInProgress.State.STARTED || snapshot.state() == SnapshotsInProgress.State.ABORTED) {
|
if (snapshot.state() == SnapshotsInProgress.State.STARTED || snapshot.state() == SnapshotsInProgress.State.ABORTED) {
|
||||||
Map<ShardId, IndexShardSnapshotStatus> localShards = currentSnapshotShards(snapshot.snapshotId());
|
Map<ShardId, IndexShardSnapshotStatus> localShards = currentSnapshotShards(snapshot.snapshotId());
|
||||||
if (localShards != null) {
|
if (localShards != null) {
|
||||||
ImmutableMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> masterShards = snapshot.shards();
|
Map<ShardId, SnapshotsInProgress.ShardSnapshotStatus> masterShards = snapshot.shards();
|
||||||
for(Map.Entry<ShardId, IndexShardSnapshotStatus> localShard : localShards.entrySet()) {
|
for(Map.Entry<ShardId, IndexShardSnapshotStatus> localShard : localShards.entrySet()) {
|
||||||
ShardId shardId = localShard.getKey();
|
ShardId shardId = localShard.getKey();
|
||||||
IndexShardSnapshotStatus localShardStatus = localShard.getValue();
|
IndexShardSnapshotStatus localShardStatus = localShard.getValue();
|
||||||
|
|
|
@ -596,7 +596,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
|
||||||
for (final SnapshotsInProgress.Entry snapshot : snapshots.entries()) {
|
for (final SnapshotsInProgress.Entry snapshot : snapshots.entries()) {
|
||||||
SnapshotsInProgress.Entry updatedSnapshot = snapshot;
|
SnapshotsInProgress.Entry updatedSnapshot = snapshot;
|
||||||
if (snapshot.state() == State.STARTED) {
|
if (snapshot.state() == State.STARTED) {
|
||||||
ImmutableMap<ShardId, ShardSnapshotStatus> shards = processWaitingShards(snapshot.shards(), routingTable);
|
Map<ShardId, ShardSnapshotStatus> shards = processWaitingShards(snapshot.shards(), routingTable);
|
||||||
if (shards != null) {
|
if (shards != null) {
|
||||||
changed = true;
|
changed = true;
|
||||||
if (!snapshot.state().completed() && completed(shards.values())) {
|
if (!snapshot.state().completed() && completed(shards.values())) {
|
||||||
|
@ -625,7 +625,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableMap<ShardId, ShardSnapshotStatus> processWaitingShards(ImmutableMap<ShardId, ShardSnapshotStatus> snapshotShards, RoutingTable routingTable) {
|
private Map<ShardId, ShardSnapshotStatus> processWaitingShards(Map<ShardId, ShardSnapshotStatus> snapshotShards, RoutingTable routingTable) {
|
||||||
boolean snapshotChanged = false;
|
boolean snapshotChanged = false;
|
||||||
ImmutableMap.Builder<ShardId, ShardSnapshotStatus> shards = ImmutableMap.builder();
|
ImmutableMap.Builder<ShardId, ShardSnapshotStatus> shards = ImmutableMap.builder();
|
||||||
for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> shardEntry : snapshotShards.entrySet()) {
|
for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> shardEntry : snapshotShards.entrySet()) {
|
||||||
|
@ -716,10 +716,10 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
|
||||||
* @param shards list of shard statuses
|
* @param shards list of shard statuses
|
||||||
* @return list of failed and closed indices
|
* @return list of failed and closed indices
|
||||||
*/
|
*/
|
||||||
private Tuple<Set<String>, Set<String>> indicesWithMissingShards(ImmutableMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards, MetaData metaData) {
|
private Tuple<Set<String>, Set<String>> indicesWithMissingShards(Map<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards, MetaData metaData) {
|
||||||
Set<String> missing = new HashSet<>();
|
Set<String> missing = new HashSet<>();
|
||||||
Set<String> closed = new HashSet<>();
|
Set<String> closed = new HashSet<>();
|
||||||
for (ImmutableMap.Entry<ShardId, SnapshotsInProgress.ShardSnapshotStatus> entry : shards.entrySet()) {
|
for (Map.Entry<ShardId, SnapshotsInProgress.ShardSnapshotStatus> entry : shards.entrySet()) {
|
||||||
if (entry.getValue().state() == State.MISSING) {
|
if (entry.getValue().state() == State.MISSING) {
|
||||||
if (metaData.hasIndex(entry.getKey().getIndex()) && metaData.index(entry.getKey().getIndex()).getState() == IndexMetaData.State.CLOSE) {
|
if (metaData.hasIndex(entry.getKey().getIndex()) && metaData.index(entry.getKey().getIndex()).getState() == IndexMetaData.State.CLOSE) {
|
||||||
closed.add(entry.getKey().getIndex());
|
closed.add(entry.getKey().getIndex());
|
||||||
|
@ -864,7 +864,7 @@ public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsServic
|
||||||
} else {
|
} else {
|
||||||
// This snapshot is currently running - stopping shards first
|
// This snapshot is currently running - stopping shards first
|
||||||
waitForSnapshot = true;
|
waitForSnapshot = true;
|
||||||
ImmutableMap<ShardId, ShardSnapshotStatus> shards;
|
Map<ShardId, ShardSnapshotStatus> shards;
|
||||||
if (snapshot.state() == State.STARTED && snapshot.shards() != null) {
|
if (snapshot.state() == State.STARTED && snapshot.shards() != null) {
|
||||||
// snapshot is currently running - stop started shards
|
// snapshot is currently running - stop started shards
|
||||||
ImmutableMap.Builder<ShardId, ShardSnapshotStatus> shardsBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<ShardId, ShardSnapshotStatus> shardsBuilder = ImmutableMap.builder();
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
|
|
||||||
private volatile ImmutableMap<String, ExecutorHolder> executors;
|
private volatile ImmutableMap<String, ExecutorHolder> executors;
|
||||||
|
|
||||||
private final ImmutableMap<String, Settings> defaultExecutorTypeSettings;
|
private final Map<String, Settings> defaultExecutorTypeSettings;
|
||||||
|
|
||||||
private final Queue<ExecutorHolder> retiredExecutors = new ConcurrentLinkedQueue<>();
|
private final Queue<ExecutorHolder> retiredExecutors = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
|
||||||
protected final Transport transport;
|
protected final Transport transport;
|
||||||
protected final ThreadPool threadPool;
|
protected final ThreadPool threadPool;
|
||||||
|
|
||||||
volatile ImmutableMap<String, RequestHandlerRegistry> requestHandlers = ImmutableMap.of();
|
volatile Map<String, RequestHandlerRegistry> requestHandlers = Collections.emptyMap();
|
||||||
final Object requestHandlerMutex = new Object();
|
final Object requestHandlerMutex = new Object();
|
||||||
|
|
||||||
final ConcurrentMapLong<RequestHolder> clientHandlers = ConcurrentCollections.newConcurrentMapLongWithAggressiveConcurrency();
|
final ConcurrentMapLong<RequestHolder> clientHandlers = ConcurrentCollections.newConcurrentMapLongWithAggressiveConcurrency();
|
||||||
|
|
|
@ -19,17 +19,22 @@
|
||||||
|
|
||||||
package org.elasticsearch.benchmark.common.recycler;
|
package org.elasticsearch.benchmark.common.recycler;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.common.recycler.AbstractRecyclerC;
|
import org.elasticsearch.common.recycler.AbstractRecyclerC;
|
||||||
import org.elasticsearch.common.recycler.Recycler;
|
import org.elasticsearch.common.recycler.Recycler;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import static org.elasticsearch.common.recycler.Recyclers.*;
|
import static org.elasticsearch.common.recycler.Recyclers.concurrent;
|
||||||
|
import static org.elasticsearch.common.recycler.Recyclers.concurrentDeque;
|
||||||
|
import static org.elasticsearch.common.recycler.Recyclers.deque;
|
||||||
|
import static org.elasticsearch.common.recycler.Recyclers.dequeFactory;
|
||||||
|
import static org.elasticsearch.common.recycler.Recyclers.locked;
|
||||||
|
import static org.elasticsearch.common.recycler.Recyclers.none;
|
||||||
|
|
||||||
/** Benchmark that tries to measure the overhead of object recycling depending on concurrent access. */
|
/** Benchmark that tries to measure the overhead of object recycling depending on concurrent access. */
|
||||||
public class RecyclerBenchmark {
|
public class RecyclerBenchmark {
|
||||||
|
@ -89,11 +94,11 @@ public class RecyclerBenchmark {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final ImmutableMap<String, Recycler<Object>> recyclers = ImmutableMap.<String, Recycler<Object>>builder()
|
Map<String, Recycler<Object>> recyclers = new HashMap<>();
|
||||||
.put("none", none(c))
|
recyclers.put("none", none(c));
|
||||||
.put("concurrent-queue", concurrentDeque(c, limit))
|
recyclers.put("concurrent-queue", concurrentDeque(c, limit));
|
||||||
.put("locked", locked(deque(c, limit)))
|
recyclers.put("locked", locked(deque(c, limit)));
|
||||||
.put("concurrent", concurrent(dequeFactory(c, limit), Runtime.getRuntime().availableProcessors())).build();
|
recyclers.put("concurrent", concurrent(dequeFactory(c, limit), Runtime.getRuntime().availableProcessors()));
|
||||||
|
|
||||||
// warmup
|
// warmup
|
||||||
final long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
|
|
|
@ -41,7 +41,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
public class DiffableTests extends ESTestCase {
|
public class DiffableTests extends ESTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testImmutableMapDiff() throws IOException {
|
public void testJdkMapDiff() throws IOException {
|
||||||
ImmutableMap.Builder<String, TestDiffable> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<String, TestDiffable> builder = ImmutableMap.builder();
|
||||||
builder.put("foo", new TestDiffable("1"));
|
builder.put("foo", new TestDiffable("1"));
|
||||||
builder.put("bar", new TestDiffable("2"));
|
builder.put("bar", new TestDiffable("2"));
|
||||||
|
@ -57,7 +57,7 @@ public class DiffableTests extends ESTestCase {
|
||||||
BytesStreamOutput out = new BytesStreamOutput();
|
BytesStreamOutput out = new BytesStreamOutput();
|
||||||
diff.writeTo(out);
|
diff.writeTo(out);
|
||||||
StreamInput in = StreamInput.wrap(out.bytes());
|
StreamInput in = StreamInput.wrap(out.bytes());
|
||||||
ImmutableMap<String, TestDiffable> serialized = DiffableUtils.readImmutableMapDiff(in, TestDiffable.PROTO).apply(before);
|
Map<String, TestDiffable> serialized = DiffableUtils.readJdkMapDiff(in, TestDiffable.PROTO).apply(before);
|
||||||
assertThat(serialized.size(), equalTo(3));
|
assertThat(serialized.size(), equalTo(3));
|
||||||
assertThat(serialized.get("foo").value(), equalTo("1"));
|
assertThat(serialized.get("foo").value(), equalTo("1"));
|
||||||
assertThat(serialized.get("baz").value(), equalTo("4"));
|
assertThat(serialized.get("baz").value(), equalTo("4"));
|
||||||
|
|
|
@ -127,6 +127,7 @@ com.google.common.collect.HashMultimap
|
||||||
com.google.common.collect.FluentIterable
|
com.google.common.collect.FluentIterable
|
||||||
com.google.common.io.Files
|
com.google.common.io.Files
|
||||||
com.google.common.primitives.Ints
|
com.google.common.primitives.Ints
|
||||||
|
com.google.common.collect.ImmutableMap#entrySet()
|
||||||
|
|
||||||
@defaultMessage Do not violate java's access system
|
@defaultMessage Do not violate java's access system
|
||||||
java.lang.reflect.AccessibleObject#setAccessible(boolean)
|
java.lang.reflect.AccessibleObject#setAccessible(boolean)
|
||||||
|
|
Loading…
Reference in New Issue