aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/buildeventstream/LastBuildEvent.java
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-07-10 13:08:19 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-10 14:37:11 +0200
commitfb3c57222799e50ae262b8a35f701cb8ef22e6f9 (patch)
treeffd16d0a991d6e5e59eb8d75df5d6c21153600b0 /src/main/java/com/google/devtools/build/lib/buildeventstream/LastBuildEvent.java
parent3d4f6d6e3640af45f62a77d379ec79b24549c61f (diff)
BEP: Positively identify the last message
Set an additional flag in the last BEP message to indicate the end of the proto sequence. While the last event is implicit from the child-relation (the sequence of protos is finished, if at least one event is seen and all announced events have occurred in the stream), an explicit marking of the last event simplifies processing. Change-Id: I6554476f975dc9e52fdb27fb3221bd27f6097ed9 PiperOrigin-RevId: 161377092
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/buildeventstream/LastBuildEvent.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildeventstream/LastBuildEvent.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/LastBuildEvent.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/LastBuildEvent.java
new file mode 100644
index 0000000000..767e9140ed
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/LastBuildEvent.java
@@ -0,0 +1,40 @@
+// Copyright 2017 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.buildeventstream;
+
+import java.util.Collection;
+
+/** Wrapper class for a build event marking it as the final event in the protocol. */
+public class LastBuildEvent implements BuildEvent {
+ private final BuildEvent event;
+
+ public LastBuildEvent(BuildEvent event) {
+ this.event = event;
+ }
+
+ public BuildEventId getEventId() {
+ return event.getEventId();
+ }
+
+ public Collection<BuildEventId> getChildrenEvents() {
+ return event.getChildrenEvents();
+ }
+
+ public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) {
+ return BuildEventStreamProtos.BuildEvent.newBuilder(event.asStreamProto(converters))
+ .setLastMessage(true)
+ .build();
+ }
+}