001/* 002 * Copyright (c) 2007-2015 Concurrent, Inc. All Rights Reserved. 003 * 004 * Project and contact information: http://www.cascading.org/ 005 * 006 * This file is part of the Cascading project. 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020 021package cascading.stats; 022 023import cascading.flow.FlowNode; 024import cascading.management.state.ClientState; 025import cascading.util.ProcessLogger; 026 027/** Class FlowNodeStats collects {@link cascading.flow.FlowNode} specific statistics. */ 028public abstract class FlowNodeStats extends CascadingStats<FlowSliceStats> 029 { 030 private final FlowNode flowNode; 031 032 protected boolean hasCapturedFinalDetail = false; 033 034 protected FlowNodeStats( FlowNode flowNode, ClientState clientState ) 035 { 036 super( flowNode.getName(), clientState ); 037 this.flowNode = flowNode; 038 } 039 040 public abstract String getKind(); 041 042 @Override 043 protected ProcessLogger getProcessLogger() 044 { 045 if( flowNode != null && flowNode instanceof ProcessLogger ) 046 return (ProcessLogger) flowNode; 047 048 return ProcessLogger.NULL; 049 } 050 051 @Override 052 public String getID() 053 { 054 return flowNode.getID(); 055 } 056 057 @Override 058 public Type getType() 059 { 060 return Type.NODE; 061 } 062 063 public FlowNode getFlowNode() 064 { 065 return flowNode; 066 } 067 068 public int getOrdinal() 069 { 070 return flowNode.getOrdinal(); 071 } 072 073 @Override 074 public synchronized void recordInfo() 075 { 076 clientState.recordFlowNode( flowNode ); 077 } 078 079 @Override 080 public String toString() 081 { 082 return "Node{" + getStatsString() + '}'; 083 } 084 085 public abstract void recordChildStats(); 086 087 public boolean hasCapturedFinalDetail() 088 { 089 return hasCapturedFinalDetail; 090 } 091 }