diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java index 7871242fd83..524e4fd3ee8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java @@ -62,7 +62,7 @@ public class ClusterStateResponse implements ActionResponse { @Override public void readFrom(StreamInput in) throws IOException { clusterName = ClusterName.readClusterName(in); - clusterState = ClusterState.Builder.readFrom(in, null, null); + clusterState = ClusterState.Builder.readFrom(in, null); } @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/ClusterState.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/ClusterState.java index 55caa39aa2e..7e1ebc325fc 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -28,7 +28,6 @@ import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.allocation.AllocationExplanation; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.common.io.stream.*; -import org.elasticsearch.common.settings.Settings; import javax.annotation.Nullable; import java.io.IOException; @@ -228,8 +227,8 @@ public class ClusterState { return os.copiedByteArray(); } - public static ClusterState fromBytes(byte[] data, Settings globalSettings, DiscoveryNode localNode) throws IOException { - return readFrom(new BytesStreamInput(data), globalSettings, localNode); + public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode) throws IOException { + return readFrom(new BytesStreamInput(data), localNode); } public static void writeTo(ClusterState state, StreamOutput out) throws IOException { @@ -241,10 +240,10 @@ public class ClusterState { state.allocationExplanation().writeTo(out); } - public static ClusterState readFrom(StreamInput in, @Nullable Settings globalSettings, @Nullable DiscoveryNode localNode) throws IOException { + public static ClusterState readFrom(StreamInput in, @Nullable DiscoveryNode localNode) throws IOException { Builder builder = new Builder(); builder.version = in.readLong(); - builder.metaData = MetaData.Builder.readFrom(in, globalSettings); + builder.metaData = MetaData.Builder.readFrom(in); builder.routingTable = RoutingTable.Builder.readFrom(in); builder.nodes = DiscoveryNodes.Builder.readFrom(in, localNode); builder.blocks = ClusterBlocks.Builder.readClusterBlocks(in); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java index f9a4e5ef805..88a850d8afc 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java @@ -35,7 +35,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; -import javax.annotation.Nullable; import java.io.IOException; import java.util.Map; @@ -284,7 +283,7 @@ public class IndexMetaData { builder.endObject(); } - public static IndexMetaData fromXContent(XContentParser parser, @Nullable Settings globalSettings) throws IOException { + public static IndexMetaData fromXContent(XContentParser parser) throws IOException { Builder builder = new Builder(parser.currentName()); String currentFieldName = null; @@ -294,7 +293,7 @@ public class IndexMetaData { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { if ("settings".equals(currentFieldName)) { - ImmutableSettings.Builder settingsBuilder = settingsBuilder().globalSettings(globalSettings); + ImmutableSettings.Builder settingsBuilder = settingsBuilder(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { String key = parser.currentName(); token = parser.nextToken(); @@ -326,10 +325,10 @@ public class IndexMetaData { return builder.build(); } - public static IndexMetaData readFrom(StreamInput in, Settings globalSettings) throws IOException { + public static IndexMetaData readFrom(StreamInput in) throws IOException { Builder builder = new Builder(in.readUTF()); builder.state(State.fromId(in.readByte())); - builder.settings(readSettingsFromStream(in, globalSettings)); + builder.settings(readSettingsFromStream(in)); int mappingsSize = in.readVInt(); for (int i = 0; i < mappingsSize; i++) { MappingMetaData mappingMd = MappingMetaData.readFrom(in); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java index 09e8a07f521..ba0bd8299fd 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java @@ -23,13 +23,11 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.collect.*; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.Immutable; import org.elasticsearch.common.xcontent.*; import org.elasticsearch.index.Index; import org.elasticsearch.indices.IndexMissingException; -import javax.annotation.Nullable; import java.io.IOException; import java.util.*; @@ -340,7 +338,7 @@ public class MetaData implements Iterable { builder.endObject(); } - public static MetaData fromXContent(XContentParser parser, @Nullable Settings globalSettings) throws IOException { + public static MetaData fromXContent(XContentParser parser) throws IOException { Builder builder = new Builder(); XContentParser.Token token = parser.currentToken(); @@ -360,7 +358,7 @@ public class MetaData implements Iterable { } else if (token == XContentParser.Token.START_OBJECT) { if ("indices".equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { - builder.put(IndexMetaData.Builder.fromXContent(parser, globalSettings)); + builder.put(IndexMetaData.Builder.fromXContent(parser)); } } else if ("templates".equals(currentFieldName)) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { @@ -372,13 +370,13 @@ public class MetaData implements Iterable { return builder.build(); } - public static MetaData readFrom(StreamInput in, @Nullable Settings globalSettings) throws IOException { + public static MetaData readFrom(StreamInput in) throws IOException { Builder builder = new Builder(); // we only serialize it using readFrom, not in to/from XContent builder.recoveredFromGateway = in.readBoolean(); int size = in.readVInt(); for (int i = 0; i < size; i++) { - builder.put(IndexMetaData.Builder.readFrom(in, globalSettings)); + builder.put(IndexMetaData.Builder.readFrom(in)); } size = in.readVInt(); for (int i = 0; i < size; i++) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java index 54f4a62204c..b503cf171ed 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java @@ -59,20 +59,13 @@ public class ImmutableSettings implements Settings { private Map settings; - private Settings globalSettings; - private transient ClassLoader classLoader; - private ImmutableSettings(Map settings, Settings globalSettings, ClassLoader classLoader) { + private ImmutableSettings(Map settings, ClassLoader classLoader) { this.settings = settings; - this.globalSettings = globalSettings == null ? this : globalSettings; this.classLoader = classLoader == null ? buildClassLoader() : classLoader; } - @Override public Settings getGlobalSettings() { - return this.globalSettings; - } - @Override public ClassLoader getClassLoader() { return this.classLoader; } @@ -106,7 +99,6 @@ public class ImmutableSettings implements Settings { builder.put(entry.getKey().substring(prefix.length()), entry.getValue()); } } - builder.globalSettings(this); builder.classLoader(classLoader); return builder.build(); } @@ -277,7 +269,7 @@ public class ImmutableSettings implements Settings { } Map retVal = new LinkedHashMap(); for (Map.Entry> entry : map.entrySet()) { - retVal.put(entry.getKey(), new ImmutableSettings(Collections.unmodifiableMap(entry.getValue()), globalSettings, classLoader)); + retVal.put(entry.getKey(), new ImmutableSettings(Collections.unmodifiableMap(entry.getValue()), classLoader)); } return Collections.unmodifiableMap(retVal); } @@ -290,8 +282,6 @@ public class ImmutableSettings implements Settings { ImmutableSettings that = (ImmutableSettings) o; if (classLoader != null ? !classLoader.equals(that.classLoader) : that.classLoader != null) return false; - if (globalSettings != null ? !globalSettings.equals(that.globalSettings) : that.globalSettings != null) - return false; if (settings != null ? !settings.equals(that.settings) : that.settings != null) return false; return true; @@ -300,7 +290,6 @@ public class ImmutableSettings implements Settings { @Override public int hashCode() { int result = settings != null ? settings.hashCode() : 0; - result = 31 * result + (globalSettings != null ? globalSettings.hashCode() : 0); result = 31 * result + (classLoader != null ? classLoader.hashCode() : 0); return result; } @@ -310,16 +299,11 @@ public class ImmutableSettings implements Settings { } public static Settings readSettingsFromStream(StreamInput in) throws IOException { - return readSettingsFromStream(in, null); - } - - public static Settings readSettingsFromStream(StreamInput in, Settings globalSettings) throws IOException { Builder builder = new Builder(); int numberOfSettings = in.readVInt(); for (int i = 0; i < numberOfSettings; i++) { builder.put(in.readUTF(), in.readUTF()); } - builder.globalSettings(globalSettings); return builder.build(); } @@ -351,8 +335,6 @@ public class ImmutableSettings implements Settings { private ClassLoader classLoader; - private Settings globalSettings; - private Builder() { } @@ -614,14 +596,6 @@ public class ImmutableSettings implements Settings { return this; } - /** - * Sets the global settings associated with the settings built. - */ - public Builder globalSettings(Settings globalSettings) { - this.globalSettings = globalSettings; - return this; - } - /** * Puts all the properties with keys starting with the provided prefix. * @@ -674,9 +648,7 @@ public class ImmutableSettings implements Settings { * set on this builder. */ public Settings build() { - return new ImmutableSettings( - Collections.unmodifiableMap(map), - globalSettings, classLoader); + return new ImmutableSettings(Collections.unmodifiableMap(map), classLoader); } } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/Settings.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/Settings.java index 7a2b76ed969..80b49775cb1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -32,17 +32,12 @@ import java.util.Map; *

Using {@link ImmutableSettings#settingsBuilder()} in order to create a builder * which in turn can create an immutable implementation of settings. * - * @author kimchy (Shay Banon) + * @author kimchy (shay.banon) * @see ImmutableSettings */ @ThreadSafe public interface Settings { - /** - * The global settings if these settings are group settings. - */ - Settings getGlobalSettings(); - /** * Component settings for a specific component. Returns all the settings for the given class, where the * FQN of the class is used, without the org.elasticsearch prefix. diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index b54bf9f917a..14d5f708714 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -227,7 +227,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem if (discovery.master) { continue; } - final ClusterState nodeSpecificClusterState = ClusterState.Builder.fromBytes(clusterStateBytes, discovery.settings, discovery.localNode); + final ClusterState nodeSpecificClusterState = ClusterState.Builder.fromBytes(clusterStateBytes, discovery.localNode); // ignore cluster state messages that do not include "me", not in the game yet... if (nodeSpecificClusterState.nodes().localNode() != null) { discovery.clusterService.submitStateUpdateTask("local-disco-receive(from master)", new ProcessedClusterStateUpdateTask() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java index 31c62a797b3..68bef312562 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/membership/MembershipAction.java @@ -124,7 +124,7 @@ public class MembershipAction extends AbstractComponent { } @Override public void readFrom(StreamInput in) throws IOException { - clusterState = ClusterState.Builder.readFrom(in, settings, nodesProvider.nodes().localNode()); + clusterState = ClusterState.Builder.readFrom(in, nodesProvider.nodes().localNode()); } @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java index 4cc2c950daa..482932b2a91 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java @@ -87,7 +87,7 @@ public class PublishClusterStateAction extends AbstractComponent { } @Override public void readFrom(StreamInput in) throws IOException { - clusterState = ClusterState.Builder.readFrom(in, settings, nodesProvider.nodes().localNode()); + clusterState = ClusterState.Builder.readFrom(in, nodesProvider.nodes().localNode()); } @Override public void writeTo(StreamOutput out) throws IOException { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java index 95341f9caea..c300dff7d34 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/blobstore/BlobStoreGateway.java @@ -192,7 +192,7 @@ public abstract class BlobStoreGateway extends SharedStorageGateway { XContentParser parser = null; try { parser = XContentFactory.xContent(XContentType.JSON).createParser(data); - return MetaData.Builder.fromXContent(parser, settings); + return MetaData.Builder.fromXContent(parser); } finally { if (parser != null) { parser.close(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java index 4cecfdd28d6..705aa40f96b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java @@ -442,7 +442,7 @@ public class LocalGateway extends AbstractLifecycleComponent implements XContentParser parser = null; try { parser = XContentFactory.xContent(XContentType.JSON).createParser(data); - return LocalGatewayMetaState.Builder.fromXContent(parser, settings); + return LocalGatewayMetaState.Builder.fromXContent(parser); } finally { if (parser != null) { parser.close(); @@ -454,7 +454,7 @@ public class LocalGateway extends AbstractLifecycleComponent implements XContentParser parser = null; try { parser = XContentFactory.xContent(XContentType.JSON).createParser(data); - return LocalGatewayStartedShards.Builder.fromXContent(parser, settings); + return LocalGatewayStartedShards.Builder.fromXContent(parser); } finally { if (parser != null) { parser.close(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java index 27904c8caa8..9314ba81b06 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayMetaState.java @@ -22,12 +22,10 @@ package org.elasticsearch.gateway.local; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import javax.annotation.Nullable; import java.io.IOException; /** @@ -91,7 +89,7 @@ public class LocalGatewayMetaState { builder.endObject(); } - public static LocalGatewayMetaState fromXContent(XContentParser parser, @Nullable Settings globalSettings) throws IOException { + public static LocalGatewayMetaState fromXContent(XContentParser parser) throws IOException { Builder builder = new Builder(); String currentFieldName = null; @@ -105,7 +103,7 @@ public class LocalGatewayMetaState { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { if ("meta-data".equals(currentFieldName)) { - builder.metaData = MetaData.Builder.fromXContent(parser, globalSettings); + builder.metaData = MetaData.Builder.fromXContent(parser); } } else if (token.isValue()) { if ("version".equals(currentFieldName)) { @@ -117,10 +115,10 @@ public class LocalGatewayMetaState { return builder.build(); } - public static LocalGatewayMetaState readFrom(StreamInput in, @Nullable Settings globalSettings) throws IOException { + public static LocalGatewayMetaState readFrom(StreamInput in) throws IOException { LocalGatewayMetaState.Builder builder = new Builder(); builder.version = in.readLong(); - builder.metaData = MetaData.Builder.readFrom(in, globalSettings); + builder.metaData = MetaData.Builder.readFrom(in); return builder.build(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java index f2400bbcda9..4ee4106732e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGatewayStartedShards.java @@ -23,13 +23,11 @@ import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.shard.ShardId; -import javax.annotation.Nullable; import java.io.IOException; import java.util.Map; @@ -126,7 +124,7 @@ public class LocalGatewayStartedShards { builder.endObject(); } - public static LocalGatewayStartedShards fromXContent(XContentParser parser, @Nullable Settings globalSettings) throws IOException { + public static LocalGatewayStartedShards fromXContent(XContentParser parser) throws IOException { Builder builder = new Builder(); String currentFieldName = null; @@ -172,7 +170,7 @@ public class LocalGatewayStartedShards { return builder.build(); } - public static LocalGatewayStartedShards readFrom(StreamInput in, @Nullable Settings globalSettings) throws IOException { + public static LocalGatewayStartedShards readFrom(StreamInput in) throws IOException { LocalGatewayStartedShards.Builder builder = new Builder(); builder.version = in.readLong(); int size = in.readVInt(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java index 3b1999461db..739539a14bb 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayMetaState.java @@ -203,7 +203,7 @@ public class TransportNodesListGatewayMetaState extends TransportNodesOperationA @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.readBoolean()) { - state = LocalGatewayMetaState.Builder.readFrom(in, null); + state = LocalGatewayMetaState.Builder.readFrom(in); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java index 3bd88561f7e..44bedcb7962 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/TransportNodesListGatewayStartedShards.java @@ -203,7 +203,7 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesOperat @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.readBoolean()) { - state = LocalGatewayStartedShards.Builder.readFrom(in, null); + state = LocalGatewayStartedShards.Builder.readFrom(in); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java index 9d7f98053d2..a0ed4226e61 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java @@ -214,7 +214,6 @@ public class InternalIndicesService extends AbstractLifecycleComponent