saurabhd336 commented on code in PR #8828:
URL: https://github.com/apache/pinot/pull/8828#discussion_r930663113
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -1984,6 +1987,82 @@ private Set<String> getAllInstancesForTable(String
tableNameWithType) {
return instanceSet;
}
+ public Map<String, String> getControllerJobZKMetadata(String taskId) {
+ String controllerJobResourcePath =
ZKMetadataProvider.constructPropertyStorePathForControllerJob();
+ if (_propertyStore.exists(controllerJobResourcePath,
AccessOption.PERSISTENT)) {
+ ZNRecord taskResourceZnRecord =
_propertyStore.get(controllerJobResourcePath, null, -1);
+ return taskResourceZnRecord.getMapFields().get(taskId);
+ } else {
+ return null;
+ }
+ }
+
+ public Map<String, Map<String, String>> getAllJobsForTable(String
tableNameWithType) {
+ String jobsResourcePath =
ZKMetadataProvider.constructPropertyStorePathForControllerJob();
+ if (_propertyStore.exists(jobsResourcePath, AccessOption.PERSISTENT)) {
+ ZNRecord tableJobsRecord = _propertyStore.get(jobsResourcePath, null,
-1);
+ Map<String, Map<String, String>> controllerJobs =
tableJobsRecord.getMapFields();
+ return controllerJobs.entrySet().stream().filter(
+ job ->
job.getValue().get(CommonConstants.ControllerJob.CONTROLLER_JOB_TABLE_NAME_WITH_TYPE)
+
.equals(tableNameWithType)).collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue));
+ } else {
+ return Collections.emptyMap();
+ }
+ }
+
+ public boolean addNewReloadSegmentJob(String tableNameWithType, String
segmentName, String jobId,
+ int numberOfMessagesSent) {
+ Map<String, String> jobMetadata = new HashMap<>();
+ jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_ID, jobId);
+ jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_TYPE,
ControllerJobType.RELOAD_SEGMENT.toString());
+
jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_SUBMISSION_TIME,
+ Long.toString(System.currentTimeMillis()));
+
jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_MESSAGES_COUNT,
+ Integer.toString(numberOfMessagesSent));
+
jobMetadata.put(CommonConstants.ControllerJob.SEGMENT_RELOAD_JOB_SEGMENT_NAME,
segmentName);
+ return addReloadJobToZK(tableNameWithType, jobId, jobMetadata);
+ }
+
+ public boolean addNewReloadAllSegmentsJob(String tableNameWithType, String
jobId, int numberOfMessagesSent) {
+ Map<String, String> jobMetadata = new HashMap<>();
+ jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_ID, jobId);
+ jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_TYPE,
+ ControllerJobType.RELOAD_ALL_SEGMENTS.toString());
+
jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_SUBMISSION_TIME,
+ Long.toString(System.currentTimeMillis()));
+
jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_MESSAGES_COUNT,
+ Integer.toString(numberOfMessagesSent));
+ return addReloadJobToZK(tableNameWithType, jobId, jobMetadata);
+ }
+
+ private boolean addReloadJobToZK(String tableNameWithType, String taskId,
Map<String, String> jobMetadata) {
+ String jobResourcePath =
ZKMetadataProvider.constructPropertyStorePathForControllerJob();
+ Stat stat = new Stat();
+ ZNRecord tableJobsZnRecord = _propertyStore.get(jobResourcePath, stat,
AccessOption.PERSISTENT);
+
jobMetadata.put(CommonConstants.ControllerJob.CONTROLLER_JOB_TABLE_NAME_WITH_TYPE,
tableNameWithType);
Review Comment:
Ack
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]