1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.hadoop.hbase;
20
21 import java.io.IOException;
22
23 import org.apache.hadoop.conf.Configurable;
24 import org.apache.hadoop.hbase.classification.InterfaceAudience;
25
26
27 /**
28 * ClusterManager is an api to manage servers in a distributed environment. It provides services
29 * for starting / stopping / killing Hadoop/HBase daemons. Concrete implementations provide actual
30 * functionality for carrying out deployment-specific tasks.
31 */
32 @InterfaceAudience.Private
33 interface ClusterManager extends Configurable {
34 /**
35 * Type of the service daemon
36 */
37 public static enum ServiceType {
38 HADOOP_NAMENODE("namenode"),
39 HADOOP_DATANODE("datanode"),
40 HADOOP_JOBTRACKER("jobtracker"),
41 HADOOP_TASKTRACKER("tasktracker"),
42 HBASE_MASTER("master"),
43 HBASE_REGIONSERVER("regionserver");
44
45 private String name;
46
47 ServiceType(String name) {
48 this.name = name;
49 }
50
51 public String getName() {
52 return name;
53 }
54
55 @Override
56 public String toString() {
57 return getName();
58 }
59 }
60
61 /**
62 * Start the service on the given host
63 */
64 void start(ServiceType service, String hostname, int port) throws IOException;
65
66 /**
67 * Stop the service on the given host
68 */
69 void stop(ServiceType service, String hostname, int port) throws IOException;
70
71 /**
72 * Restart the service on the given host
73 */
74 void restart(ServiceType service, String hostname, int port) throws IOException;
75
76 /**
77 * Kills the service running on the given host
78 */
79 void kill(ServiceType service, String hostname, int port) throws IOException;
80
81 /**
82 * Suspends the service running on the given host
83 */
84 void suspend(ServiceType service, String hostname, int port) throws IOException;
85
86 /**
87 * Resumes the services running on the given host
88 */
89 void resume(ServiceType service, String hostname, int port) throws IOException;
90
91 /**
92 * Returns whether the service is running on the remote host. This only checks whether the
93 * service still has a pid.
94 */
95 boolean isRunning(ServiceType service, String hostname, int port) throws IOException;
96
97 /* TODO: further API ideas:
98 *
99 * //return services running on host:
100 * ServiceType[] getRunningServicesOnHost(String hostname);
101 *
102 * //return which services can be run on host (for example, to query whether hmaster can run on this host)
103 * ServiceType[] getRunnableServicesOnHost(String hostname);
104 *
105 * //return which hosts can run this service
106 * String[] getRunnableHostsForService(ServiceType service);
107 */
108
109 }