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.flow.local.hadoop; 022 023import java.util.Collection; 024import java.util.Collections; 025import java.util.HashSet; 026import java.util.Map; 027import java.util.Properties; 028import java.util.Set; 029 030import cascading.flow.FlowProcess; 031import cascading.flow.FlowProcessWrapper; 032import cascading.flow.hadoop.util.HadoopUtil; 033import cascading.tap.local.hadoop.LocalHfsAdaptor; 034import org.apache.hadoop.mapred.JobConf; 035 036/** 037 * Class LocalHadoopFlowProcess is for use with the {@link LocalHfsAdaptor} implementation. 038 */ 039public class LocalHadoopFlowProcess extends FlowProcessWrapper<JobConf> 040 { 041 FlowProcess<? extends Properties> local; 042 JobConf conf; 043 044 public LocalHadoopFlowProcess( FlowProcess<? extends Properties> delegate ) 045 { 046 super( delegate ); 047 048 local = delegate; 049 } 050 051 @Override 052 public JobConf getConfig() 053 { 054 if( conf == null ) 055 conf = HadoopUtil.createJobConf( local.getConfig() ); 056 057 return conf; 058 } 059 060 @Override 061 public JobConf getConfigCopy() 062 { 063 return new JobConf( getConfig() ); 064 } 065 066 @Override 067 public Object getProperty( String key ) 068 { 069 return conf.get( key ); 070 } 071 072 @Override 073 public Collection<String> getPropertyKeys() 074 { 075 Set<String> keys = new HashSet<String>(); 076 077 for( Map.Entry<String, String> entry : conf ) 078 keys.add( entry.getKey() ); 079 080 return Collections.unmodifiableSet( keys ); 081 } 082 }