001/* 002 * Copyright (c) 2016-2017 Chris K Wensel <chris@wensel.net>. All Rights Reserved. 003 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved. 004 * 005 * Project and contact information: http://www.cascading.org/ 006 * 007 * This file is part of the Cascading project. 008 * 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 */ 021 022package cascading.tap; 023 024import java.io.IOException; 025 026import cascading.flow.FlowProcess; 027import cascading.scheme.Scheme; 028import cascading.tuple.Fields; 029import cascading.tuple.TupleEntryCollector; 030 031/** 032 * Class SourceTap is an optional base class for source only Taps. 033 * <p> 034 * Some {@link Tap} instances may only be sources (as opposed 035 * to being a sink). These types should subclass SourceTap for convenience or 036 * set {@link #isSink()} to {@code false} in a custom Tap sub-class. 037 */ 038public abstract class SourceTap<Config, Input> extends Tap<Config, Input, Void> 039 { 040 protected SourceTap() 041 { 042 } 043 044 protected SourceTap( Scheme<Config, Input, ?, ?, ?> scheme ) 045 { 046 super( (Scheme<Config, Input, Void, ?, ?>) scheme ); 047 } 048 049 @Override 050 public Fields getSinkFields() 051 { 052 throw new UnsupportedOperationException( "unable to sink tuple streams via a SourceTap instance" ); 053 } 054 055 @Override 056 public final boolean isSink() 057 { 058 return false; 059 } 060 061 @Override 062 public boolean deleteResource( Config conf ) throws IOException 063 { 064 throw new UnsupportedOperationException( "unable to delete files via a SourceTap instance" ); 065 } 066 067 @Override 068 public void sinkConfInit( FlowProcess<? extends Config> flowProcess, Config conf ) 069 { 070 throw new UnsupportedOperationException( "unable to source tuple streams via a SourceTap instance" ); 071 } 072 073 @Override 074 public boolean prepareResourceForWrite( Config conf ) throws IOException 075 { 076 throw new UnsupportedOperationException( "unable to prepare resource for write via a SourceTap instance" ); 077 } 078 079 @Override 080 public boolean createResource( Config conf ) throws IOException 081 { 082 throw new UnsupportedOperationException( "unable to make dirs via a SourceTap instance" ); 083 } 084 085 @Override 086 public boolean commitResource( Config conf ) throws IOException 087 { 088 throw new UnsupportedOperationException( "unable to commit resource via a SourceTap instance" ); 089 } 090 091 @Override 092 public boolean rollbackResource( Config conf ) throws IOException 093 { 094 throw new UnsupportedOperationException( "unable to rollback resource via a SourceTap instance" ); 095 } 096 097 @Override 098 public TupleEntryCollector openForWrite( FlowProcess<? extends Config> flowProcess, Void output ) throws IOException 099 { 100 throw new UnsupportedOperationException( "unable to open for write via a SourceTap instance" ); 101 } 102 }