View Javadoc

1   /*
2    * Copyright (c) 1998-2004 The Jgroup Team.
3    *
4    * This program is free software; you can redistribute it and/or modify
5    * it under the terms of the GNU Lesser General Public License version 2 as
6    * published by the Free Software Foundation.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Lesser General Public License for more details.
12   *
13   * You should have received a copy of the GNU Lesser General Public License
14   * along with this program; if not, write to the Free Software
15   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16   *
17   */
18  
19  package jgroup.experiment.runnables;
20  
21  import jgroup.core.ConfigurationException;
22  import jgroup.experiment.PropertyDefinition;
23  import jgroup.experiment.Runnable;
24  import jgroup.experiment.ShellCommand;
25  import jgroup.relacs.config.ExperimentConfig;
26  
27  
28  /**
29   * Kill one host.
30   * @author Bjarte Svaeren
31   */
32  public class KillHost
33    implements Runnable 
34  {
35  
36    ////////////////////////////////////////////////////////////////////////////////////////////
37    // Methods from Runnable
38    ////////////////////////////////////////////////////////////////////////////////////////////
39  
40    /* (non-Javadoc)
41     * @see jgroup.experiment.Runnable#run(jgroup.relacs.config.ExperimentConfig)
42     */
43    public void run(ExperimentConfig ec) throws ConfigurationException 
44    {
45      String userName = ec.getProperty("user");
46      String hostName = ec.getProperty(this, "exp.host.adress");
47      
48      try {
49        ShellCommand.exec(ec.ssh(hostName) + " pkill -9 -u " + userName + " java");
50      } catch (Exception e) {
51        e.printStackTrace();
52        System.out.println("Could not kill java processes at " + hostName);
53      }    
54    }
55  
56    /* (non-Javadoc)
57     * @see jgroup.experiment.Runnable#getProperties()
58     */
59    public PropertyDefinition[] getProperties() {
60      return null;
61    }
62  }