Separate persistent and global metadata serialization settings

This commit is contained in:
Igor Motov 2014-03-31 14:26:45 -04:00
parent 27d4d76769
commit 2ed8c632be
3 changed files with 14 additions and 8 deletions

View File

@ -115,7 +115,9 @@ public class MetaData implements Iterable<IndexMetaData> {
public static final MetaData EMPTY_META_DATA = builder().build();
public static final String GLOBAL_PERSISTENT_ONLY_PARAM = "global_persistent_only";
public static final String GLOBAL_ONLY_PARAM = "global_only";
public static final String PERSISTENT_ONLY_PARAM = "persistent_only";
private final String uuid;
private final long version;
@ -1231,7 +1233,8 @@ public class MetaData implements Iterable<IndexMetaData> {
}
public static void toXContent(MetaData metaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
boolean globalPersistentOnly = params.paramAsBoolean(GLOBAL_PERSISTENT_ONLY_PARAM, false);
boolean globalOnly = params.paramAsBoolean(GLOBAL_ONLY_PARAM, false);
boolean persistentOnly = params.paramAsBoolean(PERSISTENT_ONLY_PARAM, false);
builder.startObject("meta-data");
builder.field("version", metaData.version());
@ -1245,7 +1248,7 @@ public class MetaData implements Iterable<IndexMetaData> {
builder.endObject();
}
if (!globalPersistentOnly && !metaData.transientSettings().getAsMap().isEmpty()) {
if (!persistentOnly && !metaData.transientSettings().getAsMap().isEmpty()) {
builder.startObject("transient_settings");
for (Map.Entry<String, String> entry : metaData.transientSettings().getAsMap().entrySet()) {
builder.field(entry.getKey(), entry.getValue());
@ -1259,7 +1262,7 @@ public class MetaData implements Iterable<IndexMetaData> {
}
builder.endObject();
if (!globalPersistentOnly && !metaData.indices().isEmpty()) {
if (!globalOnly && !metaData.indices().isEmpty()) {
builder.startObject("indices");
for (IndexMetaData indexMetaData : metaData) {
IndexMetaData.Builder.toXContent(indexMetaData, builder, params);
@ -1269,7 +1272,7 @@ public class MetaData implements Iterable<IndexMetaData> {
for (ObjectObjectCursor<String, Custom> cursor : metaData.customs()) {
Custom.Factory factory = lookupFactorySafe(cursor.key);
if (!globalPersistentOnly || factory.isPersistent()) {
if (!persistentOnly || factory.isPersistent()) {
builder.startObject(cursor.key);
factory.toXContent(cursor.value, builder, params);
builder.endObject();

View File

@ -132,12 +132,14 @@ public class LocalGatewayMetaState extends AbstractComponent implements ClusterS
formatParams = new ToXContent.MapParams(params);
Map<String, String> globalOnlyParams = Maps.newHashMap();
globalOnlyParams.put("binary", "true");
globalOnlyParams.put(MetaData.GLOBAL_PERSISTENT_ONLY_PARAM, "true");
globalOnlyParams.put(MetaData.PERSISTENT_ONLY_PARAM, "true");
globalOnlyParams.put(MetaData.GLOBAL_ONLY_PARAM, "true");
globalOnlyFormatParams = new ToXContent.MapParams(globalOnlyParams);
} else {
formatParams = ToXContent.EMPTY_PARAMS;
Map<String, String> globalOnlyParams = Maps.newHashMap();
globalOnlyParams.put(MetaData.GLOBAL_PERSISTENT_ONLY_PARAM, "true");
globalOnlyParams.put(MetaData.PERSISTENT_ONLY_PARAM, "true");
globalOnlyParams.put(MetaData.GLOBAL_ONLY_PARAM, "true");
globalOnlyFormatParams = new ToXContent.MapParams(globalOnlyParams);
}

View File

@ -137,7 +137,8 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent<Rep
this.repositoryName = repositoryName;
this.indexShardRepository = (BlobStoreIndexShardRepository) indexShardRepository;
Map<String, String> globalOnlyParams = Maps.newHashMap();
globalOnlyParams.put(MetaData.GLOBAL_PERSISTENT_ONLY_PARAM, "true");
globalOnlyParams.put(MetaData.PERSISTENT_ONLY_PARAM, "true");
globalOnlyParams.put(MetaData.GLOBAL_ONLY_PARAM, "true");
globalOnlyFormatParams = new ToXContent.MapParams(globalOnlyParams);
snapshotRateLimiter = getRateLimiter(repositorySettings, "max_snapshot_bytes_per_sec", new ByteSizeValue(20, ByteSizeUnit.MB));
restoreRateLimiter = getRateLimiter(repositorySettings, "max_restore_bytes_per_sec", new ByteSizeValue(20, ByteSizeUnit.MB));