Skip to content

Commit f945417

Browse files
committed
Remove deprecated method
Signed-off-by: Varun Bansal <bansvaru@amazon.com>
1 parent abe7755 commit f945417

5 files changed

Lines changed: 11 additions & 39 deletions

File tree

server/src/main/java/org/opensearch/common/metadata/MetadataContentParser.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.apache.lucene.store.IndexOutput;
1313

1414
import java.io.IOException;
15-
import java.util.Map;
1615

1716
/**
1817
* Parser interface for Metadata. Holds methods to convert to/from file content streams to metadata object holder - {@link T}
@@ -31,15 +30,4 @@ public interface MetadataContentParser<T> {
3130
* @param indexOutput metadata file input stream
3231
*/
3332
void writeContent(IndexOutput indexOutput, T content) throws IOException;
34-
35-
/**
36-
* Implements logic to write metadata content from {@code content} to metadata file output stream {@code indexOutput}
37-
* This method only supports metadata content in the form {@code Map<String, String>} to support RemoteSegment store metadata content.
38-
* @param indexOutput metadata file input stream
39-
* @param content metadata content
40-
*
41-
* TODO - This will removed in future releases and only {@link #writeContent(IndexOutput, Object)} should be used.
42-
*/
43-
@Deprecated
44-
void writeContent(IndexOutput indexOutput, Map<String, String> content) throws IOException;
4533
}

server/src/main/java/org/opensearch/common/metadata/MetadataParser.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.opensearch.common.metadata;
1010

1111
import java.io.IOException;
12-
import java.util.Map;
1312

1413
import org.apache.lucene.codecs.CodecUtil;
1514
import org.apache.lucene.store.BufferedChecksumIndexInput;
@@ -53,20 +52,6 @@ public T readMetadata(IndexInput indexInput) throws IOException {
5352
return metadata;
5453
}
5554

56-
/**
57-
* Writes metadata to file output stream {@code indexOutput}
58-
* @param indexOutput file output stream which will store metadata content
59-
* @param metadata metadata content.
60-
*
61-
* TODO - This will removed in future releases and only {@link #writeMetadata(IndexOutput, Object)} should be used.
62-
*/
63-
@Deprecated
64-
public void writeMetadata(IndexOutput indexOutput, Map<String, String> metadata) throws IOException {
65-
this.writeHeader(indexOutput);
66-
this.parser.writeContent(indexOutput, metadata);
67-
this.writeFooter(indexOutput);
68-
}
69-
7055
/**
7156
* Writes metadata to file output stream {@code indexOutput}
7257
* @param indexOutput file output stream which will store metadata content

server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public void uploadMetadata(Collection<String> segmentFiles, Directory storeDirec
361361
throw new NoSuchFileException(file);
362362
}
363363
}
364-
this.remoteMetadataParser.writeMetadata(indexOutput, uploadedSegments);
364+
this.remoteMetadataParser.writeMetadata(indexOutput, RemoteSegmentMetadata.fromMapOfStrings(uploadedSegments));
365365
indexOutput.close();
366366
storeDirectory.sync(Collections.singleton(metadataFilename));
367367
remoteMetadataDirectory.copyFrom(storeDirectory, metadataFilename, metadataFilename, IOContext.DEFAULT);

server/src/main/java/org/opensearch/index/store/remote/metadata/RemoteSegmentMetadata.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public Map<String, RemoteSegmentStoreDirectory.UploadedSegmentMetadata> getMetad
4444
return this.metadata;
4545
}
4646

47+
/**
48+
* Generate {@code Map<String, String>} from {@link RemoteSegmentMetadata}
49+
* @return {@code Map<String, String>}
50+
*/
51+
public Map<String, String> toMapOfStrings() {
52+
return this.metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString()));
53+
}
54+
4755
/**
4856
* Generate {@link RemoteSegmentMetadata} from {@code segmentMetadata}
4957
* @param segmentMetadata metadata content in the form of {@code Map<String, String>}

server/src/main/java/org/opensearch/index/store/remote/metadata/RemoteSegmentMetadataContentParser.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.opensearch.index.store.remote.metadata;
1010

1111
import java.io.IOException;
12-
import java.util.Map;
1312

1413
import org.apache.lucene.store.IndexInput;
1514
import org.apache.lucene.store.IndexOutput;
@@ -35,15 +34,7 @@ public RemoteSegmentMetadata readContent(IndexInput indexInput) throws IOExcepti
3534
* @param content {@link RemoteSegmentMetadata} from which metadata content would be generated
3635
*/
3736
@Override
38-
public void writeContent(IndexOutput indexOutput, RemoteSegmentMetadata content) throws IOException {}
39-
40-
/**
41-
* Writes metadata to file output stream
42-
* @param indexOutput metadata file input stream
43-
* @param content metadata content
44-
*/
45-
@Override
46-
public void writeContent(IndexOutput indexOutput, Map<String, String> content) throws IOException {
47-
indexOutput.writeMapOfStrings(content);
37+
public void writeContent(IndexOutput indexOutput, RemoteSegmentMetadata content) throws IOException {
38+
indexOutput.writeMapOfStrings(content.toMapOfStrings());
4839
}
4940
}

0 commit comments

Comments
 (0)