poorbarcode commented on PR #16758:
URL: https://github.com/apache/pulsar/pull/16758#issuecomment-1205517309

   Hi @asafm 
   
   > > But the Transaction Log Provider will hold all the Collector of Txn 
Buffered Writer; this is confusing
   
   > Can you explain this further? I didn't understand how the provider would 
hold all the Collectors (metrics). It should only be to a single instance of 
the metric class.
   
   When `MLTransactionMetadataStoreProvider` initialized, we create `Collector` 
like this: 
   
   ```java
   public MLTransactionMetadataStoreProvider(){
      this.recordsPerBatchMetric = ...
      this.batchSizeBytesMetric = ...
      this.oldestRecordInBatchDelayTimeSecondsMetric = ...
      this.batchFlushTriggeredByMaxRecordsMetric = ...
      this.batchFlushTriggeredByMaxSizeMetric = ...
      this.batchFlushTriggeredByMaxDelayMetric = ...
   }
   ```
   
   And when creating `MlTransactionLogImpl`, pass these `Collector` to 
`MlTransactionLogImpl` like this: 
   
   ```java
   public class MLTransactionMetadataStoreProvider{
     public TransactionMetadataStore openStore(...){
       TransactionMetadataStore store = ...;
       setMetrics(store);
       return store;
     }
   
     private void setMetrics(TransactionMetadataStore store) {
       store.recordsPerBatchMetric = this.recordsPerBatchMetric;
       store.batchSizeBytesMetric = this.batchSizeBytesMetric;
       store.oldestRecordInBatchDelayTimeSecondsMetric = 
this.oldestRecordInBatchDelayTimeSecondsMetric;
       ...
     }
   }
   ```
   
   The `MLTransactionMetadataStoreProvider` will hold all the Collector of Txn 
Buffered Writer, this is confusing


-- 
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