[
https://issues.apache.org/jira/browse/STORM-1336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15136438#comment-15136438
]
ASF GitHub Bot commented on STORM-1336:
---------------------------------------
Github user jerrypeng commented on a diff in the pull request:
https://github.com/apache/storm/pull/1053#discussion_r52124710
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1367,12 +1367,67 @@ public static int toPositive(int number) {
return number & Integer.MAX_VALUE;
}
- public static RuntimeException wrapInRuntime(Exception e){
- if (e instanceof RuntimeException){
- return (RuntimeException)e;
- }else {
+ public static RuntimeException wrapInRuntime(Exception e) {
+ if (e instanceof RuntimeException) {
+ return (RuntimeException) e;
+ } else {
return new RuntimeException(e);
}
}
+
+ public static void ensure_process_killed(Integer pid) {
+ // in this function, just kill the process 5 times
+ // make sure the process be killed definitely
+ for (int i = 0; i < 5; i++) {
+ try {
+ exec_command("kill -9 " + pid);
+ LOG.info("kill -9 process " + pid);
+ sleepMs(100);
+ } catch (ExecuteException e) {
+ LOG.info("Error when trying to kill " + pid + ". Process
has been killed");
+ return;
+ } catch (Exception e) {
+ LOG.info("Error when trying to kill " + pid + ".Exception
", e);
+ }
+ }
+ }
+
+ public static void process_killed(Integer pid) {
+ try {
+ exec_command("kill " + pid);
+ LOG.info("kill process " + pid);
+ } catch (ExecuteException e) {
+ LOG.info("Error when trying to kill " + pid + ". Process has
been killed. ");
+ } catch (Exception e) {
+ LOG.info("Error when trying to kill " + pid + ".Exception ",
e);
+ }
+ }
+
+ public static void kill(Integer pid) {
+ process_killed(pid);
+
+ sleepMs(1000);
+
+ ensure_process_killed(pid);
+ }
+
+ public static void exec_command(String command) throws
ExecuteException, IOException {
+ String[] cmdlist = command.split(" ");
+ CommandLine cmd = new CommandLine(cmdlist[0]);
+ for (int i = 1; i < cmdlist.length; i++) {
+ cmd.addArgument(cmdlist[i]);
+ }
+
+ DefaultExecutor exec = new DefaultExecutor();
+ exec.execute(cmd);
+ }
+
+ public static void sleepMs(long ms) {
--- End diff --
get rid of
> Evalute/Port JStorm cgroup support
> ----------------------------------
>
> Key: STORM-1336
> URL: https://issues.apache.org/jira/browse/STORM-1336
> Project: Apache Storm
> Issue Type: New Feature
> Components: storm-core
> Reporter: Robert Joseph Evans
> Assignee: Boyang Jerry Peng
> Labels: jstorm-merger
>
> Supports controlling the upper limit of CPU core usage for a worker using
> cgroups
> Sounds like a good start, will be nice to integrate it with RAS requests too.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)