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.hbase.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 long getStartTime(); 36 String getDescription(); 37 String getStatus(); 38 long getStatusTime(); 39 State getState(); 40 long getStateTime(); 41 long getCompletionTimestamp(); 42 43 void markComplete(String msg); 44 void pause(String msg); 45 void resume(String msg); 46 void abort(String msg); 47 void expireNow(); 48 49 void setStatus(String status); 50 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 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 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 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 String toJSON() throws IOException; 77 78 }