@Override public void inc(long n) { super.inc(n); if (this.parentCounter.isPresent()) { this.parentCounter.get().inc(n); } }
@Override public ContextAwareCounter newMetric(MetricContext context, String name) { return new ContextAwareCounter(context, name); }
@Override public void dec(long n) { super.dec(n); if (this.parentCounter.isPresent()) { this.parentCounter.get().dec(n); } }
private void submitTrackingEvent(URI jobSpecURI, String jobSpecVersion, String operType) { GobblinTrackingEvent e = GobblinTrackingEvent.newBuilder() .setName(TRACKING_EVENT_NAME) .setNamespace(JobCatalog.class.getName()) .setMetadata(ImmutableMap.<String, String>builder() .put(GobblinMetricsKeys.OPERATION_TYPE_META, operType) .put(GobblinMetricsKeys.JOB_SPEC_URI_META, jobSpecURI.toString()) .put(GobblinMetricsKeys.JOB_SPEC_VERSION_META, jobSpecVersion) .build()) .build(); this.numAddedJobs.getContext().submitEvent(e); }
private void submitTrackingEvent(URI specSpecURI, String specSpecVersion, String operType) { GobblinTrackingEvent e = GobblinTrackingEvent.newBuilder() .setName(TRACKING_EVENT_NAME) .setNamespace(SpecCatalog.class.getName()) .setMetadata(ImmutableMap.<String, String>builder() .put(GobblinMetricsKeys.OPERATION_TYPE_META, operType) .put(GobblinMetricsKeys.SPEC_URI_META, specSpecURI.toString()) .put(GobblinMetricsKeys.SPEC_VERSION_META, specSpecVersion) .build()) .build(); this.numAddedSpecs.getContext().submitEvent(e); }
@Override public void onDeleteSpec(URI deletedSpecURI, String deletedSpecVersion) { this.numDeletedSpecs.inc(); submitTrackingEvent(deletedSpecURI, deletedSpecVersion, SPEC_DELETED_OPERATION_TYPE); }
@Override public void onDeleteJob(URI deletedJobURI, String deletedJobVersion) { this.numDeletedJobs.inc(); submitTrackingEvent(deletedJobURI, deletedJobVersion, JOB_DELETED_OPERATION_TYPE); }
@Override public void onUpdateJob(JobSpec updatedJob) { this.numUpdatedJobs.inc(); submitTrackingEvent(updatedJob, JOB_UPDATED_OPERATION_TYPE); } }
@Override public void onAddJob(JobSpec addedJob) { this.numAddedJobs.inc(); submitTrackingEvent(addedJob, JOB_ADDED_OPERATION_TYPE); }
@Override public void onUpdateSpec(Spec updatedSpec) { this.numUpdatedSpecs.inc(); submitTrackingEvent(updatedSpec, SPEC_UPDATED_OPERATION_TYPE); } }
@Override public void onAddSpec(Spec addedSpec) { this.numAddedSpecs.inc(); submitTrackingEvent(addedSpec, SPEC_ADDED_OPERATION_TYPE); }
@Override public void onJobCancellation(JobContext jobContext) throws Exception { super.onJobCancellation(jobContext); _jobState.switchToCancelled(); if (_instrumentationEnabled && null != _launcherMetrics) { _launcherMetrics.getNumJobsCancelled().inc(); } } }
@Override public void onJobPrepare(JobContext jobContext) throws Exception { super.onJobPrepare(jobContext); _jobContext = jobContext; if (_jobState.getRunningState() == null) { _jobState.switchToPending(); } _jobState.switchToRunning(); if (_instrumentationEnabled && null != _launcherMetrics) { _launcherMetrics.getNumJobsLaunched().inc(); } }
@Override public void onJobCompletion(JobContext jobContext) throws Exception { Preconditions.checkArgument(jobContext.getJobState().getState() == RunningState.SUCCESSFUL || jobContext.getJobState().getState() == RunningState.COMMITTED || jobContext.getJobState().getState() == RunningState.FAILED, "Unexpected state: " + jobContext.getJobState().getState() + " in " + jobContext); super.onJobCompletion(jobContext); if (_instrumentationEnabled && null != _launcherMetrics) { _launcherMetrics.getNumJobsCompleted().inc(); } if (jobContext.getJobState().getState() == RunningState.FAILED) { if (_instrumentationEnabled && null != _launcherMetrics) { _launcherMetrics.getNumJobsFailed().inc(); } _jobState.switchToFailed(); } else { // TODO Remove next line once the JobLauncher starts sending notifications for success _jobState.switchToSuccessful(); _jobState.switchToCommitted(); if (_instrumentationEnabled && null != _launcherMetrics) { _launcherMetrics.getNumJobsCommitted().inc(); } } }