aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/remote/RemoteActionCache.java
blob: e865c96e2c3e77b9f2e9a5ebae814931b0fadd5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2016 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.devtools.build.lib.remote;

import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ActionInputFileCache;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible;
import com.google.devtools.build.lib.vfs.Path;
import java.io.IOException;
import java.util.Collection;

/**
 * A cache for storing artifacts (input and output) as well as the output of running an action.
 */
@ThreadCompatible
interface RemoteActionCache {
  /**
   * Put the file in cache if it is not already in it. No-op if the file is already stored in cache.
   *
   * @return The key for fetching the file from cache.
   */
  String putFileIfNotExist(ActionInputFileCache cache, ActionInput file)
      throws IOException, InterruptedException;

  /**
   * Write the file in cache identified by key to the file system. The key must uniquely identify
   * the content of the file. Throws CacheNotFoundException if the file is not found in cache.
   */
  void writeFile(String key, Path dest, boolean executable)
      throws IOException, CacheNotFoundException;

  /**
   * Write the action output files identified by the key to the file system. The key must uniquely
   * identify the action and the content of action inputs.
   *
   * @throws CacheNotFoundException if action output is not found in cache.
   */
  void writeActionOutput(String key, Path execRoot)
      throws IOException, CacheNotFoundException;

  /** Update the cache with the action outputs for the specified key. */
  void putActionOutput(String key, Collection<? extends ActionInput> outputs)
      throws IOException, InterruptedException;

  /** Update the cache with the files for the specified key. */
  void putActionOutput(String key, Path execRoot, Collection<Path> files)
      throws IOException, InterruptedException;
}