mattisonchao commented on a change in pull request #14542:
URL: https://github.com/apache/pulsar/pull/14542#discussion_r820162093



##########
File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/MetaStoreImpl.java
##########
@@ -56,29 +58,39 @@
     private final OrderedExecutor executor;
 
     private static final int MAGIC_MANAGED_LEDGER_INFO_METADATA = 0x4778; // 
0100 0111 0111 1000
-    private final CompressionType compressionType;
+    private static final int MAGIC_MANAGED_CURSOR_INFO_METADATA = 0x4778; // 
0100 0111 0111 1000
+    private final CompressionType ledgerInfoCompressionType;
+    private final CompressionType cursorInfoCompressionType;
 
     public MetaStoreImpl(MetadataStore store, OrderedExecutor executor) {
         this.store = store;
         this.executor = executor;
-        this.compressionType = CompressionType.NONE;
+        this.ledgerInfoCompressionType = CompressionType.NONE;
+        this.cursorInfoCompressionType = CompressionType.NONE;
     }
 
-    public MetaStoreImpl(MetadataStore store, OrderedExecutor executor, String 
compressionType) {
+    public MetaStoreImpl(MetadataStore store, OrderedExecutor executor, String 
ledgerInfoCompressionType,
+                         String cursorInfoCompressionType) {
         this.store = store;
         this.executor = executor;
-        CompressionType finalCompressionType;
-        if (compressionType != null) {
-            try {
-                finalCompressionType = 
CompressionType.valueOf(compressionType);
-            } catch (Exception e) {
-                log.error("Failed to get compression type {} error msg: {}.", 
compressionType, e.getMessage());
-                throw e;
-            }
-        } else {
-            finalCompressionType = CompressionType.NONE;
+        this.ledgerInfoCompressionType = 
parseCompressionType(ledgerInfoCompressionType);
+        this.cursorInfoCompressionType = 
parseCompressionType(cursorInfoCompressionType);
+    }
+
+    private CompressionType parseCompressionType(String value) {

Review comment:
       I think it's better to move this method to ``CompressionType``, This has 
higher reusability.

##########
File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/MetaStoreImpl.java
##########
@@ -56,29 +58,39 @@
     private final OrderedExecutor executor;
 
     private static final int MAGIC_MANAGED_LEDGER_INFO_METADATA = 0x4778; // 
0100 0111 0111 1000
-    private final CompressionType compressionType;
+    private static final int MAGIC_MANAGED_CURSOR_INFO_METADATA = 0x4778; // 
0100 0111 0111 1000

Review comment:
       Why do we define the same static immutable value?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to