@SuppressWarnings("FutureReturnValueIgnored") private void scheduleRelease(JobInfo jobInfo) { WrappedContext wrapper = getCache().get(jobInfo.jobId()); Preconditions.checkState( wrapper != null, "Releasing context for unknown job: " + jobInfo.jobId()); PipelineOptions pipelineOptions = PipelineOptionsTranslation.fromProto(jobInfo.pipelineOptions()); int environmentCacheTTLMillis = pipelineOptions.as(PortablePipelineOptions.class).getEnvironmentCacheMillis(); if (environmentCacheTTLMillis > 0) { // Do immediate cleanup if this class is not loaded on Flink parent classloader. if (this.getClass().getClassLoader() != ExecutionEnvironment.class.getClassLoader()) { LOG.warn( "{} is not loaded on parent Flink classloader. " + "Falling back to synchronous environment release for job {}.", this.getClass(), jobInfo.jobId()); release(wrapper); } else { // Schedule task to clean the container later. // Ensure that this class is loaded in the parent Flink classloader. getExecutor() .schedule(() -> release(wrapper), environmentCacheTTLMillis, TimeUnit.MILLISECONDS); } } else { // Do not release this asynchronously, as the releasing could fail due to the classloader not // being available anymore after the tasks have been removed from the execution engine. release(wrapper); } }
@SuppressWarnings("FutureReturnValueIgnored") private void scheduleRelease(JobInfo jobInfo) { WrappedContext wrapper = getCache().get(jobInfo.jobId()); Preconditions.checkState( wrapper != null, "Releasing context for unknown job: " + jobInfo.jobId()); PipelineOptions pipelineOptions = PipelineOptionsTranslation.fromProto(jobInfo.pipelineOptions()); int environmentCacheTTLMillis = pipelineOptions.as(PortablePipelineOptions.class).getEnvironmentCacheMillis(); if (environmentCacheTTLMillis > 0) { // Do immediate cleanup if this class is not loaded on Flink parent classloader. if (this.getClass().getClassLoader() != ExecutionEnvironment.class.getClassLoader()) { LOG.warn( "{} is not loaded on parent Flink classloader. " + "Falling back to synchronous environment release for job {}.", this.getClass(), jobInfo.jobId()); release(wrapper); } else { // Schedule task to clean the container later. // Ensure that this class is loaded in the parent Flink classloader. getExecutor() .schedule(() -> release(wrapper), environmentCacheTTLMillis, TimeUnit.MILLISECONDS); } } else { // Do not release this asynchronously, as the releasing could fail due to the classloader not // being available anymore after the tasks have been removed from the execution engine. release(wrapper); } }