[Refactor] optimize code structure about collector and job within Manager
What's changed?
After code iterations in these years, module Manager contain more and more functions. Yet there isn't a clear code structure, such as org.apache.hertzbeat.manager.scheduler.CollectorJobScheduler holds all operations about Collector status notifications, selecting collector, dispatching jobs and so on.
I think it is time to get refactored.
This PR is only for refactoring collector selections within CollectorJobScheduler
- Use
ConfigConstants.PkgConstant.PKGinstead of hardcode inManager.java - Remove unused methods
- Create folder
propertiesin moduleManager, used for those files that read yml properties only - Integrate methods that shared the same name, such as
org.apache.hertzbeat.manager.scheduler.CollectorJobScheduler#collectSyncJobDataandorg.apache.hertzbeat.manager.scheduler.CollectorJobScheduler#updateAsyncCollectJob - Rename interface,
org.apache.hertzbeat.manager.scheduler.CollectJobScheduling->org.apache.hertzbeat.manager.scheduler.JobOperation - Split interface in order to separate responsibility.
org.apache.hertzbeat.manager.scheduler.CollectorScheduling->org.apache.hertzbeat.manager.scheduler.CollectorOperationandorg.apache.hertzbeat.manager.scheduler.CollectorOperationReceiver - Add
CollectorKeeperto take responsibility of collector selections only
After refactoring above, current code design of Manager will be like:
So far, we keep org.apache.hertzbeat.manager.scheduler.CollectorJobScheduler as the only one implementation class in order to avoid overturning.
What are the benefits?
- As for spliting interface
org.apache.hertzbeat.manager.scheduler.CollectorScheduling-> Ensure the code hierarchy clearer to facilitate further code splitting. - As for new class
CollectorKeeper-> This is for collector selections only, which means we can support more select strategy by implementing this interface, such asRound Robinand so on.
Checklist
- [x] I have read the Contributing Guide
- [x] I have written the necessary doc or comment.
- [x] I have added the necessary unit tests and all cases have passed.
Add or update API
- [ ] I have added the necessary e2e tests and all cases have passed.
hi, this need more time or others to review and test , maybe in this weekend.
hi, this need more time or others to review and test , maybe in this weekend.
Sure, looking forward to your suggestions