Skip to content

Commit

Permalink
Blob store-based gateways shouldn't serialize transient metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
imotov committed Apr 14, 2014
1 parent bcdd430 commit 6aee50e
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -21,6 +21,7 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
Expand All @@ -43,6 +44,7 @@

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
*
Expand All @@ -61,8 +63,13 @@ public abstract class BlobStoreGateway extends SharedStorageGateway {

private volatile int currentIndex;

private final ToXContent.Params persistentOnlyFormatParams;

protected BlobStoreGateway(Settings settings, ThreadPool threadPool, ClusterService clusterService, ClusterName clusterName) {
super(settings, threadPool, clusterService, clusterName);
Map<String, String> persistentOnlyParams = Maps.newHashMap();
persistentOnlyParams.put(MetaData.PERSISTENT_ONLY_PARAM, "true");
persistentOnlyFormatParams = new ToXContent.MapParams(persistentOnlyParams);
}

protected void initialize(BlobStore blobStore, ClusterName clusterName, @Nullable ByteSizeValue defaultChunkSize) throws IOException {
Expand Down Expand Up @@ -158,7 +165,7 @@ public void write(MetaData metaData) throws GatewayException {
}
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
builder.startObject();
MetaData.Builder.toXContent(metaData, builder, ToXContent.EMPTY_PARAMS);
MetaData.Builder.toXContent(metaData, builder, persistentOnlyFormatParams);
builder.endObject();
builder.close();
metaDataBlobContainer.writeBlob(newMetaData, bStream.bytes().streamInput(), bStream.bytes().length());
Expand Down

0 comments on commit 6aee50e

Please sign in to comment.