[ 
https://issues.apache.org/jira/browse/STORM-1336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15122958#comment-15122958
 ] 

ASF GitHub Bot commented on STORM-1336:
---------------------------------------

Github user vesense commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1053#discussion_r51225788
  
    --- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
    @@ -1382,5 +1385,60 @@ public static TopologyInfo getTopologyInfo(String 
name, String asUser, Map storm
         public static int toPositive(int number) {
             return number & Integer.MAX_VALUE;
         }
    +
    +    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) {
    +        try {
    +            Thread.sleep(ms);
    +        } catch (InterruptedException e) {
    +
    --- End diff --
    
    Do we need: `throw new RuntimeException(e);`


> 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)

Reply via email to