001/** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019package org.apache.hadoop.hbase.master.normalizer; 020 021import java.io.IOException; 022import java.util.Arrays; 023import org.apache.hadoop.hbase.HConstants; 024import org.apache.hadoop.hbase.client.RegionInfo; 025import org.apache.hadoop.hbase.master.MasterServices; 026import org.apache.yetus.audience.InterfaceAudience; 027import org.slf4j.Logger; 028import org.slf4j.LoggerFactory; 029 030/** 031 * Normalization plan to split region. 032 */ 033@InterfaceAudience.Private 034public class SplitNormalizationPlan implements NormalizationPlan { 035 private static final Logger LOG = LoggerFactory.getLogger(SplitNormalizationPlan.class.getName()); 036 037 private RegionInfo regionInfo; 038 private byte[] splitPoint; 039 040 public SplitNormalizationPlan(RegionInfo regionInfo, byte[] splitPoint) { 041 this.regionInfo = regionInfo; 042 this.splitPoint = splitPoint; 043 } 044 045 /** 046 * {@inheritDoc} 047 */ 048 @Override 049 public long submit(MasterServices masterServices) throws IOException { 050 return masterServices.splitRegion(regionInfo, null, HConstants.NO_NONCE, HConstants.NO_NONCE); 051 } 052 053 @Override 054 public PlanType getType() { 055 return PlanType.SPLIT; 056 } 057 058 public RegionInfo getRegionInfo() { 059 return regionInfo; 060 } 061 062 public void setRegionInfo(RegionInfo regionInfo) { 063 this.regionInfo = regionInfo; 064 } 065 066 public byte[] getSplitPoint() { 067 return splitPoint; 068 } 069 070 public void setSplitPoint(byte[] splitPoint) { 071 this.splitPoint = splitPoint; 072 } 073 074 @Override 075 public String toString() { 076 return "SplitNormalizationPlan{" + 077 "regionInfo=" + regionInfo + 078 ", splitPoint=" + Arrays.toString(splitPoint) + 079 '}'; 080 } 081 082}