-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #1362]🎨Refactor QueryAssignmentProcessor #1363
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,19 +14,83 @@ | |
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
use crate::load_balance::message_request_mode_manager::MessageRequestModeManager; | ||
use cheetah_string::CheetahString; | ||
use rocketmq_client_rust::consumer::allocate_message_queue_strategy::AllocateMessageQueueStrategy; | ||
use rocketmq_client_rust::consumer::rebalance_strategy::allocate_message_queue_averagely::AllocateMessageQueueAveragely; | ||
use rocketmq_client_rust::consumer::rebalance_strategy::allocate_message_queue_averagely_by_circle::AllocateMessageQueueAveragelyByCircle; | ||
use rocketmq_common::common::config_manager::ConfigManager; | ||
use rocketmq_remoting::code::request_code::RequestCode; | ||
use rocketmq_remoting::net::channel::Channel; | ||
use rocketmq_remoting::protocol::remoting_command::RemotingCommand; | ||
use rocketmq_remoting::runtime::connection_handler_context::ConnectionHandlerContext; | ||
use rocketmq_store::config::message_store_config::MessageStoreConfig; | ||
use std::collections::HashMap; | ||
use std::sync::Arc; | ||
|
||
use rocketmq_remoting::protocol::remoting_command::RemotingCommand; | ||
use rocketmq_remoting::runtime::connection_handler_context::ConnectionHandlerContext; | ||
pub struct QueryAssignmentProcessor { | ||
message_request_mode_manager: MessageRequestModeManager, | ||
load_strategy: HashMap<CheetahString, Arc<dyn AllocateMessageQueueStrategy>>, | ||
message_store_config: Arc<MessageStoreConfig>, | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct QueryAssignmentProcessor {} | ||
impl QueryAssignmentProcessor { | ||
pub fn new(message_store_config: Arc<MessageStoreConfig>) -> Self { | ||
let allocate_message_queue_averagely: Arc<dyn AllocateMessageQueueStrategy> = | ||
Arc::new(AllocateMessageQueueAveragely); | ||
let allocate_message_queue_averagely_by_circle: Arc<dyn AllocateMessageQueueStrategy> = | ||
Arc::new(AllocateMessageQueueAveragelyByCircle); | ||
let mut load_strategy = HashMap::new(); | ||
load_strategy.insert( | ||
CheetahString::from_static_str(allocate_message_queue_averagely.get_name()), | ||
allocate_message_queue_averagely, | ||
); | ||
load_strategy.insert( | ||
CheetahString::from_static_str(allocate_message_queue_averagely_by_circle.get_name()), | ||
allocate_message_queue_averagely_by_circle, | ||
); | ||
let manager = MessageRequestModeManager::new(message_store_config.clone()); | ||
let _ = manager.load(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle the potential error from The call to Consider handling the - let _ = manager.load();
+ manager.load().map_err(|e| {
+ // Handle the error, e.g., log it or return an error response
+ eprintln!("Failed to load MessageRequestModeManager: {:?}", e);
+ // You might choose to propagate the error further
+ })?;
|
||
Self { | ||
message_request_mode_manager: manager, | ||
load_strategy, | ||
message_store_config, | ||
} | ||
} | ||
} | ||
|
||
impl QueryAssignmentProcessor { | ||
fn process_request( | ||
&self, | ||
pub async fn process_request( | ||
&mut self, | ||
channel: Channel, | ||
ctx: ConnectionHandlerContext, | ||
request_code: RequestCode, | ||
request: RemotingCommand, | ||
) -> Option<RemotingCommand> { | ||
match request_code { | ||
RequestCode::QueryAssignment => self.query_assignment(channel, ctx, request).await, | ||
RequestCode::SetMessageRequestMode => { | ||
self.set_message_request_mode(channel, ctx, request).await | ||
} | ||
_ => None, | ||
} | ||
} | ||
|
||
async fn query_assignment( | ||
&mut self, | ||
_channel: Channel, | ||
_ctx: ConnectionHandlerContext, | ||
_request: RemotingCommand, | ||
) -> Option<RemotingCommand> { | ||
unimplemented!() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement the The Consider implementing the required functionality or returning an appropriate error response to the client. For example: - unimplemented!()
+ // TODO: Implement the query_assignment logic
+ let response = RemotingCommand::new_response(/* parameters */);
+ // Populate the response as needed
+ Some(response) If you need assistance in implementing this method, I can help develop the logic or we can open a GitHub issue to track this task.
|
||
} | ||
|
||
async fn set_message_request_mode( | ||
&mut self, | ||
_channel: Channel, | ||
_ctx: ConnectionHandlerContext, | ||
_request: RemotingCommand, | ||
) -> RemotingCommand { | ||
todo!() | ||
) -> Option<RemotingCommand> { | ||
unimplemented!() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement the Similar to Please implement the necessary logic or return an appropriate error response. Here's a guideline: - unimplemented!()
+ // TODO: Implement the set_message_request_mode logic
+ let response = RemotingCommand::new_response(/* parameters */);
+ // Populate the response as needed
+ Some(response) Let me know if you'd like assistance in implementing this method or if we should create a GitHub issue for it.
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Warning: QueryAssignmentProcessor implementation is incomplete
The verification revealed that while the processor is properly initialized and integrated into the broker's processor chain, its core functionality is not implemented:
query_assignment
method is marked asunimplemented!()
set_message_request_mode
method is marked asunimplemented!()
These unimplemented methods handle critical request codes:
RequestCode::QueryAssignment
RequestCode::SetMessageRequestMode
🔗 Analysis chain
Verify QueryAssignmentProcessor integration
The initialization follows the established pattern for processor initialization in the broker. However, let's verify the integration points.
Let me gather more information about the QueryAssignmentProcessor implementation and its usage.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 561
Script:
Length of output: 6368