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.procedure2;
019
020import java.io.IOException;
021import org.apache.yetus.audience.InterfaceAudience;
022import org.apache.yetus.audience.InterfaceStability;
023
024/**
025 * Special procedure used as a chore. Instead of bringing the Chore class in (dependencies reason),
026 * we reuse the executor timeout thread for this special case. The assumption is that procedure is
027 * used as hook to dispatch other procedures or trigger some cleanups. It does not store state in
028 * the ProcedureStore. this is just for in-memory chore executions.
029 */
030@InterfaceAudience.Private
031@InterfaceStability.Evolving
032public abstract class ProcedureInMemoryChore<TEnvironment> extends Procedure<TEnvironment> {
033  protected ProcedureInMemoryChore(final int timeoutMsec) {
034    setTimeout(timeoutMsec);
035  }
036
037  protected abstract void periodicExecute(final TEnvironment env);
038
039  @Override
040  protected Procedure<TEnvironment>[] execute(final TEnvironment env) {
041    throw new UnsupportedOperationException();
042  }
043
044  @Override
045  protected void rollback(final TEnvironment env) {
046    throw new UnsupportedOperationException();
047  }
048
049  @Override
050  protected boolean abort(final TEnvironment env) {
051    throw new UnsupportedOperationException();
052  }
053
054  @Override
055  protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException {
056  }
057
058  @Override
059  protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException {
060  }
061}