1 /* Copyright (c) 2008 Sascha Kohlmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU Affero General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 package net.sf.eos.config;
17
18 import java.util.Map.Entry;
19
20 /**
21 * Hadoop Configuration holder.
22 * @author Sascha Kohlmann
23 */
24 public class HadoopConfigurationAdapter extends Configuration {
25
26 /**
27 * Copy constructor for Hadoop configuration.
28 * @param config hadoop configuration
29 */
30 public HadoopConfigurationAdapter(final org.apache.hadoop.conf.Configuration config) {
31 super();
32 for (final Entry<String, String> entry : config) {
33 final String name = entry.getKey();
34 final String value = entry.getValue();
35 set(name, value);
36 }
37 }
38
39 /**
40 * Adds the data of the Hadoop configuration to the εοs
41 * configuration.
42 * @param from the Hadoop configuration
43 * @param to the εοs configuration
44 */
45 public static void addHadoopConfigToEosConfig(
46 final org.apache.hadoop.conf.Configuration from,
47 final Configuration to) {
48
49 for (final Entry<String, String> entry : from) {
50 final String key = entry.getKey();
51 final String value = entry.getValue();
52 to.set(key, value);
53 }
54 }
55
56 /**
57 * Adds the data of the εοs configuration to the Hadoop
58 * configuration.
59 * @param to the Hadoop configuration
60 * @param from the εοs configuration
61 */
62 public static void addEosConfigToHadoopConfig(
63 final Configuration from,
64 final org.apache.hadoop.conf.Configuration to) {
65
66 for (final Entry<String, String> entry : from) {
67 final String key = entry.getKey();
68 final String value = entry.getValue();
69 to.set(key, value);
70 }
71 }
72 }