    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.stats;
    022
    023import java.util.Map;
    024
    025/**
    026 * Typically CascadingStats objects have an internal state model with timings, the FlowSliceStats is a simplified
    027 * Stats object and only reports what the underlying platform reports, not the client side observations.
    028 * <p/>
    029 * Implementations may optionally implement the {@link cascading.stats.ProvidesCounters} interface.
    030 * <p/>
    031 * FlowSliceStats is provided as an abstract class so that implementations will be resilient to API additions.
    032 * <p/>
    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  }