Skip to content

Commit

Permalink
[GOBBLIN-2129] avoid throwing unnessary exception that is polluting l…
Browse files Browse the repository at this point in the history
…ogs (apache#4023)
  • Loading branch information
arjun4084346 authored Aug 12, 2024
1 parent bdbf43a commit 0542794
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class GobblinServiceJobScheduler extends JobScheduler implements SpecCata
protected final Boolean isWarmStandbyEnabled;
protected final Optional<UserQuotaManager> quotaManager;
protected final Optional<FlowLaunchHandler> flowTriggerHandler;
// todo - consider using JobScheduler::scheduledJobs in place of scheduledFlowSpecs
@Getter
protected final Map<String, FlowSpec> scheduledFlowSpecs;
@Getter
Expand Down Expand Up @@ -617,7 +618,7 @@ public AddSpecResponse onAddSpec(Spec addedSpec) {
* @param specURI
* @param specVersion
*/
private void unscheduleSpec(URI specURI, String specVersion) throws JobException {
private boolean unscheduleSpec(URI specURI, String specVersion) throws JobException {
if (this.scheduledFlowSpecs.containsKey(specURI.toString())) {
_log.info("Unscheduling flowSpec " + specURI + "/" + specVersion);
this.scheduledFlowSpecs.remove(specURI.toString());
Expand All @@ -630,10 +631,12 @@ private void unscheduleSpec(URI specURI, String specVersion) throws JobException
} catch (SpecNotFoundException e) {
_log.warn("Unable to retrieve spec for URI {}", specURI);
}
return true;
} else {
throw new JobException(String.format(
"Spec with URI: %s was not found in cache. May be it was cleaned, if not please clean it manually",
_log.info(String.format(
"Spec with URI: %s was not found in cache. Maybe it was cleaned, if not please clean it manually",
specURI));
return false;
}
}

Expand All @@ -659,8 +662,9 @@ public void onDeleteSpec(URI deletedSpecURI, String deletedSpecVersion, Properti

try {
Spec deletedSpec = this.scheduledFlowSpecs.get(deletedSpecURI.toString());
unscheduleSpec(deletedSpecURI, deletedSpecVersion);
this.orchestrator.remove(deletedSpec, headers);
if (unscheduleSpec(deletedSpecURI, deletedSpecVersion)) {
this.orchestrator.remove(deletedSpec, headers);
}
} catch (JobException | IOException e) {
_log.warn(String.format("Spec with URI: %s was not unscheduled cleaning", deletedSpecURI), e);
}
Expand Down

0 comments on commit 0542794

Please sign in to comment.