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.client.procedure;
019
020import java.io.IOException;
021
022import org.apache.hadoop.hbase.TableName;
023import org.apache.hadoop.hbase.master.procedure.TableProcedureInterface;
024import org.apache.hadoop.hbase.procedure2.Procedure;
025import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer;
026import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
027import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
028import org.apache.hbase.thirdparty.com.google.protobuf.StringValue;
029
030public class ShellTestProcedure extends Procedure<Object> implements TableProcedureInterface {
031  private String tableNameString;
032
033  public ShellTestProcedure() {
034  }
035
036  public ShellTestProcedure(String tableNameString) {
037    setTableNameString(tableNameString);
038  }
039
040  public String getTableNameString() {
041    return tableNameString;
042  }
043
044  public void setTableNameString(String tableNameString) {
045    this.tableNameString = tableNameString;
046  }
047
048  @Override
049  public TableName getTableName() {
050    return TableName.valueOf(tableNameString);
051  }
052
053  @Override
054  public TableOperationType getTableOperationType() {
055    return TableOperationType.EDIT;
056  }
057
058  @Override
059  protected Procedure<Object>[] execute(Object env)
060      throws ProcedureYieldException, ProcedureSuspendedException,
061      InterruptedException {
062    return null;
063  }
064
065  @Override
066  protected void rollback(Object env) throws IOException, InterruptedException {
067  }
068
069  @Override
070  protected boolean abort(Object env) {
071    return false;
072  }
073
074  @Override
075  protected void serializeStateData(ProcedureStateSerializer serializer)
076      throws IOException {
077    StringValue message = StringValue.newBuilder().setValue(tableNameString).build();
078    serializer.serialize(message);
079  }
080
081  @Override
082  protected void deserializeStateData(ProcedureStateSerializer serializer)
083      throws IOException {
084    StringValue message = serializer.deserialize(StringValue.class);
085    tableNameString = message.getValue();
086  }
087}