remove global settings from the settings conf, a relic that is no longer needed...
This commit is contained in:
parent
dddca692b8
commit
fe3f5d45de
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<IndexMetaData> {
|
|||
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<IndexMetaData> {
|
|||
} 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<IndexMetaData> {
|
|||
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++) {
|
||||
|
|
|
@ -59,20 +59,13 @@ public class ImmutableSettings implements Settings {
|
|||
|
||||
private Map<String, String> settings;
|
||||
|
||||
private Settings globalSettings;
|
||||
|
||||
private transient ClassLoader classLoader;
|
||||
|
||||
private ImmutableSettings(Map<String, String> settings, Settings globalSettings, ClassLoader classLoader) {
|
||||
private ImmutableSettings(Map<String, String> 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<String, Settings> retVal = new LinkedHashMap<String, Settings>();
|
||||
for (Map.Entry<String, Map<String, String>> 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 <tt>prefix</tt>.
|
||||
*
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,17 +32,12 @@ import java.util.Map;
|
|||
* <p>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 <tt>org.elasticsearch<tt> prefix.
|
||||
|
|
|
@ -227,7 +227,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> 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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -442,7 +442,7 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> 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<Gateway> 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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,6 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
|
|||
.put(this.settings)
|
||||
.put(settings)
|
||||
.classLoader(settings.getClassLoader())
|
||||
.globalSettings(settings.getGlobalSettings())
|
||||
.build();
|
||||
|
||||
ModulesBuilder modules = new ModulesBuilder();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ToAndFromJsonMetaDataTests {
|
|||
String metaDataSource = MetaData.Builder.toXContent(metaData);
|
||||
System.out.println("ToJson: " + metaDataSource);
|
||||
|
||||
MetaData parsedMetaData = MetaData.Builder.fromXContent(XContentFactory.xContent(XContentType.JSON).createParser(metaDataSource), null);
|
||||
MetaData parsedMetaData = MetaData.Builder.fromXContent(XContentFactory.xContent(XContentType.JSON).createParser(metaDataSource));
|
||||
|
||||
IndexMetaData indexMetaData = parsedMetaData.index("test1");
|
||||
assertThat(indexMetaData.numberOfShards(), equalTo(1));
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.cluster.routing.RoutingTable;
|
|||
import org.elasticsearch.cluster.routing.allocation.ShardsAllocation;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamInput;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.transport.DummyTransportAddress;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -59,7 +58,7 @@ public class ClusterSerializationTests {
|
|||
ShardsAllocation strategy = new ShardsAllocation();
|
||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(strategy.reroute(clusterState).routingTable()).build();
|
||||
|
||||
ClusterState serializedClusterState = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), ImmutableSettings.settingsBuilder().build(), newNode("node1"));
|
||||
ClusterState serializedClusterState = ClusterState.Builder.fromBytes(ClusterState.Builder.toBytes(clusterState), newNode("node1"));
|
||||
|
||||
assertThat(serializedClusterState.routingTable().prettyPrint(), equalTo(clusterState.routingTable().prettyPrint()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue