View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.monitoring;
20  
21  import java.io.IOException;
22  import java.util.List;
23  import java.util.Map;
24  
25  import org.apache.hadoop.hbase.classification.InterfaceAudience;
26  
27  @InterfaceAudience.Private
28  public interface MonitoredTask extends Cloneable {
29    enum State {
30      RUNNING,
31      WAITING,
32      COMPLETE,
33      ABORTED;
34    }
35  
36    public interface StatusJournalEntry {
37      String getStatus();
38  
39      long getTimeStamp();
40    }
41  
42    long getStartTime();
43    String getDescription();
44    String getStatus();
45    long getStatusTime();
46    State getState();
47    long getStateTime();
48    long getCompletionTimestamp();
49  
50    void markComplete(String msg);
51    void pause(String msg);
52    void resume(String msg);
53    void abort(String msg);
54    void expireNow();
55  
56    void setStatus(String status);
57    void setDescription(String description);
58  
59    List<StatusJournalEntry> getStatusJournal();
60  
61    /**
62     * Enable journal that will store all statuses that have been set along with the time stamps when
63     * they were set.
64     * @param includeCurrentStatus whether to include the current set status in the journal
65     */
66    void enableStatusJournal(boolean includeCurrentStatus);
67  
68    void disableStatusJournal();
69  
70    String prettyPrintJournal();
71  
72    /**
73     * Explicitly mark this status as able to be cleaned up,
74     * even though it might not be complete.
75     */
76    void cleanup();
77  
78    /**
79     * Public exposure of Object.clone() in order to allow clients to easily 
80     * capture current state.
81     * @return a copy of the object whose references will not change
82     */
83    MonitoredTask clone();
84  
85    /**
86     * Creates a string map of internal details for extensible exposure of 
87     * monitored tasks.
88     * @return A Map containing information for this task.
89     */
90    Map<String, Object> toMap() throws IOException;
91  
92    /**
93     * Creates a JSON object for parseable exposure of monitored tasks.
94     * @return An encoded JSON object containing information for this task.
95     */
96    String toJSON() throws IOException;
97  
98  }