001/*
002 * Copyright (c) 2016-2018 Chris K Wensel <chris@wensel.net>. 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.tap.local.hadoop;
022
023import java.beans.ConstructorProperties;
024import java.io.InputStream;
025import java.io.OutputStream;
026import java.util.Properties;
027
028import cascading.flow.hadoop.util.HadoopUtil;
029import cascading.flow.local.hadoop.LocalHadoopFlowProcess;
030import cascading.tap.FileAdaptorTap;
031import cascading.tap.Tap;
032import org.apache.hadoop.conf.Configuration;
033import org.apache.hadoop.mapred.OutputCollector;
034import org.apache.hadoop.mapred.RecordReader;
035
036/**
037 * Class LocalHfsAdaptor adapts the Hadoop {@link cascading.tap.hadoop.Hfs} {@link Tap} for use with the
038 * {@link cascading.flow.local.LocalFlowConnector} and {@link cascading.flow.local.planner.LocalPlanner}.
039 * <p>
040 * That is, "local mode" Cascading application can access data on an Apache Hadoop HDFS cluster if the proper
041 * Hadoop properties on are set on the LocalFlowConnector instance.
042 * <p>
043 * Use this class in order to leverage existing {@link cascading.scheme.Scheme} implementations that wrap Hadoop
044 * {@link org.apache.hadoop.mapred.InputFormat} and {@link org.apache.hadoop.mapred.OutputFormat} implementations.
045 */
046public class LocalHfsAdaptor extends FileAdaptorTap<Properties, InputStream, OutputStream, Configuration, RecordReader, OutputCollector>
047  {
048  @ConstructorProperties("original")
049  public LocalHfsAdaptor( Tap<Configuration, RecordReader, OutputCollector> original )
050    {
051    super( original, LocalHadoopFlowProcess::new, HadoopUtil::createJobConf );
052    }
053  }