-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compress and cache cluster state during validate join request
Signed-off-by: Aman Khare <amkhar@amazon.com>
- Loading branch information
Aman Khare
committed
Apr 28, 2023
1 parent
dffd822
commit fd7eebe
Showing
6 changed files
with
155 additions
and
24 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
server/src/main/java/org/opensearch/cluster/CompressionHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.opensearch.cluster; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.Version; | ||
import org.opensearch.common.bytes.BytesReference; | ||
import org.opensearch.common.compress.CompressorFactory; | ||
import org.opensearch.common.io.stream.BytesStreamOutput; | ||
import org.opensearch.common.io.stream.OutputStreamStreamOutput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.common.io.stream.Writeable; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A helper class to utilize the compressed stream. | ||
*/ | ||
public class CompressionHelper { | ||
private static final Logger logger = LogManager.getLogger(CompressionHelper.class); | ||
|
||
public static BytesReference serializedWrite(Writeable writer, Version nodeVersion, boolean streamBooleanFlag) throws IOException { | ||
final BytesStreamOutput bStream = new BytesStreamOutput(); | ||
try (StreamOutput stream = new OutputStreamStreamOutput(CompressorFactory.COMPRESSOR.threadLocalOutputStream(bStream))) { | ||
stream.setVersion(nodeVersion); | ||
stream.writeBoolean(streamBooleanFlag); | ||
writer.writeTo(stream); | ||
} | ||
final BytesReference serializedByteRef = bStream.bytes(); | ||
logger.trace( | ||
"serialized writable object for node version [{}] with size [{}]", | ||
nodeVersion, | ||
serializedByteRef.length() | ||
); | ||
return serializedByteRef; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters