001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.hbase; 020 021import java.io.IOException; 022 023import org.apache.hadoop.conf.Configurable; 024import org.apache.yetus.audience.InterfaceAudience; 025 026 027/** 028 * ClusterManager is an api to manage servers in a distributed environment. It provides services 029 * for starting / stopping / killing Hadoop/HBase daemons. Concrete implementations provide actual 030 * functionality for carrying out deployment-specific tasks. 031 */ 032@InterfaceAudience.Private 033interface ClusterManager extends Configurable { 034 /** 035 * Type of the service daemon 036 */ 037 public static enum ServiceType { 038 HADOOP_NAMENODE("namenode"), 039 HADOOP_DATANODE("datanode"), 040 HADOOP_JOBTRACKER("jobtracker"), 041 HADOOP_TASKTRACKER("tasktracker"), 042 ZOOKEEPER_SERVER("QuorumPeerMain"), 043 HBASE_MASTER("master"), 044 HBASE_REGIONSERVER("regionserver"); 045 046 private String name; 047 048 ServiceType(String name) { 049 this.name = name; 050 } 051 052 public String getName() { 053 return name; 054 } 055 056 @Override 057 public String toString() { 058 return getName(); 059 } 060 } 061 062 /** 063 * Start the service on the given host 064 */ 065 void start(ServiceType service, String hostname, int port) throws IOException; 066 067 /** 068 * Stop the service on the given host 069 */ 070 void stop(ServiceType service, String hostname, int port) throws IOException; 071 072 /** 073 * Restart the service on the given host 074 */ 075 void restart(ServiceType service, String hostname, int port) throws IOException; 076 077 /** 078 * Kills the service running on the given host 079 */ 080 void kill(ServiceType service, String hostname, int port) throws IOException; 081 082 /** 083 * Suspends the service running on the given host 084 */ 085 void suspend(ServiceType service, String hostname, int port) throws IOException; 086 087 /** 088 * Resumes the services running on the given host 089 */ 090 void resume(ServiceType service, String hostname, int port) throws IOException; 091 092 /** 093 * Returns whether the service is running on the remote host. This only checks whether the 094 * service still has a pid. 095 */ 096 boolean isRunning(ServiceType service, String hostname, int port) throws IOException; 097 098 /* TODO: further API ideas: 099 * 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}