buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 1 | // Copyright 2017 The Bazel Authors. All rights reserved. |
| 2 | // |
| 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. |
| 14 | |
| 15 | package com.google.devtools.build.lib.buildeventservice; |
| 16 | |
Googler | 62c9474 | 2017-11-07 19:09:52 +0100 | [diff] [blame] | 17 | import com.google.devtools.common.options.Converters; |
lpino | d143ca4 | 2019-04-15 04:27:39 -0700 | [diff] [blame] | 18 | import com.google.devtools.common.options.EnumConverter; |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 19 | import com.google.devtools.common.options.Option; |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 20 | import com.google.devtools.common.options.OptionDocumentationCategory; |
ccalvarin | c82a197 | 2017-07-17 21:13:39 +0200 | [diff] [blame] | 21 | import com.google.devtools.common.options.OptionEffectTag; |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 22 | import com.google.devtools.common.options.OptionsBase; |
ulfjack | f9625f0 | 2017-07-24 13:01:29 +0200 | [diff] [blame] | 23 | import java.time.Duration; |
Googler | 7477c7a | 2017-09-26 18:42:09 -0400 | [diff] [blame] | 24 | import java.util.List; |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 25 | |
| 26 | /** Options used by {@link BuildEventServiceModule}. */ |
| 27 | public class BuildEventServiceOptions extends OptionsBase { |
| 28 | |
| 29 | @Option( |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 30 | name = "bes_backend", |
| 31 | defaultValue = "", |
aehlig | 669fcbb | 2017-06-28 17:15:34 +0200 | [diff] [blame] | 32 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 33 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 34 | help = |
| 35 | "Specifies the build event service (BES) backend endpoint as HOST or HOST:PORT. " |
| 36 | + "Disabled by default." |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 37 | ) |
| 38 | public String besBackend; |
| 39 | |
| 40 | @Option( |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 41 | name = "bes_timeout", |
| 42 | defaultValue = "0s", |
aehlig | 669fcbb | 2017-06-28 17:15:34 +0200 | [diff] [blame] | 43 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 44 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 45 | help = |
| 46 | "Specifies how long bazel should wait for the BES/BEP upload to complete after the " |
| 47 | + "build and tests have finished. A valid timeout is a natural number followed by a " |
| 48 | + "unit: Days (d), hours (h), minutes (m), seconds (s), and milliseconds (ms). The " |
buchgr | 8c6a889 | 2018-09-20 08:30:47 -0700 | [diff] [blame] | 49 | + "default value is '0' which means that there is no timeout." |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 50 | ) |
| 51 | public Duration besTimeout; |
| 52 | |
| 53 | @Option( |
ulfjack | 1b97ae08 | 2018-06-07 05:29:38 -0700 | [diff] [blame] | 54 | name = "bes_best_effort", |
| 55 | defaultValue = "false", |
| 56 | deprecationWarning = |
| 57 | "BES best effort upload has been removed. The flag has no more " |
| 58 | + "functionality attached to it and will be removed in a future release.", |
| 59 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 60 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
| 61 | help = |
| 62 | "BES best effort upload has been removed. The flag has no more " |
| 63 | + "functionality attached to it and will be removed in a future release.") |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 64 | public boolean besBestEffort; |
| 65 | |
| 66 | @Option( |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 67 | name = "bes_lifecycle_events", |
| 68 | defaultValue = "true", |
aehlig | 669fcbb | 2017-06-28 17:15:34 +0200 | [diff] [blame] | 69 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 70 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 71 | help = "Specifies whether to publish BES lifecycle events. (defaults to 'true')." |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 72 | ) |
| 73 | public boolean besLifecycleEvents; |
| 74 | |
| 75 | @Option( |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 76 | name = "project_id", |
| 77 | defaultValue = "null", |
aehlig | 669fcbb | 2017-06-28 17:15:34 +0200 | [diff] [blame] | 78 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 79 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
ccalvarin | 3bc1547 | 2017-06-27 17:58:35 +0200 | [diff] [blame] | 80 | help = "Specifies the BES project identifier. Defaults to null." |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 81 | ) |
| 82 | public String projectId; |
Googler | 7477c7a | 2017-09-26 18:42:09 -0400 | [diff] [blame] | 83 | |
| 84 | @Option( |
| 85 | name = "bes_keywords", |
| 86 | defaultValue = "", |
Googler | 62c9474 | 2017-11-07 19:09:52 +0100 | [diff] [blame] | 87 | converter = Converters.CommaSeparatedOptionListConverter.class, |
Googler | 7477c7a | 2017-09-26 18:42:09 -0400 | [diff] [blame] | 88 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 89 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
| 90 | allowMultiple = true, |
| 91 | help = |
| 92 | "Specifies a list of notification keywords to be added the default set of keywords " |
| 93 | + "published to BES (\"command_name=<command_name> \", \"protocol_name=BEP\"). " |
| 94 | + "Defaults to none." |
| 95 | ) |
| 96 | public List<String> besKeywords; |
Klaus Aehlig | ad0d7e9 | 2018-01-11 00:23:45 -0800 | [diff] [blame] | 97 | |
| 98 | @Option( |
felly | 1759476 | 2019-02-07 15:24:32 -0800 | [diff] [blame] | 99 | name = "bes_outerr_buffer_size", |
| 100 | defaultValue = "10240", |
| 101 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 102 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
| 103 | help = |
| 104 | "Specifies the maximal size of stdout or stderr to be buffered in BEP, before it is " |
| 105 | + "reported as a progress event. Individual writes are still reported in a single " |
felly | d17271f | 2019-02-15 09:41:31 -0800 | [diff] [blame] | 106 | + "event, even if larger than the specified value up to --bes_outerr_chunk_size.") |
felly | 1759476 | 2019-02-07 15:24:32 -0800 | [diff] [blame] | 107 | public int besOuterrBufferSize; |
Jakob Buchgraber | d06a366 | 2018-05-07 08:03:06 -0700 | [diff] [blame] | 108 | |
| 109 | @Option( |
felly | d17271f | 2019-02-15 09:41:31 -0800 | [diff] [blame] | 110 | name = "bes_outerr_chunk_size", |
| 111 | defaultValue = "1048576", // 2^20 = 1MB |
| 112 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 113 | effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, |
| 114 | help = |
| 115 | "Specifies the maximal size of stdout or stderr to be sent to BEP in a single message.") |
| 116 | public int besOuterrChunkSize; |
| 117 | |
| 118 | @Option( |
Jakob Buchgraber | d06a366 | 2018-05-07 08:03:06 -0700 | [diff] [blame] | 119 | name = "bes_results_url", |
| 120 | defaultValue = "", |
| 121 | documentationCategory = OptionDocumentationCategory.LOGGING, |
| 122 | effectTags = {OptionEffectTag.TERMINAL_OUTPUT}, |
| 123 | help = |
| 124 | "Specifies the base URL where a user can view the information streamed to the BES" |
| 125 | + " backend. Bazel will output the URL appended by the invocation id to the" |
| 126 | + " terminal.") |
| 127 | public String besResultsUrl; |
lpino | d143ca4 | 2019-04-15 04:27:39 -0700 | [diff] [blame] | 128 | |
| 129 | @Option( |
| 130 | name = "bes_upload_mode", |
lpino | 41d4f75 | 2019-04-17 06:36:47 -0700 | [diff] [blame] | 131 | defaultValue = "wait_for_upload_complete", |
lpino | d143ca4 | 2019-04-15 04:27:39 -0700 | [diff] [blame] | 132 | converter = BesUploadModeConverter.class, |
| 133 | documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, |
| 134 | effectTags = {OptionEffectTag.EAGERNESS_TO_EXIT}, |
| 135 | help = |
| 136 | "Specifies whether the Build Event Service upload should block the build completion " |
| 137 | + "or should end the invocation immediately and finish the upload in the background.") |
| 138 | public BesUploadMode besUploadMode; |
| 139 | |
| 140 | /** Determines the mode that will be used to upload data to the Build Event Service. */ |
| 141 | public enum BesUploadMode { |
felly | 6764100 | 2019-04-23 09:31:25 -0700 | [diff] [blame] | 142 | /** Block at the end of the build waiting for the upload to complete */ |
lpino | d143ca4 | 2019-04-15 04:27:39 -0700 | [diff] [blame] | 143 | WAIT_FOR_UPLOAD_COMPLETE, |
felly | 6764100 | 2019-04-23 09:31:25 -0700 | [diff] [blame] | 144 | /** Block at the beginning of the next build waiting for upload completion */ |
| 145 | NOWAIT_FOR_UPLOAD_COMPLETE, |
| 146 | /** |
| 147 | * Block at the beginning of the next build waiting for the client to finish uploading the data, |
| 148 | * but possibly not blocking on the server acknowledgement. |
| 149 | */ |
| 150 | FULLY_ASYNC, |
lpino | d143ca4 | 2019-04-15 04:27:39 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /** Converter for {@link BesUploadMode} */ |
| 154 | public static class BesUploadModeConverter extends EnumConverter<BesUploadMode> { |
| 155 | public BesUploadModeConverter() { |
| 156 | super(BesUploadMode.class, "Mode for uploading to the Build Event Service"); |
| 157 | } |
| 158 | } |
buchgr | 2730bae | 2017-06-08 23:56:05 +0200 | [diff] [blame] | 159 | } |