001/**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.apache.hadoop.hbase.coordination;
021
022import java.io.IOException;
023import java.util.Set;
024import java.util.concurrent.ConcurrentMap;
025
026import org.apache.hadoop.hbase.ServerName;
027import org.apache.hadoop.hbase.master.MasterServices;
028import org.apache.hadoop.hbase.master.SplitLogManager.ResubmitDirective;
029import org.apache.hadoop.hbase.master.SplitLogManager.Task;
030import org.apache.yetus.audience.InterfaceAudience;
031
032/**
033 * Coordination for SplitLogManager. It creates and works with tasks for split log operations<BR>
034 * Manager prepares task by calling {@link #prepareTask} and submit it by
035 * {@link #submitTask(String)}. After that it periodically check the number of remaining tasks by
036 * {@link #remainingTasksInCoordination()} and waits until it become zero.
037 * <P>
038 * Methods required for task life circle: <BR>
039 * {@link #checkTaskStillAvailable(String)} Check that task is still there <BR>
040 * {@link #checkTasks()} check for unassigned tasks and resubmit them
041 * @deprecated since 2.4.0 and in 3.0.0, to be removed in 4.0.0, replaced by procedure-based
042 *   distributed WAL splitter, see SplitWALManager
043 */
044@InterfaceAudience.Private
045@Deprecated
046public interface SplitLogManagerCoordination {
047  /**
048   * Detail class that shares data between coordination and split log manager
049   */
050  class SplitLogManagerDetails {
051    final private ConcurrentMap<String, Task> tasks;
052    final private MasterServices master;
053    final private Set<String> failedDeletions;
054
055    public SplitLogManagerDetails(ConcurrentMap<String, Task> tasks, MasterServices master,
056        Set<String> failedDeletions) {
057      this.tasks = tasks;
058      this.master = master;
059      this.failedDeletions = failedDeletions;
060    }
061
062    /**
063     * @return the master value
064     */
065    public MasterServices getMaster() {
066      return master;
067    }
068
069    /**
070     * @return map of tasks
071     */
072    public ConcurrentMap<String, Task> getTasks() {
073      return tasks;
074    }
075
076    /**
077     * @return a set of failed deletions
078     */
079    public Set<String> getFailedDeletions() {
080      return failedDeletions;
081    }
082
083    /**
084     * @return server name
085     */
086    public ServerName getServerName() {
087      return master.getServerName();
088    }
089  }
090
091  /**
092   * Provide the configuration from the SplitLogManager
093   */
094  void setDetails(SplitLogManagerDetails details);
095
096  /**
097   * Returns the configuration that was provided previously
098   */
099  SplitLogManagerDetails getDetails();
100
101  /**
102   * Prepare the new task
103   * @param taskName name of the task
104   * @return the task id
105   */
106  String prepareTask(String taskName);
107
108  /**
109   * tells Coordination that it should check for new tasks
110   */
111  void checkTasks();
112
113  /**
114   * Return the number of remaining tasks
115   */
116  int remainingTasksInCoordination();
117
118  /**
119   * Check that the task is still there
120   * @param task node to check
121   */
122  void checkTaskStillAvailable(String task);
123
124  /**
125   * Resubmit the task in case if found unassigned or failed
126   * @param taskName path related to task
127   * @param task to resubmit
128   * @param force whether it should be forced
129   * @return whether it was successful
130   */
131
132  boolean resubmitTask(String taskName, Task task, ResubmitDirective force);
133
134  /**
135   * @param taskName to be submitted
136   */
137  void submitTask(String taskName);
138
139  /**
140   * @param taskName to be removed
141   */
142  void deleteTask(String taskName);
143
144  /**
145   * Support method to init constants such as timeout. Mostly required for UTs.
146   * @throws IOException
147   */
148  void init() throws IOException;
149}