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 ZOOKEEPER_SERVER("QuorumPeerMain"), 43 HBASE_MASTER("master"), 44 HBASE_REGIONSERVER("regionserver"); 45 46 private String name; 47 48 ServiceType(String name) { 49 this.name = name; 50 } 51 52 public String getName() { 53 return name; 54 } 55 56 @Override 57 public String toString() { 58 return getName(); 59 } 60 } 61 62 /** 63 * Start the service on the given host 64 */ 65 void start(ServiceType service, String hostname, int port) throws IOException; 66 67 /** 68 * Stop the service on the given host 69 */ 70 void stop(ServiceType service, String hostname, int port) throws IOException; 71 72 /** 73 * Restart the service on the given host 74 */ 75 void restart(ServiceType service, String hostname, int port) throws IOException; 76 77 /** 78 * Kills the service running on the given host 79 */ 80 void kill(ServiceType service, String hostname, int port) throws IOException; 81 82 /** 83 * Suspends the service running on the given host 84 */ 85 void suspend(ServiceType service, String hostname, int port) throws IOException; 86 87 /** 88 * Resumes the services running on the given host 89 */ 90 void resume(ServiceType service, String hostname, int port) throws IOException; 91 92 /** 93 * Returns whether the service is running on the remote host. This only checks whether the 94 * service still has a pid. 95 */ 96 boolean isRunning(ServiceType service, String hostname, int port) throws IOException; 97 98 /* TODO: further API ideas: 99 * 100 * //return services running on host: 101 * ServiceType[] getRunningServicesOnHost(String hostname); 102 * 103 * //return which services can be run on host (for example, to query whether hmaster can run on this host) 104 * ServiceType[] getRunnableServicesOnHost(String hostname); 105 * 106 * //return which hosts can run this service 107 * String[] getRunnableHostsForService(ServiceType service); 108 */ 109 110 }