001/** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019package org.apache.hadoop.hbase.monitoring; 020 021import java.io.IOException; 022import java.util.List; 023import java.util.Map; 024 025import org.apache.yetus.audience.InterfaceAudience; 026 027@InterfaceAudience.Private 028public interface MonitoredTask extends Cloneable { 029 enum State { 030 RUNNING, 031 WAITING, 032 COMPLETE, 033 ABORTED; 034 } 035 036 public interface StatusJournalEntry { 037 String getStatus(); 038 039 long getTimeStamp(); 040 } 041 042 long getStartTime(); 043 String getDescription(); 044 String getStatus(); 045 long getStatusTime(); 046 State getState(); 047 long getStateTime(); 048 long getCompletionTimestamp(); 049 long getWarnTime(); 050 051 void markComplete(String msg); 052 void pause(String msg); 053 void resume(String msg); 054 void abort(String msg); 055 void expireNow(); 056 057 void setStatus(String status); 058 void setDescription(String description); 059 void setWarnTime(final long t); 060 061 List<StatusJournalEntry> getStatusJournal(); 062 063 /** 064 * Enable journal that will store all statuses that have been set along with the time stamps when 065 * they were set. 066 * @param includeCurrentStatus whether to include the current set status in the journal 067 */ 068 void enableStatusJournal(boolean includeCurrentStatus); 069 070 void disableStatusJournal(); 071 072 String prettyPrintJournal(); 073 074 /** 075 * Explicitly mark this status as able to be cleaned up, 076 * even though it might not be complete. 077 */ 078 void cleanup(); 079 080 /** 081 * Public exposure of Object.clone() in order to allow clients to easily 082 * capture current state. 083 * @return a copy of the object whose references will not change 084 */ 085 MonitoredTask clone(); 086 087 /** 088 * Creates a string map of internal details for extensible exposure of 089 * monitored tasks. 090 * @return A Map containing information for this task. 091 */ 092 Map<String, Object> toMap() throws IOException; 093 094 /** 095 * Creates a JSON object for parseable exposure of monitored tasks. 096 * @return An encoded JSON object containing information for this task. 097 */ 098 String toJSON() throws IOException; 099 100}