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.Map;
23
24 import org.apache.hadoop.classification.InterfaceAudience;
25
26 @InterfaceAudience.Private
27 public interface MonitoredTask extends Cloneable {
28 enum State {
29 RUNNING,
30 WAITING,
31 COMPLETE,
32 ABORTED;
33 }
34
35 public abstract long getStartTime();
36 public abstract String getDescription();
37 public abstract String getStatus();
38 public abstract long getStatusTime();
39 public abstract State getState();
40 public abstract long getStateTime();
41 public abstract long getCompletionTimestamp();
42
43 public abstract void markComplete(String msg);
44 public abstract void pause(String msg);
45 public abstract void resume(String msg);
46 public abstract void abort(String msg);
47 public abstract void expireNow();
48
49 public abstract void setStatus(String status);
50 public abstract void setDescription(String description);
51
52 /**
53 * Explicitly mark this status as able to be cleaned up,
54 * even though it might not be complete.
55 */
56 public abstract void cleanup();
57
58 /**
59 * Public exposure of Object.clone() in order to allow clients to easily
60 * capture current state.
61 * @return a copy of the object whose references will not change
62 */
63 public abstract MonitoredTask clone();
64
65 /**
66 * Creates a string map of internal details for extensible exposure of
67 * monitored tasks.
68 * @return A Map containing information for this task.
69 */
70 public abstract Map<String, Object> toMap() throws IOException;
71
72 /**
73 * Creates a JSON object for parseable exposure of monitored tasks.
74 * @return An encoded JSON object containing information for this task.
75 */
76 public abstract String toJSON() throws IOException;
77
78 }