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  enum ServiceType {
035    HADOOP_NAMENODE("namenode"),
036    HADOOP_DATANODE("datanode"),
037    HADOOP_JOURNALNODE("journalnode"),
038    HADOOP_JOBTRACKER("jobtracker"),
039    HADOOP_TASKTRACKER("tasktracker"),
040    ZOOKEEPER_SERVER("QuorumPeerMain"),
041    HBASE_MASTER("master"),
042    HBASE_REGIONSERVER("regionserver");
043
044    private final String name;
045
046    ServiceType(String name) {
047      this.name = name;
048    }
049
050    public String getName() {
051      return name;
052    }
053
054    @Override
055    public String toString() {
056      return getName();
057    }
058  }
059
060  /**
061   * Start the service on the given host
062   */
063  void start(ServiceType service, String hostname, int port) throws IOException;
064
065  /**
066   * Stop the service on the given host
067   */
068  void stop(ServiceType service, String hostname, int port) throws IOException;
069
070  /**
071   * Restart the service on the given host
072   */
073  void restart(ServiceType service, String hostname, int port) throws IOException;
074
075  /**
076   * Kills the service running on the given host
077   */
078  void kill(ServiceType service, String hostname, int port) throws IOException;
079
080  /**
081   * Suspends the service running on the given host
082   */
083  void suspend(ServiceType service, String hostname, int port) throws IOException;
084
085  /**
086   * Resumes the services running on the given host
087   */
088  void resume(ServiceType service, String hostname, int port) throws IOException;
089
090  /**
091   * Returns whether the service is running on the remote host. This only checks whether the service
092   * still has a pid.
093   */
094  boolean isRunning(ServiceType service, String hostname, int port) throws IOException;
095
096  /*
097   * TODO: further API ideas: //return services running on host: ServiceType[]
098   * getRunningServicesOnHost(String hostname); //return which services can be run on host (for
099   * example, to query whether hmaster can run on this host) ServiceType[]
100   * getRunnableServicesOnHost(String hostname); //return which hosts can run this service String[]
101   * getRunnableHostsForService(ServiceType service);
102   */
103
104}