001/*
002 * Copyright (c) 2007-2017 Xplenty, 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.management.state;
022
023import cascading.cascade.Cascade;
024import cascading.flow.Flow;
025import cascading.flow.FlowNode;
026import cascading.flow.FlowStep;
027import cascading.stats.CascadingStats;
028
029/**
030 *
031 */
032public abstract class ClientState extends BaseState
033  {
034  public static final String STATE_SERVICE_CLASS_PROPERTY = "cascading3.management.state.service.classname";
035
036  public static ClientState NULL = new ClientState()
037  {
038  @Override
039  public void start( long time )
040    {
041    }
042
043  @Override
044  public void run( long time )
045    {
046    }
047
048  @Override
049  public void stop( long time )
050    {
051    }
052
053  @Override
054  String[] getContext( String group, String metric )
055    {
056    return new String[ 0 ];
057    }
058
059  @Override
060  public void recordStats( CascadingStats stats )
061    {
062    }
063
064  @Override
065  public void recordFlowNode( FlowNode flowNode )
066    {
067    }
068
069  @Override
070  public void recordFlowStep( FlowStep flowStep )
071    {
072    }
073
074  @Override
075  public void recordFlow( Flow flow )
076    {
077    }
078
079  @Override
080  public void recordCascade( Cascade cascade )
081    {
082    }
083  };
084
085  public ClientState()
086    {
087    }
088
089  @Override
090  String[] getContext( String group, String metric )
091    {
092    return asArray( group, metric );
093    }
094
095  public void setStatus( Enum status, long time )
096    {
097    setMetric( status, time );
098    }
099
100  public abstract void recordStats( CascadingStats stats );
101
102  public abstract void recordFlowNode( FlowNode flowNode );
103
104  public abstract void recordFlowStep( FlowStep flowStep );
105
106  public abstract void recordFlow( Flow flow );
107
108  public abstract void recordCascade( Cascade cascade );
109
110  public void record( String id, Object object )
111    {
112    store( id, object );
113    }
114
115  public void start( long time )
116    {
117    setMetric( "state", "start", time );
118    }
119
120  public void submit( long time )
121    {
122    setMetric( "state", "submit", time );
123    }
124
125  public void run( long time )
126    {
127    setMetric( "state", "run", time );
128    }
129
130  public void stop( long time )
131    {
132    setMetric( "state", "stop", time );
133    }
134  }