/* * Copyright 2011 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.mongodb.hadoop.examples.treasury; import com.mongodb.hadoop.MongoInputFormat; import com.mongodb.hadoop.MongoOutputFormat; import com.mongodb.hadoop.io.BSONWritable; import com.mongodb.hadoop.util.MapredMongoConfigUtil; import com.mongodb.hadoop.util.MongoConfigUtil; import com.mongodb.hadoop.util.MongoTool; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.util.ToolRunner; /** * The treasury yield xml config object. */ public class TreasuryYieldXMLConfig extends MongoTool { public TreasuryYieldXMLConfig() { this(new Configuration()); } public TreasuryYieldXMLConfig(final Configuration conf) { setConf(conf); if (MongoTool.isMapRedV1()) { MapredMongoConfigUtil.setInputFormat(conf, com.mongodb.hadoop.mapred.MongoInputFormat.class); MapredMongoConfigUtil.setOutputFormat(conf, com.mongodb.hadoop.mapred.MongoOutputFormat.class); } else { MongoConfigUtil.setInputFormat(conf, MongoInputFormat.class); MongoConfigUtil.setOutputFormat(conf, MongoOutputFormat.class); } MongoConfigUtil.setMapper(conf, TreasuryYieldMapper.class); MongoConfigUtil.setMapperOutputKey(conf, IntWritable.class); MongoConfigUtil.setMapperOutputValue(conf, DoubleWritable.class); MongoConfigUtil.setReducer(conf, TreasuryYieldReducer.class); MongoConfigUtil.setOutputKey(conf, IntWritable.class); MongoConfigUtil.setOutputValue(conf, BSONWritable.class); } public static void main(final String[] pArgs) throws Exception { System.exit(ToolRunner.run(new TreasuryYieldXMLConfig(), pArgs)); } }