@Override public CompletableFuture<JobStatus> requestJobStatus(Time timeout) { return CompletableFuture.completedFuture(executionGraph.getState()); }
@Override public CompletableFuture<JobStatus> requestJobStatus(Time timeout) { return CompletableFuture.completedFuture(executionGraph.getState()); }
@Override public CompletableFuture<JobStatus> requestJobStatus(Time timeout) { return CompletableFuture.completedFuture(executionGraph.getState()); }
@Override public Long getValue() { final JobStatus status = eg.getState(); if (status == JobStatus.RUNNING) { // running right now - report the uptime final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING); // we use 'Math.max' here to avoid negative timestamps when clocks change return Math.max(System.currentTimeMillis() - runningTimestamp, 0); } else if (status.isTerminalState()) { // not running any more -> finished or not on leader return NO_LONGER_RUNNING; } else { // not yet running or not up at the moment return 0L; } } }
@Override public Long getValue() { final JobStatus status = eg.getState(); if (status == JobStatus.RUNNING) { // running right now - report the uptime final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING); // we use 'Math.max' here to avoid negative timestamps when clocks change return Math.max(System.currentTimeMillis() - runningTimestamp, 0); } else if (status.isTerminalState()) { // not running any more -> finished or not on leader return NO_LONGER_RUNNING; } else { // not yet running or not up at the moment return 0L; } } }
@Override public Long getValue() { final JobStatus status = eg.getState(); if (status == JobStatus.RUNNING) { // running right now - report the uptime final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING); // we use 'Math.max' here to avoid negative timestamps when clocks change return Math.max(System.currentTimeMillis() - runningTimestamp, 0); } else if (status.isTerminalState()) { // not running any more -> finished or not on leader return NO_LONGER_RUNNING; } else { // not yet running or not up at the moment return 0L; } } }
@Override public Long getValue() { final JobStatus status = eg.getState(); if (status == JobStatus.RUNNING) { // running right now - report the uptime final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING); // we use 'Math.max' here to avoid negative timestamps when clocks change return Math.max(System.currentTimeMillis() - runningTimestamp, 0); } else if (status.isTerminalState()) { // not running any more -> finished or not on leader return NO_LONGER_RUNNING; } else { // not yet running or not up at the moment return 0L; } } }
@Override public Long getValue() { final JobStatus status = eg.getState(); if (status == JobStatus.RUNNING) { // running right now - no downtime return 0L; } else if (status.isTerminalState()) { // not running any more -> finished or not on leader return NO_LONGER_RUNNING; } else { final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING); if (runningTimestamp > 0) { // job was running at some point and is not running now // we use 'Math.max' here to avoid negative timestamps when clocks change return Math.max(System.currentTimeMillis() - runningTimestamp, 0); } else { // job was never scheduled so far return NOT_YET_RUNNING; } } } }
@Override public Long getValue() { final JobStatus status = eg.getState(); if (status == JobStatus.RUNNING) { // running right now - no downtime return 0L; } else if (status.isTerminalState()) { // not running any more -> finished or not on leader return NO_LONGER_RUNNING; } else { final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING); if (runningTimestamp > 0) { // job was running at some point and is not running now // we use 'Math.max' here to avoid negative timestamps when clocks change return Math.max(System.currentTimeMillis() - runningTimestamp, 0); } else { // job was never scheduled so far return NOT_YET_RUNNING; } } } }
@Override public Long getValue() { final JobStatus status = eg.getState(); if (status == JobStatus.RUNNING) { // running right now - no downtime return 0L; } else if (status.isTerminalState()) { // not running any more -> finished or not on leader return NO_LONGER_RUNNING; } else { final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING); if (runningTimestamp > 0) { // job was running at some point and is not running now // we use 'Math.max' here to avoid negative timestamps when clocks change return Math.max(System.currentTimeMillis() - runningTimestamp, 0); } else { // job was never scheduled so far return NOT_YET_RUNNING; } } } }
private void assignExecutionGraph( ExecutionGraph newExecutionGraph, JobManagerJobMetricGroup newJobManagerJobMetricGroup) { checkState(executionGraph == null || JobStatus.CREATED.equals(executionGraph.getState()) || executionGraph.getState().isTerminalState(), "The job state is " + (executionGraph == null ? null : executionGraph.getState())); checkState(jobManagerJobMetricGroup == null); executionGraph = newExecutionGraph; jobManagerJobMetricGroup = newJobManagerJobMetricGroup; checkState(jobStatusListener == null); // register self as job status change listener jobStatusListener = new JobManagerJobStatusListener(); executionGraph.registerJobStatusListener(jobStatusListener); setupGraphManager(); }
@Override public Void apply(StackTraceSample stackTraceSample, Throwable throwable) { synchronized (lock) { try { if (shutDown) { return null; } // Job finished, ignore. JobStatus jobState = vertex.getGraph().getState(); if (jobState.isGloballyTerminalState()) { LOG.debug("Ignoring sample, because job is in state " + jobState + "."); } else if (stackTraceSample != null) { OperatorBackPressureStats stats = createStatsFromSample(stackTraceSample); operatorStatsCache.put(vertex, stats); } else { LOG.debug("Failed to gather stack trace sample.", throwable); } } catch (Throwable t) { LOG.error("Error during stats completion.", t); } finally { pendingStats.remove(vertex); } return null; } }
@Override public Void apply(StackTraceSample stackTraceSample, Throwable throwable) { synchronized (lock) { try { if (shutDown) { return null; } // Job finished, ignore. JobStatus jobState = vertex.getGraph().getState(); if (jobState.isGloballyTerminalState()) { LOG.debug("Ignoring sample, because job is in state " + jobState + "."); } else if (stackTraceSample != null) { OperatorBackPressureStats stats = createStatsFromSample(stackTraceSample); operatorStatsCache.put(vertex, stats); } else { LOG.debug("Failed to gather stack trace sample.", throwable); } } catch (Throwable t) { LOG.error("Error during stats completion.", t); } finally { pendingStats.remove(vertex); } return null; } }
@Override public Long getValue() { final JobStatus status = eg.getState();
private void assignExecutionGraph( ExecutionGraph newExecutionGraph, JobManagerJobMetricGroup newJobManagerJobMetricGroup) { validateRunsInMainThread(); checkState(executionGraph.getState().isTerminalState()); checkState(jobManagerJobMetricGroup == null); executionGraph = newExecutionGraph; jobManagerJobMetricGroup = newJobManagerJobMetricGroup; }
@Override public void declineCheckpoint(DeclineCheckpoint decline) { final CheckpointCoordinator checkpointCoordinator = executionGraph.getCheckpointCoordinator(); if (checkpointCoordinator != null) { getRpcService().execute(() -> { try { checkpointCoordinator.receiveDeclineMessage(decline); } catch (Exception e) { log.error("Error in CheckpointCoordinator while processing {}", decline, e); } }); } else { String errorMessage = "Received DeclineCheckpoint message for job {} with no CheckpointCoordinator"; if (executionGraph.getState() == JobStatus.RUNNING) { log.error(errorMessage, jobGraph.getJobID()); } else { log.debug(errorMessage, jobGraph.getJobID()); } } }
@Override public void declineCheckpoint(DeclineCheckpoint decline) { final CheckpointCoordinator checkpointCoordinator = executionGraph.getCheckpointCoordinator(); if (checkpointCoordinator != null) { getRpcService().execute(() -> { try { checkpointCoordinator.receiveDeclineMessage(decline); } catch (Exception e) { log.error("Error in CheckpointCoordinator while processing {}", decline, e); } }); } else { String errorMessage = "Received DeclineCheckpoint message for job {} with no CheckpointCoordinator"; if (executionGraph.getState() == JobStatus.RUNNING) { log.error(errorMessage, jobGraph.getJobID()); } else { log.debug(errorMessage, jobGraph.getJobID()); } } }
private void assignExecutionGraph( ExecutionGraph newExecutionGraph, JobManagerJobMetricGroup newJobManagerJobMetricGroup) { validateRunsInMainThread(); checkState(executionGraph.getState().isTerminalState()); checkState(jobManagerJobMetricGroup == null); executionGraph = newExecutionGraph; jobManagerJobMetricGroup = newJobManagerJobMetricGroup; }
private void resetAndScheduleExecutionGraph() throws Exception { validateRunsInMainThread(); final CompletableFuture<Void> executionGraphAssignedFuture; if (executionGraph.getState() == JobStatus.CREATED) { executionGraphAssignedFuture = CompletableFuture.completedFuture(null); } else { suspendAndClearExecutionGraphFields(new FlinkException("ExecutionGraph is being reset in order to be rescheduled.")); final JobManagerJobMetricGroup newJobManagerJobMetricGroup = jobMetricGroupFactory.create(jobGraph); final ExecutionGraph newExecutionGraph = createAndRestoreExecutionGraph(newJobManagerJobMetricGroup); executionGraphAssignedFuture = executionGraph.getTerminationFuture().handleAsync( (JobStatus ignored, Throwable throwable) -> { assignExecutionGraph(newExecutionGraph, newJobManagerJobMetricGroup); return null; }, getMainThreadExecutor()); } executionGraphAssignedFuture.thenRun(this::scheduleExecutionGraph); }
private void resetAndScheduleExecutionGraph() throws Exception { validateRunsInMainThread(); final CompletableFuture<Void> executionGraphAssignedFuture; if (executionGraph.getState() == JobStatus.CREATED) { executionGraphAssignedFuture = CompletableFuture.completedFuture(null); } else { suspendAndClearExecutionGraphFields(new FlinkException("ExecutionGraph is being reset in order to be rescheduled.")); final JobManagerJobMetricGroup newJobManagerJobMetricGroup = jobMetricGroupFactory.create(jobGraph); final ExecutionGraph newExecutionGraph = createAndRestoreExecutionGraph(newJobManagerJobMetricGroup); executionGraphAssignedFuture = executionGraph.getTerminationFuture().handleAsync( (JobStatus ignored, Throwable throwable) -> { assignExecutionGraph(newExecutionGraph, newJobManagerJobMetricGroup); return null; }, getMainThreadExecutor()); } executionGraphAssignedFuture.thenRun(this::scheduleExecutionGraph); }