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