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 */
018package org.apache.hadoop.hbase;
019
020import java.io.IOException;
021import org.apache.hadoop.conf.Configurable;
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * ClusterManager is an api to manage servers in a distributed environment. It provides services for
026 * starting / stopping / killing Hadoop/HBase daemons. Concrete implementations provide actual
027 * functionality for carrying out deployment-specific tasks.
028 */
029@InterfaceAudience.Private
030interface ClusterManager extends Configurable {
031  /**
032   * Type of the service daemon
033   */
034  public static enum ServiceType {
035    HADOOP_NAMENODE("namenode"),
036    HADOOP_DATANODE("datanode"),
037    HADOOP_JOBTRACKER("jobtracker"),
038    HADOOP_TASKTRACKER("tasktracker"),
039    ZOOKEEPER_SERVER("QuorumPeerMain"),
040    HBASE_MASTER("master"),
041    HBASE_REGIONSERVER("regionserver");
042
043    private final String name;
044
045    ServiceType(String name) {
046      this.name = name;
047    }
048
049    public String getName() {
050      return name;
051    }
052
053    @Override
054    public String toString() {
055      return getName();
056    }
057  }
058
059  /**
060   * Start the service on the given host
061   */
062  void start(ServiceType service, String hostname, int port) throws IOException;
063
064  /**
065   * Stop the service on the given host
066   */
067  void stop(ServiceType service, String hostname, int port) throws IOException;
068
069  /**
070   * Restart the service on the given host
071   */
072  void restart(ServiceType service, String hostname, int port) throws IOException;
073
074  /**
075   * Kills the service running on the given host
076   */
077  void kill(ServiceType service, String hostname, int port) throws IOException;
078
079  /**
080   * Suspends the service running on the given host
081   */
082  void suspend(ServiceType service, String hostname, int port) throws IOException;
083
084  /**
085   * Resumes the services running on the given host
086   */
087  void resume(ServiceType service, String hostname, int port) throws IOException;
088
089  /**
090   * Returns whether the service is running on the remote host. This only checks whether the service
091   * still has a pid.
092   */
093  boolean isRunning(ServiceType service, String hostname, int port) throws IOException;
094
095  /*
096   * TODO: further API ideas: //return services running on host: ServiceType[]
097   * getRunningServicesOnHost(String hostname); //return which services can be run on host (for
098   * example, to query whether hmaster can run on this host) ServiceType[]
099   * getRunnableServicesOnHost(String hostname); //return which hosts can run this service String[]
100   * getRunnableHostsForService(ServiceType service);
101   */
102
103}