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.master; 019 020import java.io.IOException; 021import java.util.concurrent.CountDownLatch; 022import org.apache.hadoop.hbase.client.RegionInfo; 023import org.apache.hadoop.hbase.master.procedure.AbstractStateMachineRegionProcedure; 024import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv; 025import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException; 026import org.apache.hadoop.hbase.procedure2.ProcedureYieldException; 027 028public class DummyRegionProcedure 029 extends AbstractStateMachineRegionProcedure<DummyRegionProcedureState> { 030 031 private final CountDownLatch arrive = new CountDownLatch(1); 032 033 private final CountDownLatch resume = new CountDownLatch(1); 034 035 public DummyRegionProcedure() { 036 } 037 038 public DummyRegionProcedure(MasterProcedureEnv env, RegionInfo hri) { 039 super(env, hri); 040 } 041 042 @Override 043 public TableOperationType getTableOperationType() { 044 return TableOperationType.REGION_EDIT; 045 } 046 047 @Override 048 protected Flow executeFromState(MasterProcedureEnv env, DummyRegionProcedureState state) 049 throws ProcedureSuspendedException, ProcedureYieldException, InterruptedException { 050 arrive.countDown(); 051 resume.await(); 052 return Flow.NO_MORE_STATE; 053 } 054 055 @Override 056 protected void rollbackState(MasterProcedureEnv env, DummyRegionProcedureState state) 057 throws IOException, InterruptedException { 058 } 059 060 @Override 061 protected DummyRegionProcedureState getState(int stateId) { 062 return DummyRegionProcedureState.STATE; 063 } 064 065 @Override 066 protected int getStateId(DummyRegionProcedureState state) { 067 return 0; 068 } 069 070 @Override 071 protected DummyRegionProcedureState getInitialState() { 072 return DummyRegionProcedureState.STATE; 073 } 074 075 public void waitUntilArrive() throws InterruptedException { 076 arrive.await(); 077 } 078 079 public void resume() { 080 resume.countDown(); 081 } 082}