3636 * 3. Send commands in batches to the consensus coordinator with batch-level synchronization
3737 * 4. Support asynchronous callback notification of command processing results
3838 * 5. Track performance metrics for batch processing
39- * 6. Provide intelligent retry mechanisms for failed batches
39+
4040*/
4141class PikaCommandCollector {
4242 public:
@@ -46,14 +46,13 @@ class PikaCommandCollector {
4646 /* *
4747 * @brief constructor
4848 * @param coordinator consensus coordinator reference
49- * @param batch_size batch size (number of commands)
50- * @param batch_max_wait_time forced flush interval (milliseconds)
49+ * @param batch_max_wait_time maximum wait time in milliseconds
5150 */
5251 // Constructor with raw pointer (original)
53- PikaCommandCollector (ConsensusCoordinator* coordinator, size_t batch_size = 100 , int batch_max_wait_time = 5 );
52+ PikaCommandCollector (ConsensusCoordinator* coordinator, int batch_max_wait_time = 5 );
5453
5554 // Constructor with shared_ptr (for compatibility with make_shared calls)
56- PikaCommandCollector (std::shared_ptr<ConsensusCoordinator> coordinator, size_t batch_size = 100 , int batch_max_wait_time = 5 );
55+ PikaCommandCollector (std::shared_ptr<ConsensusCoordinator> coordinator, int batch_max_wait_time = 5 );
5756
5857 ~PikaCommandCollector ();
5958
@@ -84,12 +83,6 @@ class PikaCommandCollector {
8483 */
8584 size_t PendingCommands () const ;
8685
87- /* *
88- * @brief Set the batch size
89- * @param batch_size batch size
90- */
91- void SetBatchSize (size_t batch_size);
92-
9386 /* *
9487 * @brief Set the batch max wait time
9588 * @param batch_max_wait_time maximum wait time in milliseconds
@@ -103,10 +96,6 @@ class PikaCommandCollector {
10396 std::pair<uint64_t , uint64_t > GetBatchStats () const ;
10497
10598 /* *
106- * @brief Get average batch processing time in milliseconds
107- * @return Average processing time or nullopt if no batches processed
108- */
109- std::optional<double > GetAverageBatchTime () const ;
11099
111100 private:
112101
@@ -131,55 +120,33 @@ class PikaCommandCollector {
131120 */
132121 void HandleConflict (const std::shared_ptr<Cmd>& cmd_ptr);
133122
134- /* *
135- * @brief Retry batch processing commands
136- * @param commands List of commands to retry
137- * @param callbacks Corresponding callback function list
138- * @param priority Priority level for the retry (higher means more urgent)
139- * @return Whether the commands were successfully requeued
140- */
141- bool RetryBatch (const std::vector<std::shared_ptr<Cmd>>& commands,
142- const std::vector<CommandCallback>& callbacks,
143- int priority = 100 );
144123
145124 private:
146125 // Consensus coordinator reference
147126 ConsensusCoordinator* coordinator_;
148127
149128 // Batch processing configuration
150- std::atomic<size_t > batch_size_;
151129 std::atomic<int > batch_max_wait_time_;
130+ std::chrono::time_point<std::chrono::steady_clock> batch_start_time_;
152131
153- // Retry configuration
154- std::atomic<int > max_retry_attempts_{3 };
155- std::atomic<int > retry_backoff_ms_{50 };
156-
157132 // Command collection and processing
158133 mutable std::mutex mutex_;
159134
160135 // Pending command queue and callbacks
161136 std::list<std::pair<std::shared_ptr<Cmd>, CommandCallback>> pending_commands_;
162137
163- // Priority queue for retries
164- std::deque<std::tuple<int , std::vector<std::shared_ptr<Cmd>>, std::vector<CommandCallback>>> retry_queue_;
165-
166138 // Command key mapping, used to handle same-key conflicts
167139 std::unordered_map<std::string, std::list<std::pair<std::shared_ptr<Cmd>, CommandCallback>>::iterator> key_map_;
168140
169141 // Batch statistics
170142 std::atomic<uint64_t > total_processed_{0 };
171143 std::atomic<uint64_t > total_batches_{0 };
172- std::atomic<uint64_t > total_retries_{0 };
173144 std::atomic<uint64_t > total_conflicts_{0 };
174- std::atomic<uint64_t > total_batch_time_ms_{0 };
175- std::chrono::time_point<std::chrono::steady_clock> batch_start_time_;
176145
177146 // Performance tracking
178147 struct BatchMetrics {
179148 uint64_t batch_size;
180- uint64_t processing_time_ms;
181149 uint64_t wait_time_ms;
182- bool successful;
183150 };
184151
185152 // Circular buffer for recent batch metrics
0 commit comments