1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase;
20
21 import java.io.IOException;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.hadoop.classification.InterfaceAudience;
26 import org.apache.hadoop.conf.Configured;
27
28
29
30
31
32
33
34 @InterfaceAudience.Private
35 public abstract class ClusterManager extends Configured {
36 protected static final Log LOG = LogFactory.getLog(ClusterManager.class);
37
38 private static final String SIGKILL = "SIGKILL";
39 private static final String SIGSTOP = "SIGSTOP";
40 private static final String SIGCONT = "SIGCONT";
41
42 public ClusterManager() {
43 }
44
45
46
47
48 public static enum ServiceType {
49 HADOOP_NAMENODE("namenode"),
50 HADOOP_DATANODE("datanode"),
51 HADOOP_JOBTRACKER("jobtracker"),
52 HADOOP_TASKTRACKER("tasktracker"),
53 HBASE_MASTER("master"),
54 HBASE_REGIONSERVER("regionserver");
55
56 private String name;
57
58 ServiceType(String name) {
59 this.name = name;
60 }
61
62 public String getName() {
63 return name;
64 }
65
66 @Override
67 public String toString() {
68 return getName();
69 }
70 }
71
72
73
74
75 public abstract void start(ServiceType service, String hostname) throws IOException;
76
77
78
79
80 public abstract void stop(ServiceType service, String hostname) throws IOException;
81
82
83
84
85 public abstract void restart(ServiceType service, String hostname) throws IOException;
86
87
88
89
90 public abstract void signal(ServiceType service, String signal,
91 String hostname) throws IOException;
92
93
94
95
96 public void kill(ServiceType service, String hostname) throws IOException {
97 signal(service, SIGKILL, hostname);
98 }
99
100
101
102
103 public void suspend(ServiceType service, String hostname) throws IOException {
104 signal(service, SIGSTOP, hostname);
105 }
106
107
108
109
110 public void resume(ServiceType service, String hostname) throws IOException {
111 signal(service, SIGCONT, hostname);
112 }
113
114
115
116
117
118 public abstract boolean isRunning(ServiceType service, String hostname) throws IOException;
119
120
121
122
123
124
125
126
127
128
129
130
131
132 }