forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to
ProcessHandle
for getting the PID (bazelbuild#14842)
* RELNOTES: Refactor system suspend event handling. We are looking to add more build anomaly reporting, so refactor the current system suspend handling to match the new model where we have a module and an event that we can record. Note this deprecates the AnomalyRecord out of BES for the time being. PiperOrigin-RevId: 409502784 * Switch to `ProcessHandle` for getting the pid. Uses new Java API instead of a native method. PiperOrigin-RevId: 409973910 * fix test Co-authored-by: dmaclach <dmaclach@google.com> Co-authored-by: jhorvitz <jhorvitz@google.com>
- Loading branch information
1 parent
0c74741
commit 3297d92
Showing
35 changed files
with
423 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/com/google/devtools/build/lib/buildtool/buildevent/SystemSuspensionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2021 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.buildtool.buildevent; | ||
|
||
import com.google.devtools.build.lib.events.ExtendedEventHandler; | ||
|
||
/** | ||
* This event is fired from {@link | ||
* com.google.devtools.build.lib.platform.SystemSuspensionModule#suspendCallback} to indicate that | ||
* the user either suspended the build with a signal or put their computer to sleep. | ||
*/ | ||
public class SystemSuspensionEvent implements ExtendedEventHandler.Postable { | ||
|
||
/** The possible reasons a system could be suspended. */ | ||
public enum Reason { | ||
SIGTSTP("Signal SIGTSTP"), | ||
SIGCONT("Signal SIGCONT"), | ||
SLEEP("Computer put to sleep"), | ||
WAKE("Computer woken up"); | ||
|
||
private final String logString; | ||
|
||
Reason(String logString) { | ||
this.logString = logString; | ||
} | ||
|
||
public String logString() { | ||
return logString; | ||
} | ||
|
||
static Reason fromInt(int number) { | ||
switch (number) { | ||
case 0: | ||
return SIGTSTP; | ||
case 1: | ||
return SIGCONT; | ||
case 2: | ||
return SLEEP; | ||
case 3: | ||
return WAKE; | ||
default: | ||
throw new IllegalStateException("Unknown suspension reason: " + number); | ||
} | ||
} | ||
}; | ||
|
||
/** These constants are mapped to enum in third_party/bazel/src/main/native/unix_jni.h. */ | ||
private final Reason reason; | ||
|
||
public SystemSuspensionEvent(int reason) { | ||
this.reason = Reason.fromInt(reason); | ||
} | ||
|
||
public Reason getReason() { | ||
return reason; | ||
} | ||
|
||
public String logString() { | ||
return "SystemSuspensionEvent: " + reason.logString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
src/main/java/com/google/devtools/build/lib/platform/SuspendCounter.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.