blob: 7ec802ea45e9df41423b4de6b0212faf829c507b [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14package com.google.devtools.build.skyframe;
15
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010016import com.google.common.collect.ImmutableMap;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010017import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible;
Klaus Aehlig777b30d2017-02-24 16:30:15 +000018import com.google.devtools.build.lib.events.ExtendedEventHandler;
Janak Ramakrishnan39ad9662015-07-15 12:02:53 +000019import com.google.devtools.build.skyframe.MemoizingEvaluator.EmittedEventState;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010020import java.util.Map;
21import java.util.Set;
Googler3057add2018-08-22 07:55:23 -070022import java.util.concurrent.ExecutorService;
Googlera6d7dc72018-08-27 11:18:15 -070023import java.util.function.Supplier;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010024import javax.annotation.Nullable;
25
26/**
mschaller2f8fa642018-02-01 14:48:13 -080027 * An {@link AbstractExceptionalParallelEvaluator} implementing {@link Evaluator}, for when the only
28 * checked exception throwable by evaluation is {@link InterruptedException}.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010029 *
mschallercfe25a62017-08-05 01:40:57 +020030 * <p>This class is not intended for direct use, and is only exposed as public for use in evaluation
31 * implementations outside of this package.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010032 */
mschaller2f8fa642018-02-01 14:48:13 -080033public class ParallelEvaluator extends AbstractExceptionalParallelEvaluator<RuntimeException>
34 implements Evaluator {
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010035
Janak Ramakrishnan54111292015-09-09 21:44:07 +000036 public ParallelEvaluator(
37 ProcessableGraph graph,
38 Version graphVersion,
Mark Schaller06568802015-10-21 19:58:43 +000039 ImmutableMap<SkyFunctionName, ? extends SkyFunction> skyFunctions,
Klaus Aehlig777b30d2017-02-24 16:30:15 +000040 final ExtendedEventHandler reporter,
Janak Ramakrishnan39ad9662015-07-15 12:02:53 +000041 EmittedEventState emittedEventState,
Janak Ramakrishnane0ae6172015-10-11 23:10:01 +000042 EventFilter storedEventFilter,
nharmatabea67e92017-06-16 00:26:27 +020043 ErrorInfoManager errorInfoManager,
Janak Ramakrishnan54111292015-09-09 21:44:07 +000044 boolean keepGoing,
Chloe Calvarin860b8d22016-10-05 22:52:55 +000045 DirtyTrackingProgressReceiver progressReceiver,
janakr46706ae2018-04-30 16:18:50 -070046 GraphInconsistencyReceiver graphInconsistencyReceiver,
Googlera6d7dc72018-08-27 11:18:15 -070047 Supplier<ExecutorService> executorService,
janakre54491e2018-07-11 16:29:13 -070048 CycleDetector cycleDetector,
49 EvaluationVersionBehavior evaluationVersionBehavior) {
mschallercfe25a62017-08-05 01:40:57 +020050 super(
51 graph,
52 graphVersion,
53 skyFunctions,
54 reporter,
55 emittedEventState,
56 storedEventFilter,
57 errorInfoManager,
58 keepGoing,
59 progressReceiver,
janakr46706ae2018-04-30 16:18:50 -070060 graphInconsistencyReceiver,
Googlera6d7dc72018-08-27 11:18:15 -070061 executorService,
janakre54491e2018-07-11 16:29:13 -070062 cycleDetector,
63 evaluationVersionBehavior);
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010064 }
65
66 @Override
67 @ThreadCompatible
ulfjackbe83f132017-07-18 18:12:09 +020068 public <T extends SkyValue> EvaluationResult<T> eval(Iterable<? extends SkyKey> skyKeys)
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010069 throws InterruptedException {
mschaller2f8fa642018-02-01 14:48:13 -080070 return this.evalExceptionally(skyKeys);
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010071 }
72
mschaller2f8fa642018-02-01 14:48:13 -080073 @Override
74 Map<SkyKey, ValueWithMetadata> bubbleErrorUpExceptionally(
75 ErrorInfo leafFailure, SkyKey errorKey, Iterable<SkyKey> roots, Set<SkyKey> rdepsToBubbleUpTo)
Janak Ramakrishnan3c0adb22016-08-15 21:54:55 +000076 throws InterruptedException {
mschaller2f8fa642018-02-01 14:48:13 -080077 return super.bubbleErrorUp(leafFailure, errorKey, roots, rdepsToBubbleUpTo);
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010078 }
79
mschaller2f8fa642018-02-01 14:48:13 -080080 @Override
81 <T extends SkyValue> EvaluationResult<T> constructResultExceptionally(
Janak Ramakrishnan900acfb2016-01-04 04:47:44 +000082 Iterable<SkyKey> skyKeys,
83 @Nullable Map<SkyKey, ValueWithMetadata> bubbleErrorInfo,
Janak Ramakrishnan3c0adb22016-08-15 21:54:55 +000084 boolean catastrophe)
85 throws InterruptedException {
mschaller2f8fa642018-02-01 14:48:13 -080086 return super.constructResult(skyKeys, bubbleErrorInfo, catastrophe);
Janak Ramakrishnan5877b8b2015-09-22 17:37:10 +000087 }
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010088}