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;
021import org.apache.hadoop.hbase.TableName;
022import org.apache.hadoop.hbase.master.procedure.TableProcedureInterface;
023import org.apache.hadoop.hbase.procedure2.Procedure;
024import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer;
025import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
026import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
027
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, InterruptedException {
061    return null;
062  }
063
064  @Override
065  protected void rollback(Object env) throws IOException, InterruptedException {
066  }
067
068  @Override
069  protected boolean abort(Object env) {
070    return false;
071  }
072
073  @Override
074  protected void serializeStateData(ProcedureStateSerializer serializer) throws IOException {
075    StringValue message = StringValue.newBuilder().setValue(tableNameString).build();
076    serializer.serialize(message);
077  }
078
079  @Override
080  protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException {
081    StringValue message = serializer.deserialize(StringValue.class);
082    tableNameString = message.getValue();
083  }
084}