1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package jgroup.experiment.runnables;
20
21 import java.util.Iterator;
22
23 import jgroup.core.ConfigurationException;
24 import jgroup.experiment.PropertyDefinition;
25 import jgroup.experiment.Runnable;
26 import jgroup.experiment.ShellCommand;
27 import jgroup.relacs.config.ExperimentConfig;
28 import jgroup.relacs.config.Host;
29 import jgroup.relacs.config.HostSet;
30
31
32
33
34 public class CheckHosts implements Runnable
35 {
36
37
38
39 public void run(ExperimentConfig ec) throws ConfigurationException
40 {
41
42 HostSet hosts = (HostSet) ec.getServerConfig().getAllHosts().clone();
43
44 HostSet clients = ec.getClientConfig().getAllHosts();
45 hosts.addHosts(clients);
46 String userName = ec.getProperty("user.name");
47
48 ThreadGroup threadGroup = new ThreadGroup("CheckHosts");
49 for (Iterator iter = hosts.iterator(); iter.hasNext();) {
50 Host host = (Host) iter.next();
51 String hostName = host.getCanonicalHostName();
52 try {
53 ShellCommand.exec(ec.ssh(hostName) + " pgrep -fu " + userName + " java", threadGroup);
54 } catch (Exception e) {
55 e.printStackTrace();
56 System.out.println("Check for java process failed at " + hostName);
57 }
58 }
59 ShellCommand.waitFor(threadGroup);
60 }
61
62
63
64
65 public PropertyDefinition[] getProperties() {
66 return null;
67 }
68
69 }