001/* 002 * Copyright (c) 2016-2017 Chris K Wensel <chris@wensel.net>. All Rights Reserved. 003 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved. 004 * 005 * Project and contact information: http://www.cascading.org/ 006 * 007 * This file is part of the Cascading project. 008 * 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 */ 021 022package cascading.stats; 023 024import java.util.Map; 025 026/** 027 * Typically CascadingStats objects have an internal state model with timings, the FlowSliceStats is a simplified 028 * Stats object and only reports what the underlying platform reports, not the client side observations. 029 * <p> 030 * Implementations may optionally implement the {@link cascading.stats.ProvidesCounters} interface. 031 * <p> 032 * FlowSliceStats is provided as an abstract class so that implementations will be resilient to API additions. 033 * <ul> 034 * <li>pendingTime - when the slice is created</li> 035 * <li>startTime - when the slice was told to begin work</li> 036 * <li>submitTime - when the slice was submitted to a work queue</li> 037 * <li>runTime - when work began</li> 038 * <li>finishedTime - when work ended</li> 039 * </ul> 040 * <p> 041 * pending is mostly irrelevant and unavailable, start, submit, and runtime are by default synonymous at the slice level 042 * <p> 043 * All methods with the word 'process' like {@link #getProcessID()}, refer to the underlying implementations value. 044 * In this example, processID is the task id this slice actually represents, where the id ({@link #getID()} is a local 045 * guid not related to the platform implementation id to guarantee uniqueness. 046 */ 047public abstract class FlowSliceStats<K extends Enum> 048 { 049 public abstract static class FlowSliceAttempt 050 { 051 public String getProcessID() 052 { 053 return getProcessAttemptID(); 054 } 055 056 public abstract String getProcessAttemptID(); 057 058 public abstract int getEventId(); 059 060 public abstract int getProcessDuration(); 061 062 public abstract String getProcessStatus(); 063 064 public abstract String getStatusURL(); 065 066 public abstract CascadingStats.Status getStatus(); 067 068 public abstract String getProcessHostname(); 069 } 070 071 public abstract String getID(); 072 073 public long getProcessPendingTime() 074 { 075 return -1; 076 } 077 078 public abstract long getProcessStartTime(); 079 080 public long getProcessSubmitTime() 081 { 082 return getProcessStartTime(); 083 } 084 085 public long getProcessRunTime() 086 { 087 return getProcessStartTime(); 088 } 089 090 public abstract long getProcessFinishTime(); 091 092 public abstract CascadingStats.Status getStatus(); 093 094 public abstract K getKind(); 095 096 public String getProcessID() 097 { 098 return getProcessSliceID(); 099 } 100 101 public abstract String getProcessSliceID(); 102 103 public abstract String getProcessNodeID(); 104 105 public abstract String getProcessStepID(); 106 107 public abstract String getProcessStatus(); 108 109 public abstract float getProcessProgress(); 110 111 public abstract String[] getDiagnostics(); 112 113 public abstract Map<String, Map<String, Long>> getCounters(); 114 115 public abstract Map<Integer, FlowSliceAttempt> getAttempts(); 116 }