View Javadoc

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