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.tap.partition; 022 023import java.util.Map; 024import java.util.Properties; 025 026import cascading.property.Props; 027 028/** 029 * Class PartitionTapProps is a fluent helper class to set properties which control the behaviour of the 030 * {@link BasePartitionTap}. 031 */ 032public class PartitionTapProps extends Props 033 { 034 public static final String FAIL_ON_CLOSE = "cascading.tap.partition.failonclose"; 035 036 private boolean failOnClose = false; 037 038 /** 039 * Method setFailOnClose(boolean b) controls if the PartitionTap is ignoring all Excpetions, when a TupleEntryCollector 040 * is closed or if it should rethrow the Exception. 041 * 042 * @param properties a Map<Object, Object> 043 * @param failOnClose boolean controlling the close behaviour 044 */ 045 public static void setFailOnClose( Map<Object, Object> properties, boolean failOnClose ) 046 { 047 properties.put( FAIL_ON_CLOSE, Boolean.toString( failOnClose ) ); 048 } 049 050 /** 051 * Creates a new PartitionTapProps instance. 052 * 053 * @return PartitionTapProps instance 054 */ 055 public static PartitionTapProps partitionTapProps() 056 { 057 return new PartitionTapProps(); 058 } 059 060 /** 061 * Constructs a new PartitionTapProps instance. 062 */ 063 public PartitionTapProps() 064 { 065 } 066 067 public boolean isFailOnClose() 068 { 069 return failOnClose; 070 } 071 072 /** 073 * Method setFailOnClose controls if the PartitionTap is ignoring all Exceptions, when a TupleEntryCollector 074 * is closed or if it should rethrow the Exception. 075 * 076 * @param failOnClose boolean controlling the close behaviour 077 */ 078 public PartitionTapProps setFailOnClose( boolean failOnClose ) 079 { 080 this.failOnClose = failOnClose; 081 return this; 082 } 083 084 @Override 085 protected void addPropertiesTo( Properties properties ) 086 { 087 setFailOnClose( properties, failOnClose ); 088 } 089 }