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.rsgroup;
019
020import java.io.IOException;
021import java.util.Collections;
022import org.apache.hadoop.hbase.CoprocessorEnvironment;
023import org.apache.hadoop.hbase.coprocessor.CoreCoprocessor;
024import org.apache.hadoop.hbase.coprocessor.HasMasterServices;
025import org.apache.hadoop.hbase.coprocessor.MasterCoprocessor;
026import org.apache.hadoop.hbase.master.MasterServices;
027import org.apache.yetus.audience.InterfaceAudience;
028
029import org.apache.hbase.thirdparty.com.google.protobuf.Service;
030
031/**
032 * @deprecated Keep it here only for compatibility with old client, all the logics have been moved
033 *             into core of HBase.
034 */
035@Deprecated
036@CoreCoprocessor
037@InterfaceAudience.Private
038public class RSGroupAdminEndpoint implements MasterCoprocessor {
039  // Only instance of RSGroupInfoManager. RSGroup aware load balancers ask for this instance on
040  // their setup.
041  private MasterServices master;
042  private RSGroupAdminServiceImpl groupAdminService = new RSGroupAdminServiceImpl();
043
044  @Override
045  public void start(CoprocessorEnvironment env) throws IOException {
046    if (!(env instanceof HasMasterServices)) {
047      throw new IOException("Does not implement HMasterServices");
048    }
049    master = ((HasMasterServices) env).getMasterServices();
050    groupAdminService.initialize(master);
051  }
052
053  @Override
054  public Iterable<Service> getServices() {
055    return Collections.singleton(groupAdminService);
056  }
057
058  RSGroupInfoManager getGroupInfoManager() {
059    return master.getRSGroupInfoManager();
060  }
061
062}