    001/*
    002 * Copyright (c) 2007-2016 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.flow;
    022
    023import java.util.List;
    024import java.util.Map;
    025
    026import cascading.pipe.Pipe;
    027
    028/**
    029 * Interface AssemblyPlanner is used to allow for lazy evaluation of a pipe assembly during planning of a {@link Flow}.
    030 * <p/>
    031 * This allows for new languages or frameworks that may require additional meta-data from the
    032 * underlying platform or environment. Specifically field names and type information from incoming source
    033 * and outgoing sink {@link cascading.tap.Tap}s.
    034 * <p/>
    035 * AssemblyPlanner implementations are handed to a {@link cascading.flow.planner.FlowPlanner}
    036 * instance in the order they should be evaluated.
    037 * Every instance has the opportunity to replace any prior tails with new branches and paths.
    038 * <p/>
    039 * Every instance of AssemblyPlanner evaluated is given the current {@link FlowDef} used on the current
    040 * {@link FlowConnector}, the current Flow instance (only initialized with source and sink Taps provided by the
    041 * FlowDef), and the tails provided by the FlowDef or those returned by prior AssemblyPlanner instances.
    042 * <p/>
    043 * An AssemblyPlanner cannot change or modify the Flow, or change out any Taps used as sources, sinks, traps, or
    044 * checkpoints.
    045 * <p/>
    046 * This is an experimental API and subject to change without notice.
    047 */
    048public interface AssemblyPlanner
    049  {
    050  interface Context
    051    {
    052    FlowDef getFlowDef();
    053
    054    Flow getFlow();
    055
    056    List<Pipe> getTails();
    057    }
    058
    059  /**
    060   * Called when this AssemblyPlanner instance should return any additional tail Pipe instances for used
    061   * when completing the Flow plan.
    062   *
    063   * @param context parameter object of the Context
    064   * @return tail Pipe instances to replace the given tails
    065   */
    066  List<Pipe> resolveTails( Context context );
    067
    068  /**
    069   * Returns a map of properties giving more details about the Flow object. This can be picked up by a Flow object and
    070   * added to its internal FlowDescriptor.
    071   *
    072   * @return Map<String,String>
    073   */
    074  Map<String, String> getFlowDescriptor();
    075  }