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 long getWarnTime();
50
51 void markComplete(String msg);
52 void pause(String msg);
53 void resume(String msg);
54 void abort(String msg);
55 void expireNow();
56
57 void setStatus(String status);
58 void setDescription(String description);
59 void setWarnTime(final long t);
60
61 List<StatusJournalEntry> getStatusJournal();
62
63 /**
64 * Enable journal that will store all statuses that have been set along with the time stamps when
65 * they were set.
66 * @param includeCurrentStatus whether to include the current set status in the journal
67 */
68 void enableStatusJournal(boolean includeCurrentStatus);
69
70 void disableStatusJournal();
71
72 String prettyPrintJournal();
73
74 /**
75 * Explicitly mark this status as able to be cleaned up,
76 * even though it might not be complete.
77 */
78 void cleanup();
79
80 /**
81 * Public exposure of Object.clone() in order to allow clients to easily
82 * capture current state.
83 * @return a copy of the object whose references will not change
84 */
85 MonitoredTask clone();
86
87 /**
88 * Creates a string map of internal details for extensible exposure of
89 * monitored tasks.
90 * @return A Map containing information for this task.
91 */
92 Map<String, Object> toMap() throws IOException;
93
94 /**
95 * Creates a JSON object for parseable exposure of monitored tasks.
96 * @return An encoded JSON object containing information for this task.
97 */
98 String toJSON() throws IOException;
99
100 }